记:一次意外JTAG使用引发对于STM32内核的了解
文章目錄
- 0x01 數(shù)據(jù)異常?
- 0x02 排查過(guò)程
- 0x03 究其原因
- 下面有空更新,內(nèi)部解鎖FLASH操作。出差期間發(fā)文,很累了,暫時(shí)先寫(xiě)到這里
- 更多
0x01 數(shù)據(jù)異常?
在一次偶然的情況下,大佬發(fā)現(xiàn)他的JTAG出現(xiàn)了莫名其妙的操作——每次燒寫(xiě)之后進(jìn)行Connect數(shù)據(jù)就會(huì)出現(xiàn)內(nèi)部FLASH全擦寫(xiě)。而我自己的就不會(huì)全擦寫(xiě)。這也是最初的問(wèn)題源。
0x02 排查過(guò)程
首先,我和大佬對(duì)調(diào)了JTAG,測(cè)試了一下JTAG的方式,我的JTAG顯示固件版本是9.3.0,大佬的固件版本為8.0.0,但是我的J-FLASH是可以使用兩者進(jìn)行燒寫(xiě)的。而大佬的J-FLASH兩者也是都會(huì)擦寫(xiě)。我們使用的J-FLASH是同一個(gè)版本的。應(yīng)該是不會(huì)出現(xiàn)特別的操作的。
這樣唯一的不同點(diǎn)就在于所建立的工程的不同。
我將大佬的工程文件換成我的工程文件,結(jié)果成功的讀取到了數(shù)據(jù)。也就證明了當(dāng)前的數(shù)據(jù)工程文件出現(xiàn)了問(wèn)題。
0x03 究其原因
根據(jù)對(duì)于兩個(gè)文件的比對(duì)發(fā)現(xiàn),我的文件——下文稱為可讀工程文件,對(duì)比于大佬的文件——下文稱為擦寫(xiě)工程文件。這兩個(gè)工程文件的差異主要在兩點(diǎn):擦寫(xiě)地址為0x08000000和0x06000000,而一個(gè)工程的刷寫(xiě)腳本為XXXX,而另一個(gè)工程的刷寫(xiě)腳本為XXXX(Allow opt bytes)。而就此而言我們真正找到了原因。
根據(jù)多方面的查找,終于大佬在SEGGER的手冊(cè)中找到了相應(yīng)的介紹。
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.
也就是說(shuō),當(dāng)時(shí)是因?yàn)殚_(kāi)啟了相應(yīng)的FLASH程序刷寫(xiě),導(dǎo)致了當(dāng)前芯片F(xiàn)LASH被保護(hù)了,而Connect之前沒(méi)有在片內(nèi)進(jìn)行相應(yīng)的FLASH動(dòng)作,引發(fā)了擦寫(xiě)。
而相應(yīng)的避免擦寫(xiě)的解鎖操作在SEGGER的手冊(cè)里面也有,但是想在芯片之中直接進(jìn)行FLASH防止讀取的方式的話只能查閱該手冊(cè).
下面有空更新,內(nèi)部解鎖FLASH操作。出差期間發(fā)文,很累了,暫時(shí)先寫(xiě)到這里
更多
本文首發(fā)自 記:一次意外JTAG使用引發(fā)對(duì)于STM32內(nèi)核的了解-我的博客,更多文章可進(jìn)入我的博客詳查。
總結(jié)
以上是生活随笔為你收集整理的记:一次意外JTAG使用引发对于STM32内核的了解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 通过Cookie跳过登录验证码【限coo
- 下一篇: 时间精力管理4象限法