Qemu 运行ARMv8开发平台 ubuntu16.04

来源:互联网 发布:天津空港菜鸟网络 编辑:程序博客网 时间:2024/06/12 08:23

1. Ubuntu 安装aarch64的gcc编译工具:

sudo apt-get install gcc-aarch64-linux-gnu

2. 编译制作aarch64架构的最小文件系统

 Download busybox:

http://busybox.net/download

$cd busybox

$export ARCH=arm64

$export CROSS_COMPILE=aarch64-linux-gnu-$make menuconfig
静态编译busybox
Busybox Settings  --->
               Build Options  --->

                              [*] Build BusyBox as a static binary (no shared libs)

$make

$make install

$cp _install/ -rf ../linux-4.0/

$cd linux-4.0/_install$mkdir etc dev mnt$mkdir -p etc/init.d/
$vim init.d/rcS         mkdir -p /proc         mkdir -p /tmp         mkdir -p /sys         mkdir -p /mnt        /bin/mount -a        mkdir -p /dev/pts        mount -t devpts devpts /dev/pts        echo /sbin/mdev > /proc/sys/kernel/hotplug        mdev -s

$vim etc/fstab        proc /proc proc defaults 0 0tmpfs /tmp tmpfs defaults 0 0 sysfs /sys sysfs defaults 0 0tmpfs /dev tmpfs defaults 0 0debugfs /sys/kernel/debug debugfs defaults 0 0

$vim etc/inittab        ::sysinit:/etc/init.d/rcS::respawn:-/bin/sh::askfirst:-/bin/sh::cttlaltdel:/bin/umount -a -r

$cd dev          sudo mknod console c 5 1          sudo mknod null c 1 3

3.编译linux kernel

$export ARCH=arm64
$export CROSS_COMPILE=aarch64-linux-gnu-$make menuconfig
General setup  --->
  [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support                                                                                                         │ │  
  │ │                                                                                                    (_install) Initramfs source file(s)

 Boot options  --->
         Default kernel command string

Kernel Features  --->
         Page size (4KB)  ---> 
         Virtual address space size (48-bit)  --->

$make -j8

$qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -m 2048 -smp 2 -kernel arch/arm64/boot/Image --append "rdinit=/linuxrc console=ttyAMA0"

Booting Linux on physical CPU 0x0Initializing cgroup subsys cpusetLinux version 4.0.0 (xinchangxiang@xinchangxiang) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) ) #5 SMP Sun Oct 1 12:53:11 CST 2017CPU: AArch64 Processor [411fd070] revision 0Detected PIPT I-cache on CPU0efi: Getting EFI parameters from FDT:efi: UEFI not found.psci: probing for conduit method from DT.psci: PSCIv0.2 detected in firmware.psci: Using standard PSCI v0.2 function IDsPERCPU: Embedded 14 pages/cpu @ffff80007ffcc000 s18008 r8192 d31144 u57344Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 516096Kernel command line: rdinit=/linuxrc console=ttyAMA0PID hash table entries: 4096 (order: 3, 32768 bytes)Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)software IO TLB [mem 0xb9a00000-0xbda00000] (64MB) mapped at [ffff800079a00000-ffff80007d9fffff]Memory: 1986756K/2097152K available (4795K kernel code, 281K rwdata, 1640K rodata, 1312K init, 220K bss, 110396K reserved, 0K cma-reserved)Virtual kernel memory layout:    vmalloc : 0xffff000000000000 - 0xffff7bffbfff0000   (126974 GB)    vmemmap : 0xffff7bffc0000000 - 0xffff7fffc0000000   (  4096 GB maximum)              0xffff7bffc1000000 - 0xffff7bffc3000000   (    32 MB actual)    fixed   : 0xffff7ffffabfe000 - 0xffff7ffffac00000   (     8 KB)    PCI I/O : 0xffff7ffffae00000 - 0xffff7ffffbe00000   (    16 MB)    modules : 0xffff7ffffc000000 - 0xffff800000000000   (    64 MB)    memory  : 0xffff800000000000 - 0xffff800080000000   (  2048 MB)      .init : 0xffff8000006cb000 - 0xffff800000813000   (  1312 KB)      .text : 0xffff800000080000 - 0xffff8000006ca504   (  6442 KB)      .data : 0xffff800000815000 - 0xffff80000085b600   (   282 KB)SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1Hierarchical RCU implementation.    CONFIG_RCU_FANOUT set to non-default value of 32    Additional per-CPU info printed with stalls.    RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2NR_IRQS:64 nr_irqs:64 0Architected cp15 timer(s) running at 62.50MHz (virt).sched_clock: 56 bits at 62MHz, resolution 16ns, wraps every 2199023255552nsConsole: colour dummy device 80x25Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=625000)pid_max: default: 32768 minimum: 301Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)EFI services will not be available.CPU1: Booted secondary processorDetected PIPT I-cache on CPU1Brought up 2 CPUsSMP: Total of 2 processors activated.devtmpfs: initializedDMI not present or invalid.NET: Registered protocol family 16cpuidle: using governor laddercpuidle: using governor menuvdso: 2 pages (1 code @ ffff80000081d000, 1 data @ ffff80000081c000)hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.DMA: preallocated 256 KiB pool for atomic allocationsSerial: AMBA PL011 UART driver9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 38, base_baud = 0) is a PL011 rev1console [ttyAMA0] enabledSCSI subsystem initializedusbcore: registered new interface driver usbfsusbcore: registered new interface driver hubusbcore: registered new device driver usbAdvanced Linux Sound Architecture Driver Initialized.Switched to clocksource arch_sys_counterNET: Registered protocol family 2TCP established hash table entries: 16384 (order: 5, 131072 bytes)TCP bind hash table entries: 16384 (order: 6, 262144 bytes)TCP: Hash tables configured (established 16384 bind 16384)TCP: reno registeredUDP hash table entries: 1024 (order: 3, 32768 bytes)UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)NET: Registered protocol family 1RPC: Registered named UNIX socket transport module.RPC: Registered udp transport module.RPC: Registered tcp transport module.RPC: Registered tcp NFSv4.1 backchannel transport module.futex hash table entries: 512 (order: 3, 32768 bytes)squashfs: version 4.0 (2009/01/31) Phillip Lougherjffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.9p: Installing v9fs 9p2000 file system supportio scheduler noop registered (default)0.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000Intel/Sharp Extended Query Table at 0x0031Using buffer write method0.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000Intel/Sharp Extended Query Table at 0x0031Using buffer write methodConcatenating MTD devices:(0): "0.flash"(1): "0.flash"into device "0.flash"usbcore: registered new interface driver usb-storagemousedev: PS/2 mouse device common for all micertc-pl031 9010000.pl031: rtc core: registered pl031 as rtc0Driver 'mmcblk' needs updating - please use bus_type methodsledtrig-cpu: registered to indicate activity on CPUsusbcore: registered new interface driver usbhidusbhid: USB HID core driverTCP: cubic registeredNET: Registered protocol family 179pnet: Installing 9P2000 supportrtc-pl031 9010000.pl031: setting system clock to 2017-10-01 04:53:36 UTC (1506833616)ALSA device list:  No soundcards found.Freeing unused kernel memory: 1312K (ffff8000006cb000 - ffff800000813000)Freeing alternatives memory: 4K (ffff800000813000 - ffff800000814000)Bad inittab entry at line 4Please press Enter to activate this console.  / # lsbin      etc      mnt      sbin     tmpdev      linuxrc  proc     sys      usr/ # / # 
4.ok , 到这里就已经run起来了。