Dev/BeagleBone/BBB/From Scratch

From Embeded Linux (and more) Wiki by Nathael
< Dev‎ | BeagleBone‎ | BBB
Jump to navigation Jump to search

u-boot

Full [processors.wiki.ti.com/index.php/AM335x_U-Boot_User's_Guide AM335x U-Boot User's Guide] on ti wiki.

Grab the sources

git clone git://git.denx.de/u-boot.git
cd u-boot/
git checkout v2017.03

Optional :

git checkout -b new_branch
(Replace "new_branch" with the name of your choice !)

Patches:

wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.10/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Patched sources can be recovered on my server : uboot_***.tar.bz2.

Compile

Configure and Build:

mkdir -p ../Build/uboot/ ../Build/results/
rm -rf ../Build/uboot/*
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=../Build/uboot/ distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=../Build/uboot/ am335x_boneblack_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=../Build/uboot/ -j 8
cp ../Build/uboot/MLO ../Build/uboot/u-boot.img ../Build/results/

The resulting binaries are part of the results.tar.bz2 archive on my server.

You need both binaries as the BeagleBone Black processor (Texas Instrument AM335x), in SD card boot mode, will look for a file named "MLO", which must fit on the only available memory at this point : the instruction cache (128k minus 19k reserved for boot rom).

MLO stand for "Memory Locator" and is a "Secondary Program Loader (SPL)". It is in fact a reduced "1st stage" u-boot image, which in turns looks for a file named "u-boot.img" which the "2nd stage" uboot.

When always booting in the same known configuration it is possible to avoid the second stage u-boot and change the MLO configuration to look for a fixed name Linux kernel image and device tree and immediately load and run these instead.

Use

The MLO file must be on the first partition of the µSD card, which must be formated as FAT32 and flaged as bootable.

Configuration

Create the file ../Build/results/uEnv.txt
An example file can be found in the results.tar.bz2 archive on my server.

Linux Kernel

Grab the sources

FIXME : Must be updated to a newer kernel !! (At least the 4.4.1 I'm currently using)

using information from Robert C Nelson or Mainline Linux on the Beaglebone Black

Sources :

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Extract specific version ***FIXME***

git checkout ***

Optional (creates a new local branch) :

git checkout -b new_branch

Compilation

Create build dir and copy default config

cd linux
mkdir -p ../Build/kernel
cp config_nath_**** ../Build/kernel/.config
make ARCH=arm O=../Build/kernel/ oldconfig

Optional : make menuconfig (for example to change the cross-compiler prefix : arm-linux-gnueabihf-)

make ARCH=arm O=../Build/kernel/ menuconfig

Build kernel

make -j 8 ARCH=arm O=../Build/kernel/ zImage

Build device tree blobs

make -j 8 ARCH=arm O=../Build/kernel/ dtbs

Get the results :

cp ../Build/kernel/arch/arm/boot/zImage ../Build/kernel/arch/arm/boot/dts/am335x-boneblack.dtb ../Build/results/

Build and install modules

make -j 8 ARCH=arm O=../Build/kernel/ modules
make -j 8 ARCH=arm O=../Build/kernel/ modules_install INSTALL_MOD_PATH=../results/

Device Tree

Refer to "Build device tree blob" in the previous section.

Firmwares

make -j 8 ARCH=arm O=../Build/kernel/ firmware
make -j 8 ARCH=arm O=../Build/kernel/ firmware_install INSTALL_FW_PATH=../results/lib/firmware

Still required ??

wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O ../results/lib/firmware/am335x-pm-firmware.bin

SD Card creation

Rootfs