forked from jhoff/Split-Flap-Display
-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: grow app partitions to 1.5MB - C3 image no longer fits stock table #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # FAIL THE BUILD IF firmware.bin DOES NOT FIT THE APP PARTITION | ||
| # | ||
| # PlatformIO's "Flash: X% (used N from M)" check sums ELF sections, but the | ||
| # flashed .bin also contains MMU-alignment padding between mapped segments | ||
| # (~113KB on ESP32-C3). The bootloader validates the *full image length* | ||
| # against the app partition on every boot and refuses to boot an image that | ||
| # spills past it - an endless rst:0x3 reset loop with no error visible on | ||
| # USB-only boards. So the on-disk .bin size, not PlatformIO's figure, is the | ||
| # number that matters. | ||
| Import("env") | ||
|
|
||
| import csv | ||
| import os | ||
|
|
||
|
|
||
| def get_app_partition_size(): | ||
| partitions = env.BoardConfig().get("build.partitions", "default.csv") | ||
| path = partitions | ||
| if not os.path.isabs(path): | ||
| candidate = os.path.join(env.subst("$PROJECT_DIR"), partitions) | ||
| if os.path.exists(candidate): | ||
| path = candidate | ||
| else: | ||
| framework_dir = env.PioPlatform().get_package_dir( | ||
| "framework-arduinoespressif32" | ||
| ) | ||
| path = os.path.join(framework_dir, "tools", "partitions", partitions) | ||
| sizes = [] | ||
| with open(path) as f: | ||
| for row in csv.reader(f): | ||
| if not row or row[0].strip().startswith("#") or len(row) < 5: | ||
| continue | ||
| if row[1].strip() == "app": | ||
| sizes.append(int(row[4].strip(), 0)) | ||
| if not sizes: | ||
| raise RuntimeError("No app partitions found in " + path) | ||
| return min(sizes), path | ||
|
|
||
|
|
||
| def check_bin_size(source, target, env): | ||
| bin_path = env.subst("$BUILD_DIR/${PROGNAME}.bin") | ||
| bin_size = os.path.getsize(bin_path) | ||
| app_size, table = get_app_partition_size() | ||
| pct = bin_size / app_size * 100 | ||
| print( | ||
| "APPSIZE: firmware.bin is %d bytes, app partition is %d bytes (%.1f%%)" | ||
| % (bin_size, app_size, pct) | ||
| ) | ||
| if bin_size > app_size: | ||
| print( | ||
| "APPSIZE: ERROR - firmware.bin exceeds the app partition in %s by " | ||
| "%d bytes. The bootloader will refuse to boot this image " | ||
| "(silent rst:0x3 boot loop). Shrink the firmware or grow the app " | ||
| "partitions." % (table, bin_size - app_size) | ||
| ) | ||
| env.Exit(1) | ||
|
|
||
|
|
||
| env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_bin_size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Custom 4MB layout: app slots grown to 1.5MB (0x180000) each, filesystem | ||
| # shrunk to 896KB (0xE0000). The stock default.csv's 1.25MB app slots are too | ||
| # small for this firmware's ESP32-C3 image: the flashed .bin includes ~113KB | ||
| # of MMU-alignment padding beyond PlatformIO's reported "Flash" figure, and | ||
| # once the .bin exceeds the app partition the bootloader rejects the image on | ||
| # every boot (endless rst:0x3 loop with no output on USB-only boards). | ||
| # Name, Type, SubType, Offset, Size, Flags | ||
| nvs, data, nvs, 0x9000, 0x5000, | ||
| otadata, data, ota, 0xE000, 0x2000, | ||
| app0, app, ota_0, 0x10000, 0x180000, | ||
| app1, app, ota_1, 0x190000, 0x180000, | ||
| spiffs, data, spiffs, 0x310000, 0xE0000, | ||
| coredump, data, coredump, 0x3F0000, 0x10000, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.