Difference between revisions of "OTA experiment"
From ESS-WIKI
(Created page with "== OTA experiment == <syntaxhighlight lang="bash"> #at Linux host #download flex-installer wget https://www.nxp.com/lgfiles/sdk/lsdk2012/flex-installer && chmod +x flex-ins...") |
(No difference)
|
Latest revision as of 02:47, 15 September 2021
OTA experiment
#at Linux host
#download flex-installer
wget https://www.nxp.com/lgfiles/sdk/lsdk2012/flex-installer && chmod +x flex-installer && sudo mv flex-installer /usr/bin
flex-installer -h
#download flex-builder
tar xvzf flexbuild_lsdk2012.tgz
cd flexbuild_lsdk2012/
source setup.env
flex-builder -h
#create docker container
docker run -it --name ota --privileged -v $(pwd):/home/adv/flexbuild_lsdk2012:rw fbubuntu:18.04 /bin/bash
# -----below command are in docker container----------
cd /home/adv/flexbuild_lsdk2012
#source environment variable
source setup.env
#先build一次拉code
flex-builder -i mkfw -m ls1046ardb -b qspi
# clean
flex-builder clean
# 修改rcw_1800_qspiboot.rcw內容(才認得到eMMC)
cd /home/adv/flexbuild_lsdk2012/packages/firmware/rcw/ls1046ardb/RR_FFSSPPPH_1133_5559
vim rcw_1800_qspiboot.rcw
IIC2_EXT=0
EVDD_VSEL=0
# 重新build firmware image
flex-builder -i mkfw -m ls1046ardb -b qspi
ls -hl build/images/
# generate Ubuntu-base arm64 LSDK
flex-builder -i mkrfs -r ubuntu:lite -a arm64
ls -hl build/images/
# kernel image , dtb, distro boot script, flex_linux_<arch>.itb, small ramdiskrfs,etc.
# Flex-builder automatically builds the dependent images if the are not present.
flex-builder -i mkbootpartition -a arm64
ls -hl build/images/
exit
cd build/images/
cp firmware_ls1046ardb_uboot_qspiboot.img /tftpboot/
cp rootfs_lsdk2012_ubuntu_lite_arm64_202109080922.tgz /tftpboot/
cp bootpartition_LS_arm64_lts_5.4_202109080224.tgz /tftpboot/
#at ls1046ardb Device COM
#firmware_ls1046ardb_uboot_qspiboot.img 燒入qspi bank1
=> cpld reset
=> setenv serverip 172.22.31.153
=> dhcp
=> ping 172.22.31.153
=> tftp $load_addr firmware_ls1046ardb_uboot_qspiboot.img
=> sf probe 0:1
=> sf erase 0 +$filesize && sf write $load_addr 0 $filesize
=> cpld reset altbank
#uboot check emmc
=> mmcinfo
=> mmc list
#reboot from qspi bank4 and boot to tiny rfs
=> run qspi_bootcmd
# download bootpartition and rfs to mytftp folder
cd /media/
mkdir mytftp
cd mytftp
ifconfig fm1-mac9 up
udhcpc -i fm1-mac9
ping 172.22.31.153
#---------------------------- lite-----------------------------------------------
tftp -g -r bootpartition_LS_arm64_lts_5.4_202109080224.tgz 172.22.31.153
tftp -g -r rootfs_lsdk2012_ubuntu_lite_arm64_202109080922.tgz 172.22.31.153
# --------------------------------------------------------------------------------
sync
# format emmc
flex-installer -i pf -d /dev/mmcblk0
sync
# lite RFS -p 5P=50M:1G:50M:100M:-1 --rootpart=6 -b
#After installing successfully, run "setenv devpart_root 6;boot" in U-Boot to boot distro from the specific partition)
flex-installer -i install -p 5P=50M:1G:50M:100M:-1 -b bootpartition_LS_arm64_lts_5.4_202109080224.tgz -r rootfs_lsdk2012_ubuntu_lite_arm64_202109080922.tgz -d /dev/mmcblk0 --rootpart=6
sync
# write ota_flag = 1 to partition 5
mkdir ota
mount /dev/mmcblk0p5 ./ota/
cd ota
echo "1" > ota_flag
sync
reboot
# switch to qspi bank4 and boot to partition 6
=> cpld reset altbank
=> setenv devpart_root 6;boot
#boot into ubuntu lite
ifconfig eth4 up
dhclient eth4
apt-get update
apt-get install vim
# mount emmc
vim /etc/udev/rules.d/11-sd-mount.rules
#=============================11-sd-mount.rules=========================================
KERNEL!="mmcblk0p5",GOTO="automount_exit"
ACTION=="add", SUBSYSTEM=="block",RUN+="/bin/mkdir /mnt/emmc",RUN+="/usr/bin/systemd-mount --no-block --automount=yes $devnode /mnt/emmc"
ACTION=="remove", RUN+="/usr/bin/systemd-umount /mnt/emmc",RUN+="/bin/rmdir /mnt/emmc"
LABEL="automount_exit"
#========================================================================================
# reboot and switch to qspi bank4 and boot to partition 6
reboot
=> cpld reset altbank
=> setenv devpart_root 6;boot
# check emmc dir
ls /mnt/emmc
# add check_ota shell scripts
vim /usr/bin/check_ota.sh
:set paste
#--------------below is shell script--------------------------------
#!/bin/sh
echo "this is log" > /root/check_ota_log.txt
count=0
while true
do
echo ${count} > /root/check_ota_log.txt
count=$((count+1))
flag=$(cat /mnt/emmc/ota_flag)
echo "flag is ${flag}" >> /root/check_ota_log.txt
if [ $flag -eq 1 ]
then
echo "system restart ota" >> /root/check_ota_log.txt
else
echo "no need to restart for ota" >> /root/check_ota_log.txt
fi
sleep 1
done
#----------------------------------------------------------------------------------
chmod 777 /usr/bin/check_ota.sh
# add rc.loacl
vim /etc/rc.local
#!/bin/sh -e
check_ota.sh &
echo "this is rc.local 1"
echo "this is rc.local 2" > /root/tt.log
# this is very important
chmod 777 /etc/rc.local
# reboot and switch to qspi bank4 and boot to partition 6
reboot
=> cpld reset altbank
=> setenv devpart_root 6;boot
#check ota flag log file
cat /root/check_ota_log.txt