How to fill all memory blocks with a FILL value?

Showing results for 
Search instead for 
Did you mean: 

How to fill all memory blocks with a FILL value?

Contributor II

I would like to run an application on the generated ELF file which first fills all holes between
the segments within a certain memory range, and then computes a custom CRC value.

When the modified ELF file is flashed to the board, I run into a "Programming Error".
When comparing the unmodified ELF file with the modified ELF file;
the most obvious change is that the "fill" is generated as new sections in the ELF file.
The sections will not appear in consecutive order and has an alignment of 4 bytes.
(filler segments have zero alignment)

If I run the application, just to generate the CRC, programming succeeds.
The problem I see is that without the fill, the CRC computation will not match that of the target.

In order to continue, I would like to fill all "holes" in the desired address range using the linker.

I can see that I get the fill value in the S-Record file, but it seems incomplete.

For this to work, I need to have the fill value in the ELF file.
It appears to only fill my first section.

So how do I fill everything up to the end of a MEMORY block?

$ readelf -l Stage2.elf

Elf file type is EXEC (Executable file)
Entry point 0xbb94
There are 20 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x0003e0 0x00008000 0x00000000 0x00100 0x00100 R E 0x4
LOAD 0x0004e0 0x00008100 0x00000000 0x00020 0x00020 R E 0x4
LOAD 0x000500 0x00008120 0x00000000 0x00ee0 0x00ee0 R E 0x4
LOAD 0x001480 0x00009000 0x00000000 0x000f4 0x000f4 R E 0x100
LOAD 0x001580 0x00009100 0x00000000 0x000d4 0x000d4 R E 0x100
LOAD 0x002480 0x0000a000 0x00000000 0x03604 0x03604 R E 0x10
LOAD 0x005a88 0x0000d608 0x00000000 0x00380 0x00380 R 0x8
LOAD 0x005e08 0x0000d988 0x00000000 0x0016c 0x0016c R E 0x4
LOAD 0x005f80 0x0000db00 0x00000000 0x00500 0x00500 RWE 0x10
LOAD 0x007080 0x40008000 0x00000000 0x00000 0x00ff0 RW 0x1000
LOAD 0x007080 0x0000e000 0x00000000 0x0008c 0x0008c RW 0x8
NULL 0x007080 0x40008ff0 0x00000000 0x00000 0x0008c RW 0x8
LOAD 0x007110 0x0000e090 0x00000000 0x00004 0x00004 RW 0x8
NULL 0x007110 0x40009080 0x00000000 0x00000 0x00004 RW 0x8
LOAD 0x007118 0x40009088 0x00000000 0x00000 0x00004 RW 0x8
LOAD 0x007118 0x40009090 0x00000000 0x00000 0x02fb0 RW 0x8
Fill sections.
LOAD 0x01d939 0x000090f4 0x00000000 0x0000c 0x0000c R E 0x4
LOAD 0x01d945 0x000091d4 0x00000000 0x00e2c 0x00e2c R E 0x4
LOAD 0x01e771 0x0000d604 0x00000000 0x00004 0x00004 R E 0x4
LOAD 0x01e775 0x0000daf4 0x00000000 0x0e50c 0x0e50c R E 0x4

0 Kudos
2 Replies

Contributor II

When I read in the ELF file to calculate a CRC, my tool (ielftool) assumes any unused bytes are zero, not 0xFF, which works for segment loaded to cleared RAM but not for flash.

If I tell ielftool to fill unused values with 0xFF, then it generates och extra segments.

CodeWarrior cannot program the ELF file if the fill segments are present, which I suspect is a bug.

So in order to have a correct CRC in the ELF file I need to fill all the holes in the linker or compile the code twice to generate filler assembler files in the first pass.

I can generate an ELF file in ielftool, and then generate S-Records in ielftool.

Somehow program the S-Record file using CodeWarrior (How?) and then start debugging without download, just loading symbols.

This is again very inconvenient.

So is it impossible to fill in the linker?


0 Kudos

NXP TechSupport
NXP TechSupport

Usually data in empty Flash is 0xFF. Use this data as Flash filling.

The S-record write only required addresses. Unused addresses are not writhed.

0 Kudos