changtimwu / changtimwu.github.com

Tim's testing/practice notes
7 stars 2 forks source link

study openwrt bleeding edge on ar71xx/mvebu #13

Open changtimwu opened 8 years ago

changtimwu commented 8 years ago

setup tplink as a test device

upgrade with the trunk binary which was built from https://dev.openwrt.org/changeset/46421

changtimwu commented 8 years ago

filesystem org

root@OpenWrt:~# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00020000 00010000 "u-boot"
mtd1: 00125890 00010000 "kernel"
mtd2: 00eaa770 00010000 "rootfs"
mtd3: 00ca0000 00010000 "rootfs_data"
mtd4: 00010000 00010000 "art"
mtd5: 00fd0000 00010000 "firmware"

16MB flash , squashfs-split partitions is something I haven't seen.

[    0.720000] m25p80 spi0.0: found s25fl129p1, expected m25p80
[    0.730000] m25p80 spi0.0: s25fl129p1 (16384 Kbytes)
[    0.730000] 5 tp-link partitions found on MTD device spi0.0
[    0.740000] Creating 5 MTD partitions on "spi0.0":
[    0.740000] 0x000000000000-0x000000020000 : "u-boot"
[    0.750000] 0x000000020000-0x000000145890 : "kernel"
[    0.750000] 0x000000145890-0x000000ff0000 : "rootfs"
[    0.760000] mtd: device 2 (rootfs) set to be root filesystem
[    0.760000] 1 squashfs-split partitions found on MTD device rootfs
[    0.770000] 0x000000350000-0x000000ff0000 : "rootfs_data"
[    0.780000] 0x000000ff0000-0x000001000000 : "art"
[    0.780000] 0x000000020000-0x000000ff0000 : "firmware"
root@OpenWrt:~# cat /proc/mounts 
rootfs / rootfs rw 0 0
/dev/root /rom squashfs ro,relatime 0 0
proc /proc proc rw,noatime 0 0
sysfs /sys sysfs rw,noatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,noatime 0 0
/dev/mtdblock3 /overlay jffs2 rw,noatime 0 0
overlayfs:/overlay / overlay rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work 0 0
tmpfs /dev tmpfs rw,relatime,size=512k,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
debugfs /sys/kernel/debug debugfs rw,noatime 0 0
changtimwu commented 8 years ago

original patch https://lists.openwrt.org/pipermail/openwrt-devel/2014-September/028235.html

It was explained here http://wiki.openwrt.org/doc/techref/filesystems

_After that, if MTD_ROOTFS_SPLIT is enabled, the kernel adjusts the rootfs partition size to the minimum required by the particular SquashFS image and automatically adds rootfsdata to the list of the available mtd partitions setting its beginning to the first appropriate address after the SquashFS end and size to the remainder of the original rootfs partition. The resulting list is stored in RAM only, so no partition table of any kind gets actually modified.

畫一個 readonly 的 root partition 固定空間, 沒佔滿的沒法拿來用, 所以這個 patch 就是把 kernel 會在開機後把沒佔滿的空間產生成一個臨時 rootfs_data partition

changtimwu commented 8 years ago

