0.前言
本文的目的是爲了根據一個實例來講解在QCA4020開發板上如何啓用secure boot 功能。
1.通過OTP 編程工具使能secure boot
爲了設置OTP保險絲,我們需要使用QCA4020 SDK中包含的OTP編程工具。
(1)編輯位於target\quartz\mfg\OTP\tools\下的配置文件otp_config.xml,如下所示:
<otp_descriptor>
<firmware_region_write_disable>0</firmware_region_write_disable>
<model_id>0x0</model_id>
<pk_hash>0110203040506070809001102030405060708090011020304050607080900102</pk_hash>
<!-- <otp_encryp_key>0102030405060708090a0b0c0d0e0f00</otp_encryp_key> -->
<otp_profile>development</otp_profile>
</otp_descriptor>
(2) 編譯OTP
在target\quartz\mfg\OTP\build\gcc下,執行如下命令
build.bat t 4020 cdb
(3)在 \target\quartz\mfg\OTP\build\gcc目錄下,執行如下命令將OTP編程工具鏡像燒寫到開發板中
flash_openocd.bat
(4) 確保UDB串口線與PC線與PC機相連接,並且串口終端是活動的。
(5) 重啓機器, 我們將會看到 "OTP update success" 這個消息出現在終端上。
2.將鏡像簽名
設置完成OTP編程熔絲之後,僅僅只能由驗證過的軟件才能被執行,所以我們必須將我們的鏡像進行簽名,才能放入開發板,要不然是使用不了的。
(1)修改位於 \target\quartz\demo\QCLI_demo\build\gcc\的腳本 build.bat
SET SECBOOT=true
...
IF /I "%BOARD_VARIANT%" == "CDB" (
python %SectoolsQdnDir%\sectools.py iot -p 4020 -g m4 -i %OUTDIR%\%PROJECT%.elf -k %SectoolsCertsDir%\qpsa_rootca.key -c %SectoolsCertsDir%\qpsa_rootca.cer --cfg_oem_id=0xffff --cfg_model_id=0x0000 -o . -s
python %SectoolsQdnDir%\sectools.py iot -p 4020 -g m0 -i %RootDir%\bin\cortex-m0\threadx\ioe_ram_m0_threadx_ipt.mbn -k %SectoolsCertsDir%\qpsa_rootca.key -c %SectoolsCertsDir%\qpsa_rootca.cer --cfg_oem_id=0xffff --cfg_model_id=0x0000 -o . -s
python %SectoolsQdnDir%\sectools.py iot -p 4020 -g kf -i %RootDir%\bin\wlan\wlan_fw_img.bin -k %SectoolsCertsDir%\qpsa_rootca.key -c %SectoolsCertsDir%\qpsa_rootca.cer --cfg_oem_id=0xffff --cfg_model_id=0x0000 -o . -s
(2)Execute the command “build.bat t 4020 cdb”,then you can get the following files.
3.燒寫簽名的鏡像
(1)編輯位於 \target\quartz\demo\QCLI_demo\build\gcc\下的腳本文件flash_openocd.bat 如下:
SET M4_DIR=%ROOTDIR%\quartz\demo\QCLI_demo\build\gcc\4020\m4
SET M0_DIR=%ROOTDIR%\quartz\demo\QCLI_demo\build\gcc\4020\m0
SET WLAN_DIR=%ROOTDIR%\quartz\demo\QCLI_demo\build\gcc\4020\kf
SET M4_IMAGE="%M4_DIR%\Quartz.elf"
SET M0_IMAGE="%M0_DIR%\ioe_ram_m0_threadx_ipt.mbn"
SET WLAN_IMAGE="%WLAN_DIR%\wlan_fw_img.bin"
(2) 在\target\quartz\demo\QCLI_demo\build\gcc下執行如下命令燒寫鏡像
flash_openocd.bat