bbb板子上自带2G eMMC, 但是对很多应用来说, 容量还是远远不够, 于是我想用sd卡扩展空间, 但是发现一插入sd卡, 板子就启动不了啦, 去google了一下原因, 原来bbb的原生系统所带的uboot启动的时候如果发现有sd卡, 则sd卡会变成mmc0, eMMC则变成mmc1, 导致启动失败, 于是搜了很多资料, 努力了一个晚上终于搞定这个问题....
首先你需要一张microSD卡, 一个读卡器, 我用的是笔记本自带的, 启动ubuntu(或者别的linux系统, windows不行), 把sd卡插进读卡器里, 输入
fdisk -l
查看一下当前sd卡设备的名称, 我的是mmcblk0, 于是
fdisk /dev/mmcblk0
进行分区, 使用命令 d 删除sd卡上目前存在的所有分区, 使用n 命令分别创建2个分区, 第一个小一点的, 大概几十m就可以了, 用作启动区, 第二个分区就是剩下的所有空间, 最后输入w命令写入分区表, 如果不熟悉fdisk命令的话可以去找百度看一下.
接下来使用mkfs命令分别格式化两个分区:
mkfs -t vfat -F 16 -n boot /dev/mmcblk0p1
mkfs -V -t ext4 -j -L data /dev/mmcblk0p2
两个分区命名为boot 跟 data, 第一个是fat16格式的, 第二个是ext4格式的, 接下来挂载第一个分区到根目录下, 并在上面创建一个文件uEnv.txt , 将下面几行内容写进去:
mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro
optargs=quiet
保存后umount, 把sd卡拿出来, 插到BBB板子上, 最后上电, 启动成功!!
我刚开始的时候只是google到uEnv.txt以及它的内容, 没有注意使用fdisk以及mkfs制作启动sd卡, 插进BBB板子后启动失败, 看串口调试信息显示:
Bad partition specification mmc 1:2
于是查了半天终于发现是sd卡的分区不对, 用以上方法制作成功后, 串口观察启动过程:
U-Boot SPL 2013.04-dirty (Jun 19 2013 - 09:57:14)
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Peripheral mode controller at 47401000 using PIO, IRQ 0
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Host mode controller at 47401800 using PIO, IRQ 0
OMAP SD/MMC: 0
mmc_send_cmd : timeout: No status update
reading u-boot.img
reading u-boot.img
U-Boot 2013.04-dirty (Jun 19 2013 - 09:57:14)
I2C: ready
DRAM: 512 MiB
WARNING: Caches not enabled
NAND: No NAND device found!!!
0 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
*** Warning - readenv() failed, using default environment
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Peripheral mode controller at 47401000 using PIO, IRQ 0
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Host mode controller at 47401800 using PIO, IRQ 0
Net: not set. Validating first E-fuse MAC
cpsw, usb_ether
Hit any key to stop autoboot: 1 0
gpio: pin 53 (gpio 53) value is 1
mmc0 is current device
micro SD card found
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
SD/MMC found on device 0
reading uEnv.txt
62 bytes read in 2 ms (30.3 KiB/s)
Loaded environment from uEnv.txt
Importing environment from mmc ...
gpio: pin 55 (gpio 55) value is 1
mmc_send_cmd : timeout: No status update
4270840 bytes read in 746 ms (5.5 MiB/s)
gpio: pin 56 (gpio 56) value is 1
24129 bytes read in 51 ms (461.9 KiB/s)
Booting from mmc ...
## Booting kernel from Legacy Image at 80007fc0 ...
Image Name: Angstrom/3.8.13/beaglebone
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4270776 Bytes = 4.1 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
## Flattened Device Tree blob at 80f80000
Booting using the fdt blob at 0x80f80000
XIP Kernel Image ... OK
OK
Using Device Tree in place at 80f80000, end 80f88e40
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
[ 0.194032] omap2_mbox_probe: platform not supported
[ 0.204621] tps65217-bl tps65217-bl: no platform data provided
[ 0.281250] bone-capemgr bone_capemgr.8: slot #0: No cape found
[ 0.318357] bone-capemgr bone_capemgr.8: slot #1: No cape found
[ 0.355465] bone-capemgr bone_capemgr.8: slot #2: No cape found
[ 0.392574] bone-capemgr bone_capemgr.8: slot #3: No cape found
[ 0.412614] bone-capemgr bone_capemgr.8: slot #6: BB-BONELT-HDMIN conflict P8.45 (#5:BB-BONELT-HDMI)
[ 0.422237] bone-capemgr bone_capemgr.8: slot #6: Failed verification
[ 0.429015] bone-capemgr bone_capemgr.8: loader: failed to load slot-6 BB-BONELT-HDMIN:00A0 (prio 2)
[ 0.451672] omap_hsmmc mmc.4: of_parse_phandle_with_args of 'reset' failed
[ 0.516043] pinctrl-single 44e10800.pinmux: pin 44e10854 already requested by 44e10800.pinmux; cannot claim for gpio-leds.7
[ 0.527764] pinctrl-single 44e10800.pinmux: pin-21 (gpio-leds.7) status -22
[ 0.535082] pinctrl-single 44e10800.pinmux: could not request pin 21 on device pinctrl-single
[ 6.375621] libphy: PHY 4a101000.mdio:01 not found
[ 6.380726] net eth0: phy 4a101000.mdio:01 not found on slave 1
systemd-fsck[85]: Angstrom: clean, 50623/112672 files, 325594/449820 blocks
.---O---.
| | .-. o o
| | |-----.-----.-----.| | .----..-----.-----.
| | | __ | ---'| '--.| .-'| | |
| | | | | |--- || --'| | | ' | | | |
'---'---'--'--'--. |-----''----''--' '-----'-'-'-'
-' |
'---'
The Angstrom Distribution beaglebone ttyO0
Angstrom v2012.12 - Kernel 3.8.13
beaglebone login:
红字就是读sd卡配置环境文件uEnv.txt的过程, 因为插入sd卡后设备号有变动, 因此实际上这个方法是把root重新定义了回去, 使得系统能正确找到zImage的位置.