-
Notifications
You must be signed in to change notification settings - Fork 7k
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
west: Introduce run once commands (e.g. erase, recover) and deferred reset #69748
west: Introduce run once commands (e.g. erase, recover) and deferred reset #69748
Conversation
4ad6619
to
915fc92
Compare
a4297bd
to
518b393
Compare
518b393
to
d298929
Compare
d298929
to
29c7ef6
Compare
soc/nordic/soc.yml
Outdated
run_once: | ||
- '--recover': | ||
- boards: | ||
- /(.+)/nrf5340/cpunet/ |
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.
Why would you have an entry with a single board target like this? what's the point of saying "run once" for a single target?
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.
You could be flashing multiple images to the network core, for example mcuboot, slot0 application and slot1 application, with this if you do west flash --recover
then you get one recover and 3 flashes, without it you get 3 recovers and 3 flashes (thus a broken image). The run one actions only apply if there is an entry
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.
OK, I see!
soc/nordic/soc.yml
Outdated
- name: nrf9161 | ||
|
||
# Recovery/erase is only needed once per core. | ||
run_once: |
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.
a top-level "run_conce" key feels weird here, I'd suggest something like:
flashing:
- singlerun:
...
- anyfuturestuff:
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.
(or flash.yml
...)
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.
This was a separate file initially but moved into these files because "of too many yaml files" concerns raised by others
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.
This was a separate file initially but moved into these files because "of too many yaml files" concerns raised by others
IMHO mixing files purpose is not a good idea either.
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.
IMHO mixing files purpose is not a good idea either.
feel free to join the discussion: #50305 (comment)
I feel the same, multiple files can be easier to read understand if the are well named and organized, quote:
The fact that both files are in yaml doesn't mean there should be one huge yaml file containing everything.
But there was request to unify and have a single source for various meta data:
#50305 (comment)
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.
Main issues I see with current approach relates to yaml file / schema:
- Multiple
boards:
entries seems to be creating a group, but it's not clear what a group is, and whether such a group should have a name. Should be made clearer. - Misuse of yaml keys, so that instead of being a key, it actually is a value.
Please use akey: value
pair for such cases. board.yml
seems to be able to reference board names which have no relation to the boards defined by theboard.yml
. Please ensure that only boards defined by the board.yml itself can be referenced in the commands sections. Similar for thesoc.yml
.
scripts/west_commands/run_common.py
Outdated
for grp in data_yaml['run_once']: | ||
for c, b in grp.items(): | ||
for d in b: | ||
used_cmds.append(UsedFlashCommand(c, d['boards'])) |
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.
it has been mentioned in offline discussion that a reason for placing value
as the key is simpler Python parsing.
I assume that comment referred to this code, but why is this code simpler than:
for command in t['run_once']:
used_cmds.append(UsedFlashCommand(command.get('command'), command.get('boards))
To me, removing two for loops seems even simpler.
sequence: | ||
- type: map | ||
mapping: | ||
regex;(.*): |
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.
this makes the command to become a key in the yaml file, not a value.
As I see it, there are two main implecations of such approach
- The free form
.*
means there is effectively no schema check, as anything is allowed for a value. - A
:
must suddenly follow thevalue
.
In yaml, a value is either after the colon, like:
<key>: <value>
or a list of values, like:my_list: - value1 - value2 - value3 - ...
but you're creating a list of maps, but where the key
in that list is actually the value.
I don't see why regular key: value
mapping cannot be used, and thereby avoid tricks like this.
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.
Unification with snippets
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.
but not unified with boards.yml.
For example, the board.yml for nrf9160dk does:
board:
name: nrf9160dk
vendor: nordic
socs:
- name: nrf9160
variants:
- name: 'ns'
- name: nrf52840
and not:
board:
name: nrf9160dk
vendor: nordic
socs:
- nrf9160:
variants:
- name: 'ns'
- nrf52840:
The fact that snippet does this does not justify this principle in board or soc yaml files.
Especially not when this proposal introduces inconsistency on how things are done within the same yaml file.
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.
See also comment here: #69748 (comment)
except FileNotFoundError: | ||
continue |
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.
something to handle ?
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.
No, hwmv1 so can be ignored
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.
then please add a comment in code, for example:
except FileNotFoundError: | |
continue | |
except FileNotFoundError: | |
# Legacy boards don't have a board.yml or soc.yml. | |
continue |
soc/nordic/soc.yml
Outdated
- name: nrf9161 | ||
|
||
# Recovery/erase is only needed once per core. | ||
run_once: |
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.
IMHO mixing files purpose is not a good idea either.
feel free to join the discussion: #50305 (comment)
I feel the same, multiple files can be easier to read understand if the are well named and organized, quote:
The fact that both files are in yaml doesn't mean there should be one huge yaml file containing everything.
But there was request to unify and have a single source for various meta data:
#50305 (comment)
soc/nordic/soc.yml
Outdated
- /(.+)/nrf5340/cpunet/ | ||
- boards: | ||
- /(.+)/nrf5340/cpuapp/ | ||
- /(.+)/nrf5340/cpuapp/ns/ |
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.
A soc.yml should really not know anything about board variants.
A board variant is defined by the board and could be named anything.
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.
There needs to be a uniform naming scheme. And ns is going to be mandated by TFM anyhow
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.
For ns
, but there can be many other variant names.
Variant names, just like other board names, should not be defined by the soc.yml.
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.
That's up to vendors if they want to change, and if they do they can add this into their board.yml file, it is not an issue
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.
I agree that the groups in soc.yml
should only account for socs and cpuclusters, not whole board targets.
I can't imagine a use case where a board variant would be in a separate group from its parent soc/cpucluster anyway.
But if there is one, then further refinement should be possible in board.yml
.
Architecture WG:
|
29c7ef6
to
7477e8f
Compare
@fabiobaltieri @JordanYates is the PR acceptable? If so, can you approve please? |
To be totally honest I don't love it, it seems fairly complex, but I also don't really have any alternative to suggest so fine by me. |
@nordicjm please rebase |
This adds supports for flashing images with sysbuild where there are multiple images per board to prevent using the same command per image flash which might cause issues if they are not ran just once per flash per unique board name. A deferred reset feature is also introduced that prevents a board (or multiple) from being reset if multiple images are to be flashed until the final one has been flashed which prevents issues with e.g. security bits being enabled that then prevent flashing further images. These options can be set at a board level (in board.yml) or a SoC level (in soc.yml), if both are present then the board configuration will be used instead of the SoC, and regex can be used for matching of partial names which allows for matching specific SoCs or CPU cores regardless of the board being used Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Reformats the soc.yml file to have uniform 2-space indentation Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds configuration that allows nRF53 and nRF91-based boards to be flashed through west using sysbuild for multiple images with the recover or erase options and prevent running those commands for each image being flash, which would make the device unbootable. Also defers reset whilst all images for the cores of these SoCs are flashed. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds documentation on the new flashing configuration system Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a note that a new flashing configuration system has been added for boards and socs Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds checking that qualifiers listed in a soc.yml file are valid for the socs and cpuclusters defined in that file Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
0cea6aa
to
e2b1cda
Compare
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.
Removing assignee since @tejlmand is opting out of this particular review. |
Using `erase` with west-flash was blocked as it was messing with sysbuild. With zephyrproject-rtos#69748 the issue is fixed, hence 'erase' is no longer blocked. Remove obsolete twister test Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Using `erase` with west-flash was blocked as it was messing with sysbuild. With #69748 the issue is fixed, hence 'erase' is no longer blocked. Remove obsolete twister test Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Using `erase` with west-flash was blocked as it was messing with sysbuild. With zephyrproject-rtos#69748 the issue is fixed, hence 'erase' is no longer blocked. Remove obsolete twister test Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no> (cherry picked from commit be682e2)
Using `erase` with west-flash was blocked as it was messing with sysbuild. With zephyrproject-rtos#69748 the issue is fixed, hence 'erase' is no longer blocked. Remove obsolete twister test Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Introduces additional fields to soc.yml or board.yml which can be used to specify
west flash
commands that should be grouped for multiple boards when using sysbuild, this allows usage of e.g.--erase
to allow the flash to be erased once when flashing a set of images rather than once per image which would erase what had just been programmed. The format of this is the command then a list of boards which are part of the group whereby it will only be executed one for. Also supported is grouping boards to prevent resetting of the CPUs after programming when multiple images are being programmed until all images for the grouped cores have been programmed, at which point the CPU can be reset, this is ideal for multiple cores or things like TF-M.TODO list: