arduino / arduino/ArduinoCore-mbed
Invalid approach to setting `upload.maximum_size` property for Portenta H7
- Dominant language
- C
- Stars
- 411
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the problem
The Arduino development tools check the memory usage of the compiled sketch:
https://arduino.github.io/arduino-cli/dev/platform-specification/#recipes-to-compute-binary-sketch-size
The determined usage values are compared against the value of the `upload.maximum_size` and `upload.maximum_data_size` platform properties in order to:
- Provide relative as well as absolute values in the memory usage report
- Fail the compilation with a user friendly error if the memory usage exceeds the maximum value
For the Portenta H7 board, the appropriate `upload.maximum_size` value is dependent on two factors:
- Which core is being compiled for
- The setting of the "**Flash split**" custom board option
Previously there was a separate Portenta H7 board definition for each core. The [two board definitions were merged](https://github.com/arduino/ArduinoCore-mbed/commit/29184e93ae0ef4d03b3e0bcca74caaa52b4182eb), switching to using a custom board option to select the core. During that merge, the system for setting the `upload.maximum_size` property broke.
These lines:
https://github.com/arduino/ArduinoCore-mbed/blob/64d42ffb0021352dd4a8acd53b461d8466523413/boards.txt#L150-L152
define unused arbitrary properties named `menu.split.50_50.upload.maximum_size`, `menu.split.75_25.upload.maximum_size`, `menu.split.100_0.upload.maximum_size` rather than the `upload.maximum_size` property as intended.
🐛 The misconfiguration causes there to be no memory usage report or check when compiling for the Portenta H7.
### To reproduce
Compile any sketch for the "Arduino Portenta H7" board.
🐛 The compilation output does not include a memory usage report.
### Suggested fix
The Arduino boards platform framework does not provide a way to set properties conditional on the settings of multiple custom board options so I don't see a way to set the `upload.maximum_size` property via the platform configuration files alone. Fortunately a more powerful sizer system is now available:
https://arduino.github.io/arduino-cli/dev/platform-specification/#recipes-to-compute-binary-sketch-size-for-more-complex-systems-since-arduino-cli-0210
A custom sizer tool could be created that wraps `arm-none-eabi-size` to get the memory usage values and calculates the correct maximum values according to arguments passed to the tool via arguments in the `recipe.advanced_size.pattern` command pattern defined in `platform.txt`. The arguments would use properties set in the "Flash split" and "Target core" custom board options.
### Platform version
https://github.com/arduino/ArduinoCore-mbed/commit/64d42ffb0021352dd4a8acd53b461d8466523413
### Additional context
The Portenta X8 board is also missing a `upload.maximum_size` property and so doesn't produce a memory usage report. However, that is result of the property simply never having been added to the board definition rather than a regression.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Portenta H7 entries in boards.txt around lines 150-152 and the recipe.advanced_size.pattern configuration in platform.txt, then reproduce the missing memory report by compiling a sketch for each relevant core and Flash split. Done means the compiler reports memory usage and checks the correct maximum values for the Portenta H7 configurations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100