Using binutils 2.43.1 for riscv32, RaspberryPi RP2350.
To support loading a program into flash, I need to insert 5 magic constants (so that the boot rom recognises the binary as a valid program image) “within the first 4 kB of a flash image”.
To do a similar job for an Espressif ESP32-H2’s ‘direct boot’ feature, where two magic constants are needed at the start of the binary, this worked:
.header :
{
_rom_start = .;
LONG(0xaedb041d)
LONG(0xaedb041d)
} >flash
.text.entry ORIGIN(flash) + 8 :
{
KEEP(*(.program_entry))
} >flash
but this doesn’t work for the RP2350 (the entry point is at the start of flash, rather than +8 for the ESP32-H2):
.text.entry ORIGIN(flash):
{
KEEP(*(.program_entry));
. = ALIGN(4);
LONG(0xffffded3)
LONG(0x11010142)
LONG(0x000001ff)
LONG(0x00000000)
LONG(0xab123579)
} >flash
The 5 constants are ignored, and all that appears in the binary is the *(.program_entry)
code.
Must I provide this data in a C file?