20170119_jeffrey - silenceuncrio/diary GitHub Wiki
- 0825 - review
- 0850 - 我們 firmware 裡面的 MCSV 資訊需要保護
- 0920 - m300 的 hardware mcsv 與 software mcsv 可以參考之前 john 分享的情報
-
1040 - m300 的 hardware mcsv 可從
/tmp/etc/sysinfo.txt
取得 - 1045 - 準備一下 proposal
- 1715 - 把 rootfs 轉成 read-only 會出錯
review
因為我們 firmware 裡面的 MCSV 資訊需要保護
參考 https://www.openssl.org/docs/manmaster/man1/enc.html
假設我們 firmware 的 mcsv 資訊如下
root@Mobile Router:/tmp# cat firmware.mcsv
145a001214007612
使用 des3 作加密 密碼是我們 m300 預設的密碼 - 2wsx#EDC
openssl des3 -salt -in firmware.mcsv -out firmware.mcsv.des3 -k 2wsx#EDC
解密是這樣
openssl -d des3 -salt -in firmware.mcsv.des3 -out firmware.mcsv.des3.out -k 2wsx#EDC
檢查一下
root@Mobile Router:/tmp# cat firmware.mcsv.des3.out
145a001214007612
到時候產生 firmware.tar 前就先產生一個 firmware.mcsv
然後加密成 firmware.mcsv.des3
再打包起來
m300 再去解開 firmware.mcsv.des3
成 firmware.mcsv
然後跟目前的 hardware mcsv 作比對
關於 m300 的 hardware mcsv 與 software mcsv 可以參考之前 john 分享的情報
Dear All:
Software MCSV flow:
1)Generated in M300/proscend/Makefile
#The s/w MCSV tag generated here!!!
MCSV :=$(shell printf "%04X%04X%03X%05X" $(MODEL_ID) 0x$(BRAND_ID) 0x$(VERSION) `expr $(DATECODE) - 20000000`)
2)Saved to file system in M300/proscend/Makefile
#Save to file system /etc/mcsv
install:
@echo $(MCSV) > $(ROOTFS_DIR)/etc/mcsv
3)Module system get mcsv from /etc/mcsv and saved to parameter szSwMCSV.
4)WebUI retrieve mcsv parameter szSwMCSV from system module.
Hardware MCSV flow:
1)Uboot bring up kernel with command line with parameter mcsv=xxxxxxxxxxxxxxxxx in /proc/cmdline
2)Read mcsv out by /etc/rc.local
HW_MCSV=$(sed -e '/.*mcsv/!d' -e 's/.*mcsv=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
3)Saved to file system /tmp/etc/sysinfo.txt
echo "HW_MCSV"=$HW_MCSV >> /tmp/etc/sysinfo.txt
4)Module system get mcsv from /tmp/etc/sysinfo.txt and saved to parameter szHwMCSV.
5)WebUI retrieve mcsv parameter szHwMCSV from system module.
Best Regards
John
目前 m300 的 hardware mcsv 可從 /tmp/etc/sysinfo.txt
取得
root@Mobile Router:/# cat /tmp/etc/sysinfo.txt
UBOOT_VER=123456
MAC=12:34:56:78:9a:bc
HW_MCSV=012C123456789012
SERIALNO=
只取 HW_MCSV
root@Mobile Router:/# cat /tmp/etc/sysinfo.txt | grep HW_MCSV
HW_MCSV=012C123456789012
根據 MCSV
的編碼原則
- MMMM-CCCC-VVV-DDDDD
- Example 145A-0012-14007612
- Model ID=145A(hex)=5210(dec)
- Custom ID=0012(dec)=12
- Sw version=140
- Date code=07612(Hex)=20030226
- Example 145A-0012-14007612
- HW MCSV (Burn in Manufacture)
- SW MCSV (Board SW Image’MCSV)
- UP MCSV(Upgrade SW Image’s MCSV)
取出 Model ID - MMMM
root@Mobile Router:/# cat /tmp/etc/sysinfo.txt | grep HW_MCSV | cut -c 9-12
012C
取出 Custom ID - CCCC
root@Mobile Router:/# cat /tmp/etc/sysinfo.txt | grep HW_MCSV | cut -c 13-16
1234
取出 Sw version - VVV
root@Mobile Router:/# cat /tmp/etc/sysinfo.txt | grep HW_MCSV | cut -c 17-19
567
取出 Date code - DDDDD
root@Mobile Router:/# cat /tmp/etc/sysinfo.txt | grep HW_MCSV | cut -c 20-24
89012
Fine Tune Firmware Built and Upgrade
工作所需要的零件都準備得差不多了
組裝之前先準備一下 proposal 吧
把 rootfs 轉成 read-only 會出錯
Running local boot scripts (/etc/rc.local)uboot_env_ver=1.0
uboot_env_ver 1.0 match, nothing to do
ubi0:rootfs_a 81080 29408 47496 38% /
read-only remount a mounted root file system
attach MTD device 5 (mtd5) to UBI - ubi1:config_a
UBI device number 1, total 128 LEBs (16252928 bytes, 15.5 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
tar: Removing leading `/' from member names
### module <system> init
sh: /var/seqcmdd/ipt_cmd.pid: Read-only file system
sh: /etc/hosts: Read-only file system
### module <syslog> init
### module <switch> init
### module <wanst> init
### module <lan> init
/etc/rc.local: line 156: 299 Segmentation fault /usr/sbin/icosconfig bootinit
error
Freescale i.MX Release Distro 4.1.15-1.2.0 Mobile Router /dev/ttymxc0
Mobile Router login: