Hello,
I have a question regarding the use / limitations of flash_safe_execute / flash_range_erase / flash_range_program.
Can we not write over the part of the flash where the program is stored ? i am getting a hardfault but for an offset like 1024*1000, it works.
Using "pico_set_binary_type(Target no_flash)" makes it work for offset 0 but i can't use it on my program because it's too large to fully fit in ram.
I would have expected something like that to work :The function being __no_inline_not_in_flash_func and the interrupts being disabled, is there something missing to make it work ?
I have a question regarding the use / limitations of flash_safe_execute / flash_range_erase / flash_range_program.
Can we not write over the part of the flash where the program is stored ? i am getting a hardfault but for an offset like 1024*1000, it works.
Using "pico_set_binary_type(Target no_flash)" makes it work for offset 0 but i can't use it on my program because it's too large to fully fit in ram.
I would have expected something like that to work :
Code:
#include <stdio.h>#include "pico/stdlib.h"#include <hardware/flash.h>#include "pico/flash.h"static void call_flash_range_erase(void *param){ const uint32_t offset = (uint32_t)param; flash_range_erase(offset, FLASH_SECTOR_SIZE);}void __no_inline_not_in_flash_func (test_flash_erase)(){ int rc = flash_safe_execute(call_flash_range_erase, (void*)(uint32_t(0)), UINT32_MAX); hard_assert(rc == PICO_OK);}int main(){ stdio_init_all(); test_flash_erase();}Statistics: Posted by eccegratum — Mon Mar 24, 2025 11:27 pm