Beagle Black SD卡啟動問題
雖然BBB是開源硬體,但坑也是比較多的,還好資料和用的人也比較多,暫時還都能找到問題所在。吐槽完了來看下SD啟動的這個問題。
看了之前關於BBB啟動方式的文章應該比較清楚,在eMMC已經寫入系統的前提下(出廠已寫入系統),要想從SD卡啟動需要在啟動時按著boot健(S2),Get Started網頁和System Reference上面也都是這也說的。這種操作當然沒錯,但實際使用中發現即使不按S2,最終啟動的也是SD卡中的核心,這就奇怪了,接上UART0,看看啟動中發生了什麼
U-Boot SPL 2017.09-00002-g0f3f1c7907 (Oct 09 2017 - 15:30:22) Trying to boot from MMC1 U-Boot 2017.09-00002-g0f3f1c7907 (Oct 09 2017 - 15:30:22 -0500), Build: jenkins-github_Bootloader-Builder-607 CPU : AM335X-GP rev 2.1 I2C: ready DRAM: 512 MiB No match for driver 'omap_hsmmc' No match for driver 'omap_hsmmc' Some drivers were not found Reset Source: Power-on reset has occurred. MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1 Using default environment Board: BeagleBone Black <ethaddr> not set. Validating first E-fuse MAC BeagleBone Black: BeagleBone: cape eeprom: i2c_probe: 0x54: BeagleBone: cape eeprom: i2c_probe: 0x55: BeagleBone: cape eeprom: i2c_probe: 0x56: BeagleBone: cape eeprom: i2c_probe: 0x57: Net: eth0: MII MODE cpsw Press SPACE to abort autoboot in 2 seconds board_name=[A335BNLT] ... board_rev=[00C0] ... switch to partitions #0, OK mmc0 is current device SD/MMC found on device 0 ** Bad device 0:2 0x82000000 ** ** Bad device 0:2 0x82000000 ** switch to partitions #0, OK mmc0 is current device Scanning mmc 0:1... gpio: pin 56 (gpio 56) value is 0 gpio: pin 55 (gpio 55) value is 0 gpio: pin 54 (gpio 54) value is 0 gpio: pin 53 (gpio 53) value is 1 switch to partitions #0, OK mmc0 is current device gpio: pin 54 (gpio 54) value is 1 Checking for: /uEnv.txt ... Checking for: /boot.scr ... Checking for: /boot/boot.scr ... Checking for: /boot/uEnv.txt ... gpio: pin 55 (gpio 55) value is 1 2045 bytes read in 35 ms (56.6 KiB/s) Loaded environment from /boot/uEnv.txt Checking if uname_r is set in /boot/uEnv.txt... gpio: pin 56 (gpio 56) value is 1 Running uname_boot ... loading /boot/vmlinuz-4.4.91-ti-r133 ... 8886912 bytes read in 588 ms (14.4 MiB/s) uboot_overlays: [uboot_base_dtb=am335x-boneblack-uboot.dtb] ... uboot_overlays: Switching too: dtb=am335x-boneblack-uboot.dtb ... loading /boot/dtbs/4.4.91-ti-r133/am335x-boneblack-uboot.dtb ... 53192 bytes read in 130 ms (399.4 KiB/s) uboot_overlays: [fdt_buffer=0x60000] ... uboot_overlays: loading /lib/firmware/AM335X-20-00A0.dtbo ... 378 bytes read in 271 ms (1000 Bytes/s) uboot_overlays: loading /lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo ... 1105 bytes read in 114 ms (8.8 KiB/s) uboot_overlays: loading /lib/firmware/BB-HDMI-TDA998x-00A0.dtbo ... 4169 bytes read in 277 ms (14.6 KiB/s) uboot_overlays: loading /lib/firmware/BB-ADC-00A0.dtbo ... 695 bytes read in 428 ms (1000 Bytes/s) uboot_overlays: loading /lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo ... 2402 bytes read in 479 ms (4.9 KiB/s) uboot_overlays: loading /lib/firmware/univ-bbb-EVA-00A0.dtbo ... 54575 bytes read in 62 ms (859.4 KiB/s) loading /boot/initrd.img-4.4.91-ti-r133 ... 5416133 bytes read in 369 ms (14 MiB/s) debug: [console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet] ... debug: [bootz 0x82000000 0x88080000:52a4c5 88000000] ... ## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Loading Ramdisk to 8fad5000, end 8ffff4c5 ... OK reserving fdt memory region: addr=88000000 size=75000 Loading Device Tree to 8fa5d000, end 8fad4fff ... OK Starting kernel ... [ 0.001537] clocksource_probe: no matching clocksources found [ 2.115874] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle [ 2.354197] omap_voltage_late_init: Voltage driver support not added [ 2.362673] PM: Cannot get wkup_m3_ipc handle Debian GNU/Linux 9 beaglebone ttyS0 BeagleBoard.org Debian Image 2017-10-10 Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian default username:password is [debian:temppwd] beaglebone login:
上面是按下S2鍵的情況下的啟動資訊,可以看到直接啟動SD卡中的UBOOT(2017),然後啟動SD卡中核心。下面看看不按S2鍵的啟動資訊
U-Boot SPL 2016.01-00001-g4eb802e (Jan 13 2016 - 11:14:31) Trying to boot from MMC bad magic U-Boot 2016.01-00001-g4eb802e (Jan 13 2016 - 11:14:31 -0600), Build: jenkins-github_Bootloader-Builder-313 Watchdog enabled I2C: ready DRAM: 512 MiB Reset Source: Power-on reset has occurred. MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1 Using default environment Net: <ethaddr> not set. Validating first E-fuse MAC cpsw, usb_ether Press SPACE to abort autoboot in 2 seconds switch to partitions #0, OK mmc0 is current device Scanning mmc 0:1... gpio: pin 56 (gpio 56) value is 0 gpio: pin 55 (gpio 55) value is 0 gpio: pin 54 (gpio 54) value is 0 gpio: pin 53 (gpio 53) value is 1 switch to partitions #0, OK mmc0 is current device gpio: pin 54 (gpio 54) value is 1 Checking for: /uEnv.txt ... Checking for: /boot.scr ... Checking for: /boot/boot.scr ... Checking for: /boot/uEnv.txt ... gpio: pin 55 (gpio 55) value is 1 2045 bytes read in 36 ms (54.7 KiB/s) Loaded environment from /boot/uEnv.txt Checking if uname_r is set in /boot/uEnv.txt... gpio: pin 56 (gpio 56) value is 1 Running uname_boot ... loading /boot/vmlinuz-4.4.91-ti-r133 ... 8886912 bytes read in 513 ms (16.5 MiB/s) loading /boot/dtbs/4.4.91-ti-r133/am335x-boneblack.dtb ... 56891 bytes read in 149 ms (372.1 KiB/s) loading /boot/initrd.img-4.4.91-ti-r133 ... 5416133 bytes read in 325 ms (15.9 MiB/s) debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet] ... debug: [bootz 0x82000000 0x88080000:52a4c5 0x88000000] ... Kernel image @ 0x82000000 [ 0x000000 - 0x879a80 ] ## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Loading Ramdisk to 8fad5000, end 8ffff4c5 ... OK Loading Device Tree to 8fac4000, end 8fad4e3a ... OK
可以看到,先啟動了eMMC中的UBOOT(2016),然後出現了mmc0 is current device,mmc0就是SD卡,也就是啟動的是eMMC中的UBOOT,然後又跳轉到SD卡啟動了核心。Google了一下,在Github中(https://github.com/victronenergy/venus/wiki/bbb-boot-process-overview)對此問題有明確的解釋
Note
By default, the BBB u-boot always looks for a kernel and DTS from the SD card (MMC0) before the eMMC (MMC1) regardless of the boot device that MLO and u-boot.img loaded from.
This is a new 'feature' in u-boot.
This feature does allows for testing new kernels and rootfs systems without having to install onto the eMMC.
On the downside, every eMMC boot is now slowed slightly as u-boot looks for a kernel and DTS on the SD card, fails when there is no card present or it can't find a zImage or dts, and then tries again from the eMMC.
Disabling this behavior requires a rebuild of u-boot.
大意就是說這是UBOOT的新特性,為了利用SD卡除錯方便,不管是從eMMC還是SD卡中啟動的UBOOT,都會優先啟動SD卡中的核心。次文件發表時間是2015年11月11日,但具體是從哪個版本的UBOOT開始還沒查到可靠資料。對於此問題也有其它國外論壇在討論,並且有大神給出瞭如下啟動圖
感想:這種開源非盈利性的東西,雖然資料很多,但出現了這麼大的改動也沒人把更新到文件中。