Skip to content

Commit

Permalink
pico: restore pre-init on RP2040
Browse files Browse the repository at this point in the history
It does things we need to not crash and doesn't do any of the things that caused problems on 2350
  • Loading branch information
Daft-Freak committed Nov 26, 2024
1 parent db747b3 commit ae568a5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions 32blit-pico/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,21 @@ extern "C" bool do_init() {
return false;
#endif

// init funcs (based on pico-sdk runtime.c)
// we're not calling the preinit funcs as they're all low-level init that should've been done by the loader
// preinit/init funcs (based on pico-sdk runtime.c)
// we're not calling the preinit funcs on RP2350 as they're all low-level init that should've been done by the loader
// (on RP2040 they init the ROM functions, so we do need to call them)
#ifndef PICO_RP2350
// Start and end points of the constructor list,
// defined by the linker script.
extern void (*__preinit_array_start)();
extern void (*__preinit_array_end)();
// Call each function in the list.
// We have to take the address of the symbols, as __preinit_array_start *is*
// the first function pointer, not the address of it.
for (void (**p)(void) = &__preinit_array_start; p < &__preinit_array_end; ++p) {
(*p)();
}
#endif

// Start and end points of the constructor list,
// defined by the linker script.
Expand Down

0 comments on commit ae568a5

Please sign in to comment.