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

New installation 1.7.0 on Ubuntu 18.04 - "Failed to parse flash type or unrecognized flash type" #1290

Closed
Nightwalker-87 opened this issue Dec 30, 2022 Discussed in #1242 · 0 comments · Fixed by #1295
Closed

Comments

@Nightwalker-87
Copy link
Member

Discussed in #1242

Originally posted by wb0gaz April 9, 2022
I'm editing this as my work today (4/9/2022) has yielded progress but led me to a specific problem preventing me from using the tool.

The problem I'm encountering is unable to flash device - the STLINK device itself is being detected, and it can detect the target device properly (chip ID 0x412), however, the two errors below tell me that st-flash may not be performing the task required of it.

I populated /usr/local/stlink/chips (which was not installed when I installed 1.7.0 .deb package) by copying the /chips/ directory to /usr/local/stlink/chips.

The target is STM32F103C6T6 low-density type (0x412), 32K flash, and is being correctly identified.

Below are sessions where I have attempted to erase the target device, and then attempted to read back from the target device (expecting erased flash, FF bytes.) I removed the prefix characters from comment lines in the chips file as this was interacting with HTML.


st-flash erase yields "Failed to parse flash type or unrecognized flash type" and does not appear to run.

$ st-flash --debug erase 0x08000000 4096

st-flash 1.7.0-186-gc4762e6
Failed to parse flash type or unrecognized flash type
2022-04-09T19:48:55 DEBUG common.c: *** looking up stlink version
2022-04-09T19:48:55 DEBUG common.c: st vid = 0x0483 (expect 0x0483)
2022-04-09T19:48:55 DEBUG common.c: stlink pid = 0x3748
2022-04-09T19:48:55 DEBUG common.c: stlink version = 0x2
2022-04-09T19:48:55 DEBUG common.c: jtag version = 0x1d
2022-04-09T19:48:55 DEBUG common.c: swim version = 0x7
2022-04-09T19:48:55 DEBUG common.c: stlink current mode: mass
2022-04-09T19:48:55 DEBUG usb.c: JTAG/SWD freq set to 0
2022-04-09T19:48:55 DEBUG common.c: stlink current mode: mass
2022-04-09T19:48:55 DEBUG common.c: *** stlink_enter_swd_mode ***
2022-04-09T19:48:55 DEBUG common.c: Loading device parameters....
2022-04-09T19:48:55 DEBUG common.c: *** stlink_core_id ***
2022-04-09T19:48:55 DEBUG common.c: core_id = 0x1ba01477
2022-04-09T19:48:55 DEBUG read_write.c: *** stlink_read_debug32 0x411fc231 at 0xe000ed00
2022-04-09T19:48:55 DEBUG read_write.c: *** stlink_read_debug32 0x10006412 at 0xe0042000

detected chip_id parametres

Device Type: STM32F1xx_LD
Reference Manual: RM0008

chip_id 0x412
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x2800
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2

2022-04-09T19:48:55 DEBUG read_write.c: *** stlink_read_debug32 0000000000 at 0x1ffff7e0
2022-04-09T19:48:55 INFO common.c: STM32F1xx_LD: 10 KiB SRAM, 0 KiB flash in at least 1 KiB pages.
2022-04-09T19:48:55 DEBUG common.c: *** stlink_force_debug_mode ***
2022-04-09T19:48:55 DEBUG read_write.c: *** stlink_read_debug32 0x00000300 at 0xe0042004
2022-04-09T19:48:55 DEBUG read_write.c: *** stlink_write_debug32 0x00000300 to 0xe0042004
2022-04-09T19:48:55 DEBUG common.c: *** stlink_status ***
2022-04-09T19:48:55 DEBUG usb.c: core status: 02010001
2022-04-09T19:48:55 DEBUG common.c: core status: reset
2022-04-09T19:48:55 ERROR common_flash.c: Invalid address, it should be within 0x08000000 - 0x07ffffff
stlink_erase_flash_mass() == -1
2022-04-09T19:48:55 DEBUG common.c: *** stlink_exit_debug_mode ***
2022-04-09T19:48:55 DEBUG common.c: *** stlink_close ***
$


st-flash --flash=32k still yields "Failed to parse flash type or unrecognized flash type" but appears to run.

$ st-flash --flash=32k erase 0x08000000 4096

st-flash 1.7.0-186-gc4762e6
Failed to parse flash type or unrecognized flash type

detected chip_id parametres

Device Type: STM32F1xx_LD
Reference Manual: RM0008

chip_id 0x412
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x2800
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2

2022-04-09T19:51:06 INFO common.c: STM32F1xx_LD: 10 KiB SRAM, 0 KiB flash in at least 1 KiB pages.
Forcing flash size: --flash=0x00008000
-> Flash page at 0x8000000 erased (size: 0x400)
-> Flash page at 0x8000400 erased (size: 0x400)
-> Flash page at 0x8000800 erased (size: 0x400)
-> Flash page at 0x8000c00 erased (size: 0x400)

