12
\$\begingroup\$

I have designed a PCB for a client recently, everything is fine with the hardware and software (application is working as it is supposed to). Now we are facing the need to update the program inside the microcontroller, but since these PCBs are installed at different places over the world, it would be perfect to install a bootloader and use the same UART as used by the application.

Board description

  • AT32UC3L032
  • One UART already used to communicate between board and PC
  • Couple of I/Os for the application
  • Couple of state LEDs

Relevant PINS and config

PA01 # Used for entering ISP with high level

PA20 # Used for application and ISP UART
PA21 # Used for application and ISP UART

#define COM_USART               (&AVR32_USART2)
#define COM_USART_RX_PIN        AVR32_USART2_RXD_0_0_PIN
#define COM_USART_RX_FUNCTION   AVR32_USART2_RXD_0_0_FUNCTION
#define COM_USART_TX_PIN        AVR32_USART2_TXD_0_0_PIN
#define COM_USART_TX_FUNCTION   AVR32_USART2_TXD_0_0_FUNCTION
#define COM_USART_IRQ           AVR32_USART2_IRQ
#define COM_USART_BAUDRATE      115200

Tools used

  • Windows XP
  • Atmel Studio 6.1
  • AVRONE programmer

After many hours searching, I've found the Atmel Software Framework DFU, provided in ASF 3.14.0.834. That was looking promising, I was able to install it on my board using provided tools :

  • AVR32Studio 2.6.0
  • program_at32uc3l-uart-isp-1.0.1.cmd (provided script with ASF)
  • Flip 3.4.7 (batchisp)

At first, I used .bin and .dat provided with ASF, installed using the script. Now trying to upload application using batchisp command :

batchisp.exe -device at32uc3l032 -hardware RS232 -port COM1 -baudrate 115200 -operation erase f memory flash blankcheck loadbuffer myapp.hex program verify

But always getting :

Device selection.................... PASS
Hardware selection.................. PASS
Opening port........................ PASS
Synchronzing target................. FAIL    Timeout error.

I've tested with oscilloscope RX and TX from UART, data is going to board but PC is receiving a 27kHz square wave (can't be data from UART since there is no stop bit or anything, also frequency is probably not the same for 115200bps).

After more research, I've configured Word1 and Word2 in file at32uc3l-uart-isp_cfg-1.0.1.dat to get these values :

  • Word1 : 0xE11E0024
  • Word2 : 0x494F81AA

To use pin PA01 as option to enter in the ISP.

Also, loaded the source of the DFU in Atmel Studio 6.1 and noticed they were not using same serial port configuration, so changed for the same as my application. Also added some LEDs toggle inside the main of the DFU.

After updating the bootloader in the board, no LEDs changes, same timeout, same square wave.

Am I missing something?


\$\endgroup\$
  • 1
    \$\begingroup\$ Posted as a ticket to Atmel, will see who can really help me :D \$\endgroup\$ – Alexandre Lavoie Mar 20 '14 at 18:55
  • \$\begingroup\$ Which pins are you using (PAxx/PBxx). I don't remember exactly, but to enter the bootloader you are supposed to pull a pin high or low (depending on the two configurations words). Can you confirm you are pushing a button or similar? \$\endgroup\$ – Tom L. Mar 20 '14 at 19:11
  • \$\begingroup\$ @TomL., using PA01 (added in question). Tried with both high / low... same result. Even if this pin is used with JTAG, should not cause problem. \$\endgroup\$ – Alexandre Lavoie Mar 20 '14 at 19:15
  • \$\begingroup\$ And which pins are you using for the UART? \$\endgroup\$ – Tom L. Mar 20 '14 at 19:15
  • 1
    \$\begingroup\$ Hm ok, so nothing unusual here. Can you check the trampoline code and if the application is correctly linked to the flash start address (you should see this in the linker .map file). Can you post your linker arguments? \$\endgroup\$ – Tom L. Mar 20 '14 at 19:26
1
\$\begingroup\$

Maybe try using a AVR programmer and the Arduino IDE if that is possible. I know it works well with the AT series microcontrollers.

\$\endgroup\$
0
\$\begingroup\$

Using JTAG without proper trampoline code will overwrite the BOOTLOADER shipped by the ATMEL. So after first programming with JTAG you most likely erased the BOOTLOADER for good.

Also the fuses must be set to allow bootloader to work which default settings of JTAG programmer usually screw up.

In order to repair this you need to program the BOOTLOADER back (taken from unprogrammed yet chip) into chip by JTAG and set the fuses correctly.

I stopped using JTAG long ago as BOOTLOADER+FLIP is much more comfortable and faster. Make sure you are using hex instead of bin/elf and BOOTLOADER condition is still true after reset condition ends.

This is how I use FLIP on RS232:

avr32-objcopy -O ihex AT32UC3L064.elf AT32UC3L064.hex
Batchisp -device AT32UC3L064 -hardware RS232 -port COM1 -baudrate 115200 -operation onfail abort memory flash erase f blankcheck loadbuffer AT32UC3L064.hex program start reset 0

Where avr32-objcopy is from AVRStudio bin folder and Batchisp is from FLIP. You just need to change the filenames and AVR chip ID and COM to match your project.

In case you need it you can also use USB:

avr32-objcopy -O ihex cpp_trampoline.elf AT32UC3A3256.hex
Batchisp -device AT32UC3A3256 -hardware USB -operation onfail abort memory flash erase f blankcheck loadbuffer AT32UC3A3256.hex program start reset 0

The trampoline must be enabled in linker (project properties) this is how mine config looks like:

linker: -nostartfiles -Wl,--gc-sections -Wl,-e,_trampoline -mpart=uc3l032 -Wl,--gc-sections --direct-data --rodata-writable

I am still using AVR32 Studio 2.7.0 as the newer versions are horse shit so in them the config might be different.

[Edit1] additional info

for UC3L0the AVR32_PIN_PA20 is some RC generic clock (should be 32KHz but it varies from chip to chip quite a lot without calibration with prescalers) from the chip until its purpose is changed to GPIO or anything else so the ~27KHz clock has nothing to do with USART. Btw that clock is powered by 3.3V and generates even if the chip 1.98V core is fried for good....

The Bootloader condition is having AVR32_PIN_PA11 set to zero prior to Reset release (unless you implement your own DFU conditions/commands into your firmware) So one possibility is making an RC that you dissipate to LOW state , and reset before it charge up back ... or use some FLIP/FLOP gate or jumper ...

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.