Debug authentication 實際上就是經過設置core,須要經過認證才能使jlink attach core。html
1. debug authentication實現json
mailbox是一個模塊,用來實現ROM和debugger之間的通訊,詳情見https://www.cnblogs.com/richard-xiong/p/10041482.html測試
經過設置SOCU實現debug authentication,有以下四種狀況spa
DAP(debug authentication port):當它開啓後(SOCU_PIN置0),jlink就不能訪問core,debug
fixed開啓時(SOCU_PIN置1),可否debug由DFLT決定。htm
實際測試當中不考慮0(DAP)1(enable debug)這樣狀況blog
另外三種的優先級:1(fixed)0(disable debug)> 0(DAP)0(disable debug)>1(fixed)1(enable debug)ip
注意:只有CMPA中設置了SOCU時,纔可進一步設置CFPA,若是CMPA中SOCU所有爲0,而在CFPA的SOCU設置了,會形成ROM crash。get
實際SOCU在CMPA和CFPA中的設置及結果:flash
2. operation flow
a. generate signed image and configure FFR( CMPA and CFPA)
gen_signed_image.exe secure_boot.json ffr.yml
secure_boot.json file是用於生成signed image的
須要配置如圖所示的5項。
1是輸入image,2 image類型,3 signed image的證書,4 表示幾級證書,5 簽名證書的私鑰,6 輸出image
ffr.yml 用於配置FFR(CFPA and CMPA)
按下圖須要注意這七項的更改。
1. version必定要大於已經存在的version。
2. enable ROTKH in CFPA
bit[0:7]兩位控制一個ROTKH
00-invalid 01-enable 10 or 11 - key revoke, 若是隻enable ROTKH0:0x000000fd(11110101) enable all ROTKH 0x00000055(01010101)
3.4.5.6是用於配置debug authentication 的FFR,詳情見 https://www.cnblogs.com/linansimida/p/10072310.html
7.須要選擇 key length 2048 - c0 4096 - c1 https://www.cnblogs.com/linansimida/p/10072310.html
另外VENDOR_USAGE in CFPA 和 DAP_VENDOR_USAGE_FIXED in CMPA 分別是VU配置中的bit[15:0]和bit[31:16] 位這個與debug authentication 用到的配置文件debug_auth.yml中的UV要徹底相同。
b.將生成好的signed image和 配置CPFA及CMPA的文件寫到target上,並 reset target,即開啓了debug authentication 功能。
%blhost% %peripheral% -- flash-erase-region 0x0 0x20000
%blhost% %peripheral% -- write-memory 0x0 ledblink_signed.bin
%blhost% %peripheral% -- write-memory 0x9de00 CFPA_0x9de00.bin
%blhost% %peripheral% -- write-memory 0x9e400 CMPA_0x9e400.bin
%blhost% %peripheral% -- reset
c. 首先嚐試在沒有配置debug authentication的狀況下鏈接JLINK,此時應該鏈接失敗,而後進行debug authentication 配置後鏈接JLINK。
使用以下命令驗證debug authentication 可否驗證經過。
.tool.exe -i jlink -p 1.0 auth -c debug_auth.yml
tool.exe -i jlink -p 1.0 exit \\ 1.0 表明2048 key length, 1.1表明4096 key length
debug_auth.yml文件配置以下:
socc是固定的
cc_vu和ffr.yml文件的ENDOR_USAGE[31:16] ,DAP_VENDOR_USAGE_FIXED[15:0]必須相同。
cred_beacon和auth_beacon必須是0,除非有指定的boot demo。
rot和生成signed image的私鑰相同
dck是一個私鑰。由jlink生成:
tool.exe -i jlink -p 1.0 genkey dck_2048.pem
tool.exe -i jlink -p 1.1 genkey dck_4096.pem