Skip to content

Conversation

@LDong-Arm
Copy link
Contributor

@LDong-Arm LDong-Arm commented Jun 2, 2021

Description

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-image 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. Coverage for OUTPUT_EXT has been improved, with both mbed_config.cmake and image format to flash checked.

Test Coverage

  • This change is covered by existing or additional automated tests.
  • Manual testing has been performed (and evidence provided) as automated testing was not feasible.
  • Additional tests are not required for this change (e.g. documentation update).

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).

@LDong-Arm
Copy link
Contributor Author

@ARMmbed/mbed-os-core

@LDong-Arm LDong-Arm force-pushed the img_format_detection branch 3 times, most recently from 4c701a3 to c1f6ba7 Compare June 2, 2021 16:23
@rajkan01 rajkan01 force-pushed the img_format_detection branch 2 times, most recently from 8b54d55 to 1d4ca60 Compare June 2, 2021 18:10
@LDong-Arm LDong-Arm marked this pull request as draft June 3, 2021 12:09
@LDong-Arm LDong-Arm force-pushed the img_format_detection branch from 1d4ca60 to d066e50 Compare June 3, 2021 13:45
@LDong-Arm LDong-Arm marked this pull request as ready for review June 3, 2021 13:45
@codecov
Copy link

codecov bot commented Jun 3, 2021

Codecov Report

Merging #290 (049a07b) into master (dd71209) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ 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 
Impacted Files Coverage Δ
src/mbed_tools/build/config.py 100.00% <100.00%> (ø)
src/mbed_tools/cli/build.py 100.00% <100.00%> (ø)
src/mbed_tools/cli/configure.py 100.00% <100.00%> (ø)
@LDong-Arm LDong-Arm force-pushed the img_format_detection branch 2 times, most recently from b2ced9f to fea9046 Compare June 3, 2021 15:01
@LDong-Arm
Copy link
Contributor Author

Now tests and code coverage should be good, the PR is ready for review.

Return:
True if the target's "OUTPUT_EXT" is "hex" in targets.json.
"""
targets_data = _load_raw_targets_data(program)
Copy link
Contributor

@rwalton-arm rwalton-arm Jun 4, 2021

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@LDong-Arm LDong-Arm left a 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

Return:
True if the target's "OUTPUT_EXT" is "hex" in targets.json.
"""
targets_data = _load_raw_targets_data(program)
Copy link
Contributor Author

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.

@LDong-Arm LDong-Arm force-pushed the img_format_detection branch from fea9046 to 4a9f25a Compare June 4, 2021 11:36
@LDong-Arm LDong-Arm requested a review from rwalton-arm June 4, 2021 11:57
@rwalton-arm
Copy link
Contributor

LGTM, just needs to be rebased.

rajkan01 and others added 3 commits June 7, 2021 16:11
- 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.
@LDong-Arm LDong-Arm force-pushed the img_format_detection branch from 4a9f25a to 049a07b Compare June 7, 2021 15:11
@LDong-Arm
Copy link
Contributor Author

@rwalton-arm Thanks, rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants