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

Writing option bytes on STM32 G070/G071/G081 #1155

Closed
5 tasks done
spark-ict opened this issue Jun 22, 2021 · 3 comments
Closed
5 tasks done

Writing option bytes on STM32 G070/G071/G081 #1155

spark-ict opened this issue Jun 22, 2021 · 3 comments

Comments

@spark-ict
Copy link

spark-ict commented Jun 22, 2021

when i try to make the flash writable again rith rt-flas i get an error, looks like option boot writting is not implemented yet for this chip

  • Programmer/board type: STlink V2
  • Operating system an version: Linux
  • stlink tools version 1.7.0
  • stlink commandline tool name: st-flash
  • Target chip (and board, if applicable): STM32G070/G071/G081
command:  sudo ./st-flash --area=option_boot_add write 0xdffbe1aa

Commandline output:

2021-06-22T16:37:45 INFO common.c: G070/G071/G081: 36 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
2021-06-22T16:37:45 ERROR common.c: Option bytes boot address writing is currently not implemented for connected chip
2021-06-22T16:37:45 ERROR common.c: Flash option write failed!

thank you for helping us. if you want us to do further investigation please let me know

best regards,
Guus Hamann
Rural Spark

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Jan 22, 2022

The required device-specific parametres according to the related ST reference manual are available in the chip file and have been verified with #1216. However they don't appear to be read due to a missing implementation in option_bytes.c.

@Nightwalker-87
Copy link
Member

@gszy @simplerobot: I looked at the switch-case in int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t *base, uint32_t len) within option_bytes.c
There we find: case STM32_FLASH_TYPE_G0: without any break, so in this case it should proceed with case STM32_FLASH_TYPE_G4: where stlink_write_option_bytes_gx(sl, addr, base, len) is called, so it should actually work...

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Apr 7, 2023

I've done some further research on this issue:
The only evidence for the observed behaviour is found in option_bytes.c (Line 1078):

  switch (sl->flash_type) {
  case STM32_FLASH_TYPE_F7:
    ret = stlink_write_option_bytes_boot_add_f7(sl, option_bytes_boot_add);
    break;
  default:
    ELOG("Option bytes boot address writing is currently not implemented for connected chip\n");
    break;

This implies that a wrong flash_type must have been defined in the respective chip file G070/G071/G081 in the particular case (flash_type = 5 -> F7 instead of flash_type = 7 -> G0), dependent on the order of the defined enum stlink_flash_type { } in stlink.h

Commit 8d96e76 introduced a human readable form for the parametre flash_type to avoid such bugs and/or accidental mistakes.

@Nightwalker-87 Nightwalker-87 changed the title [feature] Support for writing option bytes on STM32 G070/G071/G081 Writing option bytes on STM32 G070/G071/G081 Apr 7, 2023
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 8, 2023
@Nightwalker-87 Nightwalker-87 unpinned this issue Apr 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants