Fix flash initialization for RP2350.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
0560e49b5c
commit
2497b633ae
2 changed files with 13 additions and 9 deletions
|
|
@ -251,8 +251,7 @@ void scan_region(bool persistent) {
|
|||
endp = end_rom_pool;
|
||||
startp = start_rom_pool;
|
||||
}
|
||||
for (uintptr_t base = flash_read_uintptr(endp); base >= startp;
|
||||
base = flash_read_uintptr(base)) {
|
||||
for (uintptr_t base = flash_read_uintptr(endp); base >= startp; base = flash_read_uintptr(base)) {
|
||||
if (base == 0x0) { //all is empty
|
||||
break;
|
||||
}
|
||||
|
|
@ -276,8 +275,8 @@ void scan_region(bool persistent) {
|
|||
void wait_flash_finish();
|
||||
void scan_flash() {
|
||||
initialize_flash(false); //soft initialization
|
||||
if (*(uintptr_t *) flash_read(end_rom_pool) == 0xffffffff &&
|
||||
*(uintptr_t *) flash_read(end_rom_pool + sizeof(uintptr_t)) == 0xffffffff) {
|
||||
uint32_t r1 = *(uintptr_t *) flash_read(end_rom_pool), r2 = *(uintptr_t *) flash_read(end_rom_pool + sizeof(uintptr_t));
|
||||
if ((r1 == 0xffffffff || r1 == 0xefefefef) && (r2 == 0xffffffff || r2 == 0xefefefef)) {
|
||||
printf("First initialization (or corrupted!)\n");
|
||||
uint8_t empty[sizeof(uintptr_t) * 2 + sizeof(uint32_t)];
|
||||
memset(empty, 0, sizeof(empty));
|
||||
|
|
|
|||
|
|
@ -52,12 +52,17 @@
|
|||
|
||||
//To avoid possible future allocations, data region starts at the end of flash and goes upwards to the center region
|
||||
|
||||
#ifdef PICO_RP2350
|
||||
// Table partition for RP2350 needs 8kb
|
||||
const uintptr_t end_flash = (XIP_BASE + PICO_FLASH_SIZE_BYTES - 2 * FLASH_SECTOR_SIZE);
|
||||
#else
|
||||
const uintptr_t end_flash = (XIP_BASE + PICO_FLASH_SIZE_BYTES);
|
||||
#endif
|
||||
|
||||
const uintptr_t end_rom_pool = end_flash - FLASH_DATA_HEADER_SIZE - 4; //This is a fixed value. DO NOT CHANGE
|
||||
const uintptr_t start_rom_pool = end_rom_pool - FLASH_PERMANENT_REGION; //This is a fixed value. DO NOT CHANGE
|
||||
const uintptr_t end_data_pool = start_rom_pool - FLASH_DATA_HEADER_SIZE; //This is a fixed value. DO NOT CHANGE
|
||||
const uintptr_t start_data_pool = (XIP_BASE + FLASH_TARGET_OFFSET);
|
||||
const uintptr_t end_data_pool = (XIP_BASE + PICO_FLASH_SIZE_BYTES) - FLASH_DATA_HEADER_SIZE -
|
||||
FLASH_PERMANENT_REGION - FLASH_DATA_HEADER_SIZE - 4; //This is a fixed value. DO NOT CHANGE
|
||||
const uintptr_t end_rom_pool = (XIP_BASE + PICO_FLASH_SIZE_BYTES) - FLASH_DATA_HEADER_SIZE - 4; //This is a fixed value. DO NOT CHANGE
|
||||
const uintptr_t start_rom_pool = (XIP_BASE + PICO_FLASH_SIZE_BYTES) - FLASH_DATA_HEADER_SIZE -
|
||||
FLASH_PERMANENT_REGION; //This is a fixed value. DO NOT CHANGE
|
||||
|
||||
extern int flash_program_block(uintptr_t addr, const uint8_t *data, size_t len);
|
||||
extern int flash_program_halfword(uintptr_t addr, uint16_t data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue