Avrstudio bootloader debuggin

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

Hi friends,
I'm starting to write a bootloader for my atmega,i'm using as4, in the makefile im using the the linker flag
--section-start=.text=0x3800... if i'm right this should write the code starting at the addresss 0x3800 of the flash.
When i go to the debugging, i see the code starts at 0x0000 :S. What can i do to fix this??? thanks in advance.

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

rogertrullo wrote:
in the makefile im using the the linker flag --section-start=.text=0x3800
With a "-Wl," in front of it, I hope.

Stefan Ernst

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

sternst wrote:
rogertrullo wrote:
in the makefile im using the the linker flag --section-start=.text=0x3800
With a "-Wl," in front of it, I hope.

Thanks for the answer
I'm using -Wl in front, but as4 still shows the code starting at address 0x0000 i don't know what is going on

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

I guess you are putting it in the wrong place in the Makefile or that Makefile is being over-written when AS4 auto-generates it. I wonder why you would do this anyway. In AS4 under Memories in Project-Configuration just enter .text as a Flash section with an address of 0x1C00 (that is half of the 0x3800 byte address) and AS4 will put the correct command into the Makefile for you.

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

clawson wrote:
I guess you are putting it in the wrong place in the Makefile or that Makefile is being over-written when AS4 auto-generates it. I wonder why you would do this anyway. In AS4 under Memories in Project-Configuration just enter .text as a Flash section with an address of 0x1C00 (that is half of the 0x3800 byte address) and AS4 will put the correct command into the Makefile for you.

Hi, i don't understand just enter .text as a Flash section with an address of 0x1C00 the memory setting just appear when i don't use an external makefile...could you explain me, thank you

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

Quote:

could you explain me

A picture is worth 1,000 words. Notice all the 0x3800's in this!

Attachment(s): 

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

clawson wrote:
Quote:

could you explain me

A picture is worth 1,000 words. Notice all the 0x3800's in this!

thanks friend, could you explain me why did you use half of the address??? i got the 0x3800's in the .map and .lss, but when im on debug and i see the program memory?, the left address starts at 0x0000. please see the pic, or i dont know if this address is unrelated with the real one. thanks in advance.

Attachment(s): 

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

The half address thing is because Atmel in the datasheet and their tools such as AS4 always address flash in terms of 16 bit words. this is because the flash is used for holding AVR opcodes and the minimum opcode size is 16bit. In fact even when flash is used for storing data (accessed by LPM) the data has to be padded to the next 16bit boundary (often a terminating 0x00 is added) so it really is the case that the minimum granularity in flash is 16 bit. So they'd tell you that a 16KB mega16 has 8K Words of storage.

GCC on the other hand is a compiler and set of tools used on processors where memory is either 8, 16, 32, 64 or even 128 bits wide so to be able to cater for everything it always uses byte addresses. So when you pass --section-start to the binutils linker it needs that address in bytes.

Atmel on the other hand, in AS4 want to encourage the user to always use word addresses so the byte address 0x3800 is also the word address 0x1C00. When I entered that value into the dialog above what AS4 actually passed to the linker was:

avr-gcc -mmcu=atmega16 -Wl,-Map=test.map -Wl,-section-start=.text=0x3800 test.o myasm.o    -lm  -o test.elf

where you can see they have converted the 0x1C00 value I entered into 0x3800 to be passed to the GCC tools.

As for the debugging thing. I can no longer use my debuggers with AS4 as they contain AS6 firmware and I don't want to down-grade them but I'm pretty sure there's an option (probably the bottom entry on the Debug menu when you are debugging) where you can tell the debugger to start execution at the BLS address (0x1C00) instead of the usual 0x0000. It's specifically for debugging bootloaders.

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

Quote:
As for the debugging thing.

The chip starts where the fuse-bits (and HWB pin ) tell it to. The simulator however has to be explicitly pointed to where to start (menu option).

No RSTDISBL, no fun!

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

Quote:

The simulator however has to be explicitly pointed to where to start (menu option).

Oh right - that's what I was thinking of (and I could, of course, have tried that!)

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

Brutte wrote:
Quote:
As for the debugging thing.

The chip starts where the fuse-bits (and HWB pin ) tell it to. The simulator however has to be explicitly pointed to where to start (menu option).

Hi, and thanks guys for your answers, can you tell me how to point the simulator where to start??

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

Quote:

Hi, and thanks guys for your answers, can you tell me how to point the simulator where to start??

Well I was going to ask exactly how hard you looked before asking that but in trying it myself I found the simulator runs to 0x1C36 (word address) anyway. Clearly it's getting the start address from the .elf file anyway and then running on to the start of main().