WinAVR overwriting bootloader section

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

Hi,

We are using NutOS, WinAVR, AVRStudio & JTAGMk1on a Mega128
There is a 4K bootloader programmed at EOL production that contains a basic bootloader but also pruduction run number, hardware revisions etc.
The problem comes about when we need to JTAG the unit for debugging, the bootloader section gets completely overwritten also overwriting our hardware revs etc that the app needs to run properly.
Is there a way in the WinAVR makefile? to specify to not overwrite the bootloader section??

Thanks,
Shane

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

The solution doesn't lie in the makefile in this case.

It's happening because the JTAG unit is re-writing the entire Flash every time you start a debug session, to make sure that the code in Flash actually matches the ROM image specified for your debug session.

In the case of debugging code compiled with WinAVR, AVR Studio will use the project's ELF file as a basis for determining what information should be sent to the Flash. If you develop and maintain the application and the bootloader separately, then I don't know of any simple way to incorporate the bootloader's content in your project's ELF file.

Instead, you should override AVR Studio's default behaviour, and suppress the automatic loading of Flash contents at the beginning of each debug session. Check out the JTAGICE / JTAGICE mkII entries of the AVR Tools help file, in the "Frontend Software" section for details.

If you do this, then make sure that the version of code actually loaded on your AVR exactly matches the ELF file you're using for the debug session. Failing to do so will lead to nonsensical results.