ARM40-A5應用——ARM40檔案的拓荒部署示例(ARM40-reclaim-OTA)
ARM40-A5應用——ARM40檔案的拓荒部署示例(ARM40-reclaim-OTA)
2018.10.9
本文適合ARM40檔案的半自動拓荒部署(即首次部署)。
一、ARM40檔案拓荒部署的步驟
1.1、伺服器端檔案
伺服器端涉及到的目錄和檔案如下:
/home/ARM40-A5/ARM40-A5-projects/noise_rdace/APP_20181009/MANAGER #目錄,存在管理檔案 /home/ARM40-A5/ARM40-A5-projects/noise_rdace/APP_20181009/RELEASE #目錄,存放下載到ARM40的檔案 /home/ARM40-A5/ARM40-A5-projects/noise_rdace/APP_20181009/MANAGER/update.sh #指令碼檔案 /home/ARM40-A5/ARM40-A5-projects/noise_rdace/APP_20181009/MANAGER/product-list/A5A1890001 #產品ID檔案
1.2、ARM40上的操作
(1)建立/opt/user/ota-rtchip.sh檔案
(2)執行/opt/user/ota-rtchip.sh A5A1890001 (A5A1890001為產品ID檔名)
(3)reboot重啟ARM40,檢查並測試。。
二、伺服器端檔案
服務端需要開啟rsync服務,參考《ARM40-A5應用——使用rsync與Linux伺服器的遠端資料同步》。
本示例中,伺服器192.168.1.130上rsync的RDACE_IDC模組的地址為:
/home/ARM40-A5/ARM40-A5-projects/noise_rdace/APP_20181009
含MANAGER和RELEASE兩個目錄。
MANAGER目錄中存放update.sh指令碼和product-list目錄。product-list目錄中存放產品ID檔案。
RELEASE目錄中存放需要下載到ARM40的檔案,其中RELEASE/tmp目錄下的檔案,在ARM40上是臨時檔案,重新上電後不會存在。
update.sh、A5A1880001、setby-meinfo.sh等檔案的內容見附錄。
三、 ARM40上的操作
(1)建立/opt/user/ota-rtchip.sh檔案
touch /opt/user/ota-rtchip.sh
chmod 755 /opt/user/ota-rtchip.sh
其內容為:
#!/bin/sh
echo "hello ARM40_IDC"
[email protected]::RDACE_IDC
#先拷貝MANAGER/tmp中的存放的rsync和libpopt.so.0
scp -r [email protected]:/home/ARM40-A5/ARM40-A5-projects/noise_rdace/APP_20181009/MANAGER/tmp/* /tmp/
echo "123456" > /etc/rsync.passwd
chmod 0600 /etc/rsync.passwd
cp /tmp/rsync /usr/bin/
cp /tmp/libpopt.so.0 /usr/lib/
rsync -avz --timeout=60 --password-file=/etc/rsync.passwd $SERVER_IDC/MANAGER/update.sh /tmp/
chmod 755 /tmp/update.sh
/tmp/update.sh $1
(2)執行 /opt/user/ota-rtchip.sh A5A1880001
ota-rtchip.sh會將伺服器上的update.sh指令碼下載到ARM40的/tmp/update.sh,並執行該指令碼。
指令碼update.sh會依次把 BATCH_FILES 中羅列的檔案拷貝到ARM40相應的位置,並修改各檔案的chmod。
指令碼update.sh的最後會執行setby-meinfo.sh $1
,例如 setby-meinfo.sh A5A1880001
,將A5A1880001指示的產品ID檔案也rsync到ARM40。然後根據A5A1880001的內容,生成MAC地址、產品ID、holer-key等產品自身相關的資訊。若更新時無此需要,則註釋掉update.sh中的setby-meinfo.sh $1
即可。
指令碼/opt/user/ota-rtchip.sh的執行示例(刪去了部分rsync的log和setby-meinfo.sh的log):
[email protected]:# /opt/user/ota-rtchip.sh A5A1880001
hello ARM40_IDC
receiving incremental file list
update.sh
hello ARM40
/etc/init.d/S40network OK
/etc/init.d/S41network OK
/opt/user/setby-meinfo.sh OK
batch_files OK
(3) 需手工完成的部分
- 1、增加armholer使用者名稱
adduser armholer
#passwd:armholer
若此處的使用者名稱、密碼與/opt/rdace-manager/rdace.info中的不同,請修改rdace.info中的資訊。 - 2、免密登陸ARM40
修改 /etc/inittab中的
console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
#console::respawn:-/bin/sh
為:
#console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
console::respawn:-/bin/sh
- 3、重啟
reboot
參考文章:
ARM40-A5應用——使用rsync與Linux伺服器的遠端資料同步
ARM40-A5應用——ARM40檔案的自動遠端更新(ARM40-auto-OTA)
ARM40-A5應用——ARM40檔案的半自動遠端更新(ARM40-semiauto-OTA)
嵌入式Linux韌體升級
https://blog.csdn.net/jsfzdd/article/details/6158258
Linux下遠端升級指令碼
https://blog.csdn.net/sdvch/article/details/14109997
Android應用增量更新 - Smart App Updates
https://github.com/cundong/SmartAppUpdates
薈聚計劃:共商 共建 共享 Grant
附:
(1)伺服器端指令碼 update.sh 的內容如下:
#!/bin/sh
#update.sh
#/opt/user/ota-rtchip.sh A5A1880001 #download A5A1880001 to /opt/rdace-manager/rdace.info
echo "hello ARM40"
[email protected]::RDACE_IDC
cp_file_to_ARM40()
{
rsync -avz --password-file=/etc/rsync.passwd $SERVER_IDC/RELEASE/$1 /$1
if [ "$?" != "0" ]; then # rsync is not OK, game over
return 1
fi
echo "/$1 OK"
return 0
}
BATCH_FILES="etc/ppp/peers/M26-gprs
etc/ppp/peers/M26-chat-connect
etc/ppp/peers/M26-chat-disconnect
etc/ppp/ip-up
etc/ppp/pon-M26-auto.sh
etc/ppp/ppp-off
etc/ppp/ppp-csq
usr/bin/holer
etc/holer-key
etc/ssh/sshd_config
opt/user/date_update.sh
opt/user/cron_user.sh
opt/rdace-manager/rdace.info
etc/network/if-public-network.sh
etc/init.d/S40network
etc/init.d/S41network
etc/localtime
etc/cron.arm40
opt/rdace10/
tmp/sqlite3.tar
tmp/tslib.tar
tmp/qte4.8.7.tar
tmp/libstdc++.so.tar
etc/pointercal
etc/profile
etc/profile.local
tmp/setby-meinfo.sh"
batch_files()
{
for batch in $BATCH_FILES
do
cp_file_to_ARM40 $batch
if [ "$?" != "0" ]; then
return 1
fi
done
echo "batch_files OK"
return 0
}
#if [ ! -d /home/test ]; then
# mkdir -p /home/test
#fi
if [ ! -d /opt/rdace-manager ]; then
mkdir -p /opt/rdace-manager
fi
batch_files
chmod 755 /etc/ppp/peers/M26-gprs
chmod 755 /etc/ppp/peers/M26-chat-connect
chmod 755 /etc/ppp/peers/M26-chat-disconnect
chmod 755 /etc/ppp/ip-up
chmod 755 /etc/ppp/pon-M26-auto.sh
chmod 755 /etc/ppp/ppp-off
chmod 755 /etc/ppp/ppp-csq
chmod 755 /usr/bin/holer
chmod 777 /etc/holer-key
chmod 644 /etc/ssh/sshd_config
chmod 755 /opt/user/date_update.sh
chmod 755 /opt/user/cron_user.sh
chmod 755 /etc/network/if-public-network.sh
chmod 755 /etc/init.d/S40network
chmod 755 /etc/init.d/S41network
chmod 664 /etc/localtime
chmod 777 /etc/cron.arm40
chmod 664 /etc/network/interfaces.eth0
chmod 664 /etc/network/interfaces.eth1
chmod 777 /opt/rdace-manager/rdace.info
tar xvf /tmp/sqlite3.tar -C /opt/
tar xvf /tmp/tslib.tar -C /opt/
tar xvf /tmp/qte4.8.7.tar -C /opt/
tar xvf /tmp/libstdc++.so.tar -C /lib/
chmod 644 /etc/pointercal
chmod 644 /etc/profile
chmod 755 /etc/profile.local
if [ -e /etc/init.d/S49ntp ]; then
mv /etc/init.d/S49ntp /etc/init.d/K49ntp
fi
/tmp/setby-meinfo.sh $1
(2)A5A1880001的內容示例如下:
ME_ID=A5A1880001
ME_MASTER=EC5002
ETH0_IP=192.168.0.250
ETH0_MAC=C8:1B:5C:05:86:9C
ETH0_GATEWAY=192.168.0.1
ETH1_IP=192.168.6.6
ETH1_MAC=C8:1B:5C:05:86:9D
ETH1_GATEWAY=192.168.6.1
GPRS_ID=PPA1880001
GPRS_SIM=null
HOLER_KEY=cbf1bea217f9608fa4b1f3361ae
HOLER_ACCESS=armholer:armholer
HOLER_PORT=63301
[email protected]
HOLER_VALIDITY=2018.8.21:180
UPS_ID=UPA1880001
MFG_DATE=2018.8.21
MFG_COO=SHANGHAI
FIX_ADDR=SHANGHAI:JINSHAN
(3)setby-meinfo.sh的內容示例如下:
#!/bin/sh
echo "hello me.info"
[email protected]::RDACE_IDC
MEINFO=/opt/rdace-manager/rdace.info
# cp product-list/$1 to /opt/rdace-manager/rdace.info (on ARM40-A5)
cp_meinfo_to_ARM40()
{
rsync -avz --password-file=/etc/rsync.passwd $SERVER_IDC/MANAGER/product-list/$1 $MEINFO
if [ "$?" != "0" ]; then # rsync is not OK, game over
return 1
fi
echo "$1 OK"
return 0
}
cp_meinfo_to_ARM40 $1 #eg: A5A1880001
ETH0_MAC=`awk '/ETH0_MAC/ {print $1}' $MEINFO |cut -d '=' -f 2`
ETH0_IP=`awk '/ETH0_IP/ {print $1}' $MEINFO |cut -d '=' -f 2`
ETH0_GATEWAY=`awk '/ETH0_GATEWAY/ {print $1}' $MEINFO |cut -d '=' -f 2`
ETH1_MAC=`awk '/ETH1_MAC/ {print $1}' $MEINFO |cut -d '=' -f 2`
ETH1_IP=`awk '/ETH1_IP/ {print $1}' $MEINFO |cut -d '=' -f 2`
ETH1_GATEWAY=`awk '/ETH1_GATEWAY/ {print $1}' $MEINFO |cut -d '=' -f 2`
echo "# Configure eth0" > /etc/network/interfaces.eth0
echo "MACADDRESS=$ETH0_MAC" >> /etc/network/interfaces.eth0
echo "IPADDRESS=$ETH0_IP" >> /etc/network/interfaces.eth0
echo "NETMASK=255.255.255.0" >> /etc/network/interfaces.eth0
echo "GATEWAY=$ETH0_GATEWAY" >> /etc/network/interfaces.eth0
echo "# Configure eth1" > /etc/network/interfaces.eth1
echo "MACADDRESS=$ETH1_MAC" >> /etc/network/interfaces.eth1
echo "IPADDRESS=$ETH1_IP" >> /etc/network/interfaces.eth1
echo "NETMASK=255.255.255.0" >> /etc/network/interfaces.eth1
echo "GATEWAY=$ETH1_GATEWAY" >> /etc/network/interfaces.eth1
HOLER_KEY=`awk '/HOLER_KEY/ {print $1}' $MEINFO |cut -d '=' -f 2`
echo "$HOLER_KEY" > /etc/holer-key
chmod 664 /etc/network/interfaces.eth0
chmod 664 /etc/network/interfaces.eth1
chmod 777 /etc/holer-key
chmod 777 /opt/rdace-manager/rdace.info
echo "********************************"
cat /etc/network/interfaces.eth0
echo "********************************"
cat /etc/network/interfaces.eth1
echo "********************************"
cat $MEINFO