@@ -29,6 +29,7 @@ import { RPSIO } from './sio.js';
29
29
import { ConsoleLogger , LogLevel , Logger } from './utils/logging.js' ;
30
30
31
31
export const FLASH_START_ADDRESS = 0x10000000 ;
32
+ export const FLASH_END_ADDRESS = 0x14000000 ;
32
33
export const RAM_START_ADDRESS = 0x20000000 ;
33
34
export const APB_START_ADDRESS = 0x40000000 ;
34
35
export const DPRAM_START_ADDRESS = 0x50100000 ;
@@ -208,11 +209,14 @@ export class RP2040 {
208
209
const { bootrom } = this ;
209
210
if ( address < bootrom . length * 4 ) {
210
211
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 ) ;
216
220
} else if ( address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this . sram . length ) {
217
221
return this . sramView . getUint32 ( address - RAM_START_ADDRESS , true ) ;
218
222
} else if (
0 commit comments