Closed
Description
Building the projects with the -DPICO_DEOPTMIZED_DEBUG=1 breaks several FLASH functions. The easiest way to reproduce it is to simply build the unique_board_id example with -DPICO_DEOPTMIZED_DEBUG=1. The code will crash with the following stack:
hw_write_masked
flash_cs_force
flash_do_cmd
flash_get_unique_id
_retrieve_unique_id_on_boot
runtime_init
platform_entry
This happens because fully disabling GCC optimization also disables function inlining, so the FLASH-related functions that are supposed to run from RAM (e.g. flash_cs_force()) still end up calling functions from FLASH (e.g. hw_write_masked()).
This can be fully solved by declaring functions in address_mapped.h with __attribute__((always_inline))
instead of just inline
, e.g.:
inline static void __attribute__((always_inline)) hw_write_masked(io_rw_32 *addr, uint32_t values, uint32_t write_mask) {
hw_xor_bits(addr, (*addr ^ values) & write_mask);
}
Metadata
Metadata
Assignees
Labels
No labels