用Qemu搭建aarch32學習環境

来源:http://www.cnblogs.com/pengdonglin137/archive/2017/02/25/6442583.html
-Advertisement-
Play Games

作者信息 作者: 彭東林 郵箱: [email protected] QQ: 405728433 軟體平臺 主機: Ubuntu14.04 64位版本 模擬器:Qemu-2.8.0 Linux內核版本: Linux-4.10 Busybox版本:busybox-1.24.2 工具鏈: ar ...


作者信息

作者: 彭東林

郵箱: [email protected]

QQ: 405728433

軟體平臺

主機: Ubuntu14.04 64位版本

模擬器:Qemu-2.8.0

Linux內核版本: Linux-4.10

Busybox版本:busybox-1.24.2

工具鏈: arm-none-linux-gnueabi-gcc  (gcc version 4.8.3 20140320)

具備的功能

模擬一個vexpress 雙核或者單核的環境,採用NFS跟Host共用一些文件,為了簡單起見,根文件系統使用的是ramdisk格式。

正文

1、編譯Qemu模擬器

請參考博文用qemu搭建aarch64學習環境

2、下載工具鏈

登錄這個網址:http://www.veryarm.com/arm-none-linux-gnueabi-gcc

我們這裡使用的是最新的Linux解壓版:

3、下載編譯最新的Linux內核

登錄https://www.kernel.org/,   下載最新的Linux版本,目前最新的是Linux-4.10。 

下麵是編譯下麵要用的kernel的命令:

1     #!/bin/bash
2     cross_compile=/home/pengdonglin/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-
3     #make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 vexpress_defconfig
4     make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 menuconfig
5     make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 zImage -j4
6     make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 dtbs -j4

編譯之前可以對kernel進行一下配置

1     Kernel Features  --->
2        Memory split (3G/1G user/kernel split)  --->
3        [*] High Memory Support
4     Device Drivers  --->
5        [*] Block devices  --->
6            <*>   RAM block device support
7            (8192)  Default RAM disk size (kbytes)

這裡我們給ramdisk設置的預設大小是8MB,不能比後面我們實際生成的ramdisk.img的size小。

這樣就有了我們下麵要用到的內核鏡像zImage。

4、製作根文件系統

登錄https://busybox.net/downloads/下載要用的busybox版本,這裡我下的是busybox-1.24.2

要設置的不多:

執行make menuconfig,配置下麵幾項:

1 Build Options  ---> 
2      [*] Build BusyBox as a static binary (no shared libs)
3     (/home/pengdonglin/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-) Cross Compiler prefix 

然後執行make && make install命令