$


After erase, expect FF bytes, however, without --flash=32k option, the read file contains no data bytes.

$ st-flash --debug read read.bin 0x08000000 32768

st-flash 1.7.0-186-gc4762e6
Failed to parse flash type or unrecognized flash type
2022-04-09T19:57:12 DEBUG common.c: *** looking up stlink version
2022-04-09T19:57:12 DEBUG common.c: st vid = 0x0483 (expect 0x0483)
2022-04-09T19:57:12 DEBUG common.c: stlink pid = 0x3748
2022-04-09T19:57:12 DEBUG common.c: stlink version = 0x2
2022-04-09T19:57:12 DEBUG common.c: jtag version = 0x1d
2022-04-09T19:57:12 DEBUG common.c: swim version = 0x7
2022-04-09T19:57:12 DEBUG common.c: stlink current mode: mass
2022-04-09T19:57:12 DEBUG usb.c: JTAG/SWD freq set to 0
2022-04-09T19:57:12 DEBUG common.c: stlink current mode: mass
2022-04-09T19:57:12 DEBUG common.c: *** stlink_enter_swd_mode ***
2022-04-09T19:57:12 DEBUG common.c: Loading device parameters....
2022-04-09T19:57:12 DEBUG common.c: *** stlink_core_id ***
2022-04-09T19:57:12 DEBUG common.c: core_id = 0x1ba01477
2022-04-09T19:57:12 DEBUG read_write.c: *** stlink_read_debug32 0x411fc231 at 0xe000ed00
2022-04-09T19:57:12 DEBUG read_write.c: *** stlink_read_debug32 0x10006412 at 0xe0042000

detected chip_id parametres

Device Type: STM32F1xx_LD
Reference Manual: RM0008

chip_id 0x412
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x2800
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2

2022-04-09T19:57:12 DEBUG read_write.c: *** stlink_read_debug32 0000000000 at 0x1ffff7e0
2022-04-09T19:57:12 INFO common.c: STM32F1xx_LD: 10 KiB SRAM, 0 KiB flash in at least 1 KiB pages.
2022-04-09T19:57:12 DEBUG common.c: *** stlink_force_debug_mode ***
2022-04-09T19:57:12 DEBUG read_write.c: *** stlink_read_debug32 0x00000300 at 0xe0042004
2022-04-09T19:57:12 DEBUG read_write.c: *** stlink_write_debug32 0x00000300 to 0xe0042004
2022-04-09T19:57:12 DEBUG common.c: *** stlink_status ***
2022-04-09T19:57:12 DEBUG usb.c: core status: 02010001
2022-04-09T19:57:12 DEBUG common.c: core status: reset
2022-04-09T19:57:12 INFO common.c: read from address 0x08000000 size 32768
2022-04-09T19:57:12 DEBUG common.c: *** stlink_exit_debug_mode ***
2022-04-09T19:57:12 DEBUG common.c: *** stlink_close ***
$

Expect command to generate read.bin of length 32768 bytes filled with FF bytes

$ ls -l read.bin
-rwx------ 1 user user 0 Apr 9 19:57 read.bin
$


Now read again, but this time with --flash=32k option (and debug disabled). The file now contains the expected number of data bytes, however, the data bytes are 00 rather than FF.

$ st-flash --flash=32k read read.bin 0x08000000 32768

st-flash 1.7.0-186-gc4762e6
Failed to parse flash type or unrecognized flash type

detected chip_id parametres

Device Type: STM32F1xx_LD
Reference Manual: RM0008

chip_id 0x412
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x2800
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2

2022-04-09T19:59:59 INFO common.c: STM32F1xx_LD: 10 KiB SRAM, 0 KiB flash in at least 1 KiB pages.
Forcing flash size: --flash=0x00008000
2022-04-09T19:59:59 INFO common.c: read from address 0x08000000 size 32768

$

Resulting file:

$ ls -l read.bin
-rwx------ 1 user user 32768 Apr 9 19:59 read.bin
$

File expected to contain FF bytes

$ xxd read.bin | more
00000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................

@Nightwalker-87 Nightwalker-87 added this to the v1.7.1 milestone Dec 30, 2022
@Nightwalker-87 Nightwalker-87 self-assigned this Dec 30, 2022
Nightwalker-87 added a commit that referenced this issue Dec 30, 2022
- Bugfix: "Failed to parse flash type or unrecognized flash type"
(Closes #1240) (Closes #1242) (Closes #1290) (Closes #1291)
- Updated README.md on OS-support
- Updated version_support.md
- Removed remnants of macOS support in CMakeLists.txt
- Minor code formatting fixes
- Updated CHANGELOG.md
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Feb 14, 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

Successfully merging a pull request may close this issue.

1 participant