EAIDK-610跑主线uboot+主线linux+busybox

前言

手里有一块 eaidk-610 的板子,一直在吃灰,前段时间偶然得知主线 linux 已经支持 eaidk-610,就尝试一下,看能不能跑起来,结果是可以的。

本文主要是我之前移植过程中的一些记录,在这里也给大家提供一些思路,有些步骤可能不是那么详细。

要跟着本文的思路走,除了一块可用的 eaidk-610 的板子,还需一张 tf 卡。

跑 uboot

主要参考这篇文章
https://cloud.tencent.com/developer/article/1571935

  1. git clone https://gitlab.denx.de/u-boot/u-boot.git
  2. git clone https://github.com/rockchip-toybrick/rkbin -b master
  3. 进到下载好的 uboot 目录瞄一眼,会惊喜的发现已经支持 eaidk-610
    liu@liu-dev:u-boot$ ls configs/ | grep rk3399
    eaidk-610-rk3399_defconfig
    evb-rk3399_defconfig
    ficus-rk3399_defconfig
    firefly-rk3399_defconfig
    khadas-edge-captain-rk3399_defconfig
    khadas-edge-rk3399_defconfig
    khadas-edge-v-rk3399_defconfig
    leez-rk3399_defconfig
    nanopc-t4-rk3399_defconfig
    nanopi-m4-2gb-rk3399_defconfig
    nanopi-m4b-rk3399_defconfig
    nanopi-m4-rk3399_defconfig
    nanopi-neo4-rk3399_defconfig
    nanopi-r4s-rk3399_defconfig
    orangepi-rk3399_defconfig
    pinebook-pro-rk3399_defconfig
    pinephone-pro-rk3399_defconfig
    puma-rk3399_defconfig
    rock960-rk3399_defconfig
    rock-pi-4c-rk3399_defconfig
    rock-pi-4-rk3399_defconfig
    rock-pi-n10-rk3399pro_defconfig
    rockpro64-rk3399_defconfig
    roc-pc-mezzanine-rk3399_defconfig
    roc-pc-rk3399_defconfig
    
    1. 编译 uboot
      export BL31=../rkbin/bin/rk33/rk3399_bl31_v1.30.elf
      make eaidk-610-rk3399_defconfig
      make CROSS_COMPILE=/home/liu/work/projects/EAIDK/EAIDK-610/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
      
      编译器自行从原有sdk拷一个,编译可能会有错误,主要缺一些库之类的。
    2. 烧写 uboot
      编译完 uboot 之后,idbloader.img 和 u-boot.itb 是我们需要的。这个是不同于 RK 自家 sdk 的。 要怎么烧写呢,烧写到哪里,我一开始想用rk的刷机工具,不成功。所以就用 dd 命令,板子上原来跑的是fedora,有 dd 命令,所以我直接就烧写到 emmc
      #用scp 命令把 uboot 考到板子上
      scp -r liu@192.168.1.155:/home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/u-boot/idbloader.img ./
      scp -r liu@192.168.1.155:/home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/u-boot/u-boot.itb ./
      #seek=64 表示偏移 64 字节处烧写,rk3399 内部 bootROM 会从这个位置开始读取
      sudo dd if=idbloader.img of=/dev/mmcblk1 seek=64
      sudo dd if=u-boot.itb of=/dev/mmcblk1 seek=16384
      
      重启,发现 uboot 的 log 显示当前 uboot 版本为 U-Boot 2023.04-rc4,而且可以发现 kernel 加载不起来,这个正常,因为前面 dd 命令已经破坏了板子上 emmc 的程序
       U-Boot 2023.04-rc4-00053-g8be7b4629e (Mar 26 2023 - 13:33:35 +0800)
      
       SoC: Rockchip rk3399
       Reset cause: RST
       Model: OPEN AI LAB EAIDK-610
       DRAM:  4 GiB (effective 3.9 GiB)
       PMIC:  RK808
       Core:  279 devices, 23 uclasses, devicetree: separate
       MMC:   mmc@fe310000: 3, mmc@fe320000: 1, mmc@fe330000: 0
       Loading Environment from MMC... OK
       In:    serial@ff1a0000
       Out:   serial@ff1a0000
       Err:   serial@ff1a0000
       Model: OPEN AI LAB EAIDK-610
       Net:
       Error: ethernet@fe300000 address not set.
       No ethernet found.
      
      正常这一步 uboot 已经算是跑起来了,不过看日志似乎网络有问题,为了后面通过网络来下载内核,网络的问题得弄好。
      Error: ethernet@fe300000 address not set. 这个错误是说网卡MAC地址没设置,设置下环境变量
      setenv ethaddr 00:10:ab:20:81:70
      
      保存一下,重启板子 uboot 就没这个报错了。

