ATXMEGA256A3U Bootloader

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wanted to build Atmel's bootloader for the 256A3U using IAR Kickstart version, but the output is over 4K, and exceeds the limit of this free version of IAR.

Has anybody tried to compile this using Atmel Studio?
Does anyone have a 256A3U USB bootloader that they can share?

I'm starting to write one myself, but there are a lot of "gotchas", because the bootloader needs to be located above the 128KB, and there are some things to be aware of like handling EIND, and the use of PROGMEM.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe I'm not doing this right, but here is what I have done: I was able to create a new project using the ASF USB DFU. I then copied some of the missing code (USB configuration, contents of main) from AVR1916 to my project.

The project compiles, and when I run it, windows enumerates the USB device... I open Flip and I can read and write to the memories, looks like I succeeded...

However, I can't jump to the application. Clicking the "Start Application" button, just resets the device, and it goes to bootloader again.

There is one file from AVR1916 that is not currently in my project: cstartup.s90. This file has the code to jump to the application. I tried adding it to the project, but it is meant for the IAR compiler.

Does anyone know how to integrate the code from that file into an Atmel Studio project?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

However, I can't jump to the application. Clicking the "Start Application" button, just resets the device, and it goes to bootloader again.

That does sound like a classic EIND error. Have you tried PUSH;PUSH;PUSH;RET or just JMP 0 (which should be a 24 bit jump)? If the code is trying to do it through a function pointer:

typedef void (*fp_t)(void);

fp_t reset = (fp_t)0;

reset();

then this won't work as you are trying to put a 24 bit destination into a 16 bit pointer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the comment, but that was not exactly the problem. When creating the DFU project with the ASF, the main was pretty much empty. I integrated the code from other completed bootloaders into mine. Everything seems to be working now.

If anyone wants to take a look at my ATXMEGA256A3U bootloader: https://github.com/ganzziani/Xpr...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

THe code runs well, I also updated the project to Studio 7 and it works there also.

Note that there is a lot of code for the custom solution of ganzziani (custom port initialization, some buzzing and so on) and a lot of hardcoded operations, like:

 

if (!(PORTE.IN & (1<<6))        // If the specified pin is pulled LOW
    || pgm_read_word(0) == 0xFFFF    // Get the value of the reset vector. If it's unprogrammed, we know
    // there's nothing useful in app flash
    || (RST.STATUS & RST_SRF_bm && start_app_key!=0x55AA) // If the app code reset into the bootloader

 

So don't bother configuring things, such as:

// Definition of hardware condition to enter in ISP mode on AVR Xmega devices
#define ISP_PORT_DIR      PORTE_DIR
#define ISP_PORT_PINCTRL  PORTE_PIN6CTRL
#define ISP_PORT_IN       PORTE_IN
#define ISP_PORT_PIN      6

Op simply doesn't use them. Anyways, this code can save you some time, needed to port from IAR and to debug several problems, that you will get instantly on adding DFU in ASF. 

Last Edited: Mon. Apr 11, 2016 - 02:47 PM