Cant set correct .text address for 2560 bootloader

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

I have a bootloader (for sysex over midi loading) that compiles and works correctly at address 0, but if I add .text=0x1F000 in memories I get an out of range error on build. (Atmel Studio 7, loading with Atmel ICE).

I can compile with .text=0xF800 and I see 1000 offset and then address starting at F000 in the hex file, while a bootloader shows 3000 offset and addresses starting at E000 (double the 1F000).

How can I get it to compile to the correct address?

 

The app is under 5K. The hex converted to binary (part of my sysex conversion  process) is 4768 bytes. The binary file also loads correctly at zero. (Used it to test my conversion - and the binary version  of my main apps also load correctly).

I just can't get any app to build at the bootloader address.

 

Thanks,

David

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

AVR has a strange mix of byte addressing and word addressing. Don't know if that is your problem, here, but it has tripped up a number of folks.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Out of range probably means it will not fit into the BLS. 1F000 is 4K from the end of the chip but you say the bootloader is 5K. Clearly that won't fit.

Last Edited: Mon. Aug 12, 2019 - 10:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1F000 is 4K words from end  (shows as 3E000 bytes in the arduino bootloader) - Start address in words if 8K boot section is enabled, which is what shows as enabled on the chip.

I have several functions in the bootloader, do they have to be specifically located in this high address area?

 

I have always used ATmel Studio for projects before and used Atmega 1284s on my boards, as it is a 40 pin DIP and easy to deal with. For this project I needed the multiple USARTS of the 2560 so I developed on an

Arduino Mega and hooked that to my custom board. All is now done except the bootloader so I can update over Midi.

This is the first time I have used the Arduino IDE.

 

Studio would not import my Arduino sketch, so I made a blank one with the 2 includes I wanted - Wire and an LCD lib so I can show messages during bootloading.

Then added back my bootloader code. It compiles, loads and runs correctly at .text = 0, but I can't compile it at the 1F000 word address for the bootloader section - out of range error.

I tried the F800 half of 1F000, in case I had the word/byte issue confused. It compiled, but the hex file had 1F000 as the address, instead of the 3E000 it should have ( and the Arduino bootloader has).

 

This is the first time I have needed to write a bootloader (didn't use them at all before, just used all of the flash for the main program).

Lots of searching online just turned up how to set the text area to move the entire app to the correct base address, so I'm not sure what I'm missing here.

 

David