stlink-org / stlink

Open source STM32 MCU programming toolset
BSD 3-Clause "New" or "Revised" License
4.42k stars 1.24k forks source link

STM32L053C8T6: Cannot flash with Release version but can do with Debug #1225

Closed mynameisdaniil closed 1 year ago

mynameisdaniil commented 2 years ago

Current develop version of st-link tools cannot flash subj MCU when I'm using locally built release version on macos@arm64, though it works fine when I'm using debug build. Timing issues? Furthermore, nor debug nor release versions work on linux@amd64 but v1.6 provided in ubuntu repo works just fine. Almost went into binge debug mode but thought somebody might know answer from the top of their head.

macos/release: ``` $ ./build/Release/bin/st-flash --reset write ./firmware.bin 0x08000000 st-flash 1.7.0-184-g468b1d2-dirty Failed to parse flash type or unrecognized flash type detected chip_id parametres # Device Type: STM32L0xxx_Cat_3 # Reference Manual: RM0451 // also RM0367 & RM0377 # chip_id 0x417 flash_type 8 flash_size_reg 0x1ff8007c flash_pagesize 0x80 sram_size 0x2000 bootrom_base 0x1ff00000 bootrom_size 0x1000 option_base 0x1ff80000 option_size 0x20 flags 0 2022-02-14T13:57:00 INFO common.c: STM32L0xxx_Cat_3: 8 KiB SRAM, 64 KiB flash in at least 128 byte pages. file ./firmware.bin md5 checksum: fbe4a7bb1c1f4fd6288d7a8721fb79, stlink checksum: 0x000fa383 2022-02-14T13:57:00 INFO common_flash.c: Attempting to write 10940 (0x2abc) bytes to stm32 address: 134217728 (0x8000000) -> Flash page at 0x8000000 erased (size: 0x80) -> Flash page at 0x8000080 erased (size: 0x80) -> Flash page at 0x8000100 erased (size: 0x80) -> Flash page at 0x8000180 erased (size: 0x80) -> Flash page at 0x8000200 erased (size: 0x80) -> Flash page at 0x8000280 erased (size: 0x80) -> Flash page at 0x8000300 erased (size: 0x80) -> Flash page at 0x8000380 erased (size: 0x80) -> Flash page at 0x8000400 erased (size: 0x80) -> Flash page at 0x8000480 erased (size: 0x80) -> Flash page at 0x8000500 erased (size: 0x80) -> Flash page at 0x8000580 erased (size: 0x80) -> Flash page at 0x8000600 erased (size: 0x80) -> Flash page at 0x8000680 erased (size: 0x80) -> Flash page at 0x8000700 erased (size: 0x80) -> Flash page at 0x8000780 erased (size: 0x80) -> Flash page at 0x8000800 erased (size: 0x80) -> Flash page at 0x8000880 erased (size: 0x80) -> Flash page at 0x8000900 erased (size: 0x80) -> Flash page at 0x8000980 erased (size: 0x80) -> Flash page at 0x8000a00 erased (size: 0x80) -> Flash page at 0x8000a80 erased (size: 0x80) -> Flash page at 0x8000b00 erased (size: 0x80) -> Flash page at 0x8000b80 erased (size: 0x80) -> Flash page at 0x8000c00 erased (size: 0x80) -> Flash page at 0x8000c80 erased (size: 0x80) -> Flash page at 0x8000d00 erased (size: 0x80) -> Flash page at 0x8000d80 erased (size: 0x80) -> Flash page at 0x8000e00 erased (size: 0x80) -> Flash page at 0x8000e80 erased (size: 0x80) -> Flash page at 0x8000f00 erased (size: 0x80) -> Flash page at 0x8000f80 erased (size: 0x80) -> Flash page at 0x8001000 erased (size: 0x80) -> Flash page at 0x8001080 erased (size: 0x80) -> Flash page at 0x8001100 erased (size: 0x80) -> Flash page at 0x8001180 erased (size: 0x80) -> Flash page at 0x8001200 erased (size: 0x80) -> Flash page at 0x8001280 erased (size: 0x80) -> Flash page at 0x8001300 erased (size: 0x80) -> Flash page at 0x8001380 erased (size: 0x80) -> Flash page at 0x8001400 erased (size: 0x80) -> Flash page at 0x8001480 erased (size: 0x80) -> Flash page at 0x8001500 erased (size: 0x80) -> Flash page at 0x8001580 erased (size: 0x80) -> Flash page at 0x8001600 erased (size: 0x80) -> Flash page at 0x8001680 erased (size: 0x80) -> Flash page at 0x8001700 erased (size: 0x80) -> Flash page at 0x8001780 erased (size: 0x80) -> Flash page at 0x8001800 erased (size: 0x80) -> Flash page at 0x8001880 erased (size: 0x80) -> Flash page at 0x8001900 erased (size: 0x80) -> Flash page at 0x8001980 erased (size: 0x80) -> Flash page at 0x8001a00 erased (size: 0x80) -> Flash page at 0x8001a80 erased (size: 0x80) -> Flash page at 0x8001b00 erased (size: 0x80) -> Flash page at 0x8001b80 erased (size: 0x80) -> Flash page at 0x8001c00 erased (size: 0x80) -> Flash page at 0x8001c80 erased (size: 0x80) -> Flash page at 0x8001d00 erased (size: 0x80) -> Flash page at 0x8001d80 erased (size: 0x80) -> Flash page at 0x8001e00 erased (size: 0x80) -> Flash page at 0x8001e80 erased (size: 0x80) -> Flash page at 0x8001f00 erased (size: 0x80) -> Flash page at 0x8001f80 erased (size: 0x80) -> Flash page at 0x8002000 erased (size: 0x80) -> Flash page at 0x8002080 erased (size: 0x80) -> Flash page at 0x8002100 erased (size: 0x80) -> Flash page at 0x8002180 erased (size: 0x80) -> Flash page at 0x8002200 erased (size: 0x80) -> Flash page at 0x8002280 erased (size: 0x80) -> Flash page at 0x8002300 erased (size: 0x80) -> Flash page at 0x8002380 erased (size: 0x80) -> Flash page at 0x8002400 erased (size: 0x80) -> Flash page at 0x8002480 erased (size: 0x80) -> Flash page at 0x8002500 erased (size: 0x80) -> Flash page at 0x8002580 erased (size: 0x80) -> Flash page at 0x8002600 erased (size: 0x80) -> Flash page at 0x8002680 erased (size: 0x80) -> Flash page at 0x8002700 erased (size: 0x80) -> Flash page at 0x8002780 erased (size: 0x80) -> Flash page at 0x8002800 erased (size: 0x80) -> Flash page at 0x8002880 erased (size: 0x80) -> Flash page at 0x8002900 erased (size: 0x80) -> Flash page at 0x8002980 erased (size: 0x80) -> Flash page at 0x8002a00 erased (size: 0x80) -> Flash page at 0x8002a80 erased (size: 0x80) 2022-02-14T13:57:01 INFO flashloader.c: Starting Flash write for L0 2022-02-14T13:57:01 INFO flash_loader.c: Successfully loaded flash loader in sram 2022-02-14T13:57:01 INFO flash_loader.c: Clear DFSR 2022-02-14T13:57:01 INFO common.c: Go to Thumb mode 2022-02-14T13:57:02 ERROR flash_loader.c: Flash loader run error 2022-02-14T13:57:02 WARN flash_loader.c: Loader state: R2 0x40022018 R15 0x1 2022-02-14T13:57:02 WARN flash_loader.c: MCU state: DHCSR 0x1080009 DFSR 0x0 CFSR 0x0 HFSR 0x0 2022-02-14T13:57:02 WARN flashloader.c: Failed to use flash loader, fallback to soft write 170/170 halfpages written 2022-02-14T13:57:02 ERROR common_flash.c: Flash memory contains a non-erased value 2022-02-14T13:57:02 ERROR common_flash.c: Flash programming error: 0x00000200 2022-02-14T13:57:02 INFO common.c: Go to Thumb mode stlink_fwrite_flash() == -1 ```
macos/debug: ``` $ ./build/Debug/bin/st-flash --reset write ./firmware.bin 0x08000000 st-flash 1.7.0-184-g468b1d2-dirty Failed to parse flash type or unrecognized flash type detected chip_id parametres # Device Type: STM32L0xxx_Cat_3 # Reference Manual: RM0451 // also RM0367 & RM0377 # chip_id 0x417 flash_type 8 flash_size_reg 0x1ff8007c flash_pagesize 0x80 sram_size 0x2000 bootrom_base 0x1ff00000 bootrom_size 0x1000 option_base 0x1ff80000 option_size 0x20 flags 0 2022-02-14T13:58:46 INFO common.c: STM32L0xxx_Cat_3: 8 KiB SRAM, 64 KiB flash in at least 128 byte pages. file ./firmware.bin md5 checksum: fbe4a7bb1c1f4fd6288d7a8721fb79, stlink checksum: 0x000fa383 2022-02-14T13:58:46 INFO common_flash.c: Attempting to write 10940 (0x2abc) bytes to stm32 address: 134217728 (0x8000000) -> Flash page at 0x8000000 erased (size: 0x80) -> Flash page at 0x8000080 erased (size: 0x80) -> Flash page at 0x8000100 erased (size: 0x80) -> Flash page at 0x8000180 erased (size: 0x80) -> Flash page at 0x8000200 erased (size: 0x80) -> Flash page at 0x8000280 erased (size: 0x80) -> Flash page at 0x8000300 erased (size: 0x80) -> Flash page at 0x8000380 erased (size: 0x80) -> Flash page at 0x8000400 erased (size: 0x80) -> Flash page at 0x8000480 erased (size: 0x80) -> Flash page at 0x8000500 erased (size: 0x80) -> Flash page at 0x8000580 erased (size: 0x80) -> Flash page at 0x8000600 erased (size: 0x80) -> Flash page at 0x8000680 erased (size: 0x80) -> Flash page at 0x8000700 erased (size: 0x80) -> Flash page at 0x8000780 erased (size: 0x80) -> Flash page at 0x8000800 erased (size: 0x80) -> Flash page at 0x8000880 erased (size: 0x80) -> Flash page at 0x8000900 erased (size: 0x80) -> Flash page at 0x8000980 erased (size: 0x80) -> Flash page at 0x8000a00 erased (size: 0x80) -> Flash page at 0x8000a80 erased (size: 0x80) -> Flash page at 0x8000b00 erased (size: 0x80) -> Flash page at 0x8000b80 erased (size: 0x80) -> Flash page at 0x8000c00 erased (size: 0x80) -> Flash page at 0x8000c80 erased (size: 0x80) -> Flash page at 0x8000d00 erased (size: 0x80) -> Flash page at 0x8000d80 erased (size: 0x80) -> Flash page at 0x8000e00 erased (size: 0x80) -> Flash page at 0x8000e80 erased (size: 0x80) -> Flash page at 0x8000f00 erased (size: 0x80) -> Flash page at 0x8000f80 erased (size: 0x80) -> Flash page at 0x8001000 erased (size: 0x80) -> Flash page at 0x8001080 erased (size: 0x80) -> Flash page at 0x8001100 erased (size: 0x80) -> Flash page at 0x8001180 erased (size: 0x80) -> Flash page at 0x8001200 erased (size: 0x80) -> Flash page at 0x8001280 erased (size: 0x80) -> Flash page at 0x8001300 erased (size: 0x80) -> Flash page at 0x8001380 erased (size: 0x80) -> Flash page at 0x8001400 erased (size: 0x80) -> Flash page at 0x8001480 erased (size: 0x80) -> Flash page at 0x8001500 erased (size: 0x80) -> Flash page at 0x8001580 erased (size: 0x80) -> Flash page at 0x8001600 erased (size: 0x80) -> Flash page at 0x8001680 erased (size: 0x80) -> Flash page at 0x8001700 erased (size: 0x80) -> Flash page at 0x8001780 erased (size: 0x80) -> Flash page at 0x8001800 erased (size: 0x80) -> Flash page at 0x8001880 erased (size: 0x80) -> Flash page at 0x8001900 erased (size: 0x80) -> Flash page at 0x8001980 erased (size: 0x80) -> Flash page at 0x8001a00 erased (size: 0x80) -> Flash page at 0x8001a80 erased (size: 0x80) -> Flash page at 0x8001b00 erased (size: 0x80) -> Flash page at 0x8001b80 erased (size: 0x80) -> Flash page at 0x8001c00 erased (size: 0x80) -> Flash page at 0x8001c80 erased (size: 0x80) -> Flash page at 0x8001d00 erased (size: 0x80) -> Flash page at 0x8001d80 erased (size: 0x80) -> Flash page at 0x8001e00 erased (size: 0x80) -> Flash page at 0x8001e80 erased (size: 0x80) -> Flash page at 0x8001f00 erased (size: 0x80) -> Flash page at 0x8001f80 erased (size: 0x80) -> Flash page at 0x8002000 erased (size: 0x80) -> Flash page at 0x8002080 erased (size: 0x80) -> Flash page at 0x8002100 erased (size: 0x80) -> Flash page at 0x8002180 erased (size: 0x80) -> Flash page at 0x8002200 erased (size: 0x80) -> Flash page at 0x8002280 erased (size: 0x80) -> Flash page at 0x8002300 erased (size: 0x80) -> Flash page at 0x8002380 erased (size: 0x80) -> Flash page at 0x8002400 erased (size: 0x80) -> Flash page at 0x8002480 erased (size: 0x80) -> Flash page at 0x8002500 erased (size: 0x80) -> Flash page at 0x8002580 erased (size: 0x80) -> Flash page at 0x8002600 erased (size: 0x80) -> Flash page at 0x8002680 erased (size: 0x80) -> Flash page at 0x8002700 erased (size: 0x80) -> Flash page at 0x8002780 erased (size: 0x80) -> Flash page at 0x8002800 erased (size: 0x80) -> Flash page at 0x8002880 erased (size: 0x80) -> Flash page at 0x8002900 erased (size: 0x80) -> Flash page at 0x8002980 erased (size: 0x80) -> Flash page at 0x8002a00 erased (size: 0x80) -> Flash page at 0x8002a80 erased (size: 0x80) 2022-02-14T13:58:47 INFO flashloader.c: Starting Flash write for L0 2022-02-14T13:58:47 INFO flash_loader.c: Successfully loaded flash loader in sram 2022-02-14T13:58:47 INFO flash_loader.c: Clear DFSR 2022-02-14T13:58:47 ERROR flash_loader.c: write_buffer_to_sram() == -1 2022-02-14T13:58:47 WARN flashloader.c: Failed to use flash loader, fallback to soft write 170/170 halfpages written 2022-02-14T13:58:47 INFO common_flash.c: Starting verification of write complete 2022-02-14T13:58:48 INFO common_flash.c: Flash written and verified! jolly good! 2022-02-14T13:58:48 WARN common.c: NRST is not connected ```
linux/release: ``` $ ./build/Release/bin/st-flash --reset write ./firmware.bin 0x08000000 st-flash 1.7.0-184-g468b1d2 Failed to parse flash type or unrecognized flash type detected chip_id parametres # Device Type: STM32L0xxx_Cat_3 # Reference Manual: RM0451 // also RM0367 & RM0377 # chip_id 0x417 flash_type 8 flash_size_reg 0x1ff8007c flash_pagesize 0x80 sram_size 0x2000 bootrom_base 0x1ff00000 bootrom_size 0x1000 option_base 0x1ff80000 option_size 0x20 flags 0 2022-02-14T14:01:39 INFO common.c: STM32L0xxx_Cat_3: 8 KiB SRAM, 64 KiB flash in at least 128 byte pages. file ./firmware.bin md5 checksum: 637a2ffa8845e9c902741fcb869ac4b, stlink checksum: 0x000f74f0 2022-02-14T14:01:39 INFO common_flash.c: Attempting to write 10728 (0x29e8) bytes to stm32 address: 134217728 (0x8000000) -> Flash page at 0x8000000 erased (size: 0x80) -> Flash page at 0x8000080 erased (size: 0x80) -> Flash page at 0x8000100 erased (size: 0x80) -> Flash page at 0x8000180 erased (size: 0x80) -> Flash page at 0x8000200 erased (size: 0x80) -> Flash page at 0x8000280 erased (size: 0x80) -> Flash page at 0x8000300 erased (size: 0x80) -> Flash page at 0x8000380 erased (size: 0x80) -> Flash page at 0x8000400 erased (size: 0x80) -> Flash page at 0x8000480 erased (size: 0x80) -> Flash page at 0x8000500 erased (size: 0x80) -> Flash page at 0x8000580 erased (size: 0x80) -> Flash page at 0x8000600 erased (size: 0x80) -> Flash page at 0x8000680 erased (size: 0x80) -> Flash page at 0x8000700 erased (size: 0x80) -> Flash page at 0x8000780 erased (size: 0x80) -> Flash page at 0x8000800 erased (size: 0x80) -> Flash page at 0x8000880 erased (size: 0x80) -> Flash page at 0x8000900 erased (size: 0x80) -> Flash page at 0x8000980 erased (size: 0x80) -> Flash page at 0x8000a00 erased (size: 0x80) -> Flash page at 0x8000a80 erased (size: 0x80) -> Flash page at 0x8000b00 erased (size: 0x80) -> Flash page at 0x8000b80 erased (size: 0x80) -> Flash page at 0x8000c00 erased (size: 0x80) -> Flash page at 0x8000c80 erased (size: 0x80) -> Flash page at 0x8000d00 erased (size: 0x80) -> Flash page at 0x8000d80 erased (size: 0x80) -> Flash page at 0x8000e00 erased (size: 0x80) -> Flash page at 0x8000e80 erased (size: 0x80) -> Flash page at 0x8000f00 erased (size: 0x80) -> Flash page at 0x8000f80 erased (size: 0x80) -> Flash page at 0x8001000 erased (size: 0x80) -> Flash page at 0x8001080 erased (size: 0x80) -> Flash page at 0x8001100 erased (size: 0x80) -> Flash page at 0x8001180 erased (size: 0x80) -> Flash page at 0x8001200 erased (size: 0x80) -> Flash page at 0x8001280 erased (size: 0x80) -> Flash page at 0x8001300 erased (size: 0x80) -> Flash page at 0x8001380 erased (size: 0x80) -> Flash page at 0x8001400 erased (size: 0x80) -> Flash page at 0x8001480 erased (size: 0x80) -> Flash page at 0x8001500 erased (size: 0x80) -> Flash page at 0x8001580 erased (size: 0x80) -> Flash page at 0x8001600 erased (size: 0x80) -> Flash page at 0x8001680 erased (size: 0x80) -> Flash page at 0x8001700 erased (size: 0x80) -> Flash page at 0x8001780 erased (size: 0x80) -> Flash page at 0x8001800 erased (size: 0x80) -> Flash page at 0x8001880 erased (size: 0x80) -> Flash page at 0x8001900 erased (size: 0x80) -> Flash page at 0x8001980 erased (size: 0x80) -> Flash page at 0x8001a00 erased (size: 0x80) -> Flash page at 0x8001a80 erased (size: 0x80) -> Flash page at 0x8001b00 erased (size: 0x80) -> Flash page at 0x8001b80 erased (size: 0x80) -> Flash page at 0x8001c00 erased (size: 0x80) -> Flash page at 0x8001c80 erased (size: 0x80) -> Flash page at 0x8001d00 erased (size: 0x80) -> Flash page at 0x8001d80 erased (size: 0x80) -> Flash page at 0x8001e00 erased (size: 0x80) -> Flash page at 0x8001e80 erased (size: 0x80) -> Flash page at 0x8001f00 erased (size: 0x80) -> Flash page at 0x8001f80 erased (size: 0x80) -> Flash page at 0x8002000 erased (size: 0x80) -> Flash page at 0x8002080 erased (size: 0x80) -> Flash page at 0x8002100 erased (size: 0x80) -> Flash page at 0x8002180 erased (size: 0x80) -> Flash page at 0x8002200 erased (size: 0x80) -> Flash page at 0x8002280 erased (size: 0x80) -> Flash page at 0x8002300 erased (size: 0x80) -> Flash page at 0x8002380 erased (size: 0x80) -> Flash page at 0x8002400 erased (size: 0x80) -> Flash page at 0x8002480 erased (size: 0x80) -> Flash page at 0x8002500 erased (size: 0x80) -> Flash page at 0x8002580 erased (size: 0x80) -> Flash page at 0x8002600 erased (size: 0x80) -> Flash page at 0x8002680 erased (size: 0x80) -> Flash page at 0x8002700 erased (size: 0x80) -> Flash page at 0x8002780 erased (size: 0x80) -> Flash page at 0x8002800 erased (size: 0x80) -> Flash page at 0x8002880 erased (size: 0x80) -> Flash page at 0x8002900 erased (size: 0x80) -> Flash page at 0x8002980 erased (size: 0x80) 2022-02-14T14:01:40 INFO flashloader.c: Starting Flash write for L0 2022-02-14T14:01:40 INFO flash_loader.c: Successfully loaded flash loader in sram 2022-02-14T14:01:40 INFO flash_loader.c: Clear DFSR 2022-02-14T14:01:40 ERROR flash_loader.c: Flash loader run error 2022-02-14T14:01:40 WARN flash_loader.c: Loader state: R2 0xB9AC1B00 R15 0x0 2022-02-14T14:01:40 WARN flash_loader.c: MCU state: DHCSR 0x1080009 DFSR 0x0 CFSR 0x0 HFSR 0x0 2022-02-14T14:01:40 WARN flashloader.c: Failed to use flash loader, fallback to soft write 167/167 halfpages written 2022-02-14T14:01:41 ERROR common_flash.c: Flash memory contains a non-erased value 2022-02-14T14:01:41 INFO common.c: Go to Thumb mode stlink_fwrite_flash() == -1 ```
linux/debug: ``` $ ./build/Debug/bin/st-flash --reset write ./firmware.bin 0x08000000 st-flash 1.7.0-184-g468b1d2 Failed to parse flash type or unrecognized flash type detected chip_id parametres # Device Type: STM32L0xxx_Cat_3 # Reference Manual: RM0451 // also RM0367 & RM0377 # chip_id 0x417 flash_type 8 flash_size_reg 0x1ff8007c flash_pagesize 0x80 sram_size 0x2000 bootrom_base 0x1ff00000 bootrom_size 0x1000 option_base 0x1ff80000 option_size 0x20 flags 0 2022-02-14T14:00:34 INFO common.c: STM32L0xxx_Cat_3: 8 KiB SRAM, 64 KiB flash in at least 128 byte pages. file ./firmware.bin md5 checksum: 637a2ffa8845e9c902741fcb869ac4b, stlink checksum: 0x000f74f0 2022-02-14T14:00:34 INFO common_flash.c: Attempting to write 10728 (0x29e8) bytes to stm32 address: 134217728 (0x8000000) -> Flash page at 0x8000000 erased (size: 0x80) -> Flash page at 0x8000080 erased (size: 0x80) -> Flash page at 0x8000100 erased (size: 0x80) -> Flash page at 0x8000180 erased (size: 0x80) -> Flash page at 0x8000200 erased (size: 0x80) -> Flash page at 0x8000280 erased (size: 0x80) -> Flash page at 0x8000300 erased (size: 0x80) -> Flash page at 0x8000380 erased (size: 0x80) -> Flash page at 0x8000400 erased (size: 0x80) -> Flash page at 0x8000480 erased (size: 0x80) -> Flash page at 0x8000500 erased (size: 0x80) -> Flash page at 0x8000580 erased (size: 0x80) -> Flash page at 0x8000600 erased (size: 0x80) -> Flash page at 0x8000680 erased (size: 0x80) -> Flash page at 0x8000700 erased (size: 0x80) -> Flash page at 0x8000780 erased (size: 0x80) -> Flash page at 0x8000800 erased (size: 0x80) -> Flash page at 0x8000880 erased (size: 0x80) -> Flash page at 0x8000900 erased (size: 0x80) -> Flash page at 0x8000980 erased (size: 0x80) -> Flash page at 0x8000a00 erased (size: 0x80) -> Flash page at 0x8000a80 erased (size: 0x80) -> Flash page at 0x8000b00 erased (size: 0x80) -> Flash page at 0x8000b80 erased (size: 0x80) -> Flash page at 0x8000c00 erased (size: 0x80) -> Flash page at 0x8000c80 erased (size: 0x80) -> Flash page at 0x8000d00 erased (size: 0x80) -> Flash page at 0x8000d80 erased (size: 0x80) -> Flash page at 0x8000e00 erased (size: 0x80) -> Flash page at 0x8000e80 erased (size: 0x80) -> Flash page at 0x8000f00 erased (size: 0x80) -> Flash page at 0x8000f80 erased (size: 0x80) -> Flash page at 0x8001000 erased (size: 0x80) -> Flash page at 0x8001080 erased (size: 0x80) -> Flash page at 0x8001100 erased (size: 0x80) -> Flash page at 0x8001180 erased (size: 0x80) -> Flash page at 0x8001200 erased (size: 0x80) -> Flash page at 0x8001280 erased (size: 0x80) -> Flash page at 0x8001300 erased (size: 0x80) -> Flash page at 0x8001380 erased (size: 0x80) -> Flash page at 0x8001400 erased (size: 0x80) -> Flash page at 0x8001480 erased (size: 0x80) -> Flash page at 0x8001500 erased (size: 0x80) -> Flash page at 0x8001580 erased (size: 0x80) -> Flash page at 0x8001600 erased (size: 0x80) -> Flash page at 0x8001680 erased (size: 0x80) -> Flash page at 0x8001700 erased (size: 0x80) -> Flash page at 0x8001780 erased (size: 0x80) -> Flash page at 0x8001800 erased (size: 0x80) -> Flash page at 0x8001880 erased (size: 0x80) -> Flash page at 0x8001900 erased (size: 0x80) -> Flash page at 0x8001980 erased (size: 0x80) -> Flash page at 0x8001a00 erased (size: 0x80) -> Flash page at 0x8001a80 erased (size: 0x80) -> Flash page at 0x8001b00 erased (size: 0x80) -> Flash page at 0x8001b80 erased (size: 0x80) -> Flash page at 0x8001c00 erased (size: 0x80) -> Flash page at 0x8001c80 erased (size: 0x80) -> Flash page at 0x8001d00 erased (size: 0x80) -> Flash page at 0x8001d80 erased (size: 0x80) -> Flash page at 0x8001e00 erased (size: 0x80) -> Flash page at 0x8001e80 erased (size: 0x80) -> Flash page at 0x8001f00 erased (size: 0x80) -> Flash page at 0x8001f80 erased (size: 0x80) -> Flash page at 0x8002000 erased (size: 0x80) -> Flash page at 0x8002080 erased (size: 0x80) -> Flash page at 0x8002100 erased (size: 0x80) -> Flash page at 0x8002180 erased (size: 0x80) -> Flash page at 0x8002200 erased (size: 0x80) -> Flash page at 0x8002280 erased (size: 0x80) -> Flash page at 0x8002300 erased (size: 0x80) -> Flash page at 0x8002380 erased (size: 0x80) -> Flash page at 0x8002400 erased (size: 0x80) -> Flash page at 0x8002480 erased (size: 0x80) -> Flash page at 0x8002500 erased (size: 0x80) -> Flash page at 0x8002580 erased (size: 0x80) -> Flash page at 0x8002600 erased (size: 0x80) -> Flash page at 0x8002680 erased (size: 0x80) -> Flash page at 0x8002700 erased (size: 0x80) -> Flash page at 0x8002780 erased (size: 0x80) -> Flash page at 0x8002800 erased (size: 0x80) -> Flash page at 0x8002880 erased (size: 0x80) -> Flash page at 0x8002900 erased (size: 0x80) -> Flash page at 0x8002980 erased (size: 0x80) 2022-02-14T14:00:34 INFO flashloader.c: Starting Flash write for L0 2022-02-14T14:00:34 INFO flash_loader.c: Successfully loaded flash loader in sram 2022-02-14T14:00:34 INFO flash_loader.c: Clear DFSR 2022-02-14T14:00:34 INFO common.c: Go to Thumb mode 2022-02-14T14:00:35 ERROR flash_loader.c: Flash loader run error 2022-02-14T14:00:35 WARN flash_loader.c: Loader state: R2 0x8 R15 0x7FDF 2022-02-14T14:00:35 WARN flash_loader.c: MCU state: DHCSR 0x1080009 DFSR 0x0 CFSR 0x0 HFSR 0x0 2022-02-14T14:00:35 WARN flashloader.c: Failed to use flash loader, fallback to soft write 167/167 halfpages written 2022-02-14T14:00:35 ERROR common_flash.c: Invalid flash address stlink_fwrite_flash() == -1 ```

