@@ -27,7 +27,6 @@ import { ConsoleLogger, Logger, LogLevel } from './utils/logging';
27
27
import { RPTBMAN } from './peripherals/tbman' ;
28
28
29
29
export const FLASH_START_ADDRESS = 0x10000000 ;
30
- export const FLASH_END_ADDRESS = 0x14000000 ;
31
30
export const RAM_START_ADDRESS = 0x20000000 ;
32
31
export const DPRAM_START_ADDRESS = 0x50100000 ;
33
32
export const SIO_START_ADDRESS = 0xd0000000 ;
@@ -188,7 +187,10 @@ export class RP2040 {
188
187
const { bootrom } = this ;
189
188
if ( address < bootrom . length * 4 ) {
190
189
return bootrom [ address / 4 ] ;
191
- } else if ( address >= FLASH_START_ADDRESS && address < FLASH_END_ADDRESS ) {
190
+ } else if (
191
+ address >= FLASH_START_ADDRESS &&
192
+ address < FLASH_START_ADDRESS + this . flash . length
193
+ ) {
192
194
return this . flashView . getUint32 ( address - FLASH_START_ADDRESS , true ) ;
193
195
} else if ( address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this . sram . length ) {
194
196
return this . sramView . getUint32 ( address - RAM_START_ADDRESS , true ) ;
@@ -218,7 +220,7 @@ export class RP2040 {
218
220
219
221
/** We assume the address is 16-bit aligned */
220
222
readUint16 ( address : number ) {
221
- if ( address >= FLASH_START_ADDRESS && address < FLASH_END_ADDRESS ) {
223
+ if ( address >= FLASH_START_ADDRESS && address < FLASH_START_ADDRESS + this . flash . length ) {
222
224
return this . flashView . getUint16 ( address - FLASH_START_ADDRESS , true ) ;
223
225
} else if ( address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this . sram . length ) {
224
226
return this . sramView . getUint16 ( address - RAM_START_ADDRESS , true ) ;
@@ -229,7 +231,7 @@ export class RP2040 {
229
231
}
230
232
231
233
readUint8 ( address : number ) {
232
- if ( address >= FLASH_START_ADDRESS && address < FLASH_END_ADDRESS ) {
234
+ if ( address >= FLASH_START_ADDRESS && address < FLASH_START_ADDRESS + this . flash . length ) {
233
235
return this . flash [ address - FLASH_START_ADDRESS ] ;
234
236
} else if ( address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this . sram . length ) {
235
237
return this . sram [ address - RAM_START_ADDRESS ] ;
@@ -249,7 +251,10 @@ export class RP2040 {
249
251
peripheral . writeUint32Atomic ( offset , value , atomicType ) ;
250
252
} else if ( address < bootrom . length * 4 ) {
251
253
bootrom [ address / 4 ] = value ;
252
- } else if ( address >= FLASH_START_ADDRESS && address < FLASH_END_ADDRESS ) {
254
+ } else if (
255
+ address >= FLASH_START_ADDRESS &&
256
+ address < FLASH_START_ADDRESS + this . flash . length
257
+ ) {
253
258
this . flashView . setUint32 ( address - FLASH_START_ADDRESS , value , true ) ;
254
259
} else if ( address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this . sram . length ) {
255
260
this . sramView . setUint32 ( address - RAM_START_ADDRESS , value , true ) ;
0 commit comments