WhyCan Forum(哇酷开发者社区)

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn

您尚未登录。

#1 2020-09-18 13:09:19

Iron
会员
注册时间: 2018-10-23
累计积分: 58
个人网站

采用 openwrt imagebuilder 构建 v3s cpio-rootfs 运行测试

系统环境:Debian/Ubuntu

参考文档:
    https://openwrt.org/docs/guide-user/additional-software/imagebuilder
    The Image Builder runs only in 64bit linux. You can however run a 64bit linux in VM (i.e. virtualbox) even from 32bit windows.

清华镜像:
    https://mirrors.tuna.tsinghua.edu.cn/help/openwrt/
    https://mirrors.tuna.tsinghua.edu.cn/openwrt/
下载文件:
    https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.4/targets/sunxi/cortexa7/openwrt-imagebuilder-19.07.4-sunxi-cortexa7.Linux-x86_64.tar.xz



1. Debian/Ubuntu 环境配置

apt-get install build-essential libncurses5-dev libncursesw5-dev zlib1g-dev gawk git gettext libssl-dev xsltproc wget unzip python

2. 解压 openwrt-imagebuilder-19.07.4-sunxi-cortexa7.Linux-x86_64.tar.xz 到指定目录

tar -xvf openwrt-imagebuilder-19.07.4-sunxi-cortexa7.Linux-x86_64.tar.xz
cd openwrt-imagebuilder-19.07.4-sunxi-cortexa7.Linux-x86_64

3. 修改 repositories.conf, 指定镜像地址,加快下载速度

# rootfs  sed -i 's_downloads.openwrt.org_mirrors.tuna.tsinghua.edu.cn/openwrt_' /etc/opkg/distfeeds.conf
sed -i 's_downloads.openwrt.org_mirrors.tuna.tsinghua.edu.cn/openwrt_' repositories.conf

3. 修改 .config 文件, 添加 cpio 格式 rootfs

CONFIG_TARGET_ROOTFS_CPIOGZ=y

4. 'make image' 
     默认会输出所有 PROFILE 配置的镜像文件,因为测试只需要 cpio 格式 rootfs, 可以指定 PROFILE 节省输出时间

# make image # 生成所有 PROFILE 镜像
make image PROFILE=sun8i-h2-plus-orangepi-zero # 指定 PROFILE
# make image PROFILE=sun8i-h2-plus-orangepi-zero PACKAGES="luci" FILES="<path>" # 指定 PROFILE,添加 PACKAGES, 添加文件到 rootfs,如网络配置等

5. make image 完成
   在 .\bin\targets\sunxi\cortexa7 目录下生成了 openwrt-19.07.4-sunxi-cortexa7-rootfs.cpio.gz 镜像文件

6. Windows sunxi-fel USB 下载运行测试,由于默认生成的 openwrt rootfs 里没有 /init 文件, kernel 命令参数需要指定 'rdinit=/sbin/init'。
_sunxi-fel_v3s_run_openwrt.bat

:: _sunxi-fel_v3s_run_openwrt.bat
:: make image PROFILE=sun8i-v3s-lichee-pi-zero PACKAGES="luci" FILES="./target/linux/sunxi/base-files" # add "/init"
:: openwrt-19.07.4-sunxi-cortexa7-rootfs_target-base-filse.cpio (2247520字节)
:: "setenv bootargs console=ttyS0,115200 initrd=0x41B00000,2247520 rdinit=/sbin/init; bootz 0x41000000 - 0x41800000"

sunxi-fel.exe -p uboot u-boot-sunxi-with-spl.bin write 0x41000000 zImage write 0x41800000 sun8i-v3s-licheepi-ethernet.dtb write 0x41B00000 openwrt-19.07.4-sunxi-cortexa7-rootfs.cpio.gz

测试文件:
https://whycan.com/files/members/1206/openwrt_v3s_usb-run-test_20200918-1316.rar


运行日志

U-Boot SPL 2020.07 (Jul 31 2020 - 15:28:00 +0800)
DRAM: 64 MiB
Trying to boot from FEL


