Saving the ROM content size in a variable

Technical Note 52791

Architectures:

ARM

Component:

linker

Updated:

5/31/2018 9:14 AM

Introduction

I have a bootloader that will compute the CRC of the application software to launch. My bootloader knows the application's start address, but I also need the application size (for use in the CRC algorithm).

I have used the "Alternative solution" using checksum-start and checksum-end markers from Technical Note 62709 (IELFTOOL Checksum - Placing the checksum).

I would like to store the size of the ROM content in flash, in a section named ROM_length_used ...

define block ROM_CONTENT with fixed order
{
 readonly section checksum,
 readonly section ROM_length_used,
 readonly section checksum_start_mark,
 readonly,
 readonly section checksum_end_mark
};

place in ROM_region { block ROM_CONTENT };

Solution using C

#pragma section = "ROM_CONTENT"
const size_t ROM_CONTENT_size @ "ROM_length_used" = __section_size("ROM_CONTENT");

Solution using assembler

SECTION ROM_length_used:CODE:NOROOT(2)

EXTERN ROM_CONTENT$$Length

DATA

DC32 ROM_CONTENT$$Length ; Number of RO bytes

END

Example

An example project is available, see link: Example project (TN 52791).zip

 

All Product names are trademarks or registered trademarks of their respective owners.

We do no longer support Internet Explorer. To get the best experience of iar.com, we recommend upgrading to a modern browser such as Chrome or Edge.