46
46
#include "src/rp2_common/hardware_flash/include/hardware/flash.h"
47
47
#include "src/common/pico_binary_info/include/pico/binary_info.h"
48
48
49
- #if !defined(RESERVED_FLASH )
50
- #define RESERVED_FLASH (1 * 1024 * 1024)
51
- #endif
52
-
53
49
#if !defined(TOTAL_FLASH_MINIMUM )
54
50
#define TOTAL_FLASH_MINIMUM (2 * 1024 * 1024)
55
51
#endif
@@ -65,8 +61,8 @@ void supervisor_flash_init(void) {
65
61
bi_decl_if_func_used (bi_block_device (
66
62
BINARY_INFO_MAKE_TAG ('C' , 'P' ),
67
63
"CircuitPython" ,
68
- RESERVED_FLASH ,
69
- TOTAL_FLASH_MINIMUM - RESERVED_FLASH , // This is a minimum. We can't set it dynamically.
64
+ CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR ,
65
+ TOTAL_FLASH_MINIMUM - CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR , // This is a minimum. We can't set it dynamically.
70
66
NULL ,
71
67
BINARY_INFO_BLOCK_DEV_FLAG_READ |
72
68
BINARY_INFO_BLOCK_DEV_FLAG_WRITE |
@@ -92,23 +88,23 @@ uint32_t supervisor_flash_get_block_size(void) {
92
88
}
93
89
94
90
uint32_t supervisor_flash_get_block_count (void ) {
95
- return (_flash_size - RESERVED_FLASH ) / FILESYSTEM_BLOCK_SIZE ;
91
+ return (_flash_size - CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR ) / FILESYSTEM_BLOCK_SIZE ;
96
92
}
97
93
98
94
void port_internal_flash_flush (void ) {
99
95
if (_cache_lba == NO_CACHE ) {
100
96
return ;
101
97
}
102
98
common_hal_mcu_disable_interrupts ();
103
- flash_range_erase (RESERVED_FLASH + _cache_lba , SECTOR_SIZE );
104
- flash_range_program (RESERVED_FLASH + _cache_lba , _cache , SECTOR_SIZE );
99
+ flash_range_erase (CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR + _cache_lba , SECTOR_SIZE );
100
+ flash_range_program (CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR + _cache_lba , _cache , SECTOR_SIZE );
105
101
common_hal_mcu_enable_interrupts ();
106
102
_cache_lba = NO_CACHE ;
107
103
}
108
104
109
105
mp_uint_t supervisor_flash_read_blocks (uint8_t * dest , uint32_t block , uint32_t num_blocks ) {
110
106
memcpy (dest ,
111
- (void * )(XIP_BASE + RESERVED_FLASH + block * FILESYSTEM_BLOCK_SIZE ),
107
+ (void * )(XIP_BASE + CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR + block * FILESYSTEM_BLOCK_SIZE ),
112
108
num_blocks * FILESYSTEM_BLOCK_SIZE );
113
109
return 0 ;
114
110
}
@@ -123,7 +119,7 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
123
119
124
120
if (_cache_lba != block_address ) {
125
121
memcpy (_cache ,
126
- (void * )(XIP_BASE + RESERVED_FLASH + sector_offset ),
122
+ (void * )(XIP_BASE + CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR + sector_offset ),
127
123
SECTOR_SIZE );
128
124
_cache_lba = sector_offset ;
129
125
}
@@ -139,8 +135,8 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
139
135
}
140
136
// Make sure we don't have an interrupt while we do flash operations.
141
137
common_hal_mcu_disable_interrupts ();
142
- flash_range_erase (RESERVED_FLASH + sector_offset , SECTOR_SIZE );
143
- flash_range_program (RESERVED_FLASH + sector_offset , _cache , SECTOR_SIZE );
138
+ flash_range_erase (CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR + sector_offset , SECTOR_SIZE );
139
+ flash_range_program (CIRCUITPY_CIRCUITPY_DRIVE_START_ADDR + sector_offset , _cache , SECTOR_SIZE );
144
140
common_hal_mcu_enable_interrupts ();
145
141
}
146
142
0 commit comments