U-Boot 2020.07 (Jul 31 2020 - 15:28:00 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   mmc@01c0f000: 0
Loading Environment from FAT... Card did not respond to voltage select!
In:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
Net:   No ethernet found.
starting USB...
No working controllers found
Hit any key to stop autoboot:  0 
Card did not respond to voltage select!
starting USB...
No working controllers found
USB is stopped. Please issue 'usb start' first.
starting USB...
No working controllers found
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-sunxi-sunxi
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-sunxi
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
starting USB...
No working controllers found
No ethernet found.
No ethernet found.
=> setenv bootargs console=ttyS0,115200 initrd=0x41B00000,2247520 rdinit=/sbin/init; bootz 0x41000000 - 0x41800000
## Flattened Device Tree blob at 41800000
   Booting using the fdt blob at 0x41800000
   Loading Device Tree to 42dfa000, end 42dff574 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.61-g6070742d3 (iron@d0483bbb7ad2) (gcc version 8.3.0 (Debian 8.3.0-2)) #1 SMP Fri Sep 18 11:33:30 CST 2020
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Lichee Pi Zero Ethernet
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Failed to reserve 16 MiB
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] percpu: Embedded 15 pages/cpu s30604 r8192 d22644 u61440
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 initrd=0x41B00000,2247520 rdinit=/sbin/init
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 52724K/65536K available (6144K kernel code, 436K rwdata, 1700K rodata, 1024K init, 246K bss, 12812K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: GICv2 detected, but range too small and irqchip.gicv2_force_probe not set
[    0.000000] random: get_random_bytes called from start_kernel+0x2b0/0x448 with crng_init=0
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000007] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000018] Switching to timer-based delay loop, resolution 41ns
[    0.000239] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000496] Console: colour dummy device 80x30
[    0.000559] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000575] pid_max: default: 32768 minimum: 301
[    0.000745] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000759] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001637] CPU: Testing write buffer coherency: ok
[    0.002170] /cpus/cpu@0 missing clock-frequency property
[    0.002196] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.003024] Setting up static identity map for 0x40100000 - 0x40100060
[    0.003255] rcu: Hierarchical SRCU implementation.
[    0.003770] smp: Bringing up secondary CPUs ...
[    0.003792] smp: Brought up 1 node, 1 CPU
[    0.003801] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.003808] CPU: All CPU(s) started in HYP mode.
[    0.003813] CPU: Virtualization extensions available.
[    0.004436] devtmpfs: initialized
[    0.007443] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.007803] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.007832] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.008050] pinctrl core: initialized pinctrl subsystem
[    0.009245] NET: Registered protocol family 16
[    0.009692] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.011038] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.011057] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.025031] SCSI subsystem initialized
[    0.025733] usbcore: registered new interface driver usbfs
[    0.025788] usbcore: registered new interface driver hub
[    0.025888] usbcore: registered new device driver usb
[    0.026150] pps_core: LinuxPPS API ver. 1 registered
[    0.026160] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.026182] PTP clock support registered
[    0.026451] Advanced Linux Sound Architecture Driver Initialized.
[    0.027671] clocksource: Switched to clocksource arch_sys_counter
[    0.039278] thermal_sys: Registered thermal governor 'step_wise'
[    0.039626] NET: Registered protocol family 2
[    0.040309] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.040343] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.040367] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.040389] TCP: Hash tables configured (established 1024 bind 1024)
[    0.040540] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.040594] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.040852] NET: Registered protocol family 1
[    0.041761] RPC: Registered named UNIX socket transport module.
[    0.041783] RPC: Registered udp transport module.
[    0.041790] RPC: Registered tcp transport module.
[    0.041796] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.042108] Unpacking initramfs...
[    0.263620] Freeing initrd memory: 2196K
[    0.265264] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.273734] NFS: Registering the id_resolver key type
[    0.273794] Key type id_resolver registered
[    0.273802] Key type id_legacy registered
[    0.273923] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
[    0.273934] io scheduler mq-deadline registered
[    0.273942] io scheduler kyber registered
[    0.274841] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[    0.278922] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.346723] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.349361] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pb not found, using dummy regulator
[    0.350481] printk: console [ttyS0] disabled
[    0.370788] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 30, base_baud = 1500000) is a U6_16550A
[    0.942089] printk: console [ttyS0] enabled
[    0.971572] libphy: Fixed MDIO Bus: probed
[    0.975684] CAN device driver interface
[    0.980120] dwmac-sun8i 1c30000.ethernet: IRQ eth_wake_irq not found
[    0.986479] dwmac-sun8i 1c30000.ethernet: IRQ eth_lpi not found
[    0.992607] dwmac-sun8i 1c30000.ethernet: PTP uses main clock
[    0.998467] dwmac-sun8i 1c30000.ethernet: No regulator found
[    1.004677] dwmac-sun8i 1c30000.ethernet: Current syscon value is not the default 38000 (expect 58000)
[    1.014087] dwmac-sun8i 1c30000.ethernet: No HW DMA feature register supported
[    1.021327] dwmac-sun8i 1c30000.ethernet: RX Checksum Offload Engine supported
[    1.028558] dwmac-sun8i 1c30000.ethernet: COE Type 2
[    1.033519] dwmac-sun8i 1c30000.ethernet: TX Checksum insertion supported
[    1.040313] dwmac-sun8i 1c30000.ethernet: Normal descriptors
[    1.045965] dwmac-sun8i 1c30000.ethernet: Chain mode enabled
[    1.051648] dwmac-sun8i 1c30000.ethernet: device MAC address e6:14:67:11:c5:ab
[    1.059155] libphy: stmmac: probed
[    1.063271] dwmac-sun8i 1c30000.ethernet: Found internal PHY node
[    1.069625] libphy: mdio_mux: probed
[    1.073227] dwmac-sun8i 1c30000.ethernet: Switch mux to internal PHY
[    1.079626] dwmac-sun8i 1c30000.ethernet: Powering internal PHY
[    1.089726] libphy: mdio_mux: probed
[    1.093637] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.100291] ehci-platform: EHCI generic platform driver
[    1.105636] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.111906] ohci-platform: OHCI generic platform driver
[    1.119030] sun6i-rtc 1c20400.rtc: registered as rtc0
[    1.124096] sun6i-rtc 1c20400.rtc: RTC enabled
[    1.128938] i2c /dev entries driver
[    1.133779] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.142518] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[    1.178964] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.186438] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[    1.197998] usbcore: registered new interface driver usbhid
[    1.203578] usbhid: USB HID core driver
[    1.209514] NET: Registered protocol family 17
[    1.213997] can: controller area network core (rev 20170425 abi 9)
[    1.220424] NET: Registered protocol family 29
[    1.224876] can: raw protocol (rev 20170425)
[    1.229192] can: broadcast manager protocol (rev 20170425 t)
[    1.234854] can: netlink gateway (rev 20190810) max_hops=1
[    1.240706] Key type dns_resolver registered
[    1.245083] Registering SWP/SWPB emulation handler
[    1.259261] usb_phy_generic usb_phy_generic.1.auto: usb_phy_generic.1.auto supply vcc not found, using dummy regulator
[    1.270932] musb-hdrc musb-hdrc.2.auto: MUSB HDRC host driver
[    1.276718] musb-hdrc musb-hdrc.2.auto: new USB bus registered, assigned bus number 1
[    1.286183] hub 1-0:1.0: USB hub found
[    1.290281] hub 1-0:1.0: 1 port detected
[    1.295849] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01T00:17:45 UTC (1065)
[    1.304408] ALSA device list:
[    1.307386]   No soundcards found.
[    1.312971] Freeing unused kernel memory: 1024K
[    1.317881] Run /sbin/init as init process
[    1.326567] cgroup1: Need name or subsystem set
[    1.362120] init: Console is alive
[    1.365821] init: - watchdog -
[    1.380092] init: - preinit -
[    1.521345] random: jshn: uninitialized urandom read (4 bytes read)
[    1.555949] random: jshn: uninitialized urandom read (4 bytes read)
[    1.581226] random: jshn: uninitialized urandom read (4 bytes read)
[    1.605149] dwmac-sun8i 1c30000.ethernet eth0: PHY [0.1:01] driver [Generic PHY]
[    1.613929] dwmac-sun8i 1c30000.ethernet eth0: No Safety Features support found
[    1.621313] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[    1.628991] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[    1.635522] dwmac-sun8i 1c30000.ethernet eth0: configuring for phy/mii link mode
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    4.761984] mount_root: mounting /dev/root
[    4.771340] urandom-seed: Seed file not found (/etc/urandom.seed)
[    4.804367] procd: - early -
[    4.807386] procd: - watchdog -
[    5.636054] procd: - watchdog -
[    5.639612] procd: - ubus -
[    5.647248] urandom_read: 1 callbacks suppressed
[    5.647261] random: ubusd: uninitialized urandom read (4 bytes read)
[    5.692897] random: ubusd: uninitialized urandom read (4 bytes read)
[    5.699824] random: ubusd: uninitialized urandom read (4 bytes read)
[    5.707025] procd: - init -
Please press Enter to activate this console.
[    6.003990] urngd: v1.0.2 started.
[    6.052981] random: crng init done
[    6.056393] random: 3 urandom warning(s) missed due to ratelimiting



BusyBox v1.30.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.4, r11208-ce6496d796
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/# 

最近编辑记录 Iron (2020-09-18 13:19:12)

离线

#2 2020-09-21 22:32:02

checkout
会员
注册时间: 2018-11-09
累计积分: 167

Re: 采用 openwrt imagebuilder 构建 v3s cpio-rootfs 运行测试

请问使用这个打包工具打包镜像,和直接使用openwrt有哪些异同?
是不是可以使用openwrt上的一些工具,例如sysupgrade升级系统?

最近编辑记录 checkout (2020-09-21 22:33:09)

离线

#3 2020-09-22 09:35:31

Iron
会员
注册时间: 2018-10-23
累计积分: 58
个人网站

Re: 采用 openwrt imagebuilder 构建 v3s cpio-rootfs 运行测试

checkout 说:

请问使用这个打包工具打包镜像,和直接使用openwrt有哪些异同?
是不是可以使用openwrt上的一些工具,例如sysupgrade升级系统?

OpenWRT Imagebuilder 最终生成的就是 SD 镜像文件。
cpio rootfs 可以通过 sunx-fel USB 下载到 SDRAM 里运行测试,我的目的是测试根文件系统和驱动时不需要烧写 SD 卡。

'sysupgrade' 功能应该是可以的,应该需要把镜像烧录到 SD 卡运行,目前也在摸索学习中。。

离线

#4 2020-09-25 09:58:09

Iron
会员
注册时间: 2018-10-23
累计积分: 58
个人网站

Re: 采用 openwrt imagebuilder 构建 v3s cpio-rootfs 运行测试

改个错误,rdinit 应该采用 rdinit=/etc/preinit

setenv bootargs console=ttyS0,115200 initrd=0x41B00000,2247520 rdinit=/etc/preinit ; bootz 0x41000000 - 0x41800000

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB