上野家のホームページ
ナーマル,マリン,ココ
[
新規
|
一覧
|
検索
|
最新
|
ヘルプ
]
開発/AVR/bootloaderのプロテクト
をテンプレートにして作成
資料室
開発/AVR/bootloaderのプロテクト をテンプレートにして作成
[
差分
|
バックアップ
|
リロード
]
[ ]
開始行:
* bootloaderのプロテクト
ATMEL AVRには,Flash ROMに書き込んだプログラムやEEPROMを...
このロックビットを操作することによって,プログラム領域,E...
もしこのロックビットの設定によりフラッシュ領域などの書き...
この場合は,''デバイスを消去する''ことによりロックビット...
** ロックビットの仕様
ロックビットの詳細はAVRデバイスのデータシートを参照する。~
ATmega328/ATmega328Pのロックビットは以下のようになってい...
|名称 |bit|内容 |既定値|h
|- |7 | |0 |
|- |6 | |0 |
|BLB12|5 |ブートローダー領域保護bit |1 |
|BLB11|4 |~|1 |
|BLB02|3 |応用領域保護bit |1 |
|BLB01|2 |~|1 |
|LB2 |1 |Flash ROMとEEPROMに対する保護用bit|1 |
|LB1 |0 |~|1 |
~
|LB種別|LB2 |LB1 |内容 ...
|1 |1 |1 |機能なし ...
|2 |1 |0 |Flash ROM, EEPROMの書き込みプロテクト...
|3 |0 |0 |Flash ROM, EEPROMの書き込み・読み出し...
~
|LB0種別|BLB02 |BLB01 |内容 ...
|1 |1 |1 |LPM, SPM命令が応用領域をアクセスす...
|2 |1 |0 |応用領域へのSPM命令はプロテクト。 ...
|3 |0 |0 |応用領域へのSPM命令はプロテクト。...
|4 |0 |1 |ブートローダー領域でのLPM命令によ...
~
|LB1種別|BLB12 |BLB11 |内容 ...
|1 |1 |1 |LPM,SPM命令がブートローダー領域を...
|2 |1 |0 |SPM命令によるブートローダー領域に...
|3 |0 |0 |SPM命令によるブートローダー領域に...
|4 |0 |1 |応用領域でのLPM命令によるブートロ...
** ロックビットを使ってFlash ROMの読み書きを禁止する手順
ロックビットを操作するために,なんらかのAVR Writerを用意...
用意したAVR WriterとターゲットのボードのISPコネクタを接続...
avrdudeを使用して接続ができているか確認する(COMポートな...
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
FUSEの現在の設定が表示される。
ロックビットの状態を確認してみる。~
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328 -U lock:...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading lock memory:
Reading | ##############################################...
avrdude.exe: writing output file "con"
0x2f
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
この場合ロックビットは0x2fに設定されていて,ブートローダ...
デフォルト状態ではロックビットは0x3fで,なんのプロテクト...
Flash ROMを読んでファイルに書き出してみる。~
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328 -U flash...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading flash memory:
Reading | ##############################################...
avrdude.exe: writing output file "program.hex"
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
うまく書き出せている。(読み込みはプロテクトされていない...
ロックビットを0x00(全領域書き込みも読み込みもプロテクト...
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -U l...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading input file "0x00"
avrdude.exe: writing lock (1 bytes):
Writing | ##############################################...
avrdude.exe: 1 bytes of lock written
avrdude.exe: verifying lock memory against 0x00:
avrdude.exe: load data lock data from input file 0x00:
avrdude.exe: input file 0x00 contains 1 bytes
avrdude.exe: reading on-chip lock data:
Reading | ##############################################...
avrdude.exe: verifying ...
avrdude.exe: 1 bytes of lock verified
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
Flash ROMを再度読んで書き出してみる。~
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -U f...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading flash memory:
Reading | ##############################################...
avrdude.exe: Flash is empty, resulting file has no conte...
avrdude.exe: writing output file "program2.hex"
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
program2.hexはファイルサイズが小さく,読み出しが出来てい...
** 再度プログラムの読み書きが出来るようにする
ロックビットを操作してプロテクトされている状態を解除する...
*** Arduino IDEを使う場合
Arduino IDEを使って「ブートローダーを書き込む」作業を行う...
Arduino IDEを使う場合でも,なんらかのAVR Writerを使用する...
*** avrdudeを使ってチップ消去を行う
avrdudeで''チップ消去''を行うには,-eオプションを使う。~
接続する。~
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
FUSEの現在の設定が表示される。~
-eオプションを使って''チップ消去''する。~
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -e
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: erasing chip
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
ロックビットを確認する。~
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -U l...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading lock memory:
Reading | ##############################################...
avrdude.exe: writing output file "con"
0x3f
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
これで''チップ消去''された。ロックビットがデフォルトの0x3...
終了行:
* bootloaderのプロテクト
ATMEL AVRには,Flash ROMに書き込んだプログラムやEEPROMを...
このロックビットを操作することによって,プログラム領域,E...
もしこのロックビットの設定によりフラッシュ領域などの書き...
この場合は,''デバイスを消去する''ことによりロックビット...
** ロックビットの仕様
ロックビットの詳細はAVRデバイスのデータシートを参照する。~
ATmega328/ATmega328Pのロックビットは以下のようになってい...
|名称 |bit|内容 |既定値|h
|- |7 | |0 |
|- |6 | |0 |
|BLB12|5 |ブートローダー領域保護bit |1 |
|BLB11|4 |~|1 |
|BLB02|3 |応用領域保護bit |1 |
|BLB01|2 |~|1 |
|LB2 |1 |Flash ROMとEEPROMに対する保護用bit|1 |
|LB1 |0 |~|1 |
~
|LB種別|LB2 |LB1 |内容 ...
|1 |1 |1 |機能なし ...
|2 |1 |0 |Flash ROM, EEPROMの書き込みプロテクト...
|3 |0 |0 |Flash ROM, EEPROMの書き込み・読み出し...
~
|LB0種別|BLB02 |BLB01 |内容 ...
|1 |1 |1 |LPM, SPM命令が応用領域をアクセスす...
|2 |1 |0 |応用領域へのSPM命令はプロテクト。 ...
|3 |0 |0 |応用領域へのSPM命令はプロテクト。...
|4 |0 |1 |ブートローダー領域でのLPM命令によ...
~
|LB1種別|BLB12 |BLB11 |内容 ...
|1 |1 |1 |LPM,SPM命令がブートローダー領域を...
|2 |1 |0 |SPM命令によるブートローダー領域に...
|3 |0 |0 |SPM命令によるブートローダー領域に...
|4 |0 |1 |応用領域でのLPM命令によるブートロ...
** ロックビットを使ってFlash ROMの読み書きを禁止する手順
ロックビットを操作するために,なんらかのAVR Writerを用意...
用意したAVR WriterとターゲットのボードのISPコネクタを接続...
avrdudeを使用して接続ができているか確認する(COMポートな...
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
FUSEの現在の設定が表示される。
ロックビットの状態を確認してみる。~
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328 -U lock:...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading lock memory:
Reading | ##############################################...
avrdude.exe: writing output file "con"
0x2f
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
この場合ロックビットは0x2fに設定されていて,ブートローダ...
デフォルト状態ではロックビットは0x3fで,なんのプロテクト...
Flash ROMを読んでファイルに書き出してみる。~
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328 -U flash...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading flash memory:
Reading | ##############################################...
avrdude.exe: writing output file "program.hex"
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
うまく書き出せている。(読み込みはプロテクトされていない...
ロックビットを0x00(全領域書き込みも読み込みもプロテクト...
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -U l...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading input file "0x00"
avrdude.exe: writing lock (1 bytes):
Writing | ##############################################...
avrdude.exe: 1 bytes of lock written
avrdude.exe: verifying lock memory against 0x00:
avrdude.exe: load data lock data from input file 0x00:
avrdude.exe: input file 0x00 contains 1 bytes
avrdude.exe: reading on-chip lock data:
Reading | ##############################################...
avrdude.exe: verifying ...
avrdude.exe: 1 bytes of lock verified
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
Flash ROMを再度読んで書き出してみる。~
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -U f...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading flash memory:
Reading | ##############################################...
avrdude.exe: Flash is empty, resulting file has no conte...
avrdude.exe: writing output file "program2.hex"
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
program2.hexはファイルサイズが小さく,読み出しが出来てい...
** 再度プログラムの読み書きが出来るようにする
ロックビットを操作してプロテクトされている状態を解除する...
*** Arduino IDEを使う場合
Arduino IDEを使って「ブートローダーを書き込む」作業を行う...
Arduino IDEを使う場合でも,なんらかのAVR Writerを使用する...
*** avrdudeを使ってチップ消去を行う
avrdudeで''チップ消去''を行うには,-eオプションを使う。~
接続する。~
> avrdude -c stk500v2 -P COM1 -b 115200 -p m328
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
FUSEの現在の設定が表示される。~
-eオプションを使って''チップ消去''する。~
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -e
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: erasing chip
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
ロックビットを確認する。~
> avrdude.exe -c stk500v2 -P COM1 -b 115200 -p m328 -U l...
avrdude.exe: AVR device initialized and ready to accept ...
Reading | ##############################################...
avrdude.exe: Device signature = 0x1e9514 (probably m328)
avrdude.exe: reading lock memory:
Reading | ##############################################...
avrdude.exe: writing output file "con"
0x3f
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:C2)
avrdude.exe done. Thank you.
これで''チップ消去''された。ロックビットがデフォルトの0x3...
ページ名:
Counter: 0, today: 0, yesterday: 0
Copyright©2008 Yuji Ueno All Rights Reserved.
ログイン
ユーザ名:
パスワード:
IDとパスワードを記憶
パスワード紛失
メインメニュー
ホーム
でぶlog
資料室
最新ページ一覧
全ページ一覧
ヘルプ
フォーラム
お問い合わせ