Extra byte in bin file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extra byte in bin file

976 Views
jean-francoisle
Contributor III

Hi everyone,

I'm using IAR and K20D72 to develop a product. We actually have a concern when we compile the code. I configure the linker file to reserve 2 differents sections in the flash 0x to 0xc000 for my boot and 0x3C000 to 0x40000 for serial number and some other informations. The linker is configured correctly and everything works fine. We have a CRC validation for the user code.

Here is me problem: I declared an array (const UINT32) to test my bootloader with a user code with the max size. I observed that in the bin file, there is always an extra byte added in the next sector.  There is a lot of 0 until the end of the sector but this extra byte is in the next sector. The problem is that I lost a complet sector for this extra 0.

Why there is an extra 0? Can I configure the linker to remove it?

Thks

0 Kudos
Reply
6 Replies

801 Views
mjbcswitzerland
Specialist V

Jean-Francois

Do you not need to configure

0x00..0xbfff and 0x3c000...0x3ffff?

Regards

Mark

0 Kudos
Reply

801 Views
jean-francoisle
Contributor III

The zone 0 to 0xbfff is reserved to the bootloader.

The zone 0x3c000 to 0x3ffff is reserved for data for production.

The last sector 0x3a000 ot 0x3bffff ca not be used because this is always an extra byte in the binairy at 0x3a000. If i use this sector, the extra byte will be in the reserved area and rejected by the linker. So I always lost the last sector for only one byte.

at 0x3a000:

0x00, 0xff, 0xff... 0xff.

any idea?

0 Kudos
Reply

801 Views
mjbcswitzerland
Specialist V

Jean-Francois

OK - you didn't originally say where the extra byte was so I thought it may have been at 0xc0000.

What do you put in 0xc000 ... 0x39ffff? Is something overflowing there? The linker will only put things there that you have somewhere declared to need to exist. It may be best to attach your linker script and map file so that this can be seen more clearly.

Regards

Mark

0 Kudos
Reply

801 Views
jean-francoisle
Contributor III

Hi,

I pasted a print screen of the bin file. The addresses are not the same as previously discussed because I change something in the code. But, the problem is still there. Before 0x2F800, we can see all padding byte. after this addr, there is one byte at 0x00 (the problematic one (the one that I want to eliminate). All all 0xFF until 0x3C000. I attached the map file. What is the linker script?

Untitled.png

0 Kudos
Reply

801 Views
mjbcswitzerland
Specialist V

Jean-Francois

I don't see what is being set in that area but maybe it is an IAR issue (?)

Have you tried the linker setting "checksum" where there is a check box "Fill unused code memory" which can be enabled and the fill pattern set to 0xff? Maybe, if the linker is filling a unused area with 0x00 (and possibly making an error), by filling it with 0xff instead would means that it no longer causes a problem.

Regards

Mark

0 Kudos
Reply

801 Views
jean-francoisle
Contributor III

Hi Mark,

In the linker I configured the checksum at the addr 0xC000. I filled the unused code with 0xFF from 0xC080 to 0x3BFFF. I'll open a ticket with IAR.

The CRC is valid too (including this extra byte).

Thks

0 Kudos
Reply