Hello,
I would like to store the firmware size in ROM. Can keil calculate the firmware size and store it in a variable post compilation. This would allow me to just grab the variable without have to create a function to calculate the firmware size.
Thanks,
Eric Micallef
On what part?
community.st.com/.../163144-how-to-jump-to-another-execution-region-defined-by-a-scatter-file
Use a linker symbol describing the image?
IMPORT ||Load$$LR$$LR_IROM1$$Length|| EXPORT romlen romlen DCD ||Load$$LR$$LR_IROM1$$Length||
Hi Clive,
Ya I think that should work. I want to try it to make sure. Where do I put these lines? the I threw them into arm_startup_nrf52.s but I got this error.
RTE\Device\nRF52832_xxAA\arm_startup_nrf52.s(76): error: A1145E: Undefined exported symbol 'romlen'
romlen needs to be the first word on the line, hard to the left margin.
In startup.s is a good place
... ; Reset handler routine Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main IMPORT SystemInit LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; sourcer32@gmail.com IMPORT ||Load$$LR$$LR_IROM1$$Length|| EXPORT romlen romlen DCD ||Load$$LR$$LR_IROM1$$Length|| ...
Access from C via
extern uint32_t romlen; ... printf("%08X\n", romlen);
after placing the LR stuff into the startup.s file I am getting a linker error
.\Objects\bootloader_adv.axf: Error: L6218E: Undefined symbol Load$$LR$$LR_IROM1$$Length (referred from arm_startup_nrf52.o).
I have been looking around on the web and stumbled across some sites like this one
infocenter.arm.com/.../index.jsp
I tried adding in the R0, RW, and ZI regions but still no luck. here is what mine looks like in
; Reset Handler
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main
LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP
IMPORT ||Load$$LR$$LR_IROM1$$R0$$Length|| EXPORT romlen romlen DCD ||Load$$LR$$LR_IROM1$$R0$$Length||
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
Do I have to add anything to the linker options in the flash configuration settings?
If you have a scatter file check what the name of the load region is, I used the generic one Keil uses for IROM1 in the auto generated files. I'm just cutting and pasting into an STM32 project building in uV 5.22, no magic involved.
Auto generated .SCT file, note "LR_IROM1", the final size of the output being computed
; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00030000 { ; load region size_region ER_IROM1 0x08000000 0x00030000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00005000 { ; RW data .ANY (+RW +ZI) } }
Ah, I was not using a scatter file. Can you explain what a scatter file does for me? All this reading from keils forum it looks like all a scatter file does is breakdown the regions of where data is being dumped?
You shouldn't need one, look for a project.sct type file in the output directory where it puts the .AXF, .HEX and .MAP files.
The region naming is important for the symbol to work