跑 Linux

  1. 下载官方 linux 内核源码
git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
  1. 切换到相应版本,我当时应该最新稳定版应该是6.2.x
git checkout -b linux-6.2.y origin/linux-6.2.y
  1. 编译,我这边是一次性过
make ARCH=arm64 defconfig && make ARCH=arm64 CROSS_COMPILE=/home/liu/work/projects/EAIDK/EAIDK-610/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-  -j8
  1. uboot 通过 tftp 下载内核镜像到板子的 ddr 上,然后启动
    我在 windows 安装了个 tftpd64,作为 tftp 服务端
#uboot先设置下板子 IP 和 服务器 IP
setenv ipaddr 192.168.1.160
setenv serverip 192.168.1.150
#通过 tftp 下载内核镜像
tftp 0x00280000 Image   #  下载内核到内存 0x00280000 处   0x00280000
#一开始通过 bootm 启动内核,报错
=> bootm 0x00280000
Wrong Image Format for bootm command
ERROR: can't get kernel image!
#后面找到原因,arm64 要用 booti 来启动内核
#booti 命令格式如下
#booti <Image Adr> <rootfs adr> <dtb adr>
#      内核地址    根文件系统地址 设备树地址
#根文件系统的地址不管,用 - 表示
#下载设备树
tftp 0x08300000 rk3399-eaidk-610.dtb #这个ddr的地址忘了当时怎么确定的了
#启动内核
=> booti 0x00280000 - 0x08300000
Moving Image from 0x00280000 to 0x400000, end=28e0000
## Flattened Device Tree blob at 08300000
   Booting using the fdt blob at 0x8300000
Working FDT set to 8300000
   Loading Device Tree to 00000000f4f0b000, end 00000000f4f1d6be ... OK
Working FDT set to f4f0b000

Starting kernel ...

上面可以看到,常见的场景,Starting kernel … 之后就不打印了
还有一个步骤没做,uboot 传递给内核的参数还没设置,可以看看以前正常启动时的参数,都会有设置 console=xxx 的,这应该是指定控制台相关的
由于 rk 的芯片一般默认是 uart2 做调试串口,所以在uboot起来之后设置下环境变量

setenv bootargs 'console=ttyS2,1500000'

然后就可以看到内核跑起来了,贴上启动日志

=> booti 0x00280000 - 0x08300000
Moving Image from 0x280000 to 0x400000, end=28e0000
## Flattened Device Tree blob at 08300000
   Booting using the fdt blob at 0x8300000
Working FDT set to 8300000
   Loading Device Tree to 00000000f4f0b000, end 00000000f4f1d6be ... OK
