记:一次意外JTAG使用引发对于STM32内核的了解
文章目錄
- 0x01 數據異常?
- 0x02 排查過程
- 0x03 究其原因
- 下面有空更新,內部解鎖FLASH操作。出差期間發文,很累了,暫時先寫到這里
- 更多
0x01 數據異常?
在一次偶然的情況下,大佬發現他的JTAG出現了莫名其妙的操作——每次燒寫之后進行Connect數據就會出現內部FLASH全擦寫。而我自己的就不會全擦寫。這也是最初的問題源。
0x02 排查過程
首先,我和大佬對調了JTAG,測試了一下JTAG的方式,我的JTAG顯示固件版本是9.3.0,大佬的固件版本為8.0.0,但是我的J-FLASH是可以使用兩者進行燒寫的。而大佬的J-FLASH兩者也是都會擦寫。我們使用的J-FLASH是同一個版本的。應該是不會出現特別的操作的。
這樣唯一的不同點就在于所建立的工程的不同。
我將大佬的工程文件換成我的工程文件,結果成功的讀取到了數據。也就證明了當前的數據工程文件出現了問題。
0x03 究其原因
根據對于兩個文件的比對發現,我的文件——下文稱為可讀工程文件,對比于大佬的文件——下文稱為擦寫工程文件。這兩個工程文件的差異主要在兩點:擦寫地址為0x08000000和0x06000000,而一個工程的刷寫腳本為XXXX,而另一個工程的刷寫腳本為XXXX(Allow opt bytes)。而就此而言我們真正找到了原因。
根據多方面的查找,終于大佬在SEGGER的手冊中找到了相應的介紹。
Allow opt bytes device selection
The “allow opt. bytes” device selection is only available for STM32F1 series devices. For later devices, memory mapped programming of the option bytes is not feasible as for some series, the option bytes become valid immediately which would cause immediate connection loss to a device (in case readout protection is enabled) before the option byte programming can be verified.
The STM32 series devices provide option bytes which allow “permanent” configuration as well as readout protection for the device. In order to enable or disable readout protection, a sequence of multiple read / write accesses to special function registers of the STM32 MCU has to be performed. The sequence is different for each sub-family of the STM32 device series and is described in the respective reference manual of the device. A list of example J-Link commander files and J-Flash projects which enable or disable the readout protection of an STM32 device is provided below. Please note that the provided files serves as an example / proof of concept. A user may alter them in order to suit their specific use case, e.g. using smaller timeouts, programming other values, etc.
也就是說,當時是因為開啟了相應的FLASH程序刷寫,導致了當前芯片FLASH被保護了,而Connect之前沒有在片內進行相應的FLASH動作,引發了擦寫。
而相應的避免擦寫的解鎖操作在SEGGER的手冊里面也有,但是想在芯片之中直接進行FLASH防止讀取的方式的話只能查閱該手冊.
下面有空更新,內部解鎖FLASH操作。出差期間發文,很累了,暫時先寫到這里
更多
本文首發自 記:一次意外JTAG使用引發對于STM32內核的了解-我的博客,更多文章可進入我的博客詳查。
總結
以上是生活随笔為你收集整理的记:一次意外JTAG使用引发对于STM32内核的了解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过Cookie跳过登录验证码【限coo
- 下一篇: 时间精力管理4象限法