-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
custom_usermod improvements #5403
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 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b97b46a
Use new section for dynamic arrays
willmmiles 3bfbbab
Formalize dynarray system
willmmiles ac1a4df
validate_modules: Remove obsolete code
willmmiles 1929267
Support lib_deps syntax in custom_usermods
willmmiles 210b4d8
Add external usermod example
willmmiles 05498f2
Apply fixes from code review
willmmiles 7f44396
validate_modules: Support LTO
willmmiles 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Add a section to the linker script to store our dynamic arrays | ||
| # This is implemented as a pio post-script to ensure that we can | ||
| # place our linker script at the correct point in the command arguments. | ||
| Import("env") | ||
| from pathlib import Path | ||
|
|
||
| platform = env.get("PIOPLATFORM") | ||
| script_file = Path(f"tools/dynarray_{platform}.ld") | ||
| if script_file.is_file(): | ||
| linker_script = f"-T{script_file}" | ||
| if platform == "espressif32": | ||
| # For ESP32, the script must be added at the right point in the list | ||
| linkflags = env.get("LINKFLAGS", []) | ||
| idx = linkflags.index("memory.ld") | ||
| linkflags.insert(idx+1, linker_script) | ||
| env.Replace(LINKFLAGS=linkflags) | ||
| else: | ||
| # For other platforms, put it in last | ||
| env.Append(LINKFLAGS=[linker_script]) | ||
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
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
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,10 @@ | ||
| /* ESP32 linker script fragment to add dynamic array section to binary */ | ||
| SECTIONS | ||
| { | ||
| .dynarray : | ||
| { | ||
| . = ALIGN(0x10); | ||
| KEEP(*(SORT_BY_INIT_PRIORITY(.dynarray.*))) | ||
| } > default_rodata_seg | ||
| } | ||
| INSERT AFTER .flash.rodata; |
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,34 @@ | ||
| /* dynarray.h | ||
|
|
||
| Macros for generating a "dynamic array", a static array of objects declared in different translation units | ||
|
|
||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| // Declare the beginning and ending elements of a dynamic array of 'type'. | ||
| // This must be used in only one translation unit in your program for any given array. | ||
| #define DECLARE_DYNARRAY(type, array_name) \ | ||
| static type const DYNARRAY_BEGIN(array_name)[0] __attribute__((__section__(DYNARRAY_SECTION "." #array_name ".0"), unused)) = {}; \ | ||
| static type const DYNARRAY_END(array_name)[0] __attribute__((__section__(DYNARRAY_SECTION "." #array_name ".99999"), unused)) = {}; | ||
|
|
||
| // Declare an object that is a member of a dynamic array. "member name" must be unique; "array_section" is an integer for ordering items. | ||
| // It is legal to define multiple items with the same section name; the order of those items will be up to the linker. | ||
| #define DYNARRAY_MEMBER(type, array_name, member_name, array_section) type const member_name __attribute__((__section__(DYNARRAY_SECTION "." #array_name "." #array_section), used)) | ||
willmmiles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #define DYNARRAY_BEGIN(array_name) array_name##_begin | ||
| #define DYNARRAY_END(array_name) array_name##_end | ||
| #define DYNARRAY_LENGTH(array_name) (&DYNARRAY_END(array_name)[0] - &DYNARRAY_BEGIN(array_name)[0]) | ||
|
|
||
| #ifdef ESP8266 | ||
| // ESP8266 linker script cannot be extended with a unique section for dynamic arrays. | ||
| // We instead pack them in the ".dtors" section, as it's sorted and uploaded to the flash | ||
| // (but will never be used in the embedded system) | ||
| #define DYNARRAY_SECTION ".dtors" | ||
|
|
||
| #else /* ESP8266 */ | ||
|
|
||
| // Use a unique named section; the linker script must be extended to ensure it's correctly placed. | ||
| #define DYNARRAY_SECTION ".dynarray" | ||
|
|
||
| #endif | ||
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.