我有一个基于 ARMv7 cpu 的嵌入式板。我想用 qemu 虚拟化它的 rootfs,这样我就可以在没有硬件的情况下工作。
我制作了船上 SD 卡的图像(这些是分区):
Disk wiser.img: 925 MiB, 969932800 bytes, 1894400 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
Disklabel type: dos
Disk identifier: 0x4adee175
Dispositivo Avvio Start Fine Settori Size Id Tipo
wiser.img1 2048 8191 6144 3M 83 Linux
wiser.img2 8192 532479 524288 256M 83 Linux
wiser.img3 532480 1894399 1361920 665M 83 Linux
帕帕德报道称p2 和 p3是外部4,但第一个分区似乎未格式化(可能是数据表文件?)
我可以挂载p2和p3。 P2 是根文件系统P3 包含数据。
我通过 SSH 登录开发板提取了以下信息:
#cat /proc/cmdline
noinitrd init=/etc/preinit root=/dev/mmcblk0p2 rw rootwait
#cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 109.09
Features : half fastmult vfp edsp neon vfpv3 tls vfpv4 idiva vfpd32 lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
Hardware : Freescale i.MX6 Ultralite (Device Tree)
Revision : 0000
Serial : 0000000000000000
#cat /proc/version
Linux version 4.4.186 (logic@build) (gcc version 5.4.0 (LEDE GCC 5.4.0 unknown) ) #0 PREEMPT Tue Jul 23 12:55:21 UTC 2019
#ls -l /dev
lrwxrwxrwx 1 root root 12 Jan 4 10:53 RS232 -> /dev/ttymxc0
lrwxrwxrwx 1 root root 12 Jan 4 10:53 RS485 -> /dev/ttymxc2
drwxr-xr-x 3 root root 60 Jan 4 10:53 bus
crw-r--r-- 1 root root 5, 1 Jan 4 10:53 console
crw-r--r-- 1 root root 10, 63 Jan 4 10:53 cpu_dma_latency
crw-rw-rw- 1 root root 1, 7 Jan 4 10:53 full
crw-r--r-- 1 root root 89, 0 Jan 4 10:53 i2c-0
crw-r--r-- 1 root root 251, 0 Jan 4 10:53 iio:device0
crw-r--r-- 1 root root 1, 11 Jan 4 10:53 kmsg
srw-rw-rw- 1 root root 0 Jan 4 10:53 log
crw-r--r-- 1 root root 10, 60 Jan 4 10:53 memory_bandwidth
brw-r--r-- 1 root root 179, 0 Jan 4 10:53 mmcblk0
brw-r--r-- 1 root root 179, 1 Jan 4 10:53 mmcblk0p1
brw-r--r-- 1 root root 179, 2 Jan 4 10:53 mmcblk0p2
brw-r--r-- 1 root root 179, 3 Jan 4 10:53 mmcblk0p3
drwxr-xr-x 2 root root 60 Jan 4 10:53 net
crw-r--r-- 1 root root 10, 62 Jan 4 10:53 network_latency
crw-r--r-- 1 root root 10, 61 Jan 4 10:53 network_throughput
crw-rw-rw- 1 root root 1, 3 Jan 4 10:53 null
crw-r--r-- 1 root root 108, 0 Jan 4 10:53 ppp
crw-r--r-- 1 root root 253, 0 Jan 4 10:53 pps0
crw-rw-rw- 1 root root 5, 2 Jan 4 11:09 ptmx
crw-r--r-- 1 root root 252, 0 Jan 4 10:53 ptp0
drwxr-xr-x 2 root root 0 Jan 1 1970 pts
crw-r--r-- 1 root root 1, 8 Jan 4 10:53 random
lrwxrwxrwx 1 root root 14 Jan 4 10:53 root -> /dev/mmcblk0p2
crw-r--r-- 1 root root 254, 0 Jan 4 10:53 rtc0
drwxr-xr-x 2 root root 60 Jan 4 10:54 shm
crw-rw-rw- 1 root root 5, 0 Jan 4 10:53 tty
crw-rw-rw- 1 root root 207, 16 Jan 4 10:53 ttymxc0
crw-rw-rw- 1 root root 207, 18 Jan 4 10:53 ttymxc2
crw-rw-rw- 1 root root 207, 21 Jan 4 11:09 ttymxc5
crw-r--r-- 1 root root 1, 9 Jan 4 10:53 urandom
crw-r--r-- 1 root root 10, 130 Jan 4 10:53 watchdog
crw-r--r-- 1 root root 250, 0 Jan 4 10:53 watchdog0
crw-rw-rw- 1 root root 1, 5 Jan 4 10:53 zero
#cat /proc/mounts
/dev/root on / type ext3 (rw,noatime,nodiratime,nodelalloc,stripe=512,data=ordered)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /dev type tmpfs (rw,noatime,size=4096k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600,ptmxmode=000)
/dev/mmcblk0p3 on /data type ext3 (rw,noatime,nodiratime,nodelalloc,stripe=512,data=ordered)
这是内核启动
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.4.186 (logic@build) (gcc version 5.4.0 (LEDE GCC 5.4.0 unknown) ) #0 PREEMPT Tue Jul 23 12:55:21 UTC 2019
[ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine model: i.MX6UL LM2i
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] On node 0 totalpages: 65536
[ 0.000000] free_area_init_node: node 0, pgdat c043a910, node_mem_map cfdfb000
[ 0.000000] Normal zone: 512 pages used for memmap
[ 0.000000] Normal zone: 0 pages reserved
[ 0.000000] Normal zone: 65536 pages, LIFO batch:15
[ 0.000000] CPU: All CPU(s) started in SVC mode.
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
[ 0.000000] Kernel command line: noinitrd init=/etc/preinit root=/dev/mmcblk0p2 rw rootwait
[ 0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[ 0.000000] Memory: 255148K/262144K available (3530K kernel code, 114K rwdata, 576K rodata, 164K init, 196K bss, 6996K reserved, 0K cma-reserved)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xd0800000 - 0xff800000 ( 752 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xd0000000 ( 256 MB)
[ 0.000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
[ 0.000000] .text : 0xc0008000 - 0xc040adec (4108 kB)
[ 0.000000] .init : 0xc040b000 - 0xc0434000 ( 164 kB)
[ 0.000000] .data : 0xc0434000 - 0xc0450bb4 ( 115 kB)
[ 0.000000] .bss : 0xc0450bb4 - 0xc0481f08 ( 197 kB)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] Preemptible hierarchical RCU implementation.
[ 0.000000] NR_IRQS:16 nr_irqs:16 16
[ 0.000000] Switching to timer-based delay loop, resolution 41ns
[ 0.000015] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.000054] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.001887] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=96000)
[ 0.001921] pid_max: default: 32768 minimum: 301
[ 0.002113] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.002137] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.003081] CPU: Testing write buffer coherency: ok
[ 0.003505] Setting up static identity map for 0x80008200 - 0x80008234
[ 0.018724] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[ 0.019276] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.019325] futex hash table entries: 256 (order: -1, 3072 bytes)
[ 0.019465] pinctrl core: initialized pinctrl subsystem
[ 0.021334] NET: Registered protocol family 16
[ 0.021962] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.081148] imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
[ 0.119456] SCSI subsystem initialized
[ 0.119639] libata version 3.00 loaded.
[ 0.120312] usbcore: registered new interface driver usbfs
[ 0.120477] usbcore: registered new interface driver hub
[ 0.122018] usbcore: registered new device driver usb
[ 0.126805] i2c i2c-0: IMX I2C adapter registered
[ 0.126853] i2c i2c-0: can't use DMA
[ 0.127519] pps_core: LinuxPPS API ver. 1 registered
[ 0.127548] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[ 0.127718] PTP clock support registered
[ 0.130596] Bluetooth: Core ver 2.21
[ 0.131191] NET: Registered protocol family 31
[ 0.131219] Bluetooth: HCI device and connection manager initialized
[ 0.131258] Bluetooth: HCI socket layer initialized
[ 0.131283] Bluetooth: L2CAP socket layer initialized
[ 0.131996] clocksource: Switched to clocksource mxc_timer1
[ 0.136438] NET: Registered protocol family 2
[ 0.137960] TCP established hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.138038] TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.138101] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.138214] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.138260] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.138534] NET: Registered protocol family 1
[ 0.172592] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[ 0.182122] io scheduler noop registered (default)
[ 0.189112] imx-sdma 20ec000.sdma: Timeout waiting for CH0 ready
[ 0.189178] imx-sdma 20ec000.sdma: loaded firmware 3.3
[ 0.205195] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 19, base_baud = 5000000) is a IMX
[ 0.206714] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 224, base_baud = 5000000) is a IMX
[ 0.207936] 21fc000.serial: ttymxc5 at MMIO 0x21fc000 (irq = 225, base_baud = 5000000) is a IMX
[ 0.213557] fsl-quadspi 21e0000.qspi: unrecognized JEDEC id bytes: ff, ff, ff
[ 0.213603] fsl-quadspi 21e0000.qspi: Freescale QuadSPI probe failed
[ 0.213728] fsl-quadspi: probe of 21e0000.qspi failed with error -2
[ 0.215091] tun: Universal TUN/TAP device driver, 1.6
[ 0.215124] tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
[ 0.215449] CAN device driver interface
[ 0.219083] 2188000.ethernet supply phy not found, using dummy regulator
[ 0.232986] pps pps0: new PPS source ptp0
[ 0.234004] libphy: fec_enet_mii_bus: probed
[ 0.236601] fec 2188000.ethernet eth0: registered PHC device 0
[ 0.237063] PPP generic driver version 2.4.2
[ 0.237608] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.237933] usbcore: registered new interface driver cdc_acm
[ 0.237960] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 0.238275] usbcore: registered new interface driver usb-storage
[ 0.238784] usbcore: registered new interface driver usbserial
[ 0.239037] usbcore: registered new interface driver ch341
[ 0.239288] usbserial: USB Serial support registered for ch341-uart
[ 0.239527] usbcore: registered new interface driver cp210x
[ 0.239762] usbserial: USB Serial support registered for cp210x
[ 0.240148] usbcore: registered new interface driver ftdi_sio
[ 0.241140] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 0.241748] usbcore: registered new interface driver mct_u232
[ 0.242152] usbserial: USB Serial support registered for MCT U232
[ 0.242413] usbcore: registered new interface driver option
[ 0.243026] usbserial: USB Serial support registered for GSM modem (1-port)
[ 0.243746] usbcore: registered new interface driver pl2303
[ 0.244245] usbserial: USB Serial support registered for pl2303
[ 0.249455] 2184000.usb supply vbus not found, using dummy regulator
[ 0.253640] ci_hdrc ci_hdrc.0: EHCI Host Controller
[ 0.253738] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[ 0.264061] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[ 0.264413] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 0.264450] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.264477] usb usb1: Product: EHCI Host Controller
[ 0.264501] usb usb1: Manufacturer: Linux 4.4.186 ehci_hcd
[ 0.264523] usb usb1: SerialNumber: ci_hdrc.0
[ 0.265862] hub 1-0:1.0: USB hub found
[ 0.265984] hub 1-0:1.0: 1 port detected
[ 0.266890] 2184200.usb supply vbus not found, using dummy regulator
[ 0.270672] ci_hdrc ci_hdrc.1: EHCI Host Controller
[ 0.270767] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2
[ 0.280066] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
[ 0.280404] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[ 0.280437] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.280463] usb usb2: Product: EHCI Host Controller
[ 0.280486] usb usb2: Manufacturer: Linux 4.4.186 ehci_hcd
[ 0.280509] usb usb2: SerialNumber: ci_hdrc.1
[ 0.281827] hub 2-0:1.0: USB hub found
[ 0.281931] hub 2-0:1.0: 1 port detected
[ 0.286852] rtc-pcf85263a 0-0051: rtc core: registered rtc-pcf85263a as rtc0
[ 0.287090] i2c /dev entries driver
[ 0.287757] lirc_dev: IR Remote Control driver registered, major 249
[ 0.289044] imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
[ 0.289824] usbcore: registered new interface driver btusb
[ 0.290745] sdhci: Secure Digital Host Controller Interface driver
[ 0.290772] sdhci: Copyright(c) Pierre Ossman
[ 0.290788] sdhci-pltfm: SDHCI platform and OF driver helper
[ 0.293645] sdhci-esdhc-imx 2194000.usdhc: No vmmc regulator found
[ 0.293685] sdhci-esdhc-imx 2194000.usdhc: No vqmmc regulator found
[ 0.332091] mmc0: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA
[ 0.353317] 2198000.adc supply vref not found, using dummy regulator
[ 0.365315] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 0.365432] NET: Registered protocol family 17
[ 0.365473] can: controller area network core (rev 20120528 abi 9)
[ 0.365632] NET: Registered protocol family 29
[ 0.365655] can: raw protocol (rev 20120528)
[ 0.370930] rtc-pcf85263a 0-0051: setting system clock to 2021-01-04 09:53:27 UTC (1609754007)
[ 0.371412] vdd3p0: disabling
[ 0.371725] Warning: unable to open an initial console.
[ 0.371780] Waiting for root device /dev/mmcblk0p2...
[ 0.387604] mmc0: host does not support reading read-only switch, assuming write-enable
[ 0.394277] mmc0: new high speed SD card at address 0260
[ 0.395033] mmcblk0: mmc0:0260 HSQ01 925 MiB
[ 0.396663] mmcblk0: p1 p2 p3
[ 0.548554] EXT4-fs (mmcblk0p2): recovery complete
[ 0.551981] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 0.552094] VFS: Mounted root (ext3 filesystem) on device 179:2.
[ 0.552441] Freeing unused kernel memory: 164K
[ 0.943923] EXT4-fs (mmcblk0p2): re-mounted. Opts: nodelalloc
[ 1.368261] fec 2188000.ethernet eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=2188000.ethernet-1:00, irq=-1)
[ 2.418232] fec 2188000.ethernet eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=2188000.ethernet-1:00, irq=-1)
[ 2.636217] EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts: nodelalloc
[ 5.432387] fec 2188000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
[ 20.192037] random: nonblocking pool is initialized
rootfs基于OpenWrt,所以我下载了armvirt 32位内核和imx6内核,但我不明白如何在qemu上运行正确的内核,在启动的机器中安装rootfs。