linux 一运行build卡,Buildroot自制文件系统sd卡启动成功--Apple的学习笔记

前言:

因为总是用芯片官网的驱动觉得太简单了,学不到什么东西,定制才比较好玩。所以uboot和驱动之前玩过,唯独文件系统没玩过。网上了解到Buildroot很爽,官网看了下,觉得不错,而且官方实验资料正好对应BB black开发板。本着资源充分利用的原则,从学习方案角度来看必须选择Buildroot。因为我手上有bb black开发板。

一,编译制作文件系统

Buildroot官网资我参考的是buildroot-labs.pdf,发现make过程中dl文件夹中下载各种库文件好慢,所以我ctrl+c终止了好多次进行手工下载放入dl文件夹,大概上周日花了一天完成了编译。总的来说没有曲折,就是慢。

二,制作sd卡启动

原来用ti sdk的话,我也是用sd卡启动,但是都是用Etcher工具烧录源码,然后替换里面的uboot或者zImage及modules。从来没自己制作过。所以坎坷来了

问题1:自制SD卡无法启动。

排查步骤1

查了MLO的启动原理,就通过am335x芯片的rom boot自动识别到FAT格式的sd卡则启动。这步骤没有问题。

排查步骤2

我用pdf中的cfdisk进行的分区。后来我将MLO和uboot放入Etcher工具制作的分区后,能成功启动。

检查原版mmc part,信息如下,发现Type是0c,而我选的是0e。结果修改后还是无法启动。

Part Start Sector Num Sectors UUID Type

1 2048 143360 5acae36b-01 0c Boot

2 145408 8013824 5acae36b-02 83

排查步骤3

渐渐的熟悉了cfdisk工具的每个选择项后,发现我可以不使用dd,直接进入cfdisk观察sdb1和sdb2的设置。那么事情就变简单了。我把用Etcher工具制作的sd通过cfdisk对比信息后,发现了启动项。原来pdf中描述的set it bootable就是要选择可启动项。

6adf51ba7328

image.png

问题1解决了

1.dd if=/dev/zero of=/dev/sdb bs=1M count=16

2.sudo cfdisk /dev/sdb

选择dos,然后创建128M主分区选择e(W95 FAT16 LBA)并且选择“写入”输入yes+回车。再创建剩余空间为83(linux)并且选择“写入”输入yes+回车。最后退出。将FAT设置为可启动

3.sudo mkfs.vfat -F 32 -n boot /dev/sdb1

4.sudo mkfs.ext4 -L rootfs -E nodiscard /dev/sdb2

问题2:无法加载zImage

其实就是uEnv.txt里面的设置问题,我看了芯片手册及一些关键参数,后来学习了正点电子中手工设置参数的方法。uEnv.txt应该怎么写我还不清楚,但是手工设置的方法我已经掌握了。这部分之后复习uboot的时候再进行深入。

解决方案如下

1.setenv bootargs 'console=ttyS0,115200n8 noinitrd root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait'

2.setenv bootcmd 'mmc dev 0; fatload mmc 0:1 82000000 zImage; fatload mmc 0:1 88000000 am335x-boneblack.dtb; bootz 82000000 - 88000000;'

3.saveenv

4.boot

问题2解决了

问题3:无法启动文件系统

[ 16.745895] Starting init: /sbin/init exists but couldn't execute it (error -8)

[ 16.764801] Run /etc/init as init process

[ 16.771681] Run /bin/init as init process

[ 16.775889] Run /bin/sh as init process

[ 16.839311] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-0000, throttling...

[ 21.839847] request_module: modprobe binfmt-0000 cannot be processed, kmod busy with 50 threads for more than 5 seconds now

[ 21.864690] Starting init: /bin/sh exists but couldn't execute it (error -8)

[ 21.883326] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.

[ 21.897917] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---

我学习buildroot的主要目的就是学习制作文件系统,这才是重点,居然无法启动文件系统,我有点崩溃了,但是也有点兴奋。我猜测解决了此问题就可以大功告成了。

排查步骤1

先在网上搜索了下Starting init: /bin/sh exists but couldn't execute it (error -8),果然有一篇https://blog.csdn.net/weixin_41974358/article/details/105279356直接给了我调查方向。我将sd卡插入PC去查看/bin下busybox是红色的,这是权限问题,通过chmod 777,依然有相同的错误。

排查步骤2

后来自己发现busybox有点奇怪,看上去不是文件也不是文件夹。通过命令file busybox发现它为empty。原来是我用sudo tar -C /media/applecai/rootfs/ -xf rootfs.tar命令进行的解压加copy导致的问题。所以我在buildroot本地解压后,查看file busybox是elf-32文件。于是将本地解压的全部copy到sd卡的rootfs。

三,大功告成

花费了我3个晚上的业余时间,有所收获,将来再遇到这样的情况不会束手无策了,哈哈,人生第一次制作linux启动文件。将来就可以玩各种花样裁剪了。

U-Boot SPL 2019.07 (Sep 06 2020 - 16:55:30 +0800)

Trying to boot from MMC1

U-Boot 2019.07 (Sep 06 2020 - 16:55:30 +0800)

CPU : AM335X-GP rev 2.1

Model: TI AM335x BeagleBone Black

DRAM: 512 MiB

NAND: 0 MiB

MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1

Loading Environment from FAT... OK

Net: eth0: ethernet@4a100000

Warning: usb_ether MAC addresses don't match:

Address in ROM is de:ad:be:ef:00:01

Address in environment is 50:33:8b:36:25:90

, eth1: usb_ether

Hit any key to stop autoboot: 0

switch to partitions #0, OK

mmc0 is current device

6020864 bytes read in 400 ms (14.4 MiB/s)

34782 bytes read in 5 ms (6.6 MiB/s)

## Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000

Loading Device Tree to 8fff4000, end 8ffff7dd ... OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0

[ 0.000000] Linux version 4.19.59 (root@applecaiHP) (gcc version 8.4.0 (Buildroot 2020.05.2)) #1 SMP Sun Sep 6 17:05:07 CST 2020

