pico: restore pre-init on RP2040 It does things we need to not crash and doesn't do any of the things that caused problems on 2350
diff --git a/32blit-pico/startup.cpp b/32blit-pico/startup.cpp index 4bf98f9..5e266f1 100644 --- a/32blit-pico/startup.cpp +++ b/32blit-pico/startup.cpp
@@ -25,8 +25,21 @@ 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.