How to boot Linux from Scratch on Beaglebone Black via SD card?
As the title suggests, I would like to boot LFS or some arbitrary GNU/Linux distribution on a Beaglebone Black from the microSD card. (To be clear, I have LFS compiled, and now I'd just like to be able to boot it.) There are any number of tutorials on how to boot from the microSD slot, but these tutorials all use wildly diverging methods and most are geared towards downloading off-the-shelf distributions where the boot procedure seems intertwined into the specific OS at hand. Not to mention, some of them are hard to follow and read like jerk textbooks, leaving the most common use cases as exercises to the reader, while highlighting esoteric things like TFTP.
We know that the following is needed MLO, u-boot.img, uEnv.txt, dtb, kernel, and so on. My question is how to make this work in 2019. What is to be done with the SD card? How is it to be partitioned? Some say to make a FAT partition (using some weird script that automagically finds some secret size) and put the u-boot related things there, others say to write it using dd to sectors < 2048 with brute force. I've tried both ways and nothing works. Secondly, can you use a stock kernel without recompiling? Compiling u-boot for BBB typically uses some bootz patches so is uImage not mandatory? In the config file I don't see anything enabling bootz, so I assumed it is. In short there are too many independent variables at work here to try tweaking one at a time. Has anyone actually done this, and if so, would you be so kind as to say what works? Thanks in advance. |
I have not done this, but i have just managed to get Archlinux ARM working on a Chromebook with similar hardware.
This tutorial explains how to get U-Boot on an SD card: https://archlinuxarm.org/platforms/a...ung-chromebook, although the supplied kernel probably will not work for your hardware. Also have you seen this: http://www.bootembedded.com/embedded...glebone-black/ which i think explains it quite well. and this: http://beagleboard.org/getting-started which gives you a pre-made version of Debian. Hope this helps, Eric. |
Thank you for those links - despite searching with several engines the 'bootembedded' technique never showed up for me. Long story short, I actually got this to work by following this method using a pre-made Ubuntu image. The primary issues are that they do not provide sources for u-boot or explain how it was compiled (patched or not), nor is it specified how the kernel was made. (By this, I do not mean the .config file, but rather what was run on the command line after "make.")
In terms of physically getting the BeagleBone to boot from the sd card, I had some trouble. The tutorials say just to press and hold the S2 button - which itself is a chore - while applying power. I use a 5V transformer and this was not happening. I found I had to do something like this - Press and hold S2 for about 3 seconds - Plug in transformer - Keep holding S2 for another 3 seconds - Wait another 3 seconds - Unplug transformer and wait 5-10 seconds - Plug in transformer (and do not press S2) and then at the very least it would attempt to do something. There are several versions of u-boot as well as partition layouts described in the tutorials. The partitioning script described on the gentoo wiki is not the least bit self-evident and seems not necessary. Whether or not you need to recompile the kernel depends on how you configure u-boot. U-boot in itself expects a uImage to be present. Patching u-boot with the patch mentioned below introduces a 'bootz' method capable of booting a zImage. When you build a kernel using most normal methods, you'll end up with a bzImage which won't work. Furthermore, the mentioned patch does not require bootz to be declared in the uEnv.txt. There is also confusion over whether you need u-boot.img or u-boot.bin. U-boot instructions, to build natively on the Beaglebone Black (not cross-compiled). Code:
# Get u-boot (use this version) and the corresponding patch: Make a fat32 file system in the first partition, and ext4 for the second (I've not tested ext3 yet). In the first partition (fat32), the structure should be like this: MLO u-boot.img uEnv.txt MLO and u-boot.img are copied from the parent directory of the u-boot source tree, which were built in the above step. uEnv is a plain text file which from the above ubuntu method contains the following: Code:
optargs= We get by using just these three files, because uEnv.txt specifies that the other files can be placed in the /boot directory of the OS, on the second partition. So, in the OS /boot directory, we can have The kernel stuff: config-xxx System.map-xxx vmlinuz-xxx (!) zImage <- where this is a symlink to vmlinuz-xxx Also in /boot, we have a subdirectory entitled dtbs. In the ubuntu tutorial, they include the entire contents of this directory found on the stock OS. I find that we can just get by using the am335x_boneblack file, see below. Also, in /boot, an empty directory entitled uboot. This directory is intentionally left empty as the first partition can be mounted in here via the OS's /etc/fstab file. Now for the kernel. If you use the patched u-boot, you can just use a zImage kernel, otherwise you'll need uImage. Building the kernel is generally straightforward if you have the appropriate sources and .config file. However this is not enough - you need to specify a LOADADDR when 'make' is run. For the Beaglebone Black, this is 0x80008000. You also must specify that the dtbs file gets built. So we configure the kernel as usual and then run 'make' like this: Code:
make zImage dtbs LOADADDR=0x80008000 Then build the modules, but do not install them Code:
make modules The zImage | uImage is in arch/arm/boot. zImage can be renamed as vimlinuz-xxx and placed in your /boot directory. Then create the symlink entitled zImage pointing to this kernel image. The dtbs file is in arch/arm/boot/dts. This should be reasonably OK, though I'm not too comfortable with the uEnv.txt. I will try the bootembedded method and see how that goes. |
All times are GMT -5. The time now is 08:56 PM. |