Skip to content

Invalid approach to setting upload.maximum_size property for Portenta H7 #642

@per1234

Description

@per1234

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, 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:

ArduinoCore-mbed/boards.txt

Lines 150 to 152 in 64d42ff

envie_m7.menu.target_core.cm4.menu.split.50_50.upload.maximum_size=1048576
envie_m7.menu.target_core.cm4.menu.split.75_25.upload.maximum_size=524288
envie_m7.menu.target_core.cm4.menu.split.100_0.upload.maximum_size=524288

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

64d42ff

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions