Skip to content
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

Fix: Improved support for writing option bytes #1102

Merged
merged 2 commits into from
Mar 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/st-flash/flash_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,14 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) {

case FLASH_CMD_WRITE:
// TODO: should be boot add 0 and boot add 1 uint32
if (o->area == FLASH_OPTION_BYTES) { // expect filename and optional address
if (ac >=1 && ac <= 2) {
o->filename = av[0];
if (o->area == FLASH_OPTION_BYTES) { // expect option byte value
if (ac != 1) { return invalid_args("option byte write <value>"); }
uint32_t val;
result = get_integer_from_char_array(av[0], &val);
if (result != 0) {
return bad_arg ("val");
} else {
return invalid_args("write <path> [addr]");
}

if (ac == 2) {
uint32_t addr;
result = get_integer_from_char_array(av[1], &addr);
if (result != 0) {
return bad_arg ("addr");
} else {
o->addr = (stm32_addr_t) addr;
}
o->val = (uint32_t) val;
}
} else if (o->area == FLASH_OPTION_BYTES_BOOT_ADD) { // expect option bytes boot address
if (ac != 1) { return invalid_args("option bytes boot_add write <value>"); }
Expand Down