musl-mipsel(680KB is a bit bigger than musl-arm(4xxkb).

root@OpenWrt:~# ls -l /lib/
-rwxrwxr-x    1 root     root         14784 Jul 18 23:14 ar71xx.sh
drwxrwxr-x    2 root     root            29 Jul 19 20:21 config
drwxr-xr-x    2 root     root             3 Jul 18 23:14 firmware
drwxrwxr-x    2 root     root           167 Jul 19 20:21 functions
-rwxrwxr-x    1 root     root          7242 Jul 18 23:14 functions.sh
lrwxrwxrwx    1 root     root             7 Jul 19 20:21 ld-musl-mips-sf.so.1 -> libc.so
-rw-r--r--    1 root     root         10072 Jul 18 23:14 libblobmsg_json.so
-rwxr-xr-x    1 root     root        680108 Jul 18 23:14 libc.so
-rw-r--r--    1 root     root         32152 Jul 18 23:14 libfstools.so
-rw-r--r--    1 root     root         89084 Jul 18 23:14 libgcc_s.so.1
-rw-r--r--    1 root     root         14924 Jul 18 23:14 libjson_script.so
-rw-r--r--    1 root     root          5432 Jul 18 23:14 libsetlbf.so
-rwxr-xr-x    1 root     root         14724 Jul 18 23:14 libsw.so
-rw-r--r--    1 root     root         39216 Jul 18 23:14 libubox.so
-rw-r--r--    1 root     root         20408 Jul 18 23:14 libubus.so
-rwxr-xr-x    1 root     root         33180 Jul 18 23:14 libuci.so
-rw-r--r--    1 root     root         15968 Jul 18 23:14 libvalidate.so
drwxr-xr-x    3 root     root            30 Jul 18 23:14 modules
drwxr-xr-x    4 root     root           197 Jul 19 20:21 netifd
drwxr-xr-x    2 root     root            49 Jul 19 20:21 network
drwxrwxr-x    2 root     root           419 Jul 19 20:21 preinit
-rw-r--r--    1 root     root           771 Jul 18 23:14 uboot-envtools.sh
drwxrwxr-x    3 root     root             0 Jul 22 00:36 uci
drwxrwxr-x    1 root     root             0 Jul 22 00:36 upgrade
drwxr-xr-x    2 root     root            34 Jul 19 20:21 wifi
changtimwu commented 8 years ago

on 385 platform, the script /lib/mvebu.sh can't detect 385-RD.

even kernel tells the board is Marvell Armada 385 Reference Design

root@OpenWrt:~# cat /proc/device-tree/model
Marvell Armada 385 Reference Design
root@OpenWrt:~#

the detection result still unknown

root@OpenWrt:~# cat /tmp/sysinfo/board_name
unknown
root@OpenWrt:~# cat /tmp/sysinfo/model
Marvell Armada 385 Reference Design
changtimwu commented 8 years ago

/lib/preinit/06_set_iface_mac load the mac addresses from mtd

  armada-385-linksys-caiman|armada-385-linksys-cobra)
                mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
                mac_wan=$(macaddr_setbit_la "$mac")
                ifconfig eth1 hw ether $mac 2>/dev/null
                ifconfig eth0 hw ether $mac_wan 2>/dev/null
changtimwu commented 8 years ago

/lib/preinit/81_linksys_syscfg has ubi recovery

       case $(mvebu_board_name) in
        armada-385-linksys-caiman|armada-385-linksys-cobra|armada-xp-linksys-mamba)
                needs_recovery=0
                ubiattach -m 8 || needs_recovery=1
                if [ $needs_recovery -eq 1 ]
                then
                        echo "ubifs syscfg partition is damaged, reformatting"
                        ubidetach -m 8
                        ubiformat -y -O 2048 -q /dev/mtd8
                        ubiattach -m 8 
                        ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
                fi

/lib/upgrade/linksys.sh /lib/upgrade/platform.sh

changtimwu commented 8 years ago

/sbin/fan_ctrl.sh

on the 385-RD board

root@OpenWrt:~# cat  /sys/class/hwmon/hwmon0/temp1_input
89877
root@OpenWrt:~# cat  /sys/class/hwmon/hwmon0/temp1_input
63691
changtimwu commented 8 years ago
changtimwu commented 8 years ago

openwrt questions:

how does procd handle daemon restart?

root@OpenWrt:~# cd /etc/init.d/
root@OpenWrt:/etc/init.d# grep PROC *
cron:USE_PROCD=1
dnsmasq:USE_PROCD=1
dropbear:USE_PROCD=1
firewall:USE_PROCD=1
gpio_switch:USE_PROCD=1
log:USE_PROCD=1
network:USE_PROCD=1
odhcpd:USE_PROCD=1
openvpn:USE_PROCD=1
pptpd:USE_PROCD=1
qos:USE_PROCD=1
rpcd:USE_PROCD=1
snmpd:USE_PROCD=1
sysntpd:USE_PROCD=1
system:USE_PROCD=1
ugps:USE_PROCD=1
uhttpd:USE_PROCD=1
usbmode:USE_PROCD=1

uci 要take effect 到底是run 哪個 restart

ubus call network restart

uci 要加一個config 很簡單, 但是如何做到連結實際app?