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

STM32F103CBT6: Flash verification fails when writing #1105

Closed
6 tasks done
HexF opened this issue Mar 16, 2021 · 6 comments · Fixed by #1113
Closed
6 tasks done

STM32F103CBT6: Flash verification fails when writing #1105

HexF opened this issue Mar 16, 2021 · 6 comments · Fixed by #1113

Comments

@HexF
Copy link

HexF commented Mar 16, 2021

In order to allow developers and other contributors to isolate and target your respective issue, please take some time to select the check boxes below
and fill out each of the following items appropriate to your specific problem.

  • Programmer/board type: STLink v2 Clone and STLink v2
  • Operating system an version: Linux (NixOS 20.09)
  • Stlink tools version and/or git commit hash: v1.6.0 (nixpkg)
  • Stlink commandline tool name: st-flash
  • Target chip (and board, if applicable): STM32F103CBT6 (Custom PCB)
nix-shell:~/Projects/brainware]$ sudo st-flash --reset write build/src/brainware.bin 0x08000000
st-flash 1.6.0
2021-03-16T18:47:27 INFO common.c: Loading device parameters....
2021-03-16T18:47:27 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2021-03-16T18:47:27 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2021-03-16T18:47:27 INFO common.c: Attempting to write 15088 (0x3af0) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08003800 erased
2021-03-16T18:47:27 INFO common.c: Finished erasing 15 pages of 1024 (0x400) bytes
2021-03-16T18:47:27 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2021-03-16T18:47:27 INFO flash_loader.c: Successfully loaded flash loader in sram
 15/15 pages written
2021-03-16T18:47:28 INFO common.c: Starting verification of write complete
2021-03-16T18:47:28 ERROR common.c: Verification of flash failed at offset: 0
stlink_fwrite_flash() == -1

The flashing of the processor seems to fail at this point, as in the aforementioned issue.
One technicality that I have noted is that people are assuming the F103C8 and F103CB chips are the same, and infact they are not.
I have tested the exact same command with a C8 chip, and it worked perfectly fine, but upgrading to a CB chip (which I have had ST confirm are genuine and not counterfeits)

I loaded up a Windows PC with the STLink Utility from ST and it flashed the chip perfectly fine. I was then able to confirm that the flash reads back using st-flash on my Linux machine fine, and it matched byte-for-byte the built firmware.
However, if I ignore the verification failing on Linux, and run the same read command - I get completely random data.

Any pointers on what to do?

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Mar 16, 2021

@HexF: Please use the latest version of the toolset (currently 1.6.1) when reporting bugs. It would also be helpful to know if the error still occurs in the latest develop branch.

@HexF
Copy link
Author

HexF commented Mar 16, 2021

Using 9956bde (latest develop commit) I get:

nix-shell:~/Projects.local/brainware]$ sudo st-flash --reset write build/src/brainware.bin 0x08000000
st-flash 1.6.1
2021-03-16T22:34:31 WARN usb.c: NRST is not connected
2021-03-16T22:34:31 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 128 KiB flash in at least 1 KiB pages.
2021-03-16T22:34:31 WARN usb.c: NRST is not connected
file build/src/brainware.bin md5 checksum: 53116e8ca4448facb7c4895364041f7, stlink checksum: 0x00179d53
2021-03-16T22:34:31 INFO common.c: Attempting to write 15088 (0x3af0) bytes to stm32 address: 134217728 (0x8000000)
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08000000 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08000400 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08000800 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08000c00 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08001000 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08001400 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08001800 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08001c00 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08002000 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08002400 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08002800 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08002c00 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08003000 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08003400 erased
2021-03-16T22:34:31 INFO common.c: Flash page at addr: 0x08003800 erased
2021-03-16T22:34:31 INFO common.c: Finished erasing 15 pages of 1024 (0x400) bytes
2021-03-16T22:34:31 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL
2021-03-16T22:34:31 INFO flash_loader.c: Successfully loaded flash loader in sram
 15/ 15 pages written
2021-03-16T22:34:32 INFO common.c: Starting verification of write complete
2021-03-16T22:34:32 ERROR common.c: Verification of flash failed at offset: 0
stlink_fwrite_flash() == -1

Basically the same, just more text

@Ant-ON
Copy link
Collaborator

Ant-ON commented Mar 19, 2021

Can you try https://github.com/Ant-ON/stlink/tree/flash_loader_rework? I'm trying to improve a work of bootloaders...

@HexF
Copy link
Author

HexF commented Mar 22, 2021

@Ant-ON That seems to have fixed it:

[nix-shell:~/Projects.local/brainware]$ st-flash --reset write build/src/brainware.bin 0x08000000
st-flash 1.6.1
2021-03-22T18:26:14 WARN usb.c: NRST is not connected
2021-03-22T18:26:14 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 128 KiB flash in at least 1 KiB pages.
2021-03-22T18:26:14 WARN usb.c: NRST is not connected
file build/src/brainware.bin md5 checksum: fe4bf5eb73e1a0fc4bfdcf37ff4a651f, stlink checksum: 0x00179d59
2021-03-22T18:26:14 INFO common.c: Attempting to write 15088 (0x3af0) bytes to stm32 address: 134217728 (0x8000000)
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08000000 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08000400 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08000800 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08000c00 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08001000 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08001400 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08001800 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08001c00 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08002000 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08002400 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08002800 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08002c00 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08003000 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08003400 erased
2021-03-22T18:26:14 INFO common.c: Flash page at addr: 0x08003800 erased
2021-03-22T18:26:14 INFO common.c: Finished erasing 15 pages of 1024 (0x400) bytes
2021-03-22T18:26:14 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL
2021-03-22T18:26:14 INFO flash_loader.c: Successfully loaded flash loader in sram
 15/ 15 pages written
2021-03-22T18:26:15 INFO common.c: Starting verification of write complete
2021-03-22T18:26:15 INFO common.c: Flash written and verified! jolly good!
2021-03-22T18:26:15 WARN usb.c: NRST is not connected

@Nightwalker-87
Copy link
Member

@HexF Can you test that in a sequence as well to verify this is not a certain coincidence?

@Nightwalker-87 Nightwalker-87 changed the title [STM32F103CBT6]: Flash verification fails when writing STM32F103CBT6: Flash verification fails when writing Mar 23, 2021
@HexF
Copy link
Author

HexF commented Mar 25, 2021

Yep, running my ninja -C build flash worked perfectly fine

@stlink-org stlink-org locked as resolved and limited conversation to collaborators Mar 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants