Build Image for Beaglebone back using Yocto Project
Beaglebone Black is a low-cost ARM Cortex-A8-based development board. it gives the flexibility to boot from SD card or onboard emmc. Yocto Project officially supports the beaglebone black board and provides minimal bootable BSP support for beaglebone board.
Follow the below steps and create the custom image for beaglebone black board using the Yocto Project.
- Download Poky
- Setup build environment
- Set machine name in local.conf
- Start bitbake to build the image
- Created SD card Partition
- Copy generated image in SD card partition
Follow the below points to prepare your host system for Yocto Project development. I am using ubuntu 16.04 LTS for this tutorial.
- You need an ubuntu-based host pc with a minimum of 50 GB free disk space.
- Internet connection is required to download the packages on local disk and reuse for the later build process.
# Install the below required package on your host machine sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping libsdl1.2-dev xterm
Poky is the Yocto reference distribution.
# Clone the poky with the below command. $ git clone git://git.yoctoproject.org/poky
Setup build environment
Run the "oe-init-build-env" script with the below command from the poky directory and it will auto-create the build directory. Now your current working directory would be the build directory.
# Setup the environment $source oe-init-build-env
Set machine name in local.conf
We are building the image for the beaglebone black board so you need to set the machine name in conf/local.conf
- local.conf is auto-generated inside build/conf location.
- This file is used for the user-based configuration.
#Open local.conf file $ vim conf/local.conf #For Beaglebone, machine variable should be beaglebone-yocto MACHINE ??= “beaglebone-yocto”
Start bitbake to build the image
Bitbake is a task executor in the Yocto Project.
- core-minimal-image recipe provides the minimal bootable image for the beaglebone black.
- Now we are ready to lunch bitbake (Yocto build engine) to create the image. it takes several hours to complete the build also depends on your internet speed.
- Once the build is completed successfully, you will get the image, root file system, and device tree file at the build/tmp/deploy/images/beaglebone-yocto/ directory.
# Run bitbake $ bitbake core-minimal-image
Create SD card Partition to boot the board
Create the partition in the SD card and copy the generated file in those partitions.
You can use GParted to create the partition.
- Create the first partition with the following details.
- Name of the partition - BOOT
- Size - 150 MB.
- Flag - Set the boot flag
- Type - FAT32
- Create 2nd partition with the below details.
- Name of the partition - ROOT.
- Size - greater than 1024 MB or remaining space of SD card.
- Type- ext4
Copy generated image in SD card partition
Make sure your SD card is mounted on the host pc and you can access both SD card partitions.
# copy files from build/tmp/deploy/images/beaglebone-yocto/ to SD card boot and root partition. cp MLO-beaglebone-yocto /media/tutorialadda/BOOT/ cp u-boot.img /media/tutorialadda/BOOT/ sudo tar -xvf core-image-minimal-beaglebone-yocto.tar.bz2 /media/tutorialadda/ROOT/
Follow the below steps and boot the board with your Custom Linux image.
- Insert SD card into beaglebone black card slot.
- Connect the serial cable to monitor bootup logs and login to beaglebone black.
- Press the S2 button while connecting power to beagle bone.
You will get the bootup log on the serial console.
Poky (Yocto Project Reference Distro) 2.6.4 beaglebone /dev/ttyUSB0 beaglebone login: root root@beaglebone:~#