STM32_CubeProgrammer V2.11.0 を使って STM32F103 の Flash 内容をバックアップします。
環境
- Ubuntu Linux 22.04
- STM32CubeProgrammer version: 2.11.0
- ST-Link V2 (パチもん?)
- RobotDyn STM32 Dev.Board ( ≒ BluePill ≒ Maple Mini )
GUI
STM32 CubeProgrammer では中身は読めるけど・・・
ファイルに落とせないのかな?
一応、Read Out Protection のフラグは操作できるので、ここが解除されていることを確認しておく。
CUI
まずは書き込みができるかどうかテスト
$ ./STM32_Programmer.sh -c PORT=SWD --erase all --write ./Blink30.ino.bin 0x08000000 -v
-------------------------------------------------------------------
STM32CubeProgrammer v2.11.0
-------------------------------------------------------------------
ST-LINK SN : 48FF6C064983535621371987
ST-LINK FW : V2J29S7
Board : --
Voltage : 3.23V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x410
Revision ID : Rev X
Device name : STM32F101/F102/F103 Medium-density
Flash size : 64 KBytes
Device type : MCU
Device CPU : Cortex-M3
BL Version : --
Mass erase ...
Mass erase successfully achieved
Memory Programming ...
Opening and parsing file: Blink30.ino.bin
File : Blink30.ino.bin
Size : 128.00 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Download in Progress:
[==================================================] 100%
File download complete
Time elapsed during download operation: 00:00:04.746
Verifying ...
Read progress:
[==================================================] 100%
Download verified successfully
書けましたね。
ではオプションを変更して読み込みします。
$ ./STM32_Programmer_CLI -c PORT=SWD -u 0x08000000 0x0020000 Blink30.ino.bin
-------------------------------------------------------------------
STM32CubeProgrammer v2.11.0
-------------------------------------------------------------------
ST-LINK SN : 48FF6C064983535621371987
ST-LINK FW : V2J29S7
Board : --
Voltage : 3.23V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x410
Revision ID : Rev X
Device name : STM32F101/F102/F103 Medium-density
Flash size : 64 KBytes
Device type : MCU
Device CPU : Cortex-M3
BL Version : --
UPLOADING ...
File : Blink30.ino.bin
Size : 131072 Bytes
Address: : 0x8000000
Read progress:
[==================================================] 100%
Data read successfully
Warning: The file Blink30.ino.bin already exists, it will be overwritten
Time elapsed during read operation is: 00:00:00.835
うまくダウンロードできたみたいです。
Flash size が 64KBytes となってますが、実際は128KBytes読めました。
ちなみに、メモリのないところを読んだつもりになっているわけではなく、サイズ 0x0020002
を指定すると
Error: Upload size is bigger than flash memory size.
と出るので、ボード情報として表示された値ではなく実メモリの容量を何らかの方法で取得しているぽいです。