Working FDT set to f4f0b000

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 6.2.8 (liu@liu-dev) (aarch64-linux-gnu-gcc (Linaro GCC 6.3-2017.05) 6.3.1 20170404, GNU ld (Linaro_Binutils-2017.05) 2.27.0.20161019) #1 SMP PREEMPT Sun Mar 26 16:26:41 CST 2023
[    0.000000] Machine model: OPEN AI LAB EAIDK-610
[    0.000000] efi: UEFI not found.
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xf77dca00-0xf77defff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] On node 0, zone DMA: 512 pages in unavailable ranges
[    0.000000] cma: Reserved 32 MiB at 0x00000000f5600000
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.0 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] percpu: Embedded 21 pages/cpu s45672 r8192 d32152 u86016
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] alternatives: applying boot alternatives
[    0.000000] Fallback order for Node 0: 0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 999432
[    0.000000] Policy zone: DMA
[    0.000000] Kernel command line: console=ttyS2,1500000
[    0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 3912128K/4061184K available (15552K kernel code, 3884K rwdata, 9612K rodata, 7936K init, 614K bss, 116288K reserved, 32768K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=6, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=6.
[    0.000000]  Trampoline variant of Tasks RCU enabled.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=6
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[    0.000000] GICv3: 256 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv3: GICv3 features: 16 PPIs
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000fef00000
[    0.000000] ITS [mem 0xfee20000-0xfee3ffff]
[    0.000000] ITS@0x00000000fee20000: allocated 65536 Devices @2c80000 (flat, esz 8, psz 64K, shr 0)
[    0.000000] ITS: using cache flushing for cmd queue
[    0.000000] GICv3: using LPI property table @0x0000000002c40000
[    0.000000] GIC: using cache flushing for LPI property table
[    0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000002c50000
[    0.000000] GICv3: GIC: PPI partition interrupt-partition-0[0] { /cpus/cpu@0[0] /cpus/cpu@1[1] /cpus/cpu@2[2] /cpus/cpu@3[3] }
[    0.000000] GICv3: GIC: PPI partition interrupt-partition-1[1] { /cpus/cpu@100[4] /cpus/cpu@101[5] }
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000001] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.005058] Console: colour dummy device 80x25
[    0.005177] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=96000)
[    0.005198] pid_max: default: 32768 minimum: 301
[    0.005305] LSM: initializing lsm=capability,integrity
[    0.005466] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.005501] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.007165] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.008121] cblist_init_generic: Setting adjustable number of callback queues.
[    0.008138] cblist_init_generic: Setting shift to 3 and lim to 1.
[    0.008264] cblist_init_generic: Setting shift to 3 and lim to 1.
[    0.008544] rcu: Hierarchical SRCU implementation.
[    0.008550] rcu:     Max phase no-delay instances is 1000.
[    0.008945] Platform MSI: interrupt-controller@fee20000 domain created
[    0.009435] PCI/MSI: /interrupt-controller@fee00000/interrupt-controller@fee20000 domain created
[    0.009777] fsl-mc MSI: interrupt-controller@fee20000 domain created
[    0.017447] EFI services will not be available.
[    0.017988] smp: Bringing up secondary CPUs ...
[    0.018833] Detected VIPT I-cache on CPU1
[    0.018940] cacheinfo: Unable to detect cache hierarchy for CPU 1
[    0.018958] GICv3: CPU1: found redistributor 1 region 0:0x00000000fef20000
[    0.018981] GICv3: CPU1: using allocated LPI pending table @0x0000000002c60000
[    0.019039] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[    0.019905] Detected VIPT I-cache on CPU2
[    0.020000] cacheinfo: Unable to detect cache hierarchy for CPU 2
[    0.020015] GICv3: CPU2: found redistributor 2 region 0:0x00000000fef40000
[    0.020033] GICv3: CPU2: using allocated LPI pending table @0x0000000002c70000
[    0.020073] CPU2: Booted secondary processor 0x0000000002 [0x410fd034]
[    0.020845] Detected VIPT I-cache on CPU3
[    0.020940] cacheinfo: Unable to detect cache hierarchy for CPU 3
[    0.020956] GICv3: CPU3: found redistributor 3 region 0:0x00000000fef60000
[    0.020975] GICv3: CPU3: using allocated LPI pending table @0x0000000002d00000
[    0.021013] CPU3: Booted secondary processor 0x0000000003 [0x410fd034]
[    0.021808] CPU features: detected: Spectre-v2
[    0.021822] CPU features: detected: Spectre-v3a
[    0.021828] CPU features: detected: Spectre-v4
[    0.021834] CPU features: detected: Spectre-BHB
[    0.021842] CPU features: detected: ARM erratum 1742098
[    0.021849] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[    0.021855] Detected PIPT I-cache on CPU4
[    0.021947] cacheinfo: Unable to detect cache hierarchy for CPU 4
[    0.021963] GICv3: CPU4: found redistributor 100 region 0:0x00000000fef80000
[    0.021981] GICv3: CPU4: using allocated LPI pending table @0x0000000002d10000
[    0.022022] CPU4: Booted secondary processor 0x0000000100 [0x410fd082]
[    0.022847] Detected PIPT I-cache on CPU5
[    0.022931] cacheinfo: Unable to detect cache hierarchy for CPU 5
[    0.022945] GICv3: CPU5: found redistributor 101 region 0:0x00000000fefa0000
[    0.022962] GICv3: CPU5: using allocated LPI pending table @0x0000000002d20000
[    0.022995] CPU5: Booted secondary processor 0x0000000101 [0x410fd082]
[    0.023111] smp: Brought up 1 node, 6 CPUs
[    0.023125] SMP: Total of 6 processors activated.
[    0.023133] CPU features: detected: 32-bit EL0 Support
[    0.023137] CPU features: detected: 32-bit EL1 Support
[    0.023146] CPU features: detected: CRC32 instructions
[    0.023264] CPU: All CPU(s) started at EL2
[    0.023296] alternatives: applying system-wide alternatives
[    0.027127] devtmpfs: initialized
[    0.040634] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.040666] futex hash table entries: 28 (order: 3, 32768 bytes, linear)
[    0.143260] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.143280] TCP established hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.143630] TCP bind hash table entries: 32768 (order: 8, 1048576 bytes, linear)
[    0.144907] TCP: Hash tables configured (established 32768 bind 32768)
[    0.145029] UDP hash table entries: 2048 (order: 4, 65536 bytes, linear)
[    0.145173] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes, linear)
[    0.145460] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.145966] RPC: Registered named UNIX socket transport module.
[    0.145975] RPC: Registered udp transport module.
[    0.145980] RPC: Registered tcp transport module.
[    0.145985] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.145997] PCI: CLS 0 bytes, default 64
[    0.147065] hw perfevents: enabled with armv8_cortex_a53 PMU driver, 7 counters available
[    0.147516] hw perfevents: enabled with armv8_cortex_a72 PMU driver, 7 counters available
[    0.148302] kvm [1]: IPA Size Limit: 40 bits
[    0.150728] kvm [1]: vgic-v2@fff20000
[    0.150761] kvm [1]: GIC system register CPU interface enabled
[    0.150982] kvm [1]: vgic interrupt IRQ18
[    0.151191] kvm [1]: Hyp mode initialized successfully
[    0.152952] Initialise system trusted keyrings
[    0.153177] workingset: timestamp_bits=42 max_order=20 bucket_order=0
[    0.153577] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.153926] NFS: Registering the id_resolver key type
[    0.153957] Key type id_resolver registered
[    0.153963] Key type id_legacy registered
[    0.153991] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.153998] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.154156] 9p: Installing v9fs 9p2000 file system support
[    0.218704] Key type asymmetric registered
[    0.218712] Asymmetric key parser 'x509' registered
[    0.218773] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[    0.218781] io scheduler mq-deadline registered
[    0.218788] io scheduler kyber registered
[    0.254290] EINJ: ACPI disabled.
[    0.280169] dma-pl330 ff6d0000.dma-controller: Loaded driver for PL330 DMAC-241330
[    0.280184] dma-pl330 ff6d0000.dma-controller:       DBUFF-32x8bytes Num_Chans-6 Num_Peri-12 Num_Events-12
[    0.281444] dma-pl330 ff6e0000.dma-controller: Loaded driver for PL330 DMAC-241330
[    0.281456] dma-pl330 ff6e0000.dma-controller:       DBUFF-128x8bytes Num_Chans-8 Num_Peri-20 Num_Events-16
[    0.304585] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.307590] ff180000.serial: ttyS0 at MMIO 0xff180000 (irq = 41, base_baud = 1500000) is a 16550A
[    0.307774] serial serial0: tty port ttyS0 registered
[    0.308685] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 42, base_baud = 1500000) is a 16550A
[    0.308864] printk: console [ttyS2] enabled
[    0.429174] SuperH (H)SCI(F) driver initialized
[    0.430787] msm_serial: driver initialized
[    0.438060] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.445009] loop: module loaded
[    0.446990] megasas: 07.719.03.00-rc1
[    0.458803] tun: Universal TUN/TAP device driver, 1.6
[    0.460980] thunder_xcv, ver 1.0
[    0.461298] thunder_bgx, ver 1.0
[    0.461615] nicpf, ver 1.0
[    0.464483] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[    0.465122] hns3: Copyright (c) 2017 Huawei Corporation.
[    0.465624] hclge is initializing
[    0.465962] e1000: Intel(R) PRO/1000 Network Driver
[    0.466396] e1000: Copyright (c) 1999-2006 Intel Corporation.
[    0.466927] e1000e: Intel(R) PRO/1000 Network Driver
[    0.467366] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.467908] igb: Intel(R) Gigabit Ethernet Network Driver
[    0.468386] igb: Copyright (c) 2007-2014 Intel Corporation
[    0.497055] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[    0.497570] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[    0.497628] ehci-platform fe380000.usb: EHCI Host Controller
[    0.497648] ohci-platform fe3a0000.usb: Generic Platform OHCI controller
[    0.497681] ohci-platform fe3a0000.usb: new USB bus registered, assigned bus number 2
[    0.497710] ehci-platform fe3c0000.usb: EHCI Host Controller
[    0.497728] ohci-platform fe3e0000.usb: Generic Platform OHCI controller
[    0.497739] ehci-platform fe3c0000.usb: new USB bus registered, assigned bus number 3
[    0.497758] ohci-platform fe3e0000.usb: new USB bus registered, assigned bus number 4
[    0.497849] ohci-platform fe3a0000.usb: irq 53, io mem 0xfe3a0000
[    0.497875] ehci-platform fe3c0000.usb: irq 52, io mem 0xfe3c0000
[    0.497951] ohci-platform fe3e0000.usb: irq 54, io mem 0xfe3e0000
[    0.498400] xhci-hcd xhci-hcd.0.auto: hcc params 0x0220fe64 hci version 0x110 quirks 0x0000000002010010
[    0.498811] ehci-platform fe380000.usb: new USB bus registered, assigned bus number 5
[    0.499420] xhci-hcd xhci-hcd.0.auto: irq 50, io mem 0xfe900000
[    0.500174] ehci-platform fe380000.usb: irq 51, io mem 0xfe380000
[    0.500731] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[    0.507172] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 6
[    0.507854] xhci-hcd xhci-hcd.0.auto: Host supports USB 3.0 SuperSpeed
[    0.509144] hub 1-0:1.0: USB hub found
[    0.509510] hub 1-0:1.0: 1 port detected
[    0.510243] usb usb6: We don't know the algorithms for LPM for this host, disabling LPM.
[    0.511528] hub 6-0:1.0: USB hub found
[    0.511891] hub 6-0:1.0: 1 port detected
[    0.513216] usbcore: registered new interface driver usb-storage
[    0.513927] ehci-platform fe3c0000.usb: USB 2.0 started, EHCI 1.00
[    0.515488] hub 3-0:1.0: USB hub found
[    0.515879] hub 3-0:1.0: 1 port detected
[    0.519570] i2c_dev: i2c /dev entries driver
[    0.525190] dw-apb-uart ff180000.serial: Failed to create device link (0x180) with 0-001b
[    0.527493] rk808 0-001b: chip id: 0x0
[    0.529931] ehci-platform fe380000.usb: USB 2.0 started, EHCI 1.00
[    0.531264] hub 5-0:1.0: USB hub found
[    0.531639] hub 5-0:1.0: 1 port detected
[    0.537860] rk808-regulator rk808-regulator.2.auto: there is no dvs0 gpio
[    0.538511] rk808-regulator rk808-regulator.2.auto: there is no dvs1 gpio
[    0.557257] dw-apb-uart ff180000.serial: Failed to create device link (0x180) with 0-001b
[    0.558818] hub 2-0:1.0: USB hub found
[    0.559223] hub 2-0:1.0: 1 port detected
[    0.559677] fan53555-regulator 0-0040: FAN53555 Option[8] Rev[1] Detected!
[    0.562739] hub 4-0:1.0: USB hub found
[    0.563117] hub 4-0:1.0: 1 port detected
[    0.564314] fan53555-regulator 0-0041: FAN53555 Option[8] Rev[1] Detected!
[    0.577643] dw_wdt ff848000.watchdog: No valid TOPs array specified
[    0.580487] ghes_edac: GHES probing device list is empty
[    0.583718] cpu cpu0: EM: created perf domain
[    0.585864] cpu cpu4: EM: created perf domain
[    0.590794] sdhci: Secure Digital Host Controller Interface driver
[    0.591347] sdhci: Copyright(c) Pierre Ossman
[    0.592365] Synopsys Designware Multimedia Card Interface Driver
[    0.593867] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.594102] dwmmc_rockchip fe310000.mmc: IDMAC supports 32-bit address mode.
[    0.594162] dwmmc_rockchip fe320000.mmc: IDMAC supports 32-bit address mode.
[    0.594182] dwmmc_rockchip fe320000.mmc: Using internal DMA controller.
[    0.594189] dwmmc_rockchip fe320000.mmc: Version ID is 270a
[    0.594232] dwmmc_rockchip fe320000.mmc: DW MMC controller at irq 71,32 bit host data width,256 deep fifo
[    0.594389] dwmmc_rockchip fe320000.mmc: Got CD GPIO
[    0.594990] dwmmc_rockchip fe310000.mmc: Using internal DMA controller.
[    0.595598] mmc2: CQHCI version 5.10
[    0.596173] dwmmc_rockchip fe310000.mmc: Version ID is 270a
[    0.599396] dwmmc_rockchip fe310000.mmc: DW MMC controller at irq 70,32 bit host data width,256 deep fifo
[    0.600295] ledtrig-cpu: registered to indicate activity on CPUs
[    0.600403] dwmmc_rockchip fe310000.mmc: allocated mmc-pwrseq
[    0.601326] mmc_host mmc0: card is non-removable.
[    0.602988] usbcore: registered new interface driver usbhid
[    0.603482] usbhid: USB HID core driver
[    0.606042] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[    0.610656] NET: Registered PF_PACKET protocol family
[    0.611147] 9pnet: Installing 9P2000 support
[    0.611555] Key type dns_resolver registered
[    0.616388] registered taskstats version 1
[    0.616875] Loading compiled-in X.509 certificates
[    0.617997] mmc_host mmc0: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[    0.621930] mmc2: SDHCI controller on fe330000.mmc [fe330000.mmc] using ADMA
[    0.638451] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    0.640093] ALSA device list:
[    0.640363]   No soundcards found.
[    0.640802] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console
[    0.641858] /dev/root: Can't open blockdev
[    0.642237] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.642890] Please append a correct "root=" boot option; here are the available partitions:
[    0.643626] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.644345] CPU: 5 PID: 1 Comm: swapper/0 Not tainted 6.2.8 #1
[    0.644855] Hardware name: OPEN AI LAB EAIDK-610 (DT)
[    0.645298] Call trace:
[    0.645514]  dump_backtrace.part.6+0xe8/0xf8
[    0.645900]  show_stack+0x14/0x20
[    0.646194]  dump_stack_lvl+0x64/0x7c
[    0.646519]  dump_stack+0x14/0x2c
[    0.646811]  panic+0x168/0x380
[    0.647083]  mount_block_root+0x12c/0x214
[    0.647438]  mount_root+0x1d4/0x218
[    0.647745]  prepare_namespace+0x138/0x178
[    0.648106]  kernel_init_freeable+0x244/0x288
[    0.648488]  kernel_init+0x20/0x128
[    0.648796]  ret_from_fork+0x10/0x20
[    0.649112] SMP: stopping secondary CPUs
[    0.649559] Kernel Offset: disabled
[    0.649865] CPU features: 0x80000,41078108,0000421b
[    0.650292] Memory Limit: none
[    0.650565] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