下麵製作啟動用的ramdisk,我把這個過程寫成了腳本,如下:

 1 #!/bin/bash
 2 sudo rm -rf rootfs
 3 sudo rm -rf tmpfs
 4 sudo rm -rf ramdisk*
 5 sudo mkdir rootfs
 6 sudo cp ../busybox-1.24.2/_install/*  rootfs/ -raf
 7 sudo mkdir -p rootfs/proc/
 8 sudo mkdir -p rootfs/sys/
 9 sudo mkdir -p rootfs/tmp/
10 sudo mkdir -p rootfs/root/
11 sudo mkdir -p rootfs/var/
12 sudo mkdir -p rootfs/mnt/
13 sudo cp etc rootfs/ -arf
14 sudo cp -arf ../arm-2014.05/arm-none-linux-gnueabi/libc/lib rootfs/
15 sudo rm -rf rootfs/lib/*.a
16 sudo ../arm-2014.05/bin/arm-none-linux-gnueabi-strip rootfs/lib/*
17 sudo mkdir -p rootfs/dev/
18 sudo mknod rootfs/dev/tty1 c 4 1
19 sudo mknod rootfs/dev/tty2 c 4 2
20 sudo mknod rootfs/dev/tty3 c 4 3
21 sudo mknod rootfs/dev/tty4 c 4 4
22 sudo mknod rootfs/dev/console c 5 1
23 sudo mknod rootfs/dev/null c 1 3
24 sudo dd if=/dev/zero of=ramdisk bs=1M count=8
25 sudo mkfs.ext4 -F ramdisk
26 sudo mkdir -p tmpfs
27 sudo mount -t ext4 ramdisk ./tmpfs/  -o loop
28 sudo cp -raf rootfs/*  tmpfs/
29 sudo umount tmpfs
30 sudo gzip --best -c ramdisk > ramdisk.gz
31 sudo mkimage -n "ramdisk" -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img

製作ramdisk用到的文件到這裡下載。

5、Qemu支持網路

請參考博客:

用Qemu模擬vexpress-a9 --- 配置 qemu 的網路功能

用Qemu模擬vexpress-a9 (三)--- 實現用u-boot引導Linux內核

6、測試

支持網路的啟方法:

 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/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel" \
 8        -initrd ./rootfs/ramdisk.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
nfs掛載:
mount -t nfs -o nolock 192.168.1.6:/nfsroot /mnt

下麵是啟動信息:

    $./run.sh
    sudo tunctl -u root -t tap0
    TUNSETIFF: Device or resource busy
    sudo ifconfig tap0 0.0.0.0 promisc up
    sudo brctl addif br0 tap0
    brctl show
    bridge name bridge id STP enabled interfaces
    br0 8000.eada212d369f no eth0
    tap0
    Booting Linux on physical CPU 0x0
    Linux version 4.10.0 (pengdonglin@pengdonglin-dell) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #9 SMP Sat Feb 25 18:51:59 CST 2017
    CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
    CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
    OF: fdt:Machine model: V2P-CA9
    debug: ignoring loglevel setting.
    Memory policy: Data cache writealloc
    On node 0 totalpages: 262144
    free_area_init_node: node 0, pgdat c092af80, node_mem_map ef7fa000
     Normal zone: 1536 pages used for memmap
     Normal zone: 0 pages reserved
     Normal zone: 196608 pages, LIFO batch:31
     HighMem zone: 65536 pages, LIFO batch:15
    percpu: Embedded 13 pages/cpu @ef7b9000 s23424 r8192 d21632 u53248
    pcpu-alloc: s23424 r8192 d21632 u53248 alloc=13*4096
    pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260608
    Kernel command line: root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel
    log_buf_len individual max cpu contribution: 4096 bytes
    log_buf_len total cpu_extra contributions: 12288 bytes
    log_buf_len min size: 16384 bytes
    log_buf_len: 32768 bytes
    early log buf free: 14860(90%)
    PID hash table entries: 4096 (order: 2, 16384 bytes)
    Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
    Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
    Memory: 1028136K/1048576K available (5120K kernel code, 174K rwdata, 1224K rodata, 1024K init, 177K bss, 20440K reserved, 0K cma-reserved, 262144K highmem)
    Virtual kernel memory layout:
       vector  : 0xffff0000 - 0xffff1000   (   4 kB)
       fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
       vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
       lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
       pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
       modules : 0xbf000000 - 0xbfe00000   (  14 MB)
         .text : 0xc0008000 - 0xc0600000   (6112 kB)
         .init : 0xc0800000 - 0xc0900000   (1024 kB)
         .data : 0xc0900000 - 0xc092bb80   ( 175 kB)
          .bss : 0xc092d000 - 0xc0959448   ( 178 kB)
    SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
    Hierarchical RCU implementation.
    Build-time adjustment of leaf fanout to 32.
    RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
    RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
    NR_IRQS:16 nr_irqs:16 16
    L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
    L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
    L2C-310 enabling early BRESP for Cortex-A9
    L2C-310 full line of zeros enabled for Cortex-A9
    L2C-310 dynamic clock gating disabled, standby mode disabled
    L2C-310 cache controller enabled, 8 ways, 128 kB
    L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
    smp_twd: clock not found -2
    sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
    clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
    Failed to initialize '/smb@04000000/motherboard/iofpga@7,00000000/timer@12000': -22
    Console: colour dummy device 80x30
    Calibrating local timer... 95.23MHz.
    Calibrating delay loop... 746.70 BogoMIPS (lpj=3733504)
    pid_max: default: 32768 minimum: 301
    Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
    Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
    CPU: Testing write buffer coherency: ok
    CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
    Setting up static identity map for 0x60100000 - 0x60100058
    smp: Bringing up secondary CPUs ...
    CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
    CPU2: failed to boot: -38
    CPU3: failed to boot: -38
    smp: Brought up 1 node, 2 CPUs
    SMP: Total of 2 processors activated (1487.66 BogoMIPS).
    CPU: All CPU(s) started in SVC mode.
    devtmpfs: initialized
    VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
    clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
    futex hash table entries: 1024 (order: 4, 65536 bytes)
    NET: Registered protocol family 16
    DMA: preallocated 256 KiB pool for atomic coherent allocations
    cpuidle: using governor ladder
    hw-breakpoint: debug architecture 0x4 unsupported.
    Serial: AMBA PL011 UART driver
    OF: amba_device_add() failed (-19) for /memory-controller@100e0000
    OF: amba_device_add() failed (-19) for /memory-controller@100e1000
    OF: amba_device_add() failed (-19) for /watchdog@100e5000
    irq: type mismatch, failed to map hwirq-75 for /interrupt-controller@1e001000!
    10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 38, base_baud = 0) is a PL011 rev1
    console [ttyAMA0] enabled
    1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 39, base_baud = 0) is a PL011 rev1
    1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 40, base_baud = 0) is a PL011 rev1
    1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 41, base_baud = 0) is a PL011 rev1
    OF: amba_device_add() failed (-19) for /smb@04000000/motherboard/iofpga@7,00000000/wdt@0f000
    SCSI subsystem initialized
    libata version 3.00 loaded.
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    Advanced Linux Sound Architecture Driver Initialized.
    clocksource: Switched to clocksource arm,sp804
    NET: Registered protocol family 2
    TCP established hash table entries: 8192 (order: 3, 32768 bytes)
    TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
    TCP: Hash tables configured (established 8192 bind 8192)
    UDP hash table entries: 512 (order: 2, 16384 bytes)
    UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
    NET: Registered protocol family 1
    RPC: Registered named UNIX socket transport module.
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    RPC: Registered tcp NFSv4.1 backchannel transport module.
    Trying to unpack rootfs image as initramfs...
    rootfs image is not initramfs (no cpio magic); looks like an initrd
    Freeing initrd memory: 2528K
    hw perfevents: enabled with armv7_cortex_a9 PMU driver, 1 counters available
    workingset: timestamp_bits=30 max_order=18 bucket_order=0
    squashfs: version 4.0 (2009/01/31) Phillip Lougher
    jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
    9p: Installing v9fs 9p2000 file system support
    bounce: pool size: 64 pages
    io scheduler noop registered (default)
    clcd-pl11x 10020000.clcd: PL111 designer 41 rev2 at 0x10020000
    clcd-pl11x 10020000.clcd: /clcd@10020000 hardware, 1024x768@59 display
    Console: switching to colour frame buffer device 128x48
    clcd-pl11x 1001f000.clcd: PL111 designer 41 rev2 at 0x1001f000
    clcd-pl11x 1001f000.clcd: /smb@04000000/motherboard/iofpga@7,00000000/clcd@1f000 hardware, 640x480@59 display
    brd: module loaded
    40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
    Intel/Sharp Extended Query Table at 0x0031
    Using buffer write method
    erase region 0: offset=0x0,size=0x80000,blocks=128
    40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
    Intel/Sharp Extended Query Table at 0x0031
    Using buffer write method
    erase region 0: offset=0x0,size=0x80000,blocks=128
    Concatenating MTD devices:
    (0): "40000000.flash"
    (1): "40000000.flash"
    into device "40000000.flash"
    libphy: Fixed MDIO Bus: probed
    libphy: smsc911x-mdio: probed
    smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
    isp1760 4f000000.usb: bus width: 32, oc: digital
    isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
    isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
    isp1760 4f000000.usb: Scratch test failed.
    isp1760 4f000000.usb: can't setup: -19
    isp1760 4f000000.usb: USB bus 1 deregistered
    usbcore: registered new interface driver usb-storage
    mousedev: PS/2 mouse device common for all mice
    rtc-pl031 10017000.rtc: rtc core: registered pl031 as rtc0
    mmci-pl18x 10005000.mmci: Got CD GPIO
    mmci-pl18x 10005000.mmci: Got WP GPIO
    mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 34,35 (pio)
    ledtrig-cpu: registered to indicate activity on CPUs
    usbcore: registered new interface driver usbhid
    usbhid: USB HID core driver
    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
    aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 33
    aaci-pl041 10004000.aaci: FIFO 512 entries
    oprofile: using arm/armv7-ca9
    NET: Registered protocol family 17
    9pnet: Installing 9P2000 support
    Registering SWP/SWPB emulation handler
    rtc-pl031 10017000.rtc: setting system clock to 2017-02-25 10:57:49 UTC (1488020269)
    ALSA device list:
     #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 33
    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
    RAMDISK: gzip image found at block 0
    EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null)
    VFS: Mounted root (ext4 filesystem) on device 1:0.
    Freeing unused kernel memory: 1024K
    Generic PHY 4e000000.etherne:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:01, irq=-1)
    smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0xf1420000, IRQ: 31
    Please press Enter to activate this console.
    [root@vexpress ]#
    [root@vexpress ]#
    [root@vexpress ]# mount -t nfs -o nolock 192.168.1.6:/nfsroot /mnt
    [root@vexpress ]# cd /mnt
    [root@vexpress mnt]# ls
    a.out                    interrupt_gpm4_0.ko      passwd
    dmesg.log                interrupt_xeint14_15.ko  shadow3
    fdt                      interrupt_xeint26_29.ko  trace

完。


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 項目中遇到一個頁面中是以一個scrollview橫向Tab展示兩個不同功能的顯示,譬如消息和公告功能,但是由於滑動返回手勢和scrollview的滑動返回手勢衝突了,導致頁面不再能夠滑動返回。類似的還有圖片瀏覽功能也出現過。 iOS系統中,滑動返回手勢,其實是一個UIPanGestureRecogn ...
  • 御花園系統開發,御花園模式定製開發,聯繫微電188-2624-7572.(我們是軟體開發公司,非平臺運營商,玩家勿擾) 御花園平臺介紹 御花園是皇家專用的花園,現在你自己也可以擁有一個屬於你私人獨有的花園,來御花園游戲系統吧!這裡有各種各樣的花朵,一年四季都能盛開,這個游戲不但好玩,賞心悅目,還能為 ...
  • 本文轉自:http://m.blog.csdn.net/article/details?id=51638925 寫在前面 本文來自iOS Tutorial Team 的 Marcelo Fabri,他是Movile的一名 iOS 程式員。這是他的個人網站:http://www.marcelofabr ...
  • 描述了在window系統下android Studio 中git如何使用Git ...
  • LruCache是一個泛型類,它內部採用LinkedHashMap,並以強引用的方式存儲外界的緩存對象,提供get和put方法來完成緩存的獲取和添加操作。當緩存滿時,LruCache會移除較早的緩存對象,然後再添加新的緩存對象。對Java中四種引用類型還不是特別清楚的讀者可以自行查閱相關資料,這裡不 ...
  • 前言 啦啦啦~各位小伙伴們好~經過這一學期的Android知識的學習,我們學到了很多和Android開發相關的知識,這一學期的學習也要告一段落了。(博客中有很多照片上有代碼,代碼文本較小,各位可按下Ctrl和前滾輪放大後再看~) 一起進入我們今天的相關內容~這次我們將一起學習使用 android 手 ...
  • 寫在前面:當你部署一臺伺服器,第一步不應該是部署應用,安全是才是首要任務 如果某一天當你登錄伺服器發現 /bin/bash –i,python -c 'import pty; pty.spawn("/bin/sh")' 等命令在伺服器上出現的時候,那麼恭喜你,伺服器被入侵了 但是入侵者都是很聰明的, ...
  • ownCloud(官網)是一款開源的私有雲框架,可以通過它實現個人網盤的功能,如果擁有一個性能不錯的VPS,那麼就可以擺脫奇慢無比的百度雲等網盤啦!我花了大約一天的時間總算搭好了ownCloud。 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...