Skip to content

Commit ab1e380

Browse files
committed
Use variable name for EEPROM length
1 parent 47ad4e9 commit ab1e380

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

builder/main.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,19 @@ def fetch_fs_size(env):
149149
flash_size = board.get("upload.maximum_size")
150150
filesystem_size = board.get("build.filesystem_size", "0MB")
151151
filesystem_size_int = convert_size_expression_to_int(filesystem_size)
152+
# last 4K are allocated for EEPROM emulation in flash.
153+
# see https://github.com/earlephilhower/arduino-pico/blob/3414b73172d307e9dc901f7fee83b41112f73457/libraries/EEPROM/EEPROM.cpp#L43-L46
154+
eeprom_size = 4096
152155

153-
maximum_sketch_size = flash_size - 4096 - filesystem_size_int
156+
maximum_sketch_size = flash_size - eeprom_size - filesystem_size_int
154157

155158
print("Flash size: %.2fMB" % (flash_size / 1024.0 / 1024.0))
156159
print("Sketch size: %.2fMB" % (maximum_sketch_size / 1024.0 / 1024.0))
157160
print("Filesystem size: %.2fMB" % (filesystem_size_int / 1024.0 / 1024.0))
158161

159-
eeprom_start = 0x10000000 + flash_size - 4096
160-
fs_start = 0x10000000 + flash_size - 4096 - filesystem_size_int
161-
fs_end = 0x10000000 + flash_size - 4096
162+
eeprom_start = 0x10000000 + flash_size - eeprom_size
163+
fs_start = 0x10000000 + flash_size - eeprom_size - filesystem_size_int
164+
fs_end = 0x10000000 + flash_size - eeprom_size
162165

163166
if maximum_sketch_size <= 0:
164167
sys.stderr.write(
@@ -173,7 +176,7 @@ def fetch_fs_size(env):
173176
env["PICO_EEPROM_START"] = eeprom_start
174177
env["FS_START"] = fs_start
175178
env["FS_END"] = fs_end
176-
# LittleFS configuration paramters taken from
179+
# LittleFS configuration parameters taken from
177180
# https://github.com/earlephilhower/arduino-pico-littlefs-plugin/blob/master/src/PicoLittleFS.java
178181
env["FS_PAGE"] = 256
179182
env["FS_BLOCK"] = 4096

0 commit comments

Comments
 (0)