内核跑起来了,接下来就要启动根文件系统了,上面日志的最后也提醒了找不到 rootfs。

跑 busybox

根文件系统选择了最简单基础的 busybox,然后放到 sd 卡里面

  1. 首先用 fdisk 对 sd 卡进行分区
liu@liu-dev:~$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1        8192 62333951 62325760 29.7G  c W95 FAT32 (LBA)

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): 1
1: unknown command

Command (m for help): 


Command (m for help): p

Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00000000

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-62333951, default 2048): 163840
Last sector, +sectors or +size{K,M,G,T,P} (163840-62333951, default 62333951): +200M

Created a new partition 1 of type 'Linux' and of size 200 MiB.

Command (m for help): p
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00000000

Device     Boot  Start    End Sectors  Size Id Type
/dev/sdb1       163840 573439  409600  200M 83 Linux

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-62333951, default 2048): 573440
Last sector, +sectors or +size{K,M,G,T,P} (573440-62333951, default 62333951): 

Created a new partition 2 of type 'Linux' and of size 29.5 GiB.

Command (m for help): p
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00000000

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdb1       163840   573439   409600  200M 83 Linux
/dev/sdb2       573440 62333951 61760512 29.5G 83 Linux

Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): c

Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): p
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00000000

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdb1       163840   573439   409600  200M  c W95 FAT32 (LBA)
/dev/sdb2       573440 62333951 61760512 29.5G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

