Skip to content

Commit

Permalink
Fix for option byte read (#1156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightwalker-87 committed Mar 18, 2023
1 parent 186e38a commit e4fd052
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/st-flash/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,25 @@ int main(int ac, char** av) {
(unsigned)remaining_option_length,
sl->option_base);

if (NULL != o.filename) {
if (0 == o.size) {
o.size = sl->option_size;
}
err = stlink_fread(sl, o.filename, o.format == FLASH_FORMAT_IHEX, sl->option_base, o.size);
} else {
uint32_t option_byte = 0;
err = stlink_read_option_bytes32(sl, &option_byte);
if (err == -1) {
printf("could not read option bytes (%d)\n", err);
uint32_t option_byte = 0;
err = stlink_read_option_bytes32(sl, &option_byte);
if (err == -1) {
printf("could not read option bytes (%d)\n", err);
goto on_error;
} else if (NULL != o.filename) {
// if (0 == o.size) { o.size = sl->option_size; }
// err = stlink_fread(sl, o.filename, o.format == FLASH_FORMAT_IHEX, sl->option_base, o.size);
int fd = open(o.filename, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 00700);
if (fd == -1) {
fprintf(stderr, "open(%s) == -1\n", o.filename);
goto on_error;
} else {
printf("%08x\n", option_byte);
}
write(fd, option_byte, 4);
close(fd);
} else {
printf("%08x\n", option_byte);
}

} else if (o.area == FLASH_OPTION_BYTES_BOOT_ADD) {
uint32_t option_byte = 0;
err = stlink_read_option_bytes_boot_add32(sl, &option_byte);
Expand Down

0 comments on commit e4fd052

Please sign in to comment.