Sunday 10 April 2016

Build Root for Beagle Bone

1. Download build root from http://buildroot.uclibc.org/download.html
For this instructions I’m using buildroot version 2014.08. Any version of buildroot that has the beagle bone config file “beaglebone_defconfig” in the configs/ folder of buildroot will work for these instructions.
2. Untar the downloaded buildroot file – “tar xf buildroot-2014.08.tar.gz
3. Now issues the commands to setup the build system
“cd buildroot-2014.08”
“make beaglebone_defconfig”
4.  By default buildroot builds the zImage which is the compressed version of then kernel image file. U-boot bootloader is capable of reading a uImage file and loading the kernel to memory. Hence it is necessary to change the output kernel image to uImage. Follow these instructions to make the change
“make menuconfig”
You will be given a graphical menu that you can navigate with the keyboard to selection various options. To change the kernel image format to uImage go to navigate down to “Kernel —>” and select it. Now go to “Kernel binary format” and use the arrow keys to select “uImage”. Now return to the main screen and exit. Make sure to save the settings before exiting.
5. Its time to do the build. Run the following command to start the build.
“make”
Sit back and relax. The build will take about 30 to 45 minutes depending on your computer. If you run into any errors about missing packages then you need to install the missing packages on your development system. If you development system is running Ubuntu then do “sudo apt-get install <package name>” or if the system is running Fedora then do “sudo yum install <package name>” to install the appropriate package.
4. Once the build is complete you will find the following files in output/images folder
uImage – Kernel image file
rootfs.ext2 – The root file system in ext2 file system saved as a file
am335x-boneblack.dtb and am335x-bone.dtb – Device tree file
MLO – A special file loaded to memory by the bootrom to initialize the hardware
5. Now it is time to copy the files to a sd card and boot the beagle bone black with the images just built.
6. The microsd card needs to be formatted with 2 active partitions. Partition 1 should be formatted as a FAT32 file system and partition 2 as a ext2 file system. Partition 1 will contain the kernel image and device tree file. Partition 2 will have the root file system. Use either fdisk or gparted to partition the sd card.
7. Create a folder in partition 1 called “boot” and copy uImage and am335x-boneblack.dtb files to this folder.
8. To copy the root filesystem to partition 2 use the following command
“sudo dd if=output/images/rootfs.ext2 of=/dev/sdb2”
Here roots.ext2 is the root file system image file and /dev/sdb2 is the sd card partition 2.
9. Now you are all set to boot the beagle bone. Place the sd card in the beagle bone and power it on.
10. Break into u-boot console by pressing any key as the beagle bone boots. By default the beagle bone is going to boot the u-boot image present in the eMMC storage.
11. Use the following commands to copy the kernel image and device tree file to memory
“fatload mmc 0 ${kloadaddr} boot/uImage”
“fatload mmc 0 ${fdtaddr} boot/am335x.dtb”
The above commands read the files from boot/ folder of the sdcard and copies it to memory address referenced in kloadaddr and fdtaddr.
12. Do “run mmcargs” to set up the boot arguments or bootargs. Boot arguments are passed to the kernel very similar to command line arguments for user applications. The bootargs should contain the path to the root file system and in the present case the root file system present in the sd card. After running “run mmcargs” command do “printenv” to ensure the “bootargs” variable is set correctly. “bootargs” should be “console=ttyO0,115200n8 root=/dev/mmcblk0p2 ro rootfstype =ext4 rootwait”
13. Now just run command “boot” to boot the beagle bone. By default the root file system contains a user “root” with no password.

Friday 8 April 2016

Building Cross Toolchain using ptxdist

Goto http://www.pengutronix.com/software/ptxdist/download/ and download ptxdist-2014.12.0.tar.bz2

cd ptxdist-2014.12.0

./configure --prefix=/home/Sajith/Documents/ptxdistconfig

make

sudo make install

export PATH=$PATH:/home/Sajith/Documents/ptxdistconfig/bin

download OSELAS.Toolchain-2014.12.2.tar.bz2 from http://www.pengutronix.de/oselas/toolchain/download/OSELAS.Toolchain-2014.12.2.tar.bz2


tar xvfj OSELAS.Toolchain-2014.12.2.tar.bz2

cd OSELAS.Toolchain-2014.12.2

ptxdist select ptxconfigs/arm-v5te-linux-gnueabi_gcc-4.9.2_glibc-2.20_binutils-2.24_kernel-3.16-sanitized.ptxconfig

ptxdist go

you can see the cross toolchain in \opt\oseleas folder