liu@liu-dev:~$ 
liu@liu-dev:~$ 
liu@liu-dev:~$ ls /dev/sdb*
/dev/sdb  /dev/sdb1  /dev/sdb2
liu@liu-dev:~$ 
liu@liu-dev:~$ sudo mkfs.ext
mkfs.ext2  mkfs.ext3  mkfs.ext4  
liu@liu-dev:~$ sudo mkfs.ext4 /dev/sdb2
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 7720064 4k blocks and 1933312 inodes
Filesystem UUID: 07a9b90c-1fa5-48d7-b5d3-fc4354087d16
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:        
done

最终 sd 卡创建了两个分区,一个是 fat32 格式的,一个是 ext4 格式的
根文件系统就放在了 ext4 分区
2. busybox 的制作是参考了正点原子的教程,只不过我们现在板子是64位的,在拷贝一些库的时候有所差别,busybox的源码也是之前玩正点原子157的板子用的,busybox-1.29.0.tar.bz2

cd busybox/

tar -xvjf busybox-1.29.0.tar.bz2

cd busybox-1.29.0/

vi Makefile  # 指定交叉编译器和架构164 行  CROSS_COMPILE ?= /home/liu/work/projects/EAIDK/EAIDK-610/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

第 190 行  ARCH ?= arm64

