Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 02-10-2019, 05:36 PM   #1
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 242

Rep: Reputation: 46
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.
Old 02-11-2019, 12:13 PM   #2
LQ Newbie
Registered: Feb 2019
Distribution: Debian, Voyager GS
Posts: 22

Rep: Reputation: Disabled
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:, although the supplied kernel probably will not work for your hardware.
Also have you seen this: which i think explains it quite well.
and this: which gives you a pre-made version of Debian.

Hope this helps,
1 members found this post helpful.
Old 02-11-2019, 02:02 PM   #3
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 242

Original Poster
Rep: Reputation: 46
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).

# Get u-boot (use this version) and the corresponding patch:


tar -xjf u-boot-2015.10.tar.bz2
cd u-boot-2015.10
patch -Np1 -i ../0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
make distclean
make am335x_boneblack_config
Now partition the sd card. The first partition is for u-boot while the second is your OS file system. Use fdisk to make these partitions, with the first beginning at 2048 and end at 4095 - yes, that small... The next can be whatever size you need for your OS but it should begin on the next sector, 4096. You can also have more partitions if they are needed.

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 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:

loadfdt=load mmc ${mmcdev}:2 ${fdtaddr} /boot/dtbs/${fdtfile}
loaduimage=mw.l 4804c134 fe1fffff; if load mmc 0:2 ${loadaddr} /boot/zImage; then setenv mmcdev 0; mw.l 4804c194 01200000; echo Booting from external microSD...; else setenv mmcdev 1; if test $mmc0 = 1; then setenv mmcroot /dev/mmcblk1p2 rw; fi; load mmc 1:2 ${loadaddr} /boot/zImage; mw.l 4804c194 00c00000; echo Booting from internal eMMC...; fi
mmcboot=run mmcargs; bootz ${loadaddr} - ${fdtaddr}
uenvcmd=i2c mw 0x24 1 0x3e; run findfdt; if test $board_name = A335BNLT; then setenv mmcdev 1; mmc dev ${mmcdev}; if mmc rescan; then setenv mmc1 1; else setenv mmc1 0; fi; fi; setenv mmcdev 0; mmc dev ${mmcdev}; if mmc rescan; then setenv mmc0 1; else setenv mmc0 0; fi; run loaduimage && run loadfdt && run mmcboot
In other words, you won't figure that out on your own by reading uBoot or TI documentation, and anyone who wants this posted outright must be immoral and illegally got paid to do some sixth grader's science project for him. But seriously, the goal here is to boot the Beaglebone Black in a similar manner as with the stock operating system, connected to the network, and logged in via ssh. Yet none of the tutorials other than the bootembedded even seem to give reasonable hints.

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:
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:

make zImage dtbs LOADADDR=0x80008000
Replace zImage with uImage if needed. Or just use uImage as it also build zImage.

Then build the modules, but do not install them

make modules
make INSTALL_MOD_PATH=/some/directory modules_install
The last command places the modules in a directory of your choosing; you can zip this up in a tar archive and extract in your target OS.

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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
u-boot not reading uEnv.txt file from SDCard on Beaglebone black olaoni Linux - Embedded & Single-board computer 1 12-21-2017 09:30 PM
Custom linux kernel does not boot on Beaglebone black mrigendra Linux - Newbie 1 07-17-2016 08:05 AM
I have to run my own u-boot loader instead of default u-boot loader of BeagleBone Black Amolp Linux - Embedded & Single-board computer 2 06-23-2016 02:12 PM
LXer: Introducing the BeagleBone Black’s Linux 3.8 kernel LXer Syndicated Linux News 0 05-24-2013 02:40 AM
ali aladdin v agp stinks :scratch: :scratch: :scratch: Mr Marmmalade Linux - Hardware 1 07-08-2003 06:11 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 02:34 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration