加快Qemu Aarch32虚拟开发板的启动速度


软件版本

Qemu: 2.8.0

虚拟开发板: vexpress-ca9

 

概述

之前的博文介绍了将Python移植到开发板上, 根文件系统采用的是ramdisk, 这个文件系统的缺点是修改的内容重启会丢失, 同时由于Python相关的文件体积很大,会严重降低开机启动速度。为此, 我们下面更换跟文件系统的格式为ext4。

 

正文

1、参考 http://www.cnblogs.com/pengdonglin137/p/6792323.html 创建一个虚拟的sd卡镜像文件, 分区如下

1  Device Boot Start End Blocks Id System 2 /dev/loop0p1            2048      104447       51200   83 Linux 3 /dev/loop0p2          104448     1153023      524288   83 Linux 4 /dev/loop0p3         1153024     2097151      472064   83  Linux

创建了一个1GB的镜像文件,第一个分区50M, 第二个400M, 剩下的都给第三个分区,最后将这三个分区都格式化为ext4格式。

第一个分区存放除/usr之外的其他目录, 将来挂载到/下, 第二个分区存放/usr目录,将来挂载到/usr下, 第三个分区存放用户数据,将来挂载到/data下面。 当然,自己根据需要也可以有其他做法。

2、 修改之前制作ramdisk的脚本

 1 #!/bin/bash  2 
 3 sudo rm -rf rootfs  4 sudo rm -rf tmpfs  5 sudo rm -rf ramdisk*
 6 
 7 sudo mkdir rootfs  8 sudo cp ../busybox-1.24.2/_install/* rootfs/ -raf  9 sudo losetup -d /dev/loop0 10 sudo losetup /dev/loop0 ./fs_vexpress_1G.img 11 
12 sudo mkdir -p rootfs/proc/ 13 sudo mkdir -p rootfs/sys/ 14 sudo mkdir -p rootfs/tmp/ 15 sudo mkdir -p rootfs/root/ 16 sudo mkdir -p rootfs/var/ 17 sudo mkdir -p rootfs/mnt/ 18 
19 sudo cp etc rootfs/ -arf 20 
21 sudo cp -arf ../arm-2014.05/arm-none-linux-gnueabi/libc/lib rootfs/ 22 
23 ver=3 24 sudo mkdir -p rootfs/usr 25 pushd rootfs/usr 26 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/lib . 27 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/include . 28 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/bin . 29 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/share . 30 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip lib/python* 31 popd 32 
33 ver=2 34 sudo mkdir -p rootfs/usr 35 pushd rootfs/usr 36 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/lib . 37 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/include . 38 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/bin . 39 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/share . 40 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip lib/python* 41 popd 42 
43 #sqlite 44 sudo cp /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/bin/* rootfs/bin/ 45 sudo cp /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/include/* rootfs/include/ 46 sudo cp /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/lib/* rootfs/lib/ 47 sudo strip /rootfs/bin/sqlite3 48 
49 #readline 50 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Readline/aarch32/include/* rootfs/include/ 51 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Readline/aarch32/lib/* rootfs/lib/ 52 
53 sudo mkdir -p rootfs/dev/ 54 sudo mknod rootfs/dev/tty1 c 4 1 55 sudo mknod rootfs/dev/tty2 c 4 2 56 sudo mknod rootfs/dev/tty3 c 4 3 57 sudo mknod rootfs/dev/tty4 c 4 4 58 sudo mknod rootfs/dev/console c 5 1 59 sudo mknod rootfs/dev/null c 1 3 60 
61 sudo rm -rf rootfs/lib/*.a 62 sudo rm -rf rootfs/lib/*.la 63 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip rootfs/lib/* 64 
65 sudo mkdir -p rootfs/tools 66 sudo cp ./other_tools/* rootfs/tools 67 
68 sudo mkdir -p tmpfs 69 sudo mount -t ext4 /dev/loop0p2 ./tmpfs 70 sudo rm -rf ./tmpfs/* 71 sudo mv rootfs/usr/* ./tmpfs/ 72 sudo umount ./tmpfs/ 73 
74 sudo mount -t ext4 /dev/loop0p1 ./tmpfs/ 75 sudo rm -rf ./tmpfs/* 76 sudo cp -raf ./rootfs/* ./tmpfs/ 77 sudo umount ./tmpfs/ 78 
79 sudo losetup -d /dev/loop0

3、 修改启动脚本/etc/init.d/rcS

 1 #!/bin/sh
 2 
 3 
 4 PATH=/sbin:/bin:/usr/sbin:/usr/bin  5 runlevel=S  6 prevlevel=N  7 umask 022
 8 export PATH runlevel prevlevel  9 
10 mount -a 11 mkdir -p /dev/pts 12 mount -t devpts devpts /dev/pts 13 14 echo /sbin/mdev > /proc/sys/kernel/hotplug 15 mdev -s 16 mkdir -p /var/lock 17 
18 ln -sf /sys/kernel/debug  /d 19 mkdir -p /usr 20 mkdir -p /data 21 
22 mount -t ext4 /dev/mmcblk0p2 /usr 23 mount -t ext4 /dev/mmcblk0p3 /data 24 
25 ifconfig lo 127.0.0.1
26 ifconfig eth0 192.168.1.2
27 
28 /bin/hostname -F /etc/sysconfig/HOSTNAME 29 
30 if [ -e /usr/sbin/telnetd ];then
31     telnetd&
32 fi

4、修改启动qemu的参数

 1 sudo qemu-system-arm \  2     -M vexpress-a9 \  3     -m 1024M \  4     -smp 2 \  5     -kernel ./linux-4.10/out_aarch32/arch/arm/boot/zImage \  6     -nographic \  7     -append "root=/dev/mmcblk0p1 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel" \  8     -sd ./rootfs/fs_vexpress_1G.img \  9     -dtb ./linux-4.10/out_aarch32/arch/arm/boot/dts/vexpress-v2p-ca9.dtb \ 10     -net nic,vlan=0 -net tap,vlan=0,ifname=tap0

5、 修改br0的ip地址,保证跟开发板在一个网段

sudo ifconfig br0:1 192.168.1.100

6、然后重新制作文件系统, 启动开发板

 1 [    0.000000] Booting Linux on physical CPU 0x0
 2 [    0.000000] Linux version 4.10.0+ (pengdonglin@pengdonglin-HP) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #12 SMP Fri Mar 24 17:16:55 CST 2017
 3 [    0.000000] CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d  4 [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache  5 [    0.000000] OF: fdt:Machine model: V2P-CA9  6 [    0.000000] debug: ignoring loglevel setting.  7 [    0.000000] Memory policy: Data cache writealloc  8 [    0.000000] On node 0 totalpages: 262144
 9 [    0.000000] free_area_init_node: node 0, pgdat c0a637c0, node_mem_map ef7fa000  10 [    0.000000]   Normal zone: 1536 pages used for memmap  11 [    0.000000]   Normal zone: 0 pages reserved  12 [    0.000000]   Normal zone: 196608 pages, LIFO batch:31
 13 [    0.000000]   HighMem zone: 65536 pages, LIFO batch:15
 14 [    0.000000] percpu: Embedded 14 pages/cpu @ef7b4000 s27648 r8192 d21504 u57344  15 [    0.000000] pcpu-alloc: s27648 r8192 d21504 u57344 alloc=14*4096
 16 [    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 
 17 [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260608
 18 [    0.000000] Kernel command line: root=/dev/mmcblk0p1 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel  19 [    0.000000] log_buf_len individual max cpu contribution: 4096 bytes  20 [    0.000000] log_buf_len total cpu_extra contributions: 12288 bytes  21 [    0.000000] log_buf_len min size: 16384 bytes  22 [    0.000000] log_buf_len: 32768 bytes  23 [    0.000000] early log buf free: 14852(90%)  24 [    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)  25 [    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)  26 [    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)  27 [    0.000000] Memory: 1029332K/1048576K available (6144K kernel code, 453K rwdata, 1440K rodata, 1024K init, 191K bss, 19244K reserved, 0K cma-reserved, 262144K highmem)  28 [    0.000000] Virtual kernel memory layout:  29 [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)  30 [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)  31 [    0.000000]     vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)  32 [    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)  33 [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)  34 [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)  35 [    0.000000]       .text : 0xc0008000 - 0xc0700000   (7136 kB)  36 [    0.000000]       .init : 0xc0900000 - 0xc0a00000   (1024 kB)  37 [    0.000000]       .data : 0xc0a00000 - 0xc0a71784   ( 454 kB)  38 [    0.000000]        .bss : 0xc0a73000 - 0xc0aa2c4c   ( 192 kB)  39 [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
 40 [    0.000000] Hierarchical RCU implementation.  41 [    0.000000]     Build-time adjustment of leaf fanout to 32.  42 [    0.000000]     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.  43 [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
 44 [    0.000000] NR_IRQS:16 nr_irqs:16 16
 45 [    0.000000] L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
 46 [    0.000000] L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
 47 [    0.000000] L2C-310 enabling early BRESP for Cortex-A9  48 [    0.000000] L2C-310 full line of zeros enabled for Cortex-A9  49 [    0.000000] L2C-310 dynamic clock gating disabled, standby mode disabled  50 [    0.000000] L2C-310 cache controller enabled, 8 ways, 128 kB  51 [    0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
 52 [    0.000000] smp_twd: clock not found -2
 53 [    0.000224] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns  54 [    0.003064] clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns  55 [    0.003667] Failed to initialize '/smb@04000000/motherboard/iofpga@7,00000000/timer@12000': -22
 56 [    0.007950] Console: colour dummy device 80x30
 57 [    0.008360] Calibrating local timer... 94.26MHz.  58 [    0.063533] Calibrating delay loop... 864.25 BogoMIPS (lpj=4321280)  59 [    0.148207] pid_max: default: 32768 minimum: 301
 60 [    0.149276] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)  61 [    0.149330] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)  62 [    0.158795] CPU: Testing write buffer coherency: ok  63 [    0.159287] ftrace: allocating 20771 entries in 61 pages  64 [    0.582666] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
 65 [    0.586510] Setting up static identity map for 0x60100000 - 0x60100058
 66 [    0.594816] smp: Bringing up secondary CPUs ...  67 [    0.675809] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
 68 [    1.618593] CPU2: failed to boot: -38
 69 [    2.561153] CPU3: failed to boot: -38
 70 [    2.561360] smp: Brought up 1 node, 2 CPUs  71 [    2.561437] SMP: Total of 2 processors activated (1717.04 BogoMIPS).  72 [    2.561524] CPU: All CPU(s) started in SVC mode.  73 [    2.592907] devtmpfs: initialized  74 [    2.609363] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
 75 [    2.624710] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns  76 [    2.625256] futex hash table entries: 1024 (order: 4, 65536 bytes)  77 [    2.670281] NET: Registered protocol family 16
 78 [    2.673665] DMA: preallocated 256 KiB pool for atomic coherent allocations  79 [    2.835405] cpuidle: using governor ladder  80 [    2.836034] hw-breakpoint: debug architecture 0x4 unsupported.  81 [    2.837337] Serial: AMBA PL011 UART driver  82 [    2.849208] OF: amba_device_add() failed (-19) for /memory-controller@100e0000  83 [    2.850164] OF: amba_device_add() failed (-19) for /memory-controller@100e1000  84 [    2.850745] OF: amba_device_add() failed (-19) for /watchdog@100e5000  85 [    2.852480] irq: type mismatch, failed to map hwirq-75 for /interrupt-controller@1e001000!
 86 [    2.868418] 10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 38, base_baud = 0) is a PL011 rev1  87 [    2.879767] console [ttyAMA0] enabled  88 [    2.883103] 1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 39, base_baud = 0) is a PL011 rev1  89 [    2.885980] 1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 40, base_baud = 0) is a PL011 rev1  90 [    2.888224] 1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 41, base_baud = 0) is a PL011 rev1  91 [    2.890106] OF: amba_device_add() failed (-19) for /smb@04000000/motherboard/iofpga@7,00000000/wdt@0f000  92 [    2.958532] SCSI subsystem initialized  93 [    2.960351] libata version 3.00 loaded.  94 [    2.961410] usbcore: registered new interface driver usbfs  95 [    2.961734] usbcore: registered new interface driver hub  96 [    2.961995] usbcore: registered new device driver usb  97 [    2.968920] Advanced Linux Sound Architecture Driver Initialized.  98 [    2.991662] clocksource: Switched to clocksource arm,sp804  99 [    3.169450] NET: Registered protocol family 2
100 [    3.175334] TCP established hash table entries: 8192 (order: 3, 32768 bytes) 101 [    3.175928] TCP bind hash table entries: 8192 (order: 4, 65536 bytes) 102 [    3.176278] TCP: Hash tables configured (established 8192 bind 8192) 103 [    3.177303] UDP hash table entries: 512 (order: 2, 16384 bytes) 104 [    3.177536] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) 105 [    3.178707] NET: Registered protocol family 1
106 [    3.182153] RPC: Registered named UNIX socket transport module. 107 [    3.182287] RPC: Registered udp transport module. 108 [    3.182386] RPC: Registered tcp transport module. 109 [    3.182476] RPC: Registered tcp NFSv4.1 backchannel transport module. 110 [    3.193307] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 1 counters available 111 [    3.205209] workingset: timestamp_bits=30 max_order=18 bucket_order=0
112 [    3.236529] squashfs: version 4.0 (2009/01/31) Phillip Lougher 113 [    3.242395] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc. 114 [    3.243965] 9p: Installing v9fs 9p2000 file system support 115 [    3.250751] bounce: pool size: 64 pages 116 [    3.250959] io scheduler noop registered (default) 117 [    3.255927] clcd-pl11x 10020000.clcd: PL111 designer 41 rev2 at 0x10020000
118 [    3.262547] clcd-pl11x 10020000.clcd: /clcd@10020000 hardware, 1024x768@59 display 119 [    3.354700] Console: switching to colour frame buffer device 128x48 120 [    3.369651] clcd-pl11x 1001f000.clcd: PL111 designer 41 rev2 at 0x1001f000
121 [    3.371374] clcd-pl11x 1001f000.clcd: /smb@04000000/motherboard/iofpga@7,00000000/clcd@1f000 hardware, 640x480@59 display 122 [    3.761034] brd: module loaded 123 [    3.766070] 40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
124 [    3.766538] Intel/Sharp Extended Query Table at 0x0031
125 [    3.767105] Using buffer write method 126 [    3.767447] erase region 0: offset=0x0,size=0x80000,blocks=128
127 [    3.771517] 40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
128 [    3.771689] Intel/Sharp Extended Query Table at 0x0031
129 [    3.772144] Using buffer write method 130 [    3.772279] erase region 0: offset=0x0,size=0x80000,blocks=128
131 [    3.772453] Concatenating MTD devices: 132 [    3.772555] (0): "40000000.flash"
133 [    3.772643] (1): "40000000.flash"
134 [    3.772710] into device "40000000.flash"
135 [    3.789874] libphy: Fixed MDIO Bus: probed 136 [    3.846445] libphy: smsc911x-mdio: probed 137 [    3.848873] smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
138 [    3.957275] isp1760 4f000000.usb: bus width: 32, oc: digital 139 [    3.959405] isp1760 4f000000.usb: NXP ISP1760 USB Host Controller 140 [    3.960632] isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
141 [    3.963035] isp1760 4f000000.usb: Scratch test failed. 142 [    3.963612] isp1760 4f000000.usb: can't setup: -19
143 [    3.964748] isp1760 4f000000.usb: USB bus 1 deregistered 144 [    3.974946] usbcore: registered new interface driver usb-storage 145 [    3.992856] mousedev: PS/2 mouse device common for all mice 146 [    4.004329] rtc-pl031 10017000.rtc: rtc core: registered pl031 as rtc0 147 [    4.014931] mmci-pl18x 10005000.mmci: Got CD GPIO 148 [    4.015185] mmci-pl18x 10005000.mmci: Got WP GPIO 149 [    4.016741] mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 34,35 (pio) 150 [    4.106224] input: AT Raw Set 2 keyboard as /devices/platform/smb@04000000/smb@04000000:motherboard/smb@04000000:motherboard:iofpga@7,00000000/10006000.kmi/serio0/input/input0 151 [    4.108713] ledtrig-cpu: registered to indicate activity on CPUs 152 [    4.123420] mmc0: new SD card at address 4567
153 [    4.125672] mmcblk0: mmc0:4567 QEMU! 1.00 GiB 154 [    4.137083] usbcore: registered new interface driver usbhid 155 [    4.140982] usbhid: USB HID core driver 156 [    4.169460] aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 33
157 [    4.169617] aaci-pl041 10004000.aaci: FIFO 512 entries 158 [    4.170516] oprofile: using arm/armv7-ca9 159 [    4.171435] NET: Registered protocol family 17
160 [    4.172032] 9pnet: Installing 9P2000 support 161 [    4.172863] Registering SWP/SWPB emulation handler 162 [    4.182829] rtc-pl031 10017000.rtc: setting system clock to 2017-05-02 08:14:40 UTC (1493712880) 163 [    4.183640] ALSA device list: 164 [    4.183720]   #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 33
165 [    4.187543] mmcblk0: p1 p2 p3 166 [    4.730607] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/smb@04000000/smb@04000000:motherboard/smb@04000000:motherboard:iofpga@7,00000000/10007000.kmi/serio1/input/input2 167 [    4.767878] random: fast init done
168 [    4.786719] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null) 169 [    4.787857] VFS: Mounted root (ext4 filesystem) on device 179:1. 170 [    4.819841] Freeing unused kernel memory: 1024K 171 [    5.349898] random: crng init done
172 ln: /d/debug: Operation not permitted 173 [    6.876743] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null) 174 [    6.902438] EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts: (null) 175 [    7.060910] Generic PHY 4e000000.etherne:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:01, irq=-1) 176 [    7.065577] smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0xf1420000, IRQ: 31
177 
178 Please press Enter to activate this console. login[804]: root login on 'pts/0'
179 
180 [root@vexpress ]# 181 [root@vexpress ]# mount
182 /dev/root on / type ext4 (rw,relatime,data=ordered) 183 proc on /proc type proc (rw,relatime) 184 tmpfs on /tmp type tmpfs (rw,relatime) 185 sysfs on /sys type sysfs (rw,relatime) 186 tmpfs on /dev type tmpfs (rw,relatime) 187 debugfs on /sys/kernel/debug type debugfs (rw,relatime) 188 devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000) 189 /dev/mmcblk0p2 on /usr type ext4 (rw,relatime,data=ordered) 190 /dev/mmcblk0p3 on /data type ext4 (rw,relatime,data=ordered)

完。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM