VAR-SOM-AM33 Yocto GS: Difference between revisions

From Variscite Wiki
m (Text replacement - "http://variwiki" to "https://variwiki")
 
(121 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{PageHeader|VAR-SOM-AM33 Yocto package User's Guide}}
{{PageHeader|VAR-SOM-AM33 Yocto 1.4 (Dylan) Distribution User's Guide}}
{{DocImage|category1=VAR-SOM-AM33|category2=Yocto}}
{{DocImage|category1=VAR-SOM-AM33|category2=Yocto}}
__toc__
__toc__
= About this Manual =
= About this Manual =


[[File:Const.jpg]] This document describes how to install Variscite's Yocto release for the VAR-SOM-AM33.
This document describes how to install Variscite's Yocto release for the VAR-SOM-AM33.


The Yocto package provides a fundamental software platform for development, deployment and execution on VAR-SOM-AM33. It abstracts the functionality provided by the hardware.
The Yocto distribution provides a fundamental software platform for development, deployment and execution on VAR-SOM-AM33. It abstracts the functionality provided by the hardware.


In this context, the document contains instructions to:
In this context, the document contains instructions to:
Line 19: Line 19:
== Prerequisites ==
== Prerequisites ==


Before starting the installation of the package, make sure below system requirements are met:
Before starting the installation, make sure below system requirements are met:


*Host machine running a version of Windows OS such as Windows XP / 7 or a Linux such as Ubuntu.
*Host machine running a Ubuntu 12.04 64 LTS.
*[T.B.D] - VAR-SOM-AM33 Evaluation Kit + sources and binaries. Please refer to support@variscite.com for obtaining FTP credentials.
*[http://www.variscite.com/products/evaluation-kits/var-dvk-am33 VAR-SOM-AM33 Evaluation Kit] + VAR-SOM-AM33 Yocto support installation sources and binaries (from FTP). Please refer to support@variscite.com for obtaining FTP credentials.


<br/>The Linux host is used for the following:  
<br/>The Linux host is used for the following:  
Line 33: Line 33:
*Running a serial console terminal application
*Running a serial console terminal application


Variscite Yocto release consists of&nbsp;: <br/>
 
Building the Yocto distribution via Bitbake will produce a complete set of downloaded source code + binaries for each component: <br/>
*Yocto build environment
*Yocto build environment
*Linux kernel source code
*Downloaded Linux kernel source code + build kernel binaries (DTB and zImage) for VAR-SOM-AM33.
*U-Boot source code
*Downloaded U-Boot source code + build U-boot binaries (MLO and U-boot) for VAR-SOM-AM33.
*Linux root file-system binaries examples.
*Linux root file-system.


=== Install the Arago toolchain ===
=== Install the Arago toolchain ===
<pre>
<pre>
$ wget --no-check-certificate https://launchpad.net/linaro-toolchain-binaries/trunk/2013.03/+download/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2
$ wget --no-check-certificate https://launchpad.net/linaro-toolchain-binaries/trunk/2013.03/+download/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2
$ tar -jxvf gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2 -C $HOME
$ sudo tar -jxvf gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2 -C /opt
</pre>
</pre>


=== Install development tools ===
=== Install development tools ===
  $ sudo apt-get install git build-essential diffstat texinfo gawk chrpath
  $ sudo apt-get install git build-essential diffstat texinfo gawk chrpath gcc-multilib ia32-libs
 
===  Install 32-bit support libraries ===
If you are using a 64-bit Linux, then you'd also need to install 32-bit support libraries, needed by the pre-built Linaro toolchain and other binary tools, as follows:
$ sudo apt-get install ia32-libs


=== Download the Yocto package ===
=== Download the Yocto Distribution ===
To quickly start making your own builds using meta-ti BSP layer and meta-arago Distribution layer, you can follow this short Quick Start section by entering below commands. For  
To quickly start making your own builds using meta-ti BSP layer and meta-arago Distribution layer, you can follow this short Quick Start section by entering below commands. For  
more expanded guide with each step detailed and sample output of the entered commands shown, please see the next Detailed Setup section.  
more expanded guide with each step detailed and sample output of the entered commands shown, please see the next Detailed Setup section.  
<pre>
<pre>
$ mkdir ~/yocto_varsomam33
$ cd ~/yocto_varsomam33
$ git clone git://arago-project.org/git/projects/oe-layersetup.git tisdk
$ git clone git://arago-project.org/git/projects/oe-layersetup.git tisdk
$ cd tisdk
$ cd tisdk
Line 62: Line 61:
$ . conf/setenv
$ . conf/setenv
</pre>
</pre>
=== local.conf customizations ===
Edit you local.conf file:
<pre>$ gedit conf/local.conf
</pre>
Change your parallel build and download directory:
==== Parallel build ====
Set the build parameters to fully utilize your host machine
BB_NUMBER_THREADS = '4'<br>PARALLEL_MAKE = '-j 6'
BB_NUMBER_THREADS should be your host machine's number of threads minus 2 or same.
PARALLEL_MAKE should be the number of threads your host machine has plus two.<br>
==== Download directory.  ====
Recommended to save download time and space.
DL_DIR = "/home/&lt;uname&gt;/yocto_dl"<br>


=== Setting up the Toolchain ===
=== Setting up the Toolchain ===
<pre>
<pre>
$ export PATH=$HOME/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH
$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH
</pre>
</pre>


== Installing the VAR-SOM-AM33 package ==
== Installing VAR-SOM-AM33 Support ==
Download the VAR-SOM-AM33 Yocto support installation from Variscite FTP:
*/General/VAR-SOM-AM33/Software/Linux/YOCTO_V2/VAR-SOM-AM33-Yocto_installation_V2.tar.gz


Extract Variscite Yocto installation package as follows:
Extract Variscite Yocto installation as follows:
  $ mkdir yocto_varsomam33_package
  $ mkdir ~/yocto_varsomam33/yocto_varsomam33_installation
  $ tar -xjf yocto_variscite_package_v1_0_installation.tar.bz2 -C ~/yocto_varsomam33_package
$ cd ~/yocto_varsomam33/yocto_varsomam33_installation
  $ tar -xvzf VAR-SOM-AM33-Yocto_installation_V2.tar.gz


Once the Arago Yocto package is installed on the Host Ubuntu machine, please extract the Variscite package tar.gz and apply the patches as follows:
Once the Arago Yocto distribution is installed on the Host Ubuntu machine, the developer should apply the Variscite installation, as follows:
$ mkdir yocto_varsomam33
  $ cd ~/yocto_varsomam33/tisdk
  $ cd ~/yocto_varsomam33/tisdk
  $ ~/yocto_varsomam33_package/variscite_utils/install_variscite_arago_var-som-am33.sh ~/yocto_varsomam33_package/ ~/yocto_varsomam33/tisdk
  $ ../yocto_varsomam33_installation/variscite_utils/install_variscite_arago_var-som-am33.sh


At this point, the Variscite Yocto package has been installed over the Yocto package and can be built.
At this point, Variscite Yocto support has been installed over the Yocto distribution and can be built.


= Building the VAR-SOM-AM33 Yocto image =
= Building the VAR-SOM-AM33 Yocto image =
First, change directory to the build directory of Yocto:
$ cd ~/yocto_varsomam33/tisdk/build


The developer can build either core-image-sato-var SW package or tisdk-rootfs-image package, as follows:
The developer can build the tisdk-rootfs-image image as follows:
$ MACHINE=varsomam33 bitbake core-image-sato-var
or
  $ MACHINE=varsomam33 bitbake tisdk-rootfs-image
  $ MACHINE=varsomam33 bitbake tisdk-rootfs-image


Line 93: Line 109:
*zImage
*zImage
*zImage-var-som-am33.dtb
*zImage-var-som-am33.dtb
*Compressed rootfs image: core-image-sato-var-varsomam33.tar.bz2 or tisdk-rootfs-image-varsomam33.tar.bz2 (Depends on the build target)
*Compressed rootfs image: tisdk-rootfs-image-varsomam33.tar.bz2  
<br/>
<br/>
If the rootfs directory already exists - Please make sure to erase all its content before extracting a new rootfs image into it:
$ sudo rm -rf ~/yocto_varsomam33/rootfs/*
Extract the rootfs as follows:
Extract the rootfs as follows:
  $ mkdir ~/yocto_varsomam33/rootfs
<pre>
  $ sudo tar xvf ./arago-tmp-external-linaro-toolchain/deploy/images/core-image-sato-var-varsomam33.tar.bz2 -C ~/yocto_varsomam33/rootfs
  $ sudo mkdir ~/yocto_varsomam33/rootfs
  $ sudo tar xvf ./arago-tmp-external-linaro-toolchain/deploy/images/tisdk-rootfs-image-varsomam33.tar.bz2 -C ~/yocto_varsomam33/rootfs
</pre>


This creates a rootfs directory for the Yocto / VAR-SOM-AM33 build.
This creates a rootfs directory for the Yocto / VAR-SOM-AM33 build.
== U-Boot Source Code  ==
*U-Boot sources can be downloaded from&nbsp;'''git://github.com/varigit/u-boot-VAR-SOM-AM33-SDK7.git'''.
*The directory will only be created after bitbake has complete building the image.
*This directory already includes Variscite's patches (already applied) to support the VAR-SOM-AM33.
*Based on the open source repositorie:&nbsp;[https://git.ti.com/ti-u-boot/ti-u-boot/trees/ti-u-boot-2013.01.01-amsdk-06.00.00.00 https://git.ti.com/ti-u-boot/ti-u-boot/trees/ti-u-boot-2013.01.01-amsdk-06.00.00.00], commit:&nbsp;540aa6fbb0c9274bda598f7e8819ed28259cad6b.
== Linux Kernel Source Code  ==
*Linux kernel sources can be downloaded from&nbsp;'''git://github.com/varigit/VAR-SOM-AM33-SDK7-Kernel.git'''<br>
*This directory will only be created after bitbake has complete building the image.
*This directory includes Variscite's patches(already applied)&nbsp;to support the VAR-SOM-AM33.
*Based on the open source repositorie:&nbsp;[http://arago-project.org/git/projects/?p=linux-am33x.git;a=shortlog;h=refs/heads/v3.2-staging http://arago-project.org/git/projects/?p=linux-am33x.git;a=shortlog;h=refs/heads/v3.2-staging], commit:&nbsp;d5720d33bc7c434f9a023dbb62c795538f976b7a


== Linux Root File-System  ==
== Linux Root File-System  ==


To boot-up Linux, a target file-system is needed. Two Arago based file-systems can be built on the Yocto package.<br>  
To boot-up Linux, a target file-system is needed. A file-systems is built from the Yocto distribution for VAR-SOM-AM33.<br>  
*Base core-image-sato-var filesystem (~170MB) - SATO build rootfs image - core-image-sato-var-varsomam33.tar.bz2
*Demo filesystem (~250MB) - This file system is created by taking the base file system and adding all the additional SDK components such as 3D graphics, matrix, profiling tools, etc... - tisdk-rootfs-image-varsomam33.tar.bz2
*Demo filesystem (~250MB) - This file system is created by taking the base file system and adding all the additional SDK components such as 3D graphics, matrix, profiling tools, etc... - tisdk-rootfs-image-varsomam33.tar.bz2


Further explanation about customizing these file-systems&nbsp;can be found [http://processors.wiki.ti.com/index.php/AMSDK_File_System_Optimization/Customization here].
Further explanation about customizing these file-systems&nbsp;can be found [http://processors.wiki.ti.com/index.php/AMSDK_File_System_Optimization/Customization here].


= U-Boot  =
= Create a bootable SD-Card =
 
In general you may Follow http://processors.wiki.ti.com/index.php/Sitara_Linux_SDK_create_SD_card_script
In AM335x the ROM code serves as the 1st stage bootloader.&nbsp;The 2nd and the 3rd stage bootloaders are based on U-Boot.  
<br>
 
Variscite has modified create-sdcard.sh script with all required options already selected.
The binary for the 2nd stage is referred to as SPL and the binary for the 3rd stage as simply U-Boot. SPL is a non-interactive loader and is a specially built version of U-Boot. It is built concurrently when building U-Boot.  


The ROM code can load the SPL image from the NAND or SDMMC devices.<br>
To create a bootable SD-Card image, which includes a UBIFS file-system based recovery image - Please do as follows:
 
* Insert a 4GB SD-Card to host computer
== Building U-Boot out-of-tree  ==
* Run dmesg command to identify which /dev/sdX was created
 
* To generate a UBIFS rootfs image that fits into 256MB flash (image size == 220MB) - Run script:
=== Downloading source code ===
First, clone the git repositories to a local directory, as follows:
<pre>
<pre>
$ mkdir ~/varsomam33
$ cd ~/yocto_varsomam33/variscite_utils
$ cd ~/varsomam33
$ sudo ./create-ubi.sh ~/yocto_varsomam33/rootfs/ tisdk-rootfs-image/
$ git clone git://github.com/varigit/u-boot-VAR-SOM-AM33-SDK7.git
</pre>
</pre>  


=== Setup Toolchain path ===
* To generate the SD-Card - Run script (and choose the correct /dev/sdX of the 4GB SD-Card inserted):
<pre>
<pre>
$ export PATH=$HOME/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH
$ cd ~/varsomam33/variscite_utils
$ sudo ./create-sdcard.sh /home/user/varsomam33/arago_yocto_am335x/tisdk /home/user/varsomam33/rootfs/
</pre>
</pre>


=== Building U-boot ===
The above procedure will result in a bootable SD-Card including MLO, U-boot, Kernel and file system + Linux recovery image to flash the NAND based on UBI file-system.
<pre>
To boot the bootable SD-Card, follow the steps below:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am33
</pre>


= Linux Kernel  =
* Insert the SD card into the SD/MMC slot of the custom board
* Press and hold the boot select switch while powering ON the board
* Login as root (no password)


== Downloading source code ==
First, clone the git repositories to a local directory, as follows:
<pre>
$ mkdir ~/varsomam33
$ cd ~/varsomam33
$ git clone git://github.com/varigit/VAR-SOM-AM33-SDK7-Kernel.git
</pre>


== Setup Toolchain path ==
Note: To generate a UBIFS image that fits into 128MB flash, please do as follows:
*Generate a YOCTO rootfs image that fits into ~100MB.
*Download kernel out-of-tree, as described below.
*Update arch/arm/boot/dts/var-som-am33.dts as follows:
<pre>
<pre>
$ export PATH=$HOME/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH
partition@9 {
label = "NAND.file-system";
reg = <0x00A00000 0x07600000>;
//reg = <0x00A00000 0x0F600000>;
};
</pre>
</pre>
 
*Build var-som-am33.dtb
== Cleaning the Kernel Sources  ==
*Update ubinize.cfg, as follows:
 
Prior to compiling the Linux kernel make sure that the kernel sources are clean.
 
Enter linux kernel directory:
 
$ cd VAR-SOM-AM33-SDK7-Kernel/
 
{{note|'''NOTE:'''<br/> The next step will delete any saved .config file in the kernel tree as well as the generated object files. If you have done a previous configuration and do not wish to lose your configuration file you should save a copy of the configuration file before proceeding. |info}}
 
The command to clean the kernel is:
 
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper
 
== Configuring the Kernel  ==
 
Before compiling the Linux kernel it needs to be configured to select which components will become part of the kernel image:
 
=== Using Default Configurations  ===
 
To build the defualt configuration for the VAR-SOM-AM33:
 
$ make ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi- tisdk_var-som-am33_defconfig
 
=== Customizing the Configuration<br>  ===
 
For configuring the kernel run:
 
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
 
Once the configuration window is open you can select which kernel components will be included in the build. Exiting the configuration will save your selections to a file in the root of the kernel tree called .config.
 
== Compiling the Kernel  ==
 
Once the kernel has been configured compile kernel:
 
$ make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage
 
This will result in a kernel image file being created in the arch/arm/boot/ directory called uImage. This file can be used by u-boot to boot your device.
 
If you selected any components of the kernel to be build as dynamic modules you must issue an additional command to compile those modules. The command is:
 
$ make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
 
This will result in .ko (kernel object) files being placed in the kernel tree. These .ko files are the dynamic kernel modules. The next section will cover how to install these modules.
 
== Building the VAR-SOM-AM33 device tree ==
To build the VAR-SOM-AM33 device tree (dtb image), please use the following command line:
<pre>
<pre>
$ make -j6 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am33.dtb
[ubifs]
mode=ubi
image=system_ubifs.img
vol_id=0
vol_size=100MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
</pre>
</pre>
 
*sudo ./create-ubi.sh ~/yocto_varsomam33/rootfs/ tisdk-rootfs-image/
The image will be located in: arch/arm/boot/dts/var-som-am33.dtb
 
== Installing the Kernel  ==
 
Once the Linux kernel and modules have been compiled they must be installed. In the case of the kernel image this can be installed by copying the uImage file to the location for downloading using TFTP, or put in an SD-card.
 
For example: when using TFTP boot, &nbsp;/tftpboot directory is the common location, whereas when booting from SD card, file shoudl be put in the first FAT partition.
 
To install the kernel modules, provide teh rootfs location, see below.
 
This command will create a directory tree in that location: lib/modules/&lt;kernel version&gt; which will contain the dynamic modules corresponding to this version of the kernel. The base location should usually be the root of your target file system. The general format of the command is:
 
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=&lt;path to root of file system&gt;
 
For example if you are installing the modules to an NFS share located at /home/user/targetNFS you would do:
 
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/home/user/targetNFS
 
 
=== Out-of-tree Kernel Modules  ===
 
{{note|'''NOTE:'''<br/> Some drivers like the SGX and WLAN drivers are delivered as modules outside of the kernel tree. These drivers binaries are already included in the pre-build root file-systems provided by Variscite.|info}}


= Boot  =
= Boot  =
Line 315: Line 256:
*Setup NFS server and export one of the provided pre-build root file-system  
*Setup NFS server and export one of the provided pre-build root file-system  
*Execute following commands at U-Boot prompt. Assuming kernel image name as 'uImage':<br>
*Execute following commands at U-Boot prompt. Assuming kernel image name as 'uImage':<br>
U-Boot # setenv fdtfile '&lt;var-som-am33.dtb filename on TFTP&gt;'
U-Boot # setenv bootfile &lt;zImage filename on TFTP&gt;
U-Boot # setenv netargs 'setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp vram=50M'
U-Boot # setenv serverip &lt;Server IP address&gt;
U-Boot # setenv rootpath '&lt;Path of the exported root file-system on the NFS server&gt;'
U-Boot # run netboot


  U-Boot # setenv serverip &lt;Server IP address&gt;
'''Note, that the roopath parameter should be the directory of the extracted rootfs image, as explained above in section [https://variwiki.com/index.php?title=VAR-SOM-AM33_Yocto_GS#Building_the_VAR-SOM-AM33_Yocto_image Building the VAR-SOM-AM33 Yocto image] extracting the image to '/home/user/yocto_varsomam33/rootfs/'.'''
U-Boot # setenv rootpath &lt;Path of the exported root file-system on the NFS server&gt;
 
U-Boot # run net_boot
= NAND Recovery =
 
As an easy and fast way to recover the VAR-SOM-AM33 NAND flash, Variscite provides a recovery SD card image that can be used to install the pre-built Linux and Android systems.<br>This SD card image includes a script (nand-recovery.sh) that installs all the boot images and root file-system.<br>
 
'''Preparing rescue SD-Card'''
 
*Plug your SD card to your Linux machine, run dmesg and see what device is added (i.e. /dev/sd<span style="color: rgb(255, 0, 0);">'''X'''</span>)
*xz -d am33-som-nand-recovery-sd_Yocto_1_6_v1.img.xz
*dd if=am33-som-nand-recovery-sd_Yocto_1_6_v1.img of=/dev/sd<span style="color: rgb(255, 0, 0);">'''X'''</span> bs=128k
*sync
 
 
'''Recover Nand Flash: TI-SDK'''
 
*Insert the SD-card into the SD/MMC slot of the custom board
*Press and hold the boot select switch while powering ON the board<br>
*Login as root (no password)
*From Linux command line, type: "'''nand-recovery.sh -o TISDK'''". (This will install Linux on the NAND)
*Unplug the SD card and reboot
 
<br> '''NAND recovery script usage:'''
<pre>usage: /sbin/nand-recovery.sh options
 
This script install Linux/Android binaries in VAR-SOM-AM33 NAND.
 
OPTIONS:
  -h Show this message
  -o &lt;Linux|Android&gt; OS type (defualt: Linux).
</pre>
 
'''Recover Nand Flash: Android'''
 
*Insert the SD-card into the SD/MMC slot of the custom board
*Press and hold the boot select switch while powering ON the board<br>
*Login as root (no password)
*From Linux command line, type: "'''android-nand.sh'''". (This will install Android on the NAND)
*Unplug the SD card and reboot


= UBIFS =
= U-Boot =


UBIFS is used for Linux root file-system on the VAR-SOM-AM33 NAND Flash.<br>
In AM335x the ROM code serves as the 1st stage bootloader.&nbsp;The 2nd and the 3rd stage bootloaders are based on U-Boot.  


{{note|'''NOTE''':<br/> Pre-built UBI root file-system binaries are provided by Variscite as part of the LSP&nbsp;binaries package. |info}
The binary for the 2nd stage is referred to as SPL and the binary for the 3rd stage as simply U-Boot. SPL is a non-interactive loader and is a specially built version of U-Boot. It is built concurrently when building U-Boot.  


== Compilling UBIFS Tools  ==
The ROM code can load the SPL image from the NAND or SDMMC devices.<br>


The MTD and UBI user-space tools are available from the the following git repository:
== Building U-Boot out-of-tree  ==
<pre>$ git clone git://git.infradead.org/mtd-utils.git
$ cd mtd-utils/
$ git checkout v1.5.0
$ make
</pre>
IMPORTANT


Tested wuth mtd-utils version is 1.5.0.  
=== Downloading source code ===
*U-Boot sources can be downloaded from&nbsp;'''git://github.com/varigit/u-boot-VAR-SOM-AM33-SDK7.git'''.
*U-boot is built automatically by bitbake.
*This directory already includes Variscite's patches (already applied) to support the VAR-SOM-AM33.
*Based on the open source repositorie:&nbsp;[https://git.ti.com/ti-u-boot/ti-u-boot/trees/ti-u-boot-2013.01.01-amsdk-06.00.00.00 https://git.ti.com/ti-u-boot/ti-u-boot/trees/ti-u-boot-2013.01.01-amsdk-06.00.00.00], commit:&nbsp;540aa6fbb0c9274bda598f7e8819ed28259cad6b.


For instructions on compiling MTD-utils, refer [http://processors.wiki.ti.com/index.php/MTD_Utilities#MTD-Utils_Compilation MTD-Utils Compilation].  
First, clone the git repositories to a local directory, as follows:
<pre>
$ mkdir ~/varsomam33
$ cd ~/varsomam33
$ git clone git://github.com/varigit/u-boot-VAR-SOM-AM33-SDK7.git
</pre>


== Creating UBIFS  ==
=== Setup Toolchain path ===
<pre>
$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH
</pre>


This section describes steps for creating a UBI rootfs image to be flashed to the VAR-SOM-AM33 NAND Flash.
=== Building U-boot ===
<pre>
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am33
</pre>


*mkfs.ubifs
=== U-Boot Environment&nbsp;Settings  ===


$ sudo mkfs.ubifs/mkfs.ubifs -r rootFS/ -F -o system_ubifs.img -m 2048 -e 126976 -c 1960
The VAR-SOM-AM33 U-Boot has default environmant settings that allows boot from NAND, SD/MMC card and Ethernet.  


Where:  
By default the boot device is NAND, for more information about boot options go to [http://www.variwiki.com/index.php?title=VAR-SOM-AM33_LSP_User%27s_Guide#Boot Boot section].


'''-m 2KiB (or 2048)'''
= Linux Kernel  =


The minimum I/O size of the underlying UBI and MTD devices. In our case, we are running the flash with no sub-page writes, so this is a 2KiB page.  
== Downloading source code ==
*Linux kernel sources can be downloaded from&nbsp;'''git://github.com/varigit/VAR-SOM-AM33-SDK7-Kernel.git'''<br>
*The kernel is built automatically by bitbake.
*This directory includes Variscite's patches(already applied)&nbsp;to support the VAR-SOM-AM33.  
*Based on the open source repositorie:&nbsp;[http://arago-project.org/git/projects/?p=linux-am33x.git;a=shortlog;h=refs/heads/v3.2-staging http://arago-project.org/git/projects/?p=linux-am33x.git;a=shortlog;h=refs/heads/v3.2-staging], commit:&nbsp;d5720d33bc7c434f9a023dbb62c795538f976b7a


'''-e 124KiB (or 126976)'''


Erase Block Size: UBI requires 2 minimum I/O units out of each Physical Erase Block (PEB) for overhead: 1 for maintaining erase count information, and 1 for maintaining the Volume ID information. The PEB size for our flash is 128KiB, so this leads to each Logical Erase Block (LEB) having 124KiB available for data.  
First, clone the git repositories to a local directory, as follows:
<pre>
$ mkdir ~/varsomam33
$ cd ~/varsomam33
$ git clone git://github.com/varigit/VAR-SOM-AM33-SDK7-Kernel.git
</pre>


'''-c 1960'''
== Setup Toolchain path ==
<pre>
$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH
</pre>


The maximum size, in LEBs, of our file system.
== Cleaning the Kernel Sources  ==


'''-r rootFS'''
Prior to compiling the Linux kernel make sure that the kernel sources are clean.


Use the contents of the ''''rootFS/'''' directory to generate the initial file system image.
Enter linux kernel directory:


'''-F'''
$ cd VAR-SOM-AM33-SDK7-Kernel/


File-system free space has to be fixed up on first mount ([http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup])
{{note|'''NOTE:'''The next step will delete any saved .config file in the kernel tree as well as the generated object files. If you have done a previous configuration and do not wish to lose your configuration file you should save a copy of the configuration file before proceeding. |info}}


'''-o system_ubifs.img'''
The command to clean the kernel is:


Output file.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper


'''NOTE: '''<span style="color: rgb(255, 0, 0);">On AM335x, -F option is required when creating ubifs image. If this option is not used, Kernel may crash while loading the Filesystem from UBI partition</span>.
== Configuring the Kernel ==


The output of the above command, 'system_ubifs.img' is fed into the '&lt;b&gt;ubinize'&lt;/b&gt; program to wrap it into a UBI image.
Before compiling the Linux kernel it needs to be configured to select which components will become part of the kernel image:
The images produced by mkfs.ubifs are later used by the ubinize tool to create a UBI image is flashed to the raw flash to be used a UBI partition.


*Create ubinize.cfg file and write the bellow contents into it:<br>
=== Using Default Configurations  ===
<pre>[rootfs]
mode=ubi
image=system_ubifs.img
vol_id=0
vol_size=220MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
</pre>
*ubinize
<pre>$ ubi-utils/ubinize -o rootfs-var-som-am33.ubi.img -m 2048 -p 128KiB -s 2048 -O 2048 ubinize.cfg
</pre>
Where:


'''-o rootfs-var-som-am33.ubi.img'''
To build the defualt configuration for the VAR-SOM-AM33:


Output file.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tisdk_var-som-am33_defconfig


'''-m 2KiB (or 2048)'''
=== Customizing the Configuration<br>  ===


Minimum flash I/O size of 2KiB page.
For configuring the kernel run:


'''-p 128KiB'''
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig


Size of the physical eraseblock of the flash this UBI image is created for
Once the configuration window is open you can select which kernel components will be included in the build. Exiting the configuration will save your selections to a file in the root of the kernel tree called .config.


'''-O 2048'''
== Compiling the Kernel  ==


offset if the VID header from start of the physical eraseblock
Once the kernel has been configured compile kernel:


The output of the above command, ''''rootfs-var-som-am33.ubi.img'''' is the required image.<br>
$ make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage


== Using UBIFS  ==
This will result in a kernel image file being created in the arch/arm/boot/ directory called uImage. This file can be used by u-boot to boot your device.


We can Flash UBIFS image from either Linux Kernel or U-Boot.  
If you selected any components of the kernel to be build as dynamic modules you must issue an additional command to compile those modules. The command is:


<u>From U-boot</u>
$ make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules


Get the UBIFS image to U-Boot from tftp or MMC/SD.  
This will result in .ko (kernel object) files being placed in the kernel tree. These .ko files are the dynamic kernel modules. The next section will cover how to install these modules.  


Since we copy the data to NAND, Empty/Erase the required RAM. Then, g et the UBIFS image to U-Boot
== Building the VAR-SOM-AM33 device tree ==
<pre>U-Boot # mw.b ${loadaddr} 0xFF &lt;filesystem_image_size&gt; &lt;=== filesystem image size is upward aligned to NAND block size(128k).
To build the VAR-SOM-AM33 device tree (dtb image), please use the following command line:
U-Boot # mmc rescan
<pre>
U-Boot # fatload mmc 0 ${loadaddr} base-rootfs-var-som-am33.ubi.img
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am33.dtb
U-Boot # nandecc hw 2
U-Boot # nand erase 0x00780000 0xF880000
U-Boot # nand write.i ${loadaddr} 0x780000 0xFC0000
</pre>  
<u>From Linux</u>
<pre>$ flash_erase /dev/mtd7 0 0
$ ubiformat /dev/mtd7 -f base-rootfs-var-som-am33.ubi.img -s 2048 -O 2048
</pre>
</pre>


= NAND Recovery =
The image will be located in: arch/arm/boot/dts/var-som-am33.dtb
 
== Installing the Kernel ==
 
Once the Linux kernel and modules have been compiled they must be installed. In the case of the kernel image this can be installed by copying the uImage file to the location for downloading using TFTP, or put in an SD-card.
 
For example: when using TFTP boot, &nbsp;/tftpboot directory is the common location, whereas when booting from SD card, file should be put in the first FAT partition.
 
To install the kernel modules, provide the rootfs location, see below.


As an easy and fast way to recover the VAR-SOM-AM33 NAND flash, Variscite provides a recovery SD card image that can be used to install the pre-built Linux and Android systems.<br>This SD card image includes a script (nand-recovery.sh) that installs all the boot images and root file-system.<br>  
First, extract the rootfs of the tisdk-rootfs-image image as follows:
<pre>
$ sudo mkdir ~/yocto_varsomam33/rootfs
$ sudo tar xvf ./arago-tmp-external-linaro-toolchain/deploy/images/tisdk-rootfs-image-varsomam33.tar.bz2 -C ../../rootfs
</pre>


'''Preparing rescue SD-Card'''
If the rootfs directory already exists - Please make sure to erase all its content before extracting a new rootfs image into it:
$ sudo rm -rf ~/yocto_varsomam33/rootfs/*


*Plug your SD card to your Linux machine, run dmesg and see what device is added (i.e. /dev/sd<span style="color: rgb(255, 0, 0);">'''X'''</span>)
This command will create a directory tree in that location: lib/modules/&lt;kernel version&gt; which will contain the dynamic modules corresponding to this version of the kernel. The base location should usually be the root of your target file system. The general format of the command is:  
*unzip am33-som-nand-recovery-sd.v17.img.gz
*dd if=am33-som-nand-recovery-sd.v17.img of=/dev/sd<span style="color: rgb(255, 0, 0);">'''X'''</span> bs=128k


'''Recover Nand Flash'''
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=&lt;path to root of file system&gt;


*Insert the SD card into the SD/MMC slot of the custom board
For example if you are installing the modules to an NFS share located at ~/yocto_varsomam33/rootfs you would do:  
*Press and hold the boot select switch while powering ON the board<br>
*Login as root (no password)
*From Linux command line, type: "'''nand-recovery.sh'''". (This will install Linux on the NAND)
*Unplug the SD card and reboot


<br> '''NAND recovery script usage:'''
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=~/yocto_varsomam33/rootfs
<pre>usage: /Linux/nand-recovery.sh options


This script install Linux/Android binaries in VAR-SOM-AM33 NAND.
=== Out-of-tree Kernel Modules  ===


OPTIONS:
{{note|'''NOTE:'''<br/> Some drivers like the SGX and WLAN drivers are delivered as modules outside of the kernel tree. These drivers binaries are already included in the pre-built root file-systems provided by Variscite.|info}}
  -h Show this message
  -o &lt;Linux|Android&gt; OS type (defualt: Linux).
</pre>


= Reference Documentation  =
= Reference Documentation  =

Latest revision as of 11:56, 10 June 2020

VAR-SOM-AM33 Yocto 1.4 (Dylan) Distribution User's Guide

About this Manual

This document describes how to install Variscite's Yocto release for the VAR-SOM-AM33.

The Yocto distribution provides a fundamental software platform for development, deployment and execution on VAR-SOM-AM33. It abstracts the functionality provided by the hardware.

In this context, the document contains instructions to:

  • Install the release on a development machine.
  • Build the sources included in this release.
  • Instaling the binaries on the VAR-SOM-AM33.
  • Booting the VAR-SOM-AM33.

Installation

Prerequisites

Before starting the installation, make sure below system requirements are met:

  • Host machine running a Ubuntu 12.04 64 LTS.
  • VAR-SOM-AM33 Evaluation Kit + VAR-SOM-AM33 Yocto support installation sources and binaries (from FTP). Please refer to support@variscite.com for obtaining FTP credentials.


The Linux host is used for the following:

  • Recompiling U-Boot / kernel.
  • Hosting the NFS server to boot the EVM with NFS as root filesystem.


Either of Windows or Linux host can be used for:

  • Hosting the TFTP server required for downloading the kernel and file-system images from U-Boot using Ethernet.
  • Running a serial console terminal application


Building the Yocto distribution via Bitbake will produce a complete set of downloaded source code + binaries for each component:

  • Yocto build environment
  • Downloaded Linux kernel source code + build kernel binaries (DTB and zImage) for VAR-SOM-AM33.
  • Downloaded U-Boot source code + build U-boot binaries (MLO and U-boot) for VAR-SOM-AM33.
  • Linux root file-system.

Install the Arago toolchain

$ wget --no-check-certificate https://launchpad.net/linaro-toolchain-binaries/trunk/2013.03/+download/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2
$ sudo tar -jxvf gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2 -C /opt

Install development tools

$ sudo apt-get install git build-essential diffstat texinfo gawk chrpath gcc-multilib ia32-libs

Download the Yocto Distribution

To quickly start making your own builds using meta-ti BSP layer and meta-arago Distribution layer, you can follow this short Quick Start section by entering below commands. For more expanded guide with each step detailed and sample output of the entered commands shown, please see the next Detailed Setup section.

$ mkdir ~/yocto_varsomam33
$ cd ~/yocto_varsomam33
$ git clone git://arago-project.org/git/projects/oe-layersetup.git tisdk
$ cd tisdk
$ ./oe-layertool-setup.sh -f configs/arago-dylan-config.txt
$ cd build
$ . conf/setenv

local.conf customizations

Edit you local.conf file:

$ gedit conf/local.conf 

Change your parallel build and download directory:

Parallel build

Set the build parameters to fully utilize your host machine BB_NUMBER_THREADS = '4'
PARALLEL_MAKE = '-j 6' BB_NUMBER_THREADS should be your host machine's number of threads minus 2 or same. PARALLEL_MAKE should be the number of threads your host machine has plus two.

Download directory.

Recommended to save download time and space. DL_DIR = "/home/<uname>/yocto_dl"

Setting up the Toolchain

$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH

Installing VAR-SOM-AM33 Support

Download the VAR-SOM-AM33 Yocto support installation from Variscite FTP:

  • /General/VAR-SOM-AM33/Software/Linux/YOCTO_V2/VAR-SOM-AM33-Yocto_installation_V2.tar.gz

Extract Variscite Yocto installation as follows:

$ mkdir ~/yocto_varsomam33/yocto_varsomam33_installation
$ cd ~/yocto_varsomam33/yocto_varsomam33_installation
$ tar -xvzf VAR-SOM-AM33-Yocto_installation_V2.tar.gz

Once the Arago Yocto distribution is installed on the Host Ubuntu machine, the developer should apply the Variscite installation, as follows:

$ cd ~/yocto_varsomam33/tisdk
$ ../yocto_varsomam33_installation/variscite_utils/install_variscite_arago_var-som-am33.sh

At this point, Variscite Yocto support has been installed over the Yocto distribution and can be built.

Building the VAR-SOM-AM33 Yocto image

First, change directory to the build directory of Yocto:

$ cd ~/yocto_varsomam33/tisdk/build

The developer can build the tisdk-rootfs-image image as follows:

$ MACHINE=varsomam33 bitbake tisdk-rootfs-image

After the image was built, all images will be located in: ~/yocto_varsomam33/tisdk/build/arago-tmp-external-linaro-toolchain/deploy/images/ - Specifically:

  • MLO image
  • u-boot.img image
  • zImage
  • zImage-var-som-am33.dtb
  • Compressed rootfs image: tisdk-rootfs-image-varsomam33.tar.bz2


If the rootfs directory already exists - Please make sure to erase all its content before extracting a new rootfs image into it:

$ sudo rm -rf ~/yocto_varsomam33/rootfs/*

Extract the rootfs as follows:

 $ sudo mkdir ~/yocto_varsomam33/rootfs
 $ sudo tar xvf ./arago-tmp-external-linaro-toolchain/deploy/images/tisdk-rootfs-image-varsomam33.tar.bz2 -C ~/yocto_varsomam33/rootfs

This creates a rootfs directory for the Yocto / VAR-SOM-AM33 build.

Linux Root File-System

To boot-up Linux, a target file-system is needed. A file-systems is built from the Yocto distribution for VAR-SOM-AM33.

  • Demo filesystem (~250MB) - This file system is created by taking the base file system and adding all the additional SDK components such as 3D graphics, matrix, profiling tools, etc... - tisdk-rootfs-image-varsomam33.tar.bz2

Further explanation about customizing these file-systems can be found here.

Create a bootable SD-Card

In general you may Follow http://processors.wiki.ti.com/index.php/Sitara_Linux_SDK_create_SD_card_script
Variscite has modified create-sdcard.sh script with all required options already selected.

To create a bootable SD-Card image, which includes a UBIFS file-system based recovery image - Please do as follows:

  • Insert a 4GB SD-Card to host computer
  • Run dmesg command to identify which /dev/sdX was created
  • To generate a UBIFS rootfs image that fits into 256MB flash (image size == 220MB) - Run script:
$ cd ~/yocto_varsomam33/variscite_utils
$ sudo ./create-ubi.sh ~/yocto_varsomam33/rootfs/ tisdk-rootfs-image/
  • To generate the SD-Card - Run script (and choose the correct /dev/sdX of the 4GB SD-Card inserted):
$ cd ~/varsomam33/variscite_utils
$ sudo ./create-sdcard.sh /home/user/varsomam33/arago_yocto_am335x/tisdk /home/user/varsomam33/rootfs/

The above procedure will result in a bootable SD-Card including MLO, U-boot, Kernel and file system + Linux recovery image to flash the NAND based on UBI file-system. To boot the bootable SD-Card, follow the steps below:

  • Insert the SD card into the SD/MMC slot of the custom board
  • Press and hold the boot select switch while powering ON the board
  • Login as root (no password)


Note: To generate a UBIFS image that fits into 128MB flash, please do as follows:

  • Generate a YOCTO rootfs image that fits into ~100MB.
  • Download kernel out-of-tree, as described below.
  • Update arch/arm/boot/dts/var-som-am33.dts as follows:
partition@9 {
	label = "NAND.file-system";
	reg = <0x00A00000 0x07600000>;
	//reg = <0x00A00000 0x0F600000>;
};
  • Build var-som-am33.dtb
  • Update ubinize.cfg, as follows:
[ubifs]
mode=ubi
image=system_ubifs.img
vol_id=0
vol_size=100MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
  • sudo ./create-ubi.sh ~/yocto_varsomam33/rootfs/ tisdk-rootfs-image/

Boot

The Kernel and root the file-system can be booted either from NAND, SD-Card or can be retrieved via ethernet to RAM using TFTP.

Nand Flash root file-system is UBIFS based which is the most recommended filesystem for nand flashes.

Following sections describe various kernel boot options possible.

Boot from MMC/SD

For creating a bootable SD , follow the below instruction on creating a resude SD. http://www.variwiki.com/index.php?title=VAR-SOM-AM33_Arago_GS#NAND_Recovery

To boot the Linux, type:

U-Boot# run mmc_boot

Boot from NAND

By default the VAR-SOM-AM33 boots from NAND.

The SPL, U-Boot, kernel uImage and UBIFS filesystem are flashed on the NAND flash at production.

Flash Images to NAND

Replacing Nand Flash images can be done from either Linux user space or U-Boot.

From U-Boot

U-Boot # mmc rescan
U-Boot # nand erase 0x0 0x280000
U-Boot # mmc rescan
U-Boot # fatload mmc ${mmc_dev} ${loadaddr} MLO
U-Boot # nand write ${loadaddr} 0x0 0x20000
U-Boot # nand write ${loadaddr} 0x20000 0x20000
U-Boot # nand write ${loadaddr} 0x40000 0x20000
U-Boot # fatload mmc ${mmc_dev} ${loadaddr} u-boot.img
U-Boot # nand write ${loadaddr} 0x80000 0x1c0000
U-Boot # fatload mmc ${mmc_dev} ${loadaddr} uImage
U-Boot # nand erase 0x280000 0x500000
U-Boot # nand write ${loadaddr} 0x280000 0x500000

From Linux shell

  << Install SPL >>
$ flash_erase /dev/mtd0 0 0
$ flash_erase /dev/mtd1 0 0
$ flash_erase /dev/mtd2 0 0
$ flash_erase /dev/mtd3 0 0
$ nandwrite -p /dev/mtd0 <MLO file>
$ nandwrite -p /dev/mtd1 <MLO file>
$ nandwrite -p /dev/mtd2 <MLO file>
$ nandwrite -p /dev/mtd3 <MLO file>

  << Install U-Boot >>
$ flash_erase /dev/mtd4 0 0
$ flash_erase /dev/mtd5 0 0
$ nandwrite -p /dev/mtd4 <u-boot.img file>

  << Install Kernel >>
$ flash_erase /dev/mtd6 0 0
$ nandwrite -p /dev/mtd6 <uImage file>

Boot over Network (Ethernet)

NOTE:
When setting a MAC address please ensure that the LS-bit of the 1st byte is not 1 i.e. when setting the MAC address: y in xy:ab:cd:ef:gh:jk has to be an even number.

            For more info this refer to the wiki page http://en.wikipedia.org/wiki/MAC_address.

When kernel image and root file-system are fetched from a TFTP/NFS server:

  • Ensure that the SOM is connected to network with DHCP and TFTP server set up
  • If the TFTP server supports negotiation between client and server, Disable it
  • Copy 'uImage' kernel image to TFTP server's root directory.
  • Set 'ethaddr' U-Boot environment variable with proper ethernet address in format 'xx:xx:xx:xx:xx:xx' (replace 'xx' with proper hexadecimal values)
  • Setup NFS server and export one of the provided pre-build root file-system
  • Execute following commands at U-Boot prompt. Assuming kernel image name as 'uImage':
U-Boot # setenv fdtfile '<var-som-am33.dtb filename on TFTP>'
U-Boot # setenv bootfile <zImage filename on TFTP>
U-Boot # setenv netargs 'setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp vram=50M'
U-Boot # setenv serverip <Server IP address>
U-Boot # setenv rootpath '<Path of the exported root file-system on the NFS server>'
U-Boot # run netboot

Note, that the roopath parameter should be the directory of the extracted rootfs image, as explained above in section Building the VAR-SOM-AM33 Yocto image extracting the image to '/home/user/yocto_varsomam33/rootfs/'.

NAND Recovery

As an easy and fast way to recover the VAR-SOM-AM33 NAND flash, Variscite provides a recovery SD card image that can be used to install the pre-built Linux and Android systems.
This SD card image includes a script (nand-recovery.sh) that installs all the boot images and root file-system.

Preparing rescue SD-Card

  • Plug your SD card to your Linux machine, run dmesg and see what device is added (i.e. /dev/sdX)
  • xz -d am33-som-nand-recovery-sd_Yocto_1_6_v1.img.xz
  • dd if=am33-som-nand-recovery-sd_Yocto_1_6_v1.img of=/dev/sdX bs=128k
  • sync


Recover Nand Flash: TI-SDK

  • Insert the SD-card into the SD/MMC slot of the custom board
  • Press and hold the boot select switch while powering ON the board
  • Login as root (no password)
  • From Linux command line, type: "nand-recovery.sh -o TISDK". (This will install Linux on the NAND)
  • Unplug the SD card and reboot


NAND recovery script usage:

usage: /sbin/nand-recovery.sh options

This script install Linux/Android binaries in VAR-SOM-AM33 NAND.

OPTIONS:
  -h Show this message
  -o <Linux|Android> OS type (defualt: Linux).

Recover Nand Flash: Android

  • Insert the SD-card into the SD/MMC slot of the custom board
  • Press and hold the boot select switch while powering ON the board
  • Login as root (no password)
  • From Linux command line, type: "android-nand.sh". (This will install Android on the NAND)
  • Unplug the SD card and reboot

U-Boot

In AM335x the ROM code serves as the 1st stage bootloader. The 2nd and the 3rd stage bootloaders are based on U-Boot.

The binary for the 2nd stage is referred to as SPL and the binary for the 3rd stage as simply U-Boot. SPL is a non-interactive loader and is a specially built version of U-Boot. It is built concurrently when building U-Boot.

The ROM code can load the SPL image from the NAND or SDMMC devices.

Building U-Boot out-of-tree

Downloading source code

First, clone the git repositories to a local directory, as follows:

$ mkdir ~/varsomam33
$ cd ~/varsomam33
$ git clone git://github.com/varigit/u-boot-VAR-SOM-AM33-SDK7.git

Setup Toolchain path

$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH

Building U-boot

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am33

U-Boot Environment Settings

The VAR-SOM-AM33 U-Boot has default environmant settings that allows boot from NAND, SD/MMC card and Ethernet.

By default the boot device is NAND, for more information about boot options go to Boot section.

Linux Kernel

Downloading source code


First, clone the git repositories to a local directory, as follows:

$ mkdir ~/varsomam33
$ cd ~/varsomam33
$ git clone git://github.com/varigit/VAR-SOM-AM33-SDK7-Kernel.git

Setup Toolchain path

$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin:$PATH

Cleaning the Kernel Sources

Prior to compiling the Linux kernel make sure that the kernel sources are clean.

Enter linux kernel directory:

$ cd VAR-SOM-AM33-SDK7-Kernel/


NOTE:The next step will delete any saved .config file in the kernel tree as well as the generated object files. If you have done a previous configuration and do not wish to lose your configuration file you should save a copy of the configuration file before proceeding.

The command to clean the kernel is:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper

Configuring the Kernel

Before compiling the Linux kernel it needs to be configured to select which components will become part of the kernel image:

Using Default Configurations

To build the defualt configuration for the VAR-SOM-AM33:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tisdk_var-som-am33_defconfig

Customizing the Configuration

For configuring the kernel run:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Once the configuration window is open you can select which kernel components will be included in the build. Exiting the configuration will save your selections to a file in the root of the kernel tree called .config.

Compiling the Kernel

Once the kernel has been configured compile kernel:

$ make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage

This will result in a kernel image file being created in the arch/arm/boot/ directory called uImage. This file can be used by u-boot to boot your device.

If you selected any components of the kernel to be build as dynamic modules you must issue an additional command to compile those modules. The command is:

$ make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules

This will result in .ko (kernel object) files being placed in the kernel tree. These .ko files are the dynamic kernel modules. The next section will cover how to install these modules.

Building the VAR-SOM-AM33 device tree

To build the VAR-SOM-AM33 device tree (dtb image), please use the following command line:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am33.dtb

The image will be located in: arch/arm/boot/dts/var-som-am33.dtb

Installing the Kernel

Once the Linux kernel and modules have been compiled they must be installed. In the case of the kernel image this can be installed by copying the uImage file to the location for downloading using TFTP, or put in an SD-card.

For example: when using TFTP boot,  /tftpboot directory is the common location, whereas when booting from SD card, file should be put in the first FAT partition.

To install the kernel modules, provide the rootfs location, see below.

First, extract the rootfs of the tisdk-rootfs-image image as follows:

 $ sudo mkdir ~/yocto_varsomam33/rootfs
 $ sudo tar xvf ./arago-tmp-external-linaro-toolchain/deploy/images/tisdk-rootfs-image-varsomam33.tar.bz2 -C ../../rootfs

If the rootfs directory already exists - Please make sure to erase all its content before extracting a new rootfs image into it:

$ sudo rm -rf ~/yocto_varsomam33/rootfs/*

This command will create a directory tree in that location: lib/modules/<kernel version> which will contain the dynamic modules corresponding to this version of the kernel. The base location should usually be the root of your target file system. The general format of the command is:

$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=<path to root of file system> 

For example if you are installing the modules to an NFS share located at ~/yocto_varsomam33/rootfs you would do:

$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=~/yocto_varsomam33/rootfs

Out-of-tree Kernel Modules

NOTE:
Some drivers like the SGX and WLAN drivers are delivered as modules outside of the kernel tree. These drivers binaries are already included in the pre-built root file-systems provided by Variscite.

Reference Documentation