@@ -29,6 +29,7 @@ import { RPSIO } from './sio.js';
2929import { ConsoleLogger , LogLevel , Logger } from './utils/logging.js' ;
3030
3131export const FLASH_START_ADDRESS = 0x10000000 ;
32+ export const FLASH_END_ADDRESS = 0x14000000 ;
3233export const RAM_START_ADDRESS = 0x20000000 ;
3334export const APB_START_ADDRESS = 0x40000000 ;
3435export const DPRAM_START_ADDRESS = 0x50100000 ;
@@ -208,11 +209,14 @@ export class RP2040 {
208209 const { bootrom } = this ;
209210 if ( address < bootrom . length * 4 ) {
210211 return bootrom [ address / 4 ] ;
211- } else if (
212- address >= FLASH_START_ADDRESS &&
213- address < FLASH_START_ADDRESS + this . flash . length
214- ) {
215- return this . flashView . getUint32 ( address - FLASH_START_ADDRESS , true ) ;
212+ } else if ( address >= FLASH_START_ADDRESS && address < FLASH_END_ADDRESS ) {
213+ // Flash is mirrored four times:
214+ // - 0x10000000 XIP
215+ // - 0x11000000 XIP_NOALLOC
216+ // - 0x12000000 XIP_NOCACHE
217+ // - 0x13000000 XIP_NOCACHE_NOALLOC
218+ const offset = address & 0x00ff_ffff ;
219+ return this . flashView . getUint32 ( offset , true ) ;
216220 } else if ( address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this . sram . length ) {
217221 return this . sramView . getUint32 ( address - RAM_START_ADDRESS , true ) ;
218222 } else if (
0 commit comments