20171023_jeffrey - silenceuncrio/diary GitHub Wiki
review
繼續 OSPF
試著把 ospfd
叫起來後發現我不知道怎麼來驗證 ospf 的功能
試著 google 幾篇文章來科普一下
下午讓腦子休息一下
先進行 emmc 相關的工作
review 一下之前為了 emmc 做的努力
2017-09
日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|---|---|---|---|---|---|
- | 18 | 19 | 20 | 21 | 22 | - |
- | 25 | 26 | 27 | 28 | 29 |
2017-10
日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|---|---|---|---|---|---|
- | 02 | 03 | - | 05 | 06 | - |
-
20170920_jeffrey
-
CTC: -40 ~ 85 C
開工 - 從
source proenv.sh
開始分析
-
-
20170921_jeffrey
- local configuration file
- machine configuration file
- distribution configuration file
-
20170922_jeffrey
- mfgtool
-
20170925_jeffrey
- emmc 的 uboot 啟動成功
-
20170926_jeffrey
- 挖到 MX6UL_Development_database_2017.4.21_V7.doc
- emmc 的 linux kernel 開機成功
-
20170927_jeffrey
- mksdcard.sh
-
20170928_jeffrey
- Patch uboot for supporting emmc
- Patch linux kernel for supporting emmc
-
20170929_jeffrey
- 修改 proscend\prosrc\icos\script\icos_pam.sh 暫時解決在 rc.local 修改之前不能登入的問題
- 查到 emmc 的 uboot 開機成功與不成功的差異處了
- 確認可成功燒錄的 ucl2.xml
- 確定這次打回來的 10 片 emmc 燒錄後都能開機且 rootfs 都掛載成功
-
20171002_jeffrey
- Add the manufacturing tool:
- nandflash
- tools for manufacturing with nandflash
- emmc
- tools for manufactueing with emmc
- nandflash
- Add the manufacturing tool:
目前手上有一片 emmc 開機且 rootfs 掛載成功
Running local boot scripts (/etc/rc.local)Cannot open /dev/mtd1: No such file or directory
uboot_env_ver not match, patching for the current applicaiton
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
...
m300e login:
用目前的帳密即可登入
先來看一下目前的 /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# by Ariel Chang
# Update: 2016/7/28
#UBOOT_VER=$(sed -e '/.*ubootver/!d' -e 's/.*ubootver=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
#MAC=$(sed -e '/.*ethaddr/!d' -e 's/.*ethaddr=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
#HW_MCSV=$(sed -e '/.*mcsv/!d' -e 's/.*mcsv=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
#SERIALNO=$(sed -e '/.*serialNo/!d' -e 's/.*serialNo=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
export PATH=$PATH:/usr/sbin/icos
export CONFDIR=/etc/icos
/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0
# Enable forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# ==========================================================================
# | set printk level
# ==========================================================================
/bin/echo 1 > /proc/sys/kernel/printk
# [ -f /etc/sysctl.conf ] && sysctl -p -e >&-
# ======================================================================
# | apply the uboot env variables related to current application
# ======================================================================
/usr/sbin/icos/uboot_env.sh
# ======================================================================
# | run bootcmd_v1.1 define in uboot_env.sh
# ======================================================================
fw_setenv bootcmd 'run bootcmd_v1.3'
# ======================================================================
# | read-only remount a mounted root file system
# | attach MTD device to UBI according to the current rootfs
# ======================================================================
/bin/mkdir -p /mnt/data
/bin/mkdir -p /mnt/config
/bin/mkdir -p /home/log
if df | grep rootfs_a
then
#echo "read-only remount a mounted root file system"
#mount -t ubifs ubi0:rootfs_a / -o remount,ro
echo "attach MTD device 5 (mtd5) to UBI - ubi1:config_a"
ubiattach -m 5
mount -t ubifs ubi1:config_a /mnt/config
else
#echo "read-only remount a mounted root file system"
#mount -t ubifs ubi0:rootfs_b / -o remount,ro
echo "attach MTD device 10 (mtd10) to UBI - ubi1:config_b"
ubiattach -m 10
mount -t ubifs ubi1:config_b /mnt/config
fi
# ======================================================================
# | prepare '/mnt/data' and '/home/log' for the application
# ======================================================================
/bin/mkdir -p /mnt/config/data
/bin/mkdir -p /mnt/config/log
mount /mnt/config/data /mnt/data
mount /mnt/config/log /home/log
# ======================================================================
# | prepare '/tmp/etc/sysinfo.txt' and backup to '/mnt/data/sysinfo.txt'
# ======================================================================
UBOOT_ENV_VER=$(fw_printenv uboot_env_ver 2>/dev/null | awk -F"=" '{ print $2 }')
if [ "$UBOOT_ENV_VER" = "" ]; then
UBOOT_ENV_VER="NA"
fi
MAC=$(fw_printenv ethaddr 2>/dev/null | awk -F"=" '{ print $2 }')
if [ "$MAC" = "" ]; then
MAC="random"
fi
HW_MCSV=$(fw_printenv hw_mcsv 2>/dev/null | awk -F"=" '{ print $2 }')
if [ "$HW_MCSV" = "" ]; then
HW_MCSV=$(cat /mnt/data/sysinfo.txt | grep HW_MCSV | awk -F"=" '{ print $2 }')
if [ $? == 0 ]
then
fw_setenv hw_mcsv "$HW_MCSV"
else
HW_MCSV="012C000000000000"
fi
fi
SERIALNO=$(fw_printenv serialno 2>/dev/null | awk -F"=" '{ print $2 }')
if [ "$SERIALNO" = "" ]; then
SERIALNO=$(cat /mnt/data/sysinfo.txt | grep SERIALNO | awk -F"=" '{ print $2 }')
if [ $? == 0 ]
then
fw_setenv serialno "$SERIALNO"
else
SERIALNO="NA"
fi
fi
/bin/mkdir -p /tmp/etc
echo "UBOOT_ENV_VER"=$UBOOT_ENV_VER > /tmp/etc/sysinfo.txt
echo "MAC"=$MAC >> /tmp/etc/sysinfo.txt
echo "HW_MCSV"=$HW_MCSV >> /tmp/etc/sysinfo.txt
echo "SERIALNO"=$SERIALNO >> /tmp/etc/sysinfo.txt
# backup to '/mnt/data/sysinfo.txt'
cp /tmp/etc/sysinfo.txt /mnt/data/sysinfo.txt
# ==========================================================================
# | mkdir /mnt/data/icos for icos data storage (/etc/icos)
# | mkdir /mnt/data/etc for other app data storage
# ==========================================================================
/bin/mkdir -p /mnt/data/icos
/bin/mkdir -p /mnt/data/etc
/sbin/ifconfig eth1 0.0.0.0
/sbin/ifconfig eth0 0.0.0.0
/usr/sbin/brctl addbr lan
/usr/sbin/brctl addif lan eth0
ifconfig lan 192.168.1.1
ifconfig lan up
ethaddr=$(fw_printenv ethaddr 2>/dev/null | awk -F"=" '{ print $2 }')
if [[ "$ethaddr" =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then
ifconfig eth0 hw ether $ethaddr
mac=$(printf "%d" 0x`echo $ethaddr | sed -e 's/://g'`)
mac=$(expr $mac + 1)
mac=$(printf "%012x" $mac | sed -e 's/../&:/g' -e 's/:$//')
ifconfig eth1 hw ether $mac
fi
# Support 2017/01/01 12:00:00 or 2017-01-01 12:00:00
sys_time=$(fw_printenv sys_time 2>/dev/null | awk -F"=" '{ print $2 }')
sys_time=$(echo $sys_time | sed -e "s/\//-/g")
if [ ! -z "$sys_time" ]; then
temp=$(date -s "$sys_time")
fw_setenv sys_time ""
fi
# Ariel: icospromsg need to before icosconfig for share memory init
modprobe cryptodev
/usr/sbin/seqcmdd -C /run/seqcmdd/ipt_cmd &
/usr/sbin/icospromsg &
/usr/sbin/icosconfig bootinit
/usr/sbin/rs485 --enable > /dev/null 2>&1
/usr/sbin/read_modem &
/usr/sbin/icos/gpio_button.sh \
--click "reboot" \
--debounce 500 \
--time 5 \
--hold "heartbeat_all_led.sh; icosconfig reset ; reboot" \
--active-low 1 \
--hold-exit 5 0 &
# Ariel: make icos watch dog to be the last one.Max timeout is 128 seconds.
/usr/sbin/icoswdog -T 120 &
# ======================================================================
# | reset the uboot env no_good counter
# | we think our applicaion is good at this moment
# ======================================================================
# Replaced by wdog,John
# fw_setenv no_good .
# Ariel: start telnetd
telnetd &
# John: delay 1s to prevent the wdog infomation be treated as login name and password
sleep 1
不要貪心
一次跑一點就好
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# by Ariel Chang
# Update: 2016/7/28
#UBOOT_VER=$(sed -e '/.*ubootver/!d' -e 's/.*ubootver=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
#MAC=$(sed -e '/.*ethaddr/!d' -e 's/.*ethaddr=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
#HW_MCSV=$(sed -e '/.*mcsv/!d' -e 's/.*mcsv=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
#SERIALNO=$(sed -e '/.*serialNo/!d' -e 's/.*serialNo=\(.*\)/\1/' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' /proc/cmdline)
export PATH=$PATH:/usr/sbin/icos
export CONFDIR=/etc/icos
/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0
# Enable forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# ==========================================================================
# | set printk level
# ==========================================================================
/bin/echo 1 > /proc/sys/kernel/printk
# [ -f /etc/sysctl.conf ] && sysctl -p -e >&-
echo -e "\ncheck point 1"
exit
存檔後重開機
Running local boot scripts (/etc/rc.local)
check point 1
.
m300e login:
繼續前進
echo -e "\ncheck point 1"
# ======================================================================
# | apply the uboot env variables related to current application
# ======================================================================
/usr/sbin/icos/uboot_env.sh
echo -e "\ncheck poiont 2"
exit
console 如下
Running local boot scripts (/etc/rc.local)
check point 1
Cannot open /dev/mtd1: No such file or directory
uboot_env_ver not match, patching for the current applicaiton
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
error
m300e login:
目前 uboot_env.sh
內容如下
#!/bin/bash
# uboot env
uboot_env_ver=1.3
if fw_printenv uboot_env_ver | grep $uboot_env_ver
then
echo "uboot_env_ver $uboot_env_ver match, nothing to do"
exit 0
else
echo "uboot_env_ver not match, patching for the current applicaiton"
fi
# set default hardware MCSV and serial number
fw_setenv hw_mcsv '012C000000000000'
fw_setenv serialno 'NA'
# set nandread_a and nandread_b
fw_setenv nandread_a 'nand read ${loadaddr} ${kernel_a_addr} 0x800000; \
nand read ${fdt_addr} ${dtb_a_addr} 0x100000;'
fw_setenv nandread_b 'nand read ${loadaddr} ${kernel_b_addr} 0x800000; \
nand read ${fdt_addr} ${dtb_b_addr} 0x100000;'
# set bootargs_a and bootargs_b
fw_setenv bootargs_a 'echo bootargs for room a; \
setenv bootargs console=ttymxc0,115200 ubi.mtd=4 root=ubi0:rootfs_a rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)'
fw_setenv bootargs_b 'echo bootargs for room b; \
setenv bootargs console=ttymxc0,115200 ubi.mtd=9 root=ubi0:rootfs_b rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)'
# ======================================================================
# | dual image
# ======================================================================
fw_setenv no_good .
# according to the current running rootfs to set the primary app
if df | grep rootfs_a
then
fw_setenv app_primary a
fw_setenv app_secondary b
else
fw_setenv app_primary b
fw_setenv app_secondary a
fi
fw_setenv app_replace 'if test ${app_primary} = a; \
then echo a to b; setenv app_primary b; setenv app_secondary a; \
else echo b to a; setenv app_primary a; setenv app_secondary b; \
fi'
fw_setenv app_choose 'if test ${no_good} = ".xx"; \
then echo replace primary app; run app_replace; setenv no_good .; \
else echo run primary app; \
fi'
# sys led - GPIO2-IO20
# +----------+--------+-----------+------+
# | Instance | Signal | Pad | Mode |
# | GPIO2 | IO20 | SD1_DATA2 | ALT5 |
# +----------+--------+-----------+------+
#
# SW_MUX_CTL_PAD_SD1_DATA2 - select mux mode: ALT5 mux port
# - mw 0x020E01CC 0x00000005 1
# GPIO2_GDIR - define the direction of the GPIO2-IO20 as OUTPUT
# - mw 0x020A0004 00100000 1
# GPIO2_DR - define the value of the GPIO2-IO20 OUTPUT to 0 - pull low
# - mw 0x020A0000 00000000 1
fw_setenv turnon_sysled 'mw 0x020E01CC 0x00000005 1; mw 0x020A0004 00100000 1; mw 0x020A0000 00000000 1'
# Ethernet 1 Reset PIN - GPIO1-IO30
# +----------+--------+---------------+------+
# | Instance | Signal | Pad | Mode |
# | GPIO1 | IO30 | UART5_TX_DATA | ALT5 |
# +----------+--------+---------------+------+
#
# IOMUXC_SW_MUX_CTL_PAD_UART5_TX_DATA - select mux mode: ALT5 mux port
# mw 0x020E00BC 00000005 1
# GPIO1_GDIR - define the direction of the GPIO1-IO30 as OUTPUT
# mw 0x0209C004 40000000 1
# GPIO1_DR - define the value of the GPIO1-IO30 OUTPUT to 0 - pull low
# mw 0x0209C000 00000000 1
# GPIO1_DR - define the value of the GPIO1-IO30 OUTPUT to 1 - pull high
# mw 0x0209C000 40000000 1
# Ethernet 2 Reset PIN - GPIO1-IO30
# +----------+--------+---------------+------+
# | Instance | Signal | Pad | Mode |
# | GPIO1 | IO31 | UART5_RX_DATA | ALT5 |
# +----------+--------+---------------+------+
#
# IOMUXC_SW_MUX_CTL_PAD_UART5_RX_DATA - select mux mode: ALT5 mux port
# mw 0x020E00C0 00000005 1
# GPIO1_GDIR - define the direction of the GPIO1-IO31 as OUTPUT
# mw 0x0209C004 80000000 1
# GPIO1_DR - define the value of the GPIO1-IO31 OUTPUT to 0 - pull low
# mw 0x0209C000 00000000 1
# GPIO1_DR - define the value of the GPIO1-IO31 OUTPUT to 1 - pull high
# mw 0x0209C000 80000000 1
# Mobile Reset PIN - GPIO5-IO7
# +----------+--------+--------------+-----------------+
# | Instance | Signal | Pad | Mode |
# | GPIO5 | IO7 | SNVS_TAMPER7 | No Muxing(ALT5) |
# +----------+--------+--------------+-----------------+
#
# GPIO5_GDIR - define the direction of the GPIO5-IO7 as OUTPUT
# mw 0x020AC004 00000080 1
# GPIO5_DR - define the value of the GPIO5-IO7 OUTPUT to 0 - pull low
# mw 0x020AC000 00000000 1
# GPIO5_DR - define the value of the GPIO5-IO7 OUTPUT to 1 - pull high
# mw 0x020AC000 00000080 1
fw_setenv reset_ethernet_and_mobile 'mw 0x020E00BC 00000005 1; mw 0x020E00C0 00000005 1; \
mw 0x0209C004 C0000000 1; mw 0x020AC004 00000080 1; \
mw 0x0209C000 00000000 1; mw 0x020AC000 00000000 1; \
sleep 1; \
mw 0x0209C000 C0000000 1; mw 0x020AC000 00000080 1'
# ======================================================================
# | bootcmd
# ======================================================================
# turn on the system LED first - zero the bootdelay
fw_setenv bootdelay 0
fw_setenv bootcmd_v1.3 'run turnon_sysled; run reset_ethernet_and_mobile; \
run app_choose; \
echo run bootargs_${app_primary}; run bootargs_${app_primary}; \
run nandread_${app_primary}; \
setenv no_good ${no_good}x; \
saveenv; \
bootz ${loadaddr} - ${fdt_addr}'
# set the current uboot env version into uboot env MTD
fw_setenv uboot_env_ver $uboot_env_ver
# bondary for protect the uboot env
fw_setenv uboot_env_1.3_bondary_1 'therer are 3 bondary'
fw_setenv uboot_env_1.3_bondary_2 'therer are 3 bondary'
fw_setenv uboot_env_1.3_bondary_3 'therer are 3 bondary'
目前 fw_printenv
和 fw_setenv
執行都會出錯
root@m300e:~# fw_printenv
Cannot open /dev/mtd1: No such file or directory
root@m300e:~# fw_setenv xxx
Cannot open /dev/mtd1: No such file or directory
Error: environment not initialized
先在 /etc/rc.local
註解掉 uboot_env.sh
使其先不執行
echo -e "\ncheck point 1"
# ======================================================================
# | apply the uboot env variables related to current application
# ======================================================================
#/usr/sbin/icos/uboot_env.sh
echo -e "\ncheck poiont 2"
exit
存檔後開機
Running local boot scripts (/etc/rc.local)
check point 1
check poiont 2
.
m300e login:
繼續也是一個利用 fw_setenv
執行的敘述
fw_setenv bootcmd 'run bootcmd_v1.3'
先註解掉
echo -e "\ncheck poiont 2"
# | run bootcmd_v1.1 define in uboot_env.sh
# ======================================================================
#fw_setenv bootcmd 'run bootcmd_v1.3'
echo -e "\ncheck point 3"
exit
存檔後開機
Running local boot scripts (/etc/rc.local)
check point 1
check point 2
check point 3
.
m300e login:
再來的開始複雜了
echo -e "\ncheck point 3"
# ======================================================================
# | read-only remount a mounted root file system
# | attach MTD device to UBI according to the current rootfs
# ======================================================================
/bin/mkdir -p /mnt/data
/bin/mkdir -p /mnt/config
/bin/mkdir -p /home/log
if df | grep rootfs_a
then
#echo "read-only remount a mounted root file system"
#mount -t ubifs ubi0:rootfs_a / -o remount,ro
echo "attach MTD device 5 (mtd5) to UBI - ubi1:config_a"
ubiattach -m 5
mount -t ubifs ubi1:config_a /mnt/config
else
#echo "read-only remount a mounted root file system"
#mount -t ubifs ubi0:rootfs_b / -o remount,ro
echo "attach MTD device 10 (mtd10) to UBI - ubi1:config_b"
ubiattach -m 10
mount -t ubifs ubi1:config_b /mnt/config
fi
echo -e "\ncheck point 4"
exit
存檔後開機
Running local boot scripts (/etc/rc.local)
check point 1
check point 2
check point 3
attach MTD device 10 (mtd10) to UBI - ubi1:config_b
ubiattach: error!: cannot attach mtd10
error 19 (No such device)
error
m300e login:
目前 emmc 的檔案系統已經不適合再用 ubiattach
注意到目前 mfgtool 使用的 mksdcard.sh.tar
自己對於這個主題相關的探索有
先利用 USB 隨身碟插一張 8GB SD 卡來練習
利用 cat /proc/partitions
來觀察
➜ www git:(develop) ✗ cat /proc/partitions
major minor #blocks name
11 0 1048575 sr0
8 0 125829120 sda
8 1 123730944 sda1
8 2 1 sda2
8 5 2095104 sda5
8 16 7761920 sdb
8 17 512000 sdb1
8 18 7147520 sdb2
解開 mksdcard.sh.tar
得到 mksdcard.sh
目前 mksdcard.sh
內容如下
#!/bin/sh
# partition size in MB
BOOT_ROM_SIZE=10
# wait for the SD/MMC device node ready
while [ ! -e $1 ]
do
sleep 1
echo “wait for $1 appear”
done
# call sfdisk to create partition table
# destroy the partition table
node=$1
dd if=/dev/zero of=${node} bs=1024 count=1
sfdisk --force ${node} << EOF
${BOOT_ROM_SIZE}M,500M,0c
600M,,83
EOF
解析 dd if=/dev/zero of=${node} bs=1024 count=1
這要在 /dev/sdb
操作的話變成 dd if=/dev/zero of=/dev/sdb bs=1024 count=1
實際操作後如下
➜ www git:(develop) ✗ sudo dd if=/dev/zero of=/dev/sdb bs=1024 count=1
[sudo] password for jeffrey:
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.160586 s, 6.4 kB/s
➜ www git:(develop) ✗ cat /proc/partitions
major minor #blocks name
11 0 1048575 sr0
8 0 125829120 sda
8 1 123730944 sda1
8 2 1 sda2
8 5 2095104 sda5
8 16 7761920 sdb
看來就是把 /dev/sdb
的前 1024 bytes 寫成 dev/zero
注意到 cat /proc/partition
相關於 sdb
的前後差別
dd 前
8 16 7761920 sdb
8 17 512000 sdb1
8 18 7147520 sdb2
dd 後
8 16 7761920 sdb
發現到 sdb1
和 sdb2
都不見了
注意到 mksdcard.sh
裡以下的敘述
sfdisk --force ${node} << EOF
${BOOT_ROM_SIZE}M,500M,0c
600M,,83
EOF
把 ${node}
和 ${BOOT_ROM_SIZE}
換成實際的數值後得到
sfdisk --force /dev/mmcblk0 << EOF
10M,500M,0c
600M,,83
EOF
若要在 /dev/sdb
做實驗的話
sfdisk --force /dev/sdb << EOF
10M,500M,0c
600M,,83
EOF
實際操作的紀錄如下
➜ www git:(develop) ✗ sudo sfdisk --force /dev/sdb << EOF
10M,500M,0c
600M,,83
EOF
Checking that no-one is using this disk right now ... OK
Disk /dev/sdb: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
>>> Created a new DOS disklabel with disk identifier 0x5ec2a2a6.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 500 MiB.
/dev/sdb2: Created a new partition 2 of type 'Linux' and of size 6.8 GiB.
/dev/sdb3:
New situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb1 20480 1044479 1024000 500M c W95 FAT32 (LBA)
/dev/sdb2 1228800 15523839 14295040 6.8G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
再次利用 cat /prooc/partitions
➜ www git:(develop) ✗ cat /proc/partitions
major minor #blocks name
11 0 1048575 sr0
8 0 125829120 sda
8 1 123730944 sda1
8 2 1 sda2
8 5 2095104 sda5
8 16 7761920 sdb
8 17 512000 sdb1
8 18 7147520 sdb2
稍微理解了 sfdidk 的使用方式之後
稍微前進的腳步為再建立一個 partition 讓開機時可以做 mount 的練習
sfdisk --force /dev/sdb << EOF
10M,500M,0c
600M,360M,83
1G,,83
EOF
實際操作如下
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.166683 s, 6.1 kB/s
➜ www git:(develop) ✗ sudo sfdisk --force /dev/sdb << EOF
10M,500M,0c
600M,360M,83
1G,,83
EOF
Checking that no-one is using this disk right now ... OK
Disk /dev/sdb: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
>>> Created a new DOS disklabel with disk identifier 0xbad4081c.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 500 MiB.
/dev/sdb2: Created a new partition 2 of type 'Linux' and of size 360 MiB.
/dev/sdb3: Created a new partition 3 of type 'Linux' and of size 6.4 GiB.
/dev/sdb4:
New situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb1 20480 1044479 1024000 500M c W95 FAT32 (LBA)
/dev/sdb2 1228800 1966079 737280 360M 83 Linux
/dev/sdb3 2097152 15523839 13426688 6.4G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
造樣造句
解壓 mksdcard.sh.tar
得到 mksdcard.sh
➜ OS Firmware git:(develop) ✗ tar xvf mksdcard.sh.tar
mksdcard.sh
編輯 mksdcard.sh
再壓縮回 mksdcard.sh.tar
➜ OS Firmware git:(develop) ✗ vi mksdcard.sh
➜ OS Firmware git:(develop) ✗ rm mksdcard.sh.tar
➜ OS Firmware git:(develop) ✗ tar cvf mksdcard.sh.tar mksdcard.sh
mksdcard.sh
➜ OS Firmware git:(develop) ✗ rm mksdcard.sh
解壓再次確認 mksdcard.sh
的內容
➜ OS Firmware git:(develop) ✗ tar xvf mksdcard.sh.tar
mksdcard.sh
➜ OS Firmware git:(develop) ✗ cat mksdcard.sh
#!/bin/sh
# partition size in MB
BOOT_ROM_SIZE=10
# wait for the SD/MMC device node ready
while [ ! -e $1 ]
do
sleep 1
echo “wait for $1 appear”
done
# call sfdisk to create partition table
# destroy the partition table
node=$1
dd if=/dev/zero of=${node} bs=1024 count=1
sfdisk --force ${node} << EOF
${BOOT_ROM_SIZE}M,500M,0c
600M,360M,83
1G,,83
EOF
➜ OS Firmware git:(develop) ✗ ls
files firmware mksdcard.sh mksdcard.sh.tar ucl2.xml
➜ OS Firmware git:(develop) ✗ rm mksdcard.sh
利用 mfgtool 燒錄
開機
root@m300e:~# ls /dev/mmcblk1* -al
brw-rw---- 1 root disk 179, 0 Jan 1 1970 /dev/mmcblk1
brw-rw---- 1 root disk 179, 8 Jan 1 1970 /dev/mmcblk1boot0
brw-rw---- 1 root disk 179, 16 Jan 1 1970 /dev/mmcblk1boot1
brw-rw---- 1 root disk 179, 1 Jan 1 1970 /dev/mmcblk1p1
brw-rw---- 1 root disk 179, 2 Jan 1 1970 /dev/mmcblk1p2
brw-rw---- 1 root disk 179, 3 Jan 1 1970 /dev/mmcblk1p3
brw-rw---- 1 root disk 179, 24 Jan 1 1970 /dev/mmcblk1rpmb
root@m300e:~#
目標 /dev/mmcblk1p3
出現
試著 mount 看看
root@m300e:~# mkdir /mnt/test
root@m300e:~# mount -t ext3 /dev/mmcblk1p3 /mnt/test/
mount: mounting /dev/mmcblk1p3 on /mnt/test/ failed: Invalid argument
root@m300e:~#
回頭看一下 ucl2.xml
我應該要先利用 mkfs.ext3
來格式化 /dev/mmcblk1p3
修一下 ucl2.xml
diff --git a/manufacturing_tool/emmc/mfgtools/Profiles/Linux/OS Firmware/ucl2.xml b/manufacturing_tool/emmc/mfgtools/Profiles/Linux/OS Firmware/ucl2.xml
index ef0a962..81f9483 100644
--- a/manufacturing_tool/emmc/mfgtools/Profiles/Linux/OS Firmware/ucl2.xml
+++ b/manufacturing_tool/emmc/mfgtools/Profiles/Linux/OS Firmware/ucl2.xml
@@ -89,6 +89,20 @@
+ <!-- test -->
+ <CMD state="Updater" type="push"
+ body="$ mkfs.ext3 -j /dev/mmcblk%mmc%p3">Formatting test partition</CMD>
+ <CMD state="Updater" type="push"
+ body="$ mkdir -p /mnt/mmcblk%mmc%p3"/>
+ <CMD state="Updater" type="push"
+ body="$ mount -t ext3 /dev/mmcblk%mmc%p3 /mnt/mmcblk%mmc%p3"/>
+ <CMD state="Updater" type="push"
+ body="$ echo 'hello world' > /mnt/mmcblk%mmc%p3/test"/>
+ <CMD state="Updater" type="push"
+ body="$ umount /mnt/mmcblk%mmc%p3">Unmounting test partition</CMD>
+
+
+
<CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
</LIST>
mfgtoo 燒錄... ok
開機
這次就 mount 成功囉
root@m300e:~# mkdir /mnt/test
root@m300e:~# mount -t ext3 /dev/mmcblk1p3 /mnt/test/
root@m300e:~#
看看我在 ucl2.xml
放的 hello world
root@m300e:~# cat /mnt/test/test
hello world
root@m300e:~#
哈哈哈
大進展阿...
紀錄一下歷程
commit 1525d01599b6a5adced46afc3b32de431e8eced6
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date: Mon Oct 23 17:38:05 2017 +0800
emmc first step
- create another partion
- after power on, use the following commands to see our beatiful first step:
- mkdir /mnt/test
- mount -t ext3 /mnt/dev/mmcblkp3 /mnt/test
- cat /mnt/test/test
.../Profiles/Linux/OS Firmware/mksdcard.sh | 22 +++++++++++++++++++++
.../Profiles/Linux/OS Firmware/mksdcard.sh.tar | Bin 10240 -> 10240 bytes
.../mfgtools/Profiles/Linux/OS Firmware/ucl2.xml | 14 +++++++++++++
3 files changed, 36 insertions(+)