Expected/description:

I expect it to work in all cases.

mynameisdaniil commented 2 years ago

I'd add os/linux too, since it doesn't work on Linux either. It's just easier to debug on macos since it works in case of debug build.

Nightwalker-87 commented 1 year ago

@gszy Do you have an idea on this one? There appears to be a timeout leading to the first error:

    if (timeout) {
        ELOG("Flash loader run error\n");
        goto error;
    }

flashloader.c: Failed to use flash loader, fallback to soft write derives from the old implementation as far as I am concerned. flash_loader.c has been rewritten/edited by @chenguokai and is a new approach from scratch as to my knowledge. Maybe there is a conflict between both upon being called ...

Nightwalker-87 commented 1 year ago

@mynameisdaniil When looking at your outputs, we find that there is erroneous behaviour in all four of them, even though you claim the "macOS Debug" case to be working - the flash loader isn't doing so.

Nightwalker-87 commented 1 year ago

@Ant-ON This is another strange topic where I'm unsure where to look at, really. Is it possibly timeout-related only or is there an improper way of implementation when trying to select the flash loader? I couldn't make it out yet. Several problems seem to remain especially affecting the L0 series.

mynameisdaniil commented 1 year ago

Is there any way I can help you?

Nightwalker-87 commented 1 year ago

