全志平台Tina系统R18用dragonSN同时烧写key到efuse和flash

在产品生产的过程中,客户可能会选择使用安全固件,这样的话安全相关的rotpk是烧写到efues中的,而普通的key诸如bt_mac \ wifi_mac是需要烧到flash中的private中的,这个时候就需要做如下修改:

1.工具dragonSN支持同时烧录两种存储介质的KEY

        2.5.7版本以上的dragonSN应该已经支持了这个功能。2.5.7之前很多个版本应该就就已经支持了,没有测试,不能确定是哪个版本开始支持的。

2.设备端uboot支持同时烧录两种存储介质的KEY:

(1)uboot中加入这个宏:

chenkunyao@Exdroid35:~/workspace/ftina2.0/etina/lichee/brandy/u-boot-2014.07/include/configs$ git diff .
diff --git a/u-boot-2014.07/include/configs/sun50iw1p1.h b/u-boot-2014.07/include/configs/sun50iw1p1.h
index 6ef4cd0..ba49d9f 100755
--- a/u-boot-2014.07/include/configs/sun50iw1p1.h
+++ b/u-boot-2014.07/include/configs/sun50iw1p1.h
@@ -129,6 +129,9 @@
 #define CONFIG_SYS_I2C_SPEED    400000
 #define CONFIG_SYS_I2C_SLAVE    0x10
 
+//R18 sgw flash rotpk and flash key at the same time
+#define CONFIG_SUNXI_PRIVATE_KEY
+
 //#define CONFIG_SUNXI_DMA
 #define CONFIG_SUNXI_CHIPID
 #define CONFIG_SUNXI_ARISC_EXIST
 

(2)重新编译uboot:

source build/envsetup.sh 获取环境变量

lunch 选择要编的方案

cd lichee 进入内核目录

mboot 编译

 

./tools/add_hash_uboot.sh -f u-boot.bin -m uboot
 build_uboot 
"u-boot.bin" -> "u-boot-spinor-sun50iw1p1.bin"
"u-boot-spinor-sun50iw1p1.bin" -> "/home/chenkunyao/workspace/ftina2.0/etina/lichee/brandy/u-boot-2014.07/../../../target/allwinner/tulip-common/bin/u-boot-spinor-sun50iw1p1.bin"
mboot success!
(3)将重新编译出来的uboot 复制到相应的地方,如果没有修改打包时获取uboot的位置的话,这一步可以不做

        

(4)pack 重新编译打包

(5)使用dragonSN,全局变量设置为安全key,烧写key

(6)这个时候烧进去private的key没有文件系统,是裸数据,不能挂载之后看到,可以用hexdump看到:

 

root@TinaLinux:/tmp# hexdump -C /dev/by-name/private

00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

*

000fe000 73 75 6e 78 69 00 ff ff 01 00 00 00 ff ff ff ff |sunxi...........|

000fe010 ff ff ff ff ff ff ff ff 73 6e 00 ff ff ff ff ff |........sn......|

000fe020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|

000fe030 ff ff ff ff ff ff ff ff 31 32 33 00 ff ff ff ff |........123.....|

000fe040 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|

*

000fe0b0 ff ff ff ff ff ff ff ff 01 00 00 00 ff ff ff ff |................|

000fe0c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|

更多推荐