编译
make 

make install CONFIG_PREFIX=/home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs  # 把 busybox 制作好的原始文件考到我们的目录

把交叉编译器相关的库考到根文件系统目录中

cd /home/liu/work/projects/EAIDK/EAIDK-610/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/libc/lib/

cp *so* /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs/lib/ -d  # 软连接保留

cp ld-linux-aarch64.so.1 /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs/lib/  # 这一步就和正点原子文档说的不一样了,文档是 ld-linux-armhf.so.3, 这个库是64位的

cd /home/liu/work/projects/EAIDK/EAIDK-610/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/lib64  # 这里是进到 lib64

cp *so* *.a /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs/lib/ -d

cd /home/liu/work/projects/EAIDK/EAIDK-610/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/lib

cp *so* *.a /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs/usr/lib/ -d

本来接下来按照文档是要先通过网络根文件系统来启动,但是我一直没成功,就没继续尝试了

接下来是把 /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs 这个目录的东西拷贝到 sd 卡中

cd /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/rootfs

tar cvpzf rootfs.tgz ./  #  压缩

cd ../

mkdir sd_rootfs

mount /dev/sdb2 sd_rootfs/  # sd 卡挂载分区到 sd_rootfs

sudo tar xvpzf rootfs.tgz -C sd_rootfs/  # 解压

sudo umount /home/liu/work/projects/EAIDK/EAIDK-610/my_sdk/sd_rootfs

接着拔下sd卡插到板子上

设置cmd参数

setenv bootargs 'console=ttyS2,1500000 root=/dev/mmcblk1p2 rootwait rw'

tftp 0x00280000 Image
tftp 0x08300000 rk3399-eaidk-610.dtb
booti 0x00280000 - 0x08300000

这样就能启动了

至此也完成了目标,虽然很简陋,后面就是各种完善了,例如把 uboot 和 kernel 都放到 sd 卡上,板子的外设用起来,busybox换成 buildroot 或者各种发行版等等,我就抛个砖。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值