qemu-system-aarch64/cortex-a53/Linux

99 篇文章 0 订阅
36 篇文章 0 订阅


1.  LTS kernel 

git clone -b   v4.19   --depth 1    https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

2. Build with aarch64-linux-gnu-gcc/Linaro/GCC7.2.1/2017

lake@localhost:~/local/lfs/root-aarch64$ aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc 

gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)

$ make ARCH=arm64    CROSS_COMPILE=aarch64-linux-gnu-    defconfig

 $make ARCH=arm64    CROSS_COMPILE=aarch64-linux-gnu-    -j32 

3. Build busybox  (default it is dymanic link)

 make ARCH=arm64    CROSS_COMPILE=aarch64-linux-gnu-    defconfig

lake@localhost:~/local/lfs/busybox-1.31.0$ file busybox
busybox: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 3.7.0, BuildID[sha1]=20fd8a1e8adb75fadfa1c11b683ca61bd0af7d4a, stripped
lake@localhost:~/local/lfs/busybox-1.31.0$

######### copy shard lib for busybox
lake@localhost:~/local/lfs/root-aarch64$ aarch64-linux-gnu-readelf  -a  ../busybox-1.31.0/_install/bin/busybox   |grep Shared
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libresolv.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
lake@localhost:~/local/lfs/root-aarch64$

4. Prepare  root fs 

mkdir proc  etc  lib  etc/init.d/   sys lib dev  

 sudo mknod  dev/tty1 c 4 1
 sudo  mknod  dev/tty1 c 4 1
  sudo mknod  dev/tty1 c 4 1
 sudo mknod  dev/tty2 c 4 2
   sudo mknod  dev/tty3 c 4 3
 sudo mknod  dev/tty4 c 4 4
  sudo mknod  dev/console c 5 1
   sudo mknod  dev/null c 1 3


lake@localhost:~/local/lfs/root-aarch64$ cat etc/init.d/rcS
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s

######### copy shard lib for busybox
lake@localhost:~/local/lfs/root-aarch64$ aarch64-linux-gnu-readelf  -a  ../busybox-1.31.0/_install/bin/busybox   |grep Shared
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libresolv.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
lake@localhost:~/local/lfs/root-aarch64$


5.  initramfs for initrd 

lake@localhost:~/local/lfs/root-aarch64$ find . |cpio -o  --format=newc > ../initramfs
3723 blocks
lake@localhost:~/local/lfs/root-aarch64$ find . | cpio -H newc -o | gzip > ../initram-root.cpio.gz
3723 blocks

### Note    extract/change/modify initram.cpio.gz

====>   sudo   zcat ../initram-root.cpio.gz   | sudo  cpio -idmv