Thanks for the offering @mynameisdaniil. The current problem I have here is a missing clue where to look at specifically. The people most recently involved in or related topics around this implementation have been triggered already. We're still waiting for any response or anyone else familiar with the topic. I'd be looking forward to resolve this issue as well...

Nightwalker-87 commented 1 year ago

Duplicate of #681.

Nightwalker-87 commented 1 year ago

@mynameisdaniil Please continue to follow the main thread in #681. I've just reviewed and summarized the relevant facts there.

mynameisdaniil commented 1 year ago

@Nightwalker-87 will do. Thanks for the heads-up.

Ant-ON commented 1 year ago

@Nightwalker-87 I think this might be another problem with halfpage write mode. Need to check the changes suggested in #1203. Yes, this changes is to completely remove halpage mode, but it is better to be slower than with errors...

Nightwalker-87 commented 1 year ago

@Ant-ON We should address everything in #681, as the derived result is at least very similar if not the same. It does not matter should there be several reasons of origin. It is difficult to track and discuss an issue in several threads. I've added the relevant info from other related tickets there as well.

Ant-ON commented 1 year ago

@Nightwalker-87 For reasons not clear to me (most likely due to the state of MCU) does not work writing by half page. Without hardware this problem is hard to find. I think the best solution at the moment is to disable this code.