Trying to use 100% of flash

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

ATXMEGA32A4 Flash: 32KB + 4KB for Boot

I have the bootloader working, it uses around 3KB. My main application is very large and doesn't fit with the bootloader, so I'm trying to fill the remaining space in the bootloader with some constant tables.

The problem is that when the bootloader gets above 4036 bytes, I get an error when I try to program:

The contents of the objectfile exceeds the maximum program memory of the device

Why? I assume there might be gaps when the linker generates the HEX file. How do I get closer to 4096 bytes?

This is how the HEX file looks like when exceeding 4036 bytes, the first part seems to be in sequence, but at the end, there is something else:

:108000000C94CA420C94E0420C94E0420C94E0427E
:108010000C94E0420C94E0420C94E0420C94E04258
:108020000C94E0420C94E0420C94E0420C94E04248
.
.
.
:108FA00008958091CF0187FDFCCF80E3E0ECF1E0F4
:108FB0008287EBECF1E021E030E088ED90E084BFC7
:088FC00020830895F894FFCF0F
:108FC800EE27FF2719BEDC0143E24093CA0150E8AF
:108FD8002DE90D901D9020933400E89532965A950E
:108FE800C1F711240895FC014093CA012DE920938B
:0A8FF8003400E89511243BBF0895F2
:040000030000800079
:00000001FF

And a second question, once I get the bootloader done, is there a way I can generate an error if the main application exceeds 32KB?

The bootloader code is here if anyone wants to take a look.

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

Quote:
The problem is that when the bootloader gets above 4036 bytes, I get an error when I try to program:
You are exceding the the max limit of bootloader.
Quote:
so I'm trying to fill the remaining space in the bootloader with some constant tables.

Also you have to be sure with bootlock bits weather it allows LPM from application flash to read content of boot flash.

Quote:
This is how the HEX file looks like when exceeding 4036 bytes, the first part seems to be in sequence, but at the end, there is something else:
This is intel hex format. read following link to debug it.
http://www.scienceprog.com/shelling-the-intel-8-bit-hex-file-format/

Quote:
And a second question, once I get the bootloader done, is there a way I can generate an error if the main application exceeds 32KB?
I think you will get unexpected behaviour

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

Since your question was only XMEGA related, you should ask the moderator to move it into the XMEGA forum.

Peter

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

katochd46 wrote:
You are exceding the the max limit of bootloader.
Let me rephrase my question. Why does the compiler report 4036 bytes used if the device is already full? Shouldn't "full" mean 4096 bytes?

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

I dont suppose its ignoring the bootloader interrupt vector table?

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

Quote:

I dont suppose its ignoring the bootloader interrupt vector table?

There's a lot more than 60 bytes in a ATXMEGA32A4 vector table.

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

Ah well, it was bit of a guess.
Still getting my head from mega to Xmega.

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

I am back working on the bootloader. Again, I want to maximize what I can fit in the bootloader. I am checking the assembly listing and I see the vector table:

00008000 <__vectors>:
8000: 0c 94 bc 41 jmp 0x8378 ; 0x8378 <__ctors_end>
8004: 0c 94 d2 41 jmp 0x83a4 ; 0x83a4 <__bad_interrupt>
8008: 0c 94 d2 41 jmp 0x83a4 ; 0x83a4 <__bad_interrupt>
.
.
.
8170: 0c 94 d2 41 jmp 0x83a4 ; 0x83a4 <__bad_interrupt>
8174: 0c 94 d2 41 jmp 0x83a4 ; 0x83a4 <__bad_interrupt>

My bootloader will not use interrupts, how can I use this section for my own use (code or data)?

edit: currently reading the bootloader FAQ.

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

Read this:

Smallest bootloader?

Note in particular my techniques for ditching the CRT (including the vector table) but keeping a (nearly) all C solution.

Cliff

(-nostartfiles and -nodefaultlibs are your friends)

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

EasyBootXAvr takes around 700bytes. CRC and serial number.

You could put a constant in C on the location the bootloader will be and then overwrite the booloader in the hex file. I am not a C guy, I just guess.

The problem is you can not lock the boot area for writing if you want to update your application residing in the boot area. This would expose the bootloader to unintended writings.

George.

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

Quote:
when the bootloader gets above 4036 bytes

What tool are you using to get this "4036 bytes" number? Some tools won't show all of the sections that actually have to be loaded into flash for everything to work. (trivial example, the flash used is the sum of text and data segments reported by avr-size.)

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

westfw wrote:
Quote:
when the bootloader gets above 4036 bytes

What tool are you using to get this "4036 bytes" number?
avr-gcc under AVR Studio.

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

Quote:

avr-gcc under AVR Studio.

You mean "avr-size" in AS5? (or AS4?)

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

AVR Studio 4