[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d

[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

[ 0.000000] OF: fdt: Machine model: TI AM335x BeagleBone Black

[ 0.000000] Memory policy: Data cache writeback

[ 0.000000] cma: Reserved 16 MiB at 0x9e800000

[ 0.000000] CPU: All CPU(s) started in SVC mode.

[ 0.000000] AM335X ES2.1 (sgx neon)

[ 0.000000] random: get_random_bytes called from start_kernel+0x8c/0x4a8 with crng_init=0

[ 0.000000] percpu: Embedded 18 pages/cpu s42152 r8192 d23384 u73728

[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 129412

[ 0.000000] Kernel command line: console=ttyS0,115200n8 noinitrd root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait

[ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)

[ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)

[ 0.000000] Memory: 480012K/522240K available (8192K kernel code, 790K rwdata, 2620K rodata, 1024K init, 7473K bss, 25844K reserved, 16384K cma-reserved, 0K highmem)

[ 0.000000] Virtual kernel memory layout:

[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)

[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)

[ 0.000000] vmalloc : 0xe0000000 - 0xff800000 ( 504 MB)

[ 0.000000] lowmem : 0xc0000000 - 0xdfe00000 ( 510 MB)

[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)

[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)

[ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (9184 kB)

[ 0.000000] .init : 0x(ptrval) - 0x(ptrval) (1024 kB)

[ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 791 kB)

[ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) (7474 kB)

[ 0.000000] Running RCU self tests

[ 0.000000] rcu: Hierarchical RCU implementation.

[ 0.000000] rcu: RCU event tracing is enabled.

[ 0.000000] rcu: RCU lockdep checking is enabled.

[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.

[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1

[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16

[ 0.000000] IRQ: Found an INTC at 0x(ptrval) (revision 5.0) with 128 interrupts

[ 0.000000] OMAP clockevent source: timer2 at 24000000 Hz

[ 0.000021] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns

[ 0.000055] clocksource: timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns

[ 0.000113] OMAP clocksource: timer1 at 24000000 Hz

[ 0.000632] timer_probe: no matching timers found

[ 0.001591] Console: colour dummy device 80x30

[ 0.001651] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar

[ 0.001669] ... MAX_LOCKDEP_SUBCLASSES: 8

[ 0.001685] ... MAX_LOCK_DEPTH: 48

[ 0.001700] ... MAX_LOCKDEP_KEYS: 8191

[ 0.001715] ... CLASSHASH_SIZE: 4096

[ 0.001731] ... MAX_LOCKDEP_ENTRIES: 32768

[ 0.001746] ... MAX_LOCKDEP_CHAINS: 65536

[ 0.001761] ... CHAINHASH_SIZE: 32768

[ 0.001776] memory used by lock dependency info: 4655 kB

[ 0.001792] per task-struct memory footprint: 1536 bytes

[ 0.001882] Calibrating delay loop... 996.14 BogoMIPS (lpj=4980736)

[ 0.078547] pid_max: default: 32768 minimum: 301

[ 0.079009] Security Framework initialized

[ 0.079157] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)

[ 0.079181] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)

[ 0.082541] CPU: Testing write buffer coherency: ok

[ 0.082729] CPU0: Spectre v2: using BPIALL workaround

[ 0.084247] CPU0: thread -1, cpu 0, socket -1, mpidr 0

[ 0.086700] Setting up static identity map for 0x80100000 - 0x80100078

[ 0.087360] rcu: Hierarchical SRCU implementation.

[ 0.089542] smp: Bringing up secondary CPUs ...

[ 0.089575] smp: Brought up 1 node, 1 CPU

[ 0.089595] SMP: Total of 1 processors activated (996.14 BogoMIPS).

[ 0.089613] CPU: All CPU(s) started in SVC mode.

[ 0.093704] devtmpfs: initialized

[ 0.121117] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3

[ 0.121918] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns

[ 0.121995] futex hash table entries: 256 (order: 2, 16384 bytes)

[ 0.123687] pinctrl core: initialized pinctrl subsystem

[ 0.128929] NET: Registered protocol family 16

[ 0.136041] DMA: preallocated 256 KiB pool for atomic coherent allocations

[ 0.242858] audit: initializing netlink subsys (disabled)

[ 0.245763] cpuidle: using governor menu

[ 0.259929] audit: type=2000 audit(0.240:1): state=initialized audit_enabled=0 res=1

[ 0.261358] OMAP GPIO hardware version 0.1

[ 0.286936] No ATAGs?

[ 0.286963] hw-breakpoint: debug architecture 0x4 unsupported.

[ 0.287421] omap4_sram_init:Unable to allocate sram needed to handle errata I688

[ 0.287451] omap4_sram_init:Unable to get sram pool needed to handle errata I688

[ 0.325797] edma 49000000.edma: TI EDMA DMA engine driver

[ 0.332549] vgaarb: loaded

[ 0.333677] SCSI subsystem initialized

[ 0.335681] pps_core: LinuxPPS API ver. 1 registered

[ 0.335710] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti

[ 0.335766] PTP clock support registered

[ 0.340094] clocksource: Switched to clocksource timer1

[ 0.495688] VFS: Disk quotas dquot_6.6.0

[ 0.495898] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)

[ 0.523329] NET: Registered protocol family 2

[ 0.525671] tcp_listen_portaddr_hash hash table entries: 256 (order: 1, 10240 bytes)

[ 0.525764] TCP established hash table entries: 4096 (order: 2, 16384 bytes)

[ 0.525862] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)

[ 0.526425] TCP: Hash tables configured (established 4096 bind 4096)

[ 0.526830] UDP hash table entries: 256 (order: 2, 20480 bytes)

[ 0.526949] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)

[ 0.527378] NET: Registered protocol family 1

[ 0.530508] RPC: Registered named UNIX socket transport module.

[ 0.530596] RPC: Registered udp transport module.

[ 0.530615] RPC: Registered tcp transport module.

[ 0.530633] RPC: Registered tcp NFSv4.1 backchannel transport module.

[ 0.534019] hw perfevents: enabled with armv7_cortex_a8 PMU driver, 5 counters available

[ 0.539291] Initialise system trusted keyrings

[ 0.540617] workingset: timestamp_bits=14 max_order=17 bucket_order=3

[ 0.544081] NFS: Registering the id_resolver key type

[ 0.544270] Key type id_resolver registered

[ 0.544339] Key type id_legacy registered

[ 0.544525] jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.

[ 0.552777] Key type asymmetric registered

[ 0.553010] Asymmetric key parser 'x509' registered

[ 0.553198] io scheduler noop registered

[ 0.553224] io scheduler deadline registered

[ 0.553420] io scheduler cfq registered (default)

[ 0.553449] io scheduler mq-deadline registered

[ 0.553468] io scheduler kyber registered

[ 0.556308] pinctrl-single 44e10800.pinmux: 142 pins, size 568

[ 0.564527] Serial: 8250/16550 driver, 6 ports, IRQ sharing enabled

[ 0.577837] console [ttyS0] disabled

[ 0.578361] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 30, base_baud = 3000000) is a 8250

[ 1.263550] console [ttyS0] enabled

[ 1.300834] brd: module loaded

[ 1.332036] loop: module loaded

[ 1.337877] mtdoops: mtd device (mtddev=name/number) must be supplied

[ 1.347712] libphy: Fixed MDIO Bus: probed

[ 1.430036] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6, bus freq 1000000

[ 1.437790] davinci_mdio 4a101000.mdio: detected phy mask fffffffb

[ 1.448842] libphy: 4a101000.mdio: probed

[ 1.453168] davinci_mdio 4a101000.mdio: phy[2]: device 4a101000.mdio:02, driver SMSC LAN8710/LAN8720

[ 1.464158] cpsw 4a100000.ethernet: Detected MACID = 50:33:8b:36:25:8e

[ 1.471307] cpsw 4a100000.ethernet: initialized cpsw ale version 1.4

[ 1.477714] cpsw 4a100000.ethernet: ALE Table size 1024

[ 1.483144] cpsw 4a100000.ethernet: cpts: overflow check period 500 (jiffies)

[ 1.493916] i2c /dev entries driver

[ 1.501061] sdhci: Secure Digital Host Controller Interface driver

[ 1.507302] sdhci: Copyright(c) Pierre Ossman

[ 1.513185] omap_gpio 44e07000.gpio: Could not set line 6 debounce to 200000 microseconds (-22)

[ 1.522088] omap_hsmmc 48060000.mmc: Got CD GPIO

[ 1.528518] omap_hsmmc 48060000.mmc: Linked as a consumer to regulator.1

[ 1.563656] omap_hsmmc 481d8000.mmc: Linked as a consumer to regulator.1

[ 1.596014] sdhci-pltfm: SDHCI platform and OF driver helper

[ 1.603064] ledtrig-cpu: registered to indicate activity on CPUs

[ 1.612421] oprofile: using arm/armv7

[ 1.616886] Initializing XFRM netlink socket

[ 1.621945] NET: Registered protocol family 10

[ 1.631253] Segment Routing with IPv6

[ 1.635118] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver

[ 1.643241] NET: Registered protocol family 17

[ 1.647804] NET: Registered protocol family 15

[ 1.652822] Key type dns_resolver registered

[ 1.657290] ThumbEE CPU extension supported.

[ 1.661729] Registering SWP/SWPB emulation handler

[ 1.666562] omap_voltage_late_init: Voltage driver support not added

[ 1.673047] sr_dev_init: Unknown instance smartreflex0

[ 1.678674] SmartReflex Class3 initialized

[ 1.686896] Loading compiled-in X.509 certificates

[ 1.740089] mmc0: host does not support reading read-only switch, assuming write-enable

[ 1.751463] mmc0: new high speed SDHC card at address 0007

[ 1.767528] mmcblk0: mmc0:0007 SD32G 29.0 GiB

[ 1.778828] mmcblk0: p1 p2

[ 1.794956] random: fast init done

[ 1.821470] tps65217 0-0024: TPS65217 ID 0xe version 1.2

[ 1.827959] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz

[ 1.838611] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz

[ 1.846438] hctosys: unable to open rtc device (rtc0)

[ 1.851692] sr_init: No PMIC hook to init smartreflex

[ 1.864298] mmc1: new high speed MMC card at address 0001

[ 1.874688] mmcblk1: mmc1:0001 M62704 3.56 GiB

[ 1.881278] mmcblk1boot0: mmc1:0001 M62704 partition 1 2.00 MiB

[ 1.889015] mmcblk1boot1: mmc1:0001 M62704 partition 2 2.00 MiB

[ 1.897744] mmcblk1rpmb: mmc1:0001 M62704 partition 3 512 KiB, chardev (248:0)

[ 1.911400] mmcblk1: p1

[ 20.306804] EXT4-fs (mmcblk0p2): recovery complete

[ 20.317196] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)

[ 20.325839] VFS: Mounted root (ext4 filesystem) on device 179:2.

[ 20.333311] devtmpfs: mounted

[ 20.338534] Freeing unused kernel memory: 1024K

[ 20.344126] Run /sbin/init as init process

[ 20.463166] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)

Starting syslogd: OK

Starting klogd: OK

Running sysctl: OK

Saving random seed: [ 20.835541] random: dd: uninitialized urandom read (512 bytes read)

OK

Starting network: OK

Welcome to Buildroot

buildroot login: root

# ls

# cd /

# ls

bin lib media proc sbin usr

dev lib32 mnt root sys var

etc linuxrc opt run tmp

#

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值