From zero to main(): Bare metal C

@francois You referenced the Reset boot-up behavior as Section 5.9.2 of the Cortex-M3 TRM
For the Cortex-M4 TRM I cannot find anything similar. Would it be fine to just assume the same steps as in the Cortex-M3?

Yes, I noticed they removed that section for the M4 TRM. I think it’s moved to a ARM-v7m manual rather than specific core. In any case, it’s fine to use the same steps.

@francois Why is it uint32_t *init_values_ptr = &_etext; taken at the end of the text section and not uint32_t *init_values_ptr = &_stext; taken at the start of the text section?

From part 2:

.text :
    {
        KEEP(*(.vectors .vectors.*))
        *(.text.*)
        *(.rodata.*)
        _etext = .;
    } > rom

Because initial values for data are added to flash after the .text section, this is what the AT > rom bit does. Since _etext points to the end of the text section, that’s where we expect the initialization values to be found. It would be better if we had a variable explicitly pointing to the address that AT > rom resolves to, but that’s not something you can do AFAIK.

François,

Could a Nucleo-G070RB be used for “From zero to main(): Bare metal C” in place of the Metro M0 Express and the CMSIS-DAP Adapter.

I see no reason why not. You’ll need to change the memory map of course.

Great article thanks.

I think you have a mistake in your pseudo code. For the Cortex-M0+ the IPSR size is 6 bits not 9 (M3/4/7). As a result the for loop in the pseudo code should be:
for i = 0 to 63 (not 511)

David.