6 start with qemu/qemu-system-aarch64    
lake@localhost:~/local/lfs/linux-stable$ qemu-system-aarch64        -nographic    -M  virt    -cpu cortex-a53   -smp 2   -m 1024M  -kernel  arch/arm64/boot/Image   -initrd  ../initram-root.cpio.gz    -append "root=/dev/ram rdinit=/sbin/init"
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 4.19.0 (lake@localhost) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #3 SMP PREEMPT Wed Jul 31 21:44:46 CST 2019
[    0.000000] Machine model: linux,dummy-virt
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x000000007e000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x7dfea680-0x7dfebe3f]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv0.2 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] random: get_random_bytes called from start_kernel+0xa8/0x410 with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @(____ptrval____) s56128 r8192 d29888 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: enabling workaround for ARM erratum 843419
[    0.000000] CPU features: enabling workaround for ARM erratum 845719
[    0.000000] CPU features: detected: Kernel page table isolation (KPTI)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 258048
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: root=/dev/ram rdinit=/sbin/init
[    0.000000] Memory: 976628K/1048576K available (7804K kernel code, 1242K rwdata, 4108K rodata, 1216K init, 336K bss, 39180K reserved, 32768K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=2.
[    0.000000]  Tasks RCU enabled.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv2m: range[mem 0x08020000-0x08020fff], SPI[80:143]
[    0.000000] arch_timer: cp15 timer(s) running at 62.50MHz (virt).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
[    0.001051] sched_clock: 56 bits at 62MHz, resolution 16ns, wraps every 4398046511096ns
[    0.031956] Console: colour dummy device 80x25
[    0.043895] console [tty0] enabled
[    0.051962] Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=250000)
[    0.052953] pid_max: default: 32768 minimum: 301
[    0.059371] Security Framework initialized
[    0.065081] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.068397] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
[    0.069455] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
[    0.069903] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes)
[    0.225233] ASID allocator initialised with 32768 entries
[    0.234249] rcu: Hierarchical SRCU implementation.
[    0.268260] EFI services will not be available.
[    0.276422] smp: Bringing up secondary CPUs ...
[    0.309744] Detected VIPT I-cache on CPU1
[    0.312786] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[    0.326539] smp: Brought up 1 node, 2 CPUs
[    0.327106] SMP: Total of 2 processors activated.
[    0.333259] CPU features: detected: 32-bit EL0 Support
[    0.367651] CPU: All CPU(s) started at EL1
[    0.368879] alternatives: patching kernel code
[    0.438372] devtmpfs: initialized
[    0.505483] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.506826] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.551789] pinctrl core: initialized pinctrl subsystem
[    0.634956] DMI not present or invalid.
[    0.643751] NET: Registered protocol family 16
[    0.684103] cpuidle: using governor menu
[    0.692266] vdso: 2 pages (1 code @ (____ptrval____), 1 data @ (____ptrval____))
[    0.693003] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    0.728685] DMA: preallocated 256 KiB pool for atomic allocations
[    0.750318] Serial: AMBA PL011 UART driver
[    0.926760] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 39, base_baud = 0) is a PL011 rev1
[    0.952750] console [ttyAMA0] enabled
[    1.186884] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    1.199209] cryptd: max_cpu_qlen set to 1000
[    1.214979] ACPI: Interpreter disabled.
[    1.236682] vgaarb: loaded
[    1.243250] SCSI subsystem initialized
[    1.263052] pps_core: LinuxPPS API ver. 1 registered
[    1.263553] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    1.266837] EDAC MC: Ver: 3.0.0
[    1.326259] clocksource: Switched to clocksource arch_sys_counter
[    1.334883] VFS: Disk quotas dquot_6.6.0
[    1.336956] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    1.345599] pnp: PnP ACPI: disabled
[    1.496443] Trying to unpack rootfs image as initramfs...
[    2.309186] Freeing initrd memory: 6592K
[    2.323403] hw perfevents: enabled with armv8_pmuv3 PMU driver, 5 counters available
[    2.325812] kvm [1]: HYP mode not available
[    2.377818] Initialise system trusted keyrings
[    2.384092] workingset: timestamp_bits=44 max_order=18 bucket_order=0
[    2.483802] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    2.488929] pstore: using deflate compression
[    2.524378] Key type asymmetric registered
[    2.525436] Asymmetric key parser 'x509' registered
[    2.526670] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[    2.527971] io scheduler noop registered
[    2.528583] io scheduler deadline registered
[    2.531128] io scheduler cfq registered (default)
[    2.531734] io scheduler mq-deadline registered
[    2.532175] io scheduler kyber registered
[    2.630284] pl061_gpio 9030000.pl061: PL061 GPIO chip @0x0000000009030000 registered
[    2.655300] pci-host-generic 4010000000.pcie: host bridge /pcie@10000000 ranges:
[    2.658282] pci-host-generic 4010000000.pcie:    IO 0x3eff0000..0x3effffff -> 0x00000000
[    2.660872] pci-host-generic 4010000000.pcie:   MEM 0x10000000..0x3efeffff -> 0x10000000
[    2.662282] pci-host-generic 4010000000.pcie:   MEM 0x8000000000..0xffffffffff -> 0x8000000000
[    2.666425] pci-host-generic 4010000000.pcie: ECAM at [mem 0x4010000000-0x401fffffff] for [bus 00-ff]
[    2.672042] pci-host-generic 4010000000.pcie: PCI host bridge to bus 0000:00
[    2.673896] pci_bus 0000:00: root bus resource [bus 00-ff]
[    2.674852] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    2.675466] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[    2.676143] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[    2.719846] pci 0000:00:01.0: BAR 6: assigned [mem 0x10000000-0x1003ffff pref]
[    2.722206] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[    2.723397] pci 0000:00:01.0: BAR 1: assigned [mem 0x10040000-0x10040fff]
[    2.724118] pci 0000:00:01.0: BAR 0: assigned [io  0x1000-0x101f]
[    2.764243] EINJ: ACPI disabled.
[    2.920927] virtio-pci 0000:00:01.0: enabling device (0000 -> 0003)
[    3.009065] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    3.046795] SuperH (H)SCI(F) driver initialized
[    3.055390] msm_serial: driver initialized
[    3.071413] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    3.234103] brd: module loaded
[    3.337079] loop: module loaded
[    3.411226] VFIO - User Level meta-driver version: 0.3
[    3.446706] rtc-pl031 9010000.pl031: rtc core: registered pl031 as rtc0
[    3.460512] i2c /dev entries driver
[    3.532749] sdhci: Secure Digital Host Controller Interface driver
[    3.533747] sdhci: Copyright(c) Pierre Ossman
[    3.538855] Synopsys Designware Multimedia Card Interface Driver
[    3.554181] sdhci-pltfm: SDHCI platform and OF driver helper
[    3.575368] ledtrig-cpu: registered to indicate activity on CPUs
[    3.634987] 9pnet: Installing 9P2000 support
[    3.643627] Loading compiled-in X.509 certificates
[    3.687209] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    3.699848] rtc-pl031 9010000.pl031: setting system clock to 2019-07-31 16:13:33 UTC (1564589613)
[    3.720579] uart-pl011 9000000.pl011: no DMA platform data
[    4.150002] Freeing unused kernel memory: 1216K
[    4.154274] Run /sbin/init as init process


Please press Enter to activate this console. #

# ls -l /bin/busybox
-rwxr-xr-x    1 1028     27         1843472 Jul 31 16:03 /bin/busybox
# ls -l
drwxr-xr-x    2 1028     27               0 Jul 31 13:58 bin
drwxr-xr-x    2 1028     27               0 Jul 31 16:13 dev
drwxr-xr-x    3 0        0                0 Jul 31 14:18 etc
drwxr-xr-x    2 1028     27               0 Jul 31 16:11 lib
lrwxrwxrwx    1 1028     27              11 Jul 31 13:58 linuxrc -> bin/busybox
dr-xr-xr-x   55 0        0                0 Jan  1  1970 proc
-rw-r--r--    1 1028     27             298 Jul 31 16:05 readme.txt
drwx------    2 0        0                0 Jul 31 12:03 root
drwxr-xr-x    2 1028     27               0 Jul 31 13:58 sbin
dr-xr-xr-x   13 0        0                0 Jul 31 16:13 sys
drwxr-xr-x    4 1028     27               0 Jul 31 13:58 usr
# mount
rootfs on / type rootfs (rw)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
#
# cat /proc/version
Linux version 4.19.0 (lake@localhost) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #3 SMP PREEMPT Wed Jul 31 21:44:46 CST 2019
#


# cat /proc/version
Linux version 4.19.0 (lake@localhost) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #3 SMP PREEMPT Wed Jul 31 21:44:46 CST 2019
# cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 125.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
BogoMIPS        : 125.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

#


# power
poweroff  powertop
# poweroff
# umount: can't umount /: Invalid argument
swapoff: /etc/fstab: No such file or directory
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system poweroff
[  202.789623] reboot: Power down
 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值