This document describes how Embedian builds a customized version of TI’s’s AM437X official Processor SDK 04.01.00.06 (Yocto Morty) BSP release for Embedian’s SMARC-T437X product platform. The approach is to pull from Embedian’s Github repository and build that using bitbake. The reason why we use this approach is that it allows co-development. The build output is comprised of binary images, feed packages, and an SDK for SMARC-T437X specific development.

TI makes their Processor-SDK-04.01.00.06 Arago build scripts available via the following GIT repository:
If you’re interested in TI’s overall Processor SDK build and test process you should analyze the following repository:
It is this repository that actually pulls in the oe-layersetup project to perform the Linux Processor-SDK builds for TI’s entire suite of ARM Cortex-A chips. In this document we are only concerned with the oe-layersetup project.
Overview of the meta-embedian
Yocto Layer
The supplied meta-mebedian Yocto compliant layer has the following organization:
.
|-- conf
| |-- layer.conf
| |-- site.conf
| |-- machine
| | `-- smarct437x.conf
|-- README
|-- recipes-bsp
| |-- u-boot
| |-- u-boot-smarc.inc
| `-- u-boot-smarct437x_2017.01-smarct437x.bb
|-- recipes-core
| |-- busybox
| |-- busybox_1.23.1.bbappend
| | |-- busybox
| | | `-- defconfig
| |-- images
| | |-- meta-toolchain-smarc-tisdk.bb
| | |-- smarc-image.inc
| | |-- meta-toolchain-smarc-tisdk.inc
| | `-- smarct437x-rootfs-image.bb
| `-- packagegroups
| |-- packagegroup-smarc-console.bb
| |-- packagegroup-smarc-tisdk-addons.bb
| `-- packagegroup-smarct437x-sdk.bb
`-- recipes-kernel
| |-- linux
| |-- cmem.inc
| |-- ti-uio.inc
| |-- setup-defconfig.inc
| |-- copy-defconfig.inc
| |-- linux-smarct437x-staging_4.9.bb
| `-- linux-smarct437x-staging-4.9
| | '-- defconfig
| |-- files
| |-- configs
| | '-- empty
| |-- dra7xx
| | |-- am572x-pru-uio.dtsi
| | |-- cmem-dra71x.dtsi
| | |-- cmem.dtsi
| | |-- cmem-am571x.dtsi
| | '-- cmem-dra72x.dtsi
| |-- k2e
| | |-- cmem.dtsi
| | '-- k2e-uio.dtsi
| |-- k2g
| | '-- cmem.dtsi
| |-- k2hk
| | |-- cmem.dtsi
| | '-- k2hk-uio.dtsi
| |-- k2l-evm
| | |-- cmem.dtsi
| | '-- k2l-uio.dtsi
| |-- keystone
| | '-- keystone-uio.dtsi
| |-- ti33x
| | '-- am335x-pru-uio.dtsi
| `-- ti43x
| | '-- am437x-pru-uio.dtsi
| |-- linux-libc-headers
| `-- cryptodev-module_%.bbappendd
| `-- kselftests
| | '-- kselftests_4.9.bb
Notes on meta-embedian layer content
conf/machine/*
This folder contains the machine definitions for for the smarct437x platform and backup repository in Embedian. These select the associated kernel, kernel config, u-boot, u-boot config, and tar.bz2 image settings.
recipes-bsp/u-boot/*
This folder contains recipes used to build DAS U-boot for smarct437x platform.
recipes-core/busybox/*
This folder remove telnetd from busybox for all Embedian’s platform.
recipes-core/images/*
These recipes are used to create the final target images for the devices. When you run Bitbake one of these recipes would be specified. For example, to build the root file system for the smarct437x platform:
$ MACHINE=smarct437x bitbake -k smarct437x-rootfs-image
recipes-kernel/linux/*
Contains the recipes needed to build for all Embedian’s platform Linux kernels.
Setting Up the Tools and Build Environment
To build the latest TI AM437X Processor-SDK-04.01.00.06, you first need an Ubuntu 14.04 LTS or 16.04 LTS installation. Because of support for 32-bit host is dropped as Linaro toolchain is available only for 64-bit machines., an x86_64 ubuntu 14.04 is highly recommended. Since bitbake does not accept building images using root privileges, please do not login as a root user when performing the instructions in this section.
Once you have Ubuntu 14.04 LTS running, install the additional required support packages using the following console command:
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo build-essential chrpath libsdl1.2-dev xterm python python-m2crypto bc dos2unix socat libsdl1.2-dev -y
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.
$ sudo dpkg --add-architecture i386
$ sudo apt-get update
$ sudo apt-get install curl g++-multilib gcc-multilib lib32z1-dev libcrypto++9:i386 libcrypto++-dev:i386 liblzo2-dev:i386 libusb-1.0-0:i386 libusb-1.0-0-dev:i386 uuid-dev:i386
You’ll also need to change the default shell to bash from Ubuntu’s default dash shell (select the <No> option):
$ sudo dpkg-reconfigure dash
To build TI’s am437x Processor-SDK-04.01.00.06 you will need to install the Linaro arm compiler that TI used for the release:
$ wget -c http://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/arm-linux-gnueabihf/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz
$ sudo tar -C /opt -xJf gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz
Add the following PATH
definition to the .bashrc
file in your $HOME
directory:
$ export PATH=/opt/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin:$PATH
Next clone and intialize TI’s am437x SDK build process:
$ git clone https://git.ti.com/git/arago-project/oe-layersetup.git smarct4x-sdk-04.01.00.06
$ cd smarct4x-sdk-04.01.00.06
$ git checkout -b smarct4x-processor-sdk-04.01.00.06 acbcedb4911f3e6804610c757f56b7dfd4e31086
$ wget ftp://ftp.embedian.com/public/dev/minfs/morty/smarct437x-processor-sdk-04.01.00.06-config.txt
$ ./oe-layertool-setup.sh -f smarct437x-processor-sdk-04.01.00.06-config.txt
Add the Embedian’s meta-embedian
layer to the build process.
$ cd sources
$ git clone https://github.com/embedian/meta-embedian.git -b smarct4x-processor-sdk-04010006
$ cd ~/smarct4x-sdk-04.01.00.06/build
Edit the ~/smarct4x-sdk-04.01.00.06/build/conf/bblayers.conf file to include the meta-embedian layer in the layer list. It should look something like this (the example reflects the absolute paths on my machine):
This template file was created by taking the oe-core/meta/conf/bblayers.conf
file and removing the BBLAYERS section at the end.
LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
changes incompatibly
LCONF_VERSION = "7"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
Layers configured by oe-core-setup script
BBLAYERS += " \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-embedian \
/home/eric/smarct4x-sdk-04.0sources/meta-processor-sdk \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-arago/meta-arago-distro \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-arago/meta-arago-extras \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-browser \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-qt5 \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-openembedded/meta-networking \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-openembedded/meta-ruby \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-openembedded/meta-python \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-openembedded/meta-oe \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-openembedded/meta-gnome \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-ti \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-linaro/meta-linaro-toolchain \
/home/eric/smarct4x-sdk-04.01.00.06/sources/meta-linaro/meta-optee \
/home/eric/smarct4x-sdk-04.01.00.06/sources/oe-core/meta \
"
Building the Target Platforms
To build Embedian/TI Processor SDK BSP, use the following commands:
$ cd ~/smarct4x-sdk-04.01.00.06/build
$ source conf/setenv
$ MACHINE=smarct437x bitbake -k smarct437x-rootfs-image
Once it done, you can find all required images under ~/smarct4x-sdk-04.01.00.06/build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x/
You may want to build programs that aren’t installed into a root file system so you can make them available via a feed site (described below.) To do this you can build the package directly and then build the package named package-index to add the new package to the feed site.
The following example builds the minicom program and makes it available on the feed site:
$ MACHINE=smarct437x bitbake minicom
$ MACHINE=smarct437x bitbake package-index
Once the build(s) are completed, you will find the resulting images, rpm and licenses in folder ~/smarct4x-sdk-04.01.00.06/build/arago-tmp-external-linaro-toolchain/deploy/
deploy/images/smarct437x/*
This folder contains the binary images for the root file system and the Embedian SMARC-T437X specific version of the am437x SDK. Specifically the images are:
deploy/images/smarct437x/u-boot.imx
This is u-boot binary file for SMARC-T437X.
deploy/images/smarct437x/MLO.byteswap
The “Stage 1 SPI NOR flash Boot Loader” for SMARC-T437X. Its purpose is load the Stage 2 Boot Loader (u-boot.img).
deploy/images/smarct437x/zImage
The kernel zImage for SMARC-T437X.
deploy/images/smarct437x/zImage-am437x-smarct437x.dtb
The device tree binary file for SMARC-T437X.
deploy/images/smarct437x/smarct437x-rootfs-image-smarct437x*
Embedian root file system images for software development on Embedian’s SMARC-T437X platforms.
deploy/ipk/*
This folder contains all the packages used to construct the root file system images. They are in opkg format (similar format to Debian packages) and can be dynamically installed on the target platform via a properly constructed feed file. Here is an example of the feed file (named base-feeds.conf) that is used internally at Embedian to install upgrades onto a smarct437x platform without reflashing the file system:
src/gz smarct335x http://www.embedian.com/core-sdk/smarct437x/processor-sdk-04.01.00.06/deploy/ipk/all
src/gz armv7ahf-neon http://www.embedian.com/core-sdk/smarct437x/smarct4x-processor-sdk-04.01.00.06/deploy/ipk/armv7ahf-neon
src/gz smarct437x http://www.embedian.com/core-sdk/smarct437x/smarct4x-processor-sdk-04.01.00.06/deploy/ipk/smarct437x
deploy/licenses/*
A database of all licenses used in all packages built for the system.
deploy/sdk/arago-2017.06-armv7a-linux-gnueabi-tisdk.sh
The installer for ARM toolchain that was created for the target platform. In Embedian’s case that means that the headers for the Boost libraries are baked into the tools. (Generate by meta-toolchain-smarc-tisdk image)
Setup SD Card
For these instruction, we are assuming: DISK=/dev/mmcblk0, “lsblk” is very useful for determining the device id.
$ export DISK=/dev/mmcblk0
Erase SD card:
$ sudo dd if=/dev/zero of=${DISK} bs=1M count=160
Create Partition Layout: Leave 1MB offset for boot file. With util-linux v2.26, sfdisk was rewritten and is now based on libfdisk.
(sfdisk)
$ sudo sfdisk --version
sfdisk from util-linux 2.34
Create Partitions:
(sfdisk >=2.26.x)
$ sudo sfdisk ${DISK} <<-__EOF__
1M,48M,0x83,*
,,,-
__EOF__
(sfdisk <=2.25)
$ sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,48,0xE,*
,,,-
__EOF__
Format Partitions:
for: DISK=/dev/mmcblk0$ sudo mkfs.vfat -F 16 ${DISK}p1 -n boot
$ sudo mkfs.ext4 ${DISK}p2 -L rootfs
for: DISK=/dev/sdX$ sudo mkfs.vfat -F 16 ${DISK}1 -n boot
$ sudo mkfs.ext4 ${DISK}2 -L rootfs
Mount Partitions:
On some systems, these partitions may be auto-mounted…
$ sudo mkdir -p /media/boot/
$ sudo mkdir -p /media/rootfs/
for: DISK=/dev/mmcblk0$ sudo mount ${DISK}p1 /media/boot/
$ sudo mount ${DISK}p2 /media/rootfs/
for: DISK=/dev/sdX$ sudo mount ${DISK}1 /media/boot/
$ sudo mount ${DISK}2 /media/rootfs/
U-boot file is factory default flashed at on-module SPI NOR flash.
Install Bootloader
The MLO.byteswap and u-boot.img is pre-installed in SPI NOR flash at factory default. SMARC-T4378 is designed to always boot u-boot from SPI NOR flash and to load zImage and root file systems based on the setting of BOOT_SEL. If users need to fuse their own u-boot or perform u-boot upgrade. This section will instruct you how to do that.
Copy MLO.byteswap and u-boot.imx to the first boot partition of your SD card.
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo cp -v MLO.byteswap /media/boot/
$ sudo cp -v u-boot.img /media/boot/spi-u-boot.img
To write MLO.byteswap and u-boot.img to the SPI NOR flash.
Stop at U-Boot command prompt (Press any key when booting up). Copy and Paste the following script under u-boot command prompt.
U-Boot Command Prompt
U-Boot# sf probe
U-Boot# sf erase 0 400000
U-Boot# mmc rescan
U-Boot# fatload mmc 0 ${loadaddr} MLO.byteswap
U-Boot# sf write ${loadaddr} 0 ${filesize}U-Boot# fatload mmc 0 ${loadaddr} spi-u-boot.img
U-Boot# sf write ${loadaddr} 0x20000 ${filesize}
Notes
MLO.byteswap and u-boot.img are generated from u-boot smarct437x_evm_spi_uart3_defconfig
In some cases, when SPI NOR flash is erased or the u-boot is under development, we need a way to boot from SD card first. Users need to shunt cross the TEST# pin to ground. In this way, SMARC-T437X will always boot up from SD card.
Copy MLO and u-boot.img to the boot partition
Write u-boot.imx to the SD card boot partition.
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo cp -v MLO /media/boot/
$
sudo cp -v u-boot.img /media/boot/
Notes
1. MLO and u-boot.img are generated from smarct437x_evm_uart3_defconfig. Modify the config file under sources/meta-embedian/conf/machine/smarct437x.conf
UBOOT_MACHINE = “smarct437x_evm_spi_uart3_defconfig”
# If Test# pin is shunt
# UBOOT_MACHINE = “smarct437x_evm_uart3_defconfig”
Also modify sources/meta-embedian/recipes-bsp/u-boot/u-boot-smarct437x_2017.01-smarct437x.bb
# If TEST# pin is shunt #
# SPL_BINARY = “MLO”
SPL_BINARY = “MLO.byteswap”
If your u-boot hasn’t been finalized and still under development, it is recommended to shunt cross the test pin and boot directly from SD card first. Once your u-boot is fully tested and finalized, you can make smarct437x_evm_spi_uart3_defconfig again fuse your u-boot to SPI NOR flash.
2. If your u-boot hasn’t been finalized and still under development, it is recommended to shunt cross the test pin and boot directly from SD card first (shunt cross TEST# to GND). Once your u-boot is fully tested and finalized, you can write your u-boot file to SPI NOR flash.
3. When TEST# pin of SMARC-T437X is not shunt crossed, it will always boot up from on-module SPI NOR flash. U-boot will read the BOOT_SEL configuration and determine where it should load Image and device tree blob. When TEST# is shunt crossed (pull low), it will always boot up from SD card.
Install uEnv.txt based bootscript
Create “uEnv.txt” boot script: ($ vim uEnv.txt)
~/uEnv.txt
optargs=”consoleblank=0 mem=512M”
#u-boot eMMC specific overrides; Angstrom Distribution (SMARC-T437X) 2014-05-20
kernel_file=zImage
initrd_file=initrd.img
loadaddr=0x82000000
initrd_addr=0x88080000
fdtaddr=0x88000000
fdtfile=am437x-smarct437x.dtb
initrd_high=0xffffffff
fdt_high=0xffffffff
loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${kernel_file}
loadinitrd=load mmc ${mmcdev}:${mmcpart} ${initrd_addr} ${initrd_file}; setenv initrd_size ${filesize}
loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} /dtbs/${fdtfile}
#
##Un-comment to enable systemd in Debian Wheezy
#optargs=quiet init=/lib/systemd/systemd
console=ttyS4,115200n8
mmcroot=/dev/mmcblk1p2 ro
mmcrootfstype=ext4 rootwait fixrtc
mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}
#zImage:
uenvcmd=run loadimage; run loadfdt; run mmcargs; bootz ${loadaddr} – ${fdtaddr}
#zImage + uInitrd: where uInitrd has to be generated on the running system.
#boot_fdt=run loadimage; run loadinitrd; run loadfdt
#uenvcmd=run boot_fdt; run mmcargs; bootz ${loadaddr} ${initrd_addr}:${initrd_size} ${fdtaddr}
###Begin Rootfs from NFS
#serverip=192.168.1.51
#rootpath=/srv/nfs/smarct335x/ubuntu1204/
#nfsopts=nolock,acdirmin=60
#netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
##netboot=echo Loading kernel from SDCARD and booting from NFS …; run loadimage; run netargs; bootz ${loadaddr} – ${fdtaddr}
##uenvcmd=run netboot
###End Rootfs from NFS
###Begin Load kernel from TFTP
#netmask=255.255.255.0
#ipaddr=192.168.1.65
#serverip=192.168.1.51
#netboot=echo Loading kernel and device tree from TFTP and booting from NFS …; setenv autoload no; tftp ${loadaddr} ${kernel_file}; tftp ${fdtaddr} ${fdtfile}; run netargs; bootz ${loadaddr} – ${fdtaddr}
#uenvcmd=run netboot
###End Load kernel from TFTP
Copy uEnv.txt to the boot partition:
~/
$
sudo cp -v ~/uEnv.txt /media/boot/
Install Linux Kernel zImage
Copy zImage to the boot partition:
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo cp -v zImage /media/boot/
Install Linux Kernel Device Tree Binary
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo mkdir -p /media/boot/dtbs
$ sudo cp -v zImage-am437x-smarct437x.dtb /media/boot/dtbs/am437x-smarct437x.dtb
Install Root Filesystem
Extract the Yocto built root filesystem to your SD card
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo tar Jxvf smarct437x-rootfs-image-smarct437x.tar.xz -C /media/rootfs
Notes
1. SMARC-T437X always boots up from on-module SPI NOR flash first. The bootloader file in SPI NOR flash is factory pre-installed from Embedian. It will read the BOOT_SEL configuration that defined by SMARC specification on your carrier board and load Image and device tree blob from the partition one of the device (could be SD card, eMMC, GBE,..etc) that you selected.
2. MAC address is factory pre-installed at on board I2C EEPROM at offset 60 bytes. It starts with Embedian’s vendor code 10:0D:32. u-boot will read it and pass this parameter to kernel.
3. The kernel modules is already included in the rootfs.
Remove SD card:
$ sync
$ sudo umount /media/boot
$ sudo umount /media/rootfs
Shunt cross TEST# pin to ground and set the BOOT_SEL to ON OFF OFF. The module will boot up from SD card.
Feed Packages
You need to setup Apache2 web server on your development host machine first.
The Apache server default web page directory is /var/www/html .We need to populate it with a link pointing to our deb package repository.
$ sudo ln -s /path/to/build/arago-tmp-external-linaro-toolchain/deploy/deb /var/www/html/deb
The following procedure can be used on a Embedian SMARC-T437X device to download and utilize the feed file show above to install the tcpdump terminal emulation program:
# vim /etc/apt/sources.list.d/yocto.list
Only keep the following four lines.
# vim /etc/opkg/base-feeds.conf
Only keep the following three lines:
src/gz all http://<ip address>/all
src/gz armv7ahf-neon http://<ip address>/armv7ahf-neon
src/gz smarct437x http://<ip address>/smarct437x
# opkg update
# opkg upgrade
# opkg install tcpdump
Writing Bitbake Recipes
In order to package your application and include it in the root filesystem image, you must write a BitBake recipe for it.
When starting from scratch, it is easiest to learn by example from existing recipes.
Example HelloWorld recipe using autotools
For software that uses autotools (./configure; make; make install), writing recipes can be very simple:
DESCRIPTION = "Hello World Recipe using autotools"
HOMEPAGE = "http://www.embedian.com/"
SECTION = "console/utils"
PRIORITY = "optional"
LICENSE = "GPL"
PR = "r0"
SRC_URI = "git://github.com/embedian/helloworld-autotools.git;protocol=https"
S = "${WORKDIR}/git"
inherit autotools
SRC_URI
specifies the location to download the source from. It can take the form of any standard URL using http://, ftp://, etc. It can also fetch from SCM systems, such as git in the example above.
PR
is the package revision variable. Any time a recipe is updated that should require the package to be rebuilt, this variable should be incremented.
inherit autotools
brings in support for the package to be built using autotools, and thus no other instructions on how to compile and install the software are needed unless something needs to be customized.
S
is the source directory variable. This specifies where the source code will exist after it is fetched from SRC_URI and unpacked. The default value is ${WORKDIR}/${PN}-${PV}
, where PN
is the package name and PV
is the package version. Both PN
and PV
are set by default using the filename of the recipe, where the filename has the format PN_PV.bb
.
Example HelloWorld recipe using a single source file
This example shows a simple case of building a helloworld.c file directly using the default compiler (gcc). Since it isn’t using autotools or make, we have to tell BitBake how to build it explicitly.
DESCRIPTION = "HelloWorld"
SECTION = "examples"
LICENSE = "GPL"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} helloworld.c -o helloworld
}
do_install() {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}
}
In this case, SRC_URI
specifies a file that must exist locally with the recipe. Since there is no code to download and unpack, we set S
to WORKDIR
since that is where helloworld.c will be copied to before it is built.
WORKDIR
is located at ${OETREE}/build/arago-tmp-external-linaro-toolchain/work/armv7ahf-neon-linux-gnueabi/<package name and version
for most packages. If the package is machine-specific (rather than generic for the armv8a architecture), it may be located in the smarct437x-linux-gnueabi
subdirectory depending on your hardware (this applies to kernel packages, images, etc).
do_compile
defines how to compile the source. In this case, we just call gcc directly. If it isn’t defined, do_compile
runs make
in the source directory by default.
do_install
defines how to install the application. This example runs install
to create a bin directory where the application will be copied to and then copies the application there with permissions set to 755.
D
is the destination directory where the application is installed to before it is packaged.
${bindir}
is the directory where most binary applications are installed, typically /usr/bin
.
For a more in-depth explanation of BitBake recipes, syntax, and variables, see the Recipe Chapter of the OpenEmbedded User Manual.
Setup eMMC
Setting up eMMC usually is the last step at development stage after the development work is done at your SD card or NFS environments. From software point of view, eMMC is nothing but a non-removable SD card on board. For SMARC-T437X, the SD card is always emulated as /dev/mmcblk1
and on-module eMMC is always emulated as /dev/mmcblk0
. Setting up eMMC now is nothing but changing the device descriptor.
This section gives a step-by-step procedure to setup eMMC flash. Users can write a shell script your own at production to simplify the steps.
First, we need to backup the final firmware from your SD card or NFS.
Prepare for eMMC binaries from SD card (or NFS):
Insert SD card into your Linux PC. For these instructions, we are assuming: DISK=/dev/mmcblk0, “lsblk” is very useful for determining the device id.
For these instruction, we are assuming: DISK=/dev/mmcblk0
, “lsblk
” is very useful for determining the device id.
$ export DISK=/dev/mmcblk0
Mount Partitions:
On some systems, these partitions may be auto-mounted…
$ sudo mkdir -p /media/boot/
$ sudo mkdir -p /media/rootfs/
for: DISK=/dev/mmcblk0
$ sudo mount ${DISK}p1 /media/boot/
$ sudo mount ${DISK}p2 /media/rootfs/
for: DISK=/dev/sdX
$ sudo mount ${DISK}1 /media/boot/
$ sudo mount ${DISK}2 /media/rootfs/
Copy zImage to rootfs partition
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo cp -v zImage /media/rootfs/home/root
Copy uEnv.txt to rootfs partition
Copy and paste the following contents to /media/rootfs/home/root ($ sudo vim /media/rootfs/home/root/uEnv.txt)
~/uEnv.txt
optargs=”consoleblank=0 mem=512M”
#u-boot eMMC specific overrides; Angstrom Distribution (SMARC-T437X) 2014-05-20
kernel_file=zImage
initrd_file=initrd.img
loadaddr=0x82000000
initrd_addr=0x88080000
fdtaddr=0x88000000
fdtfile=am437x-smarct437x.dtb
initrd_high=0xffffffff
fdt_high=0xffffffff
loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${kernel_file}
loadinitrd=load mmc ${mmcdev}:${mmcpart} ${initrd_addr} ${initrd_file}; setenv initrd_size ${filesize}
loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} /dtbs/${fdtfile}
#
##Un-comment to enable systemd in Debian Wheezy
#optargs=quiet init=/lib/systemd/systemd
console=ttyS4,115200n8
mmcroot=/dev/mmcblk0p2 ro
mmcrootfstype=ext4 rootwait fixrtc
mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}
#zImage:
uenvcmd=run loadimage; run loadfdt; run mmcargs; bootz ${loadaddr} – ${fdtaddr}
#zImage + uInitrd: where uInitrd has to be generated on the running system.
#boot_fdt=run loadimage; run loadinitrd; run loadfdt
#uenvcmd=run boot_fdt; run mmcargs; bootz ${loadaddr} ${initrd_addr}:${initrd_size} ${fdtaddr}
###Begin Rootfs from NFS
#serverip=192.168.1.51
#rootpath=/srv/nfs/smarct335x/ubuntu1204/
#nfsopts=nolock,acdirmin=60
#netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
##netboot=echo Loading kernel from SDCARD and booting from NFS …; run loadimage; run netargs; bootz ${loadaddr} – ${fdtaddr}
##uenvcmd=run netboot
###End Rootfs from NFS
###Begin Load kernel from TFTP
#netmask=255.255.255.0
#ipaddr=192.168.1.65
#serverip=192.168.1.51
#netboot=echo Loading kernel and device tree from TFTP and booting from NFS …; setenv autoload no; tftp ${loadaddr} ${kernel_file}; tftp ${fdtaddr} ${fdtfile}; run netargs; bootz ${loadaddr} – ${fdtaddr}
#uenvcmd=run netboot
###End Load kernel from TFTP
Copy device tree binary to rootfs partition
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ sudo cp -v /media/boot/dtbs/am437x-smarct437x.dtb /media/rootfs/home/root/am437x-smarct437x.dtb
Copy final root file system to rootfs partition
build/arago-tmp-external-linaro-toolchain/deploy/images/smarct437x
$ pushd /media/rootfs
$ sudo tar cvfz ~/smarct437x-emmc-rootfs.tar.gz .
$ sudo mv ~/smarct437x-emmc-rootfs.tar.gz /media/rootfs/home/root
$ popd
Remove SD card:
$ sync
$ sudo umount /media/boot
rootfs$ sudo umount /media/
Copy Binaries to eMMC from SD card
Insert this SD card into your SMARC-T437X device.
Now it will be almost the same as you did when setup your SD card, but the eMMC device descriptor is /dev/mmcblk0 now. Booting up the device from SD card (shunt cross TEST#).
$ export DISK=/dev/mmcblk0
Erase eMMC:
$ sudo dd if=/dev/zero of=${DISK} bs=1M count=160
Create Partition Layout:
$ sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,48,0x83,*
,,,-
__EOF__
Format Partitions:
$ sudo mkfs.vfat -F 16 ${DISK}p1 -n boot
$ sudo mkfs.ext4 ${DISK}p2 -L rootfs
Mount Partitions:
$ sudo mkdir -p /media/boot/
$ sudo mkdir -p /media/rootfs/
$ sudo mount ${DISK}p1 /media/boot/
$ sudo mount ${DISK}p2 /media/rootfs/
Copy binaries to boot partition
Copy uEnv.txt/Image/*.dtb to the boot partition
$ sudo cp -v zImage uEnv.txt /media/boot/
Copy Linux kernel device tree binary
$ sudo mkdir -p /media/boot/dtbs
$ sudo cp -v am437x-smarct437x.dtb /media/boot/dtbs/
Copy root file system to rootfs partition
$ sudo tar -zxvf smarct437x-emmc-rootfs.tar.gz -C /media/rootfs
Unmount eMMC:
$ sync
$ sudo umount /media/boot
$ sudo umount /media/rootfs
Switch your Boot Select to eMMC (OFF ON ON) and you will be able to boot up from eMMC now.
version 1.0a, 10/28/2024
Last updated 2024-10-28