0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

STM32 の Flash をバックアップする

Posted at

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 では中身は読めるけど・・・

image.png

ファイルに落とせないのかな?
一応、Read Out Protection のフラグは操作できるので、ここが解除されていることを確認しておく。

image.png

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.

と出るので、ボード情報として表示された値ではなく実メモリの容量を何らかの方法で取得しているぽいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?