- Notifications
You must be signed in to change notification settings - Fork 29
build: Automatically determine image format to flash #290
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
Conversation
| @ARMmbed/mbed-os-core |
4c701a3 to c1f6ba7 Compare 8b54d55 to 1d4ca60 Compare 1d4ca60 to d066e50 Compare Codecov Report
@@ Coverage Diff @@ ## master #290 +/- ## ========================================== - Coverage 97.08% 97.08% -0.01% ========================================== Files 92 92 Lines 2781 2779 -2 ========================================== - Hits 2700 2698 -2 Misses 81 81
|
b2ced9f to fea9046 Compare | Now tests and code coverage should be good, the PR is ready for review. |
src/mbed_tools/build/config.py Outdated
| Return: | ||
| True if the target's "OUTPUT_EXT" is "hex" in targets.json. | ||
| """ | ||
| targets_data = _load_raw_targets_data(program) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than loading and parsing targets.json again here just to find the output extension, should we refactor generate_config to separate the rendering and writing of the output file from the config assembly and make it return a Config? Then we can just pull OUTPUT_EXT out of the Config object in build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a Config is a nice idea! I was wondering how to avoid loading json twice.
Currently generate_config returns the path to the output file, I'm changing it to also return the config itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwalton-arm Thanks, nice suggestions
src/mbed_tools/build/config.py Outdated
| Return: | ||
| True if the target's "OUTPUT_EXT" is "hex" in targets.json. | ||
| """ | ||
| targets_data = _load_raw_targets_data(program) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a Config is a nice idea! I was wondering how to avoid loading json twice.
Currently generate_config returns the path to the output file, I'm changing it to also return the config itself.
fea9046 to 4a9f25a Compare | LGTM, just needs to be rebased. |
- Added diff, color, check to help to show the failure logs
In 23f24a4 we added support for `MBED_OUTPUT_EXT` in `mbed_config.cmake`. Test coverage for it was previously missing.
The default image format is bin, but targets can override it with `"OUTPUT_EXT": "hex"` in `targets.json`. This is already taken care of in the CMake configuration generated by mbed-tools, but user still need to pass `--hex-file` if they want to run `mbed-tools compile` with `--flash` to flash a hex image. This commit makes the image selection automatic based on `OUTPUT_EXT`. Note: `--hex-file` is now redundant and thus removed. It does not make sense to have it anymore without also offering `--bin-file` for completeness. The test cases for bin and hex image flashing have been updated accordingly.
4a9f25a to 049a07b Compare | @rwalton-arm Thanks, rebased. |
Description
The default image format is bin, but targets can override it with
"OUTPUT_EXT": "hex"intargets.json. This is already taken care of in the CMake configuration generated by mbed-tools, but user still need to pass--hex-imageif they want to runmbed-tools compilewith--flashto flash a hex image.This commit makes the image selection automatic based on
OUTPUT_EXT.Note:
--hex-fileis now redundant and thus removed. It does not make sense to have it anymore without also offering--bin-filefor completeness.The test cases for bin and hex image flashing have been updated accordingly. Coverage for
OUTPUT_EXThas been improved, with bothmbed_config.cmakeand image format to flash checked.Test Coverage
The test case for hex image flashing has been updated accordingly.
Also manually tested on NRF52_DK (hex image) and DISCO_L475VG_IOT01A (bin image).