From 0c91aab002c5a91df0ca889fe6331c3cf8547ff6 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Tue, 15 Oct 2024 16:59:14 +0100 Subject: [PATCH] Use FLASH_SECTOR_SIZE instead of 4096 --- src/rp2_common/pico_cyw43_driver/cyw43_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rp2_common/pico_cyw43_driver/cyw43_driver.c b/src/rp2_common/pico_cyw43_driver/cyw43_driver.c index 9a6aaf49e..95748ae10 100644 --- a/src/rp2_common/pico_cyw43_driver/cyw43_driver.c +++ b/src/rp2_common/pico_cyw43_driver/cyw43_driver.c @@ -23,6 +23,7 @@ static async_context_t *cyw43_async_context = NULL; #if CYW43_USE_PARTITION_FIRMWARE #include "pico/bootrom.h" + #include "hardware/flash.h" #include "boot/picobin.h" #include @@ -161,8 +162,8 @@ bool cyw43_driver_init(async_context_t *context) { assert(ret == 3); uint32_t location_and_permissions = buffer[1]; - uint32_t saddr = ((location_and_permissions >> PICOBIN_PARTITION_LOCATION_FIRST_SECTOR_LSB) & 0x1fffu) * 4096; - uint32_t eaddr = (((location_and_permissions >> PICOBIN_PARTITION_LOCATION_LAST_SECTOR_LSB) & 0x1fffu) + 1) * 4096; + uint32_t saddr = ((location_and_permissions >> PICOBIN_PARTITION_LOCATION_FIRST_SECTOR_LSB) & 0x1fffu) * FLASH_SECTOR_SIZE; + uint32_t eaddr = (((location_and_permissions >> PICOBIN_PARTITION_LOCATION_LAST_SECTOR_LSB) & 0x1fffu) + 1) * FLASH_SECTOR_SIZE; // Starts with metadata block while(saddr < eaddr && *(uint32_t*)(XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE + saddr) != PICOBIN_BLOCK_MARKER_END) { saddr += 4;