Project

General

Profile

2019 MDK Release Guide

This wiki will cover all the information on the 2019 MDK release for the Mitysom 335x.

Contents:

Installing the MDK

Critical Link has created an MDK that contains all the required components to boot the 335x, as well as a toolchain to build the different components from the source code.

The MDK can be found here: TBD

To install simply run these commands and then follow the prompt:

chmod +x mitysom-335x-devkit-MDK-2019-05-00.sh
sudo ./mitysom-335x-devkit-MDK-2019-05-00.sh

The default installation path will be /opt/criticallink/mitysom-335x_2019-05-00.

Preparing a new SD card

There exists a script called populate_am335x_dev_sd in the MDK that populates an SD card with all the required components for booting the 335x. The script can be found under <MDK Path>/deploy.

Usage: populate_am335x_dev_sd [opts] <MMC device>
    -h|--help        Print this help
    -b|--bootdir       Directory containing boot files
    -c|--continuous  Continue and make multiple copies
    -f|--force       Don't ask.. just do it
    -v|--verbose     Be more verbose when working
    -m|--mount=<mount point> mount the disk at mount point
    -r|--rootfs=<rootfs tarfile> Use the specified tar file for root fs
    -p|--probe       Find mmccards and exit
    -N|--noformat    skip formatting SD card
    <MMC device> is the path to the /dev device for the SD card

To populate an SD card simply run:

cd <MDK Path>/deploy
cp fitImage boot
cp 512MB_NAND/* boot
sudo ./populate_am335x_dev_sd -b boot -r mitysom-335x-devkit-rootfs.tar.bz2 /dev/sd<letter>

Where /dev/sd<letter> is your SD card.

Note: This example is for a 512MB NAND SOM, use the correct folder for the NAND size of your SOM (i.e 256MB_NAND or 1GB_NAND).

If you just want to format the SD card, you can run the mksd script in the deploy folder.

./mksd /dev/sd<letter>

Again where /dev/sd<letter> is your SD card.

BE VERY CAREFUL WHICH DEVICE TO TELL THESE SCRIPTS TO WORK ON... You dont want to format your linux machine!!!

Manually Installing Filesystem

The MDK comes packaged with a prebuilt root filesystem. This can be found in the MDK's install directory under deploy.

First, backup the filesystem currently on the SD card (you will need to modify the paths based on your specific Linux distribution):

sudo cd /path/to/media/rootfs/
sudo tar czvf ~/rootfs-backup.tar.gz .

Then, you can install the new root filesystem with

rm -rf /path/to/media/rootfs/*
tar xvf <MDK path>/deploy/mitysom-335x-devkit-rootfs.tar.bz2 -C /path/to/media/rootfs/
sync

NOTE: It's required that you flush any buffered data to the root filesystem media with sync to avoid corruption. This command will not print any status output and can take a long time to run depending on the write speed of the media.

Please note that when you update the root filesystem to the latest MDK, you will also want to replace your kernel image with the latest MDK's kernel image.

Installing U-Boot and Linux:

cp <MDK path>/deploy/<SOM NAND size>/MLO /path/to/media/boot/
cp <MDK path>/deploy/<SOM NAND size>/u-boot.img /path/to/media/boot/
cp <MDK path>/deploy/fitImage /path/to/media/boot/
sync

Note: The fitImage can only be booted from the 2018 U-Boot.

Booting from the fitImage should be handled by the default u-boot enviroment. So there is no need for any manual commands to be run in u-boot.

Flashing Filesystem to NAND

See UBIFS Nand Boot.

Before building the UBIFS image, unpack the prebuilt root filesystem that ships with the MDK. This may be found in the MDK's install directory under deploy.

cd <your working directory>
mkdir filesystem
tar xf <MDK path>/deploy/mitysom-335x-devkit-rootfs.tar.bz2 -C ./filesystem

When flashing the kernel image, use the new FIT image instead of zImage or uImage. This FIT image contains the kernel, device tree, and overlays.
The image can be found at

<MDK path>/deploy/fitImage

Network Boot

TFTP

U-Boot loads the zImage and device-tree over the network using TFTP.

Install the TFTP server

sudo apt-get install tftpd-hpa

Configure the server
Add/Update the following line in /etc/conf.d/tftpd:

TFTPD_DIRECTORY="/srv/tftp" 

Create the TFTP folder

mkdir -p /srv/tftp

Reload the TFTP server

sudo service tftpd-hpa restart

Add the kernel image and device tree from the MDK

mkdir /srv/tftp/mitysom/
cp <MDK path>/deploy/fitImage /srv/tftp/mitysom/

NFS

After U-Boot loads the kernel, the kernel may use an NFS drive as it's root filesystem.

Install an NFS server

sudo apt-get install nfs-kernel-server

Make the NFS rootfs folder

mkdir -p /srv/nfs/mitysom

Export the rootfs folder
Add the following entry to /etc/exports:

/srv/nfs/mitysom *(rw,async,nohide,insecure,no_root_squash,no_subtree_check)

Update the NFS server's exports

sudo exportfs -arv

Make the NFS server serve over UDP
Add the following to /etc/nfs.conf

[nfsd]
 udp=y
 vers2=y

Restart the NFS server

systemctl restart nfs-server.service

Uncompress the MDK rootfs

tar xf <MDK path>/deploy/mitysom-335x-devkit-rootfs.tar.bz2 -C /srv/nfs/mitysom

In order to sucessfully boot, DHCP needs to be disabled in systemd for the network adapter connecting to the NFS server.

mkdir -p /srv/nfs/mitysom/etc/connman
vi /srv/nfs/mitysom/etc/connman/main.conf

Then add the following lines to /srv/nfs/mitysom/etc/connman/main.conf:
[General]
NetworkInterfaceBlacklist=eth

Booting

Configure and boot U-Boot:

U-Boot# set kloadaddr 0x80007FC0
U-Boot# set serverip <host machine IP>
U-Boot# set rootpath "/srv/nfs/mitysom" 
U-Boot# set autoload no
U-Boot# set bootcmd "dhcp; tftp $kloadaddr /mitysom/fitImage; run net_args; bootm $kloadaddr;" 
U-Boot# saveenv
U-Boot# boot

Note that you can use loadb, fatload, tftp, nfs, etc to get the images into RAM, and that the particulars of the NFS command are specific to the environment at Critical Link.

U-Boot

This section will cover how to build U-Boot for the 335x from the source code and how to write to NAND from u-boot.

https://support.criticallink.com/gitweb/?p=u-boot-mityarm-335x.git;a=summary

Please familiarize yourself with the TI port of u-boot described here as the Critical Link MitySOM-335X port is based on the TI port, and many of the AM335X processor specifics are detailed on the TI wiki.

Checkout U-Boot

Download your own copy of U-Boot:

git clone git://support.criticallink.com/home/git/u-boot-mityarm-335x.git
cd u-boot-mityarm-335x
git checkout u-boot-2018.01

These commands will download the repository and check out the u-boot-2018.01 branch from the server. If you intend to make changes you will need to be moderately familiar with Git (See the docs).

Setting up the environment

source <MDK path>/environment-setup-cortexa8hf-neon-criticallink-linux-gnueabi

NOTE: The MDK installation script will default the MDK installation to /opt/criticallink

Building U-Boot

The U-Boot build needs to be configured depending on which SOM you're using.

  • mitysom335x_devkit_256MB_defconfig - Config for 256MB NAND SOMs
  • mitysom335x_devkit_512MB_defconfig - Config for 512MB NAND SOMs
  • mitysom335x_devkit_1GB_defconfig - Config for 1GB NAND SOMs
    SOMs with no nand can use any of the above configs
make distclean
make mitysom335x_devkit_<nand size>_defconfig
make

For a faster build, add "-j$(nproc)" to build with multiple threads, @$(nproc) will use as many threads as the building machine has cores.

When built successfully, there are several files created in the source directory.

  • spl/u-boot-spl.bin - The second-stage bootloader (a stripped down version of u-boot that fits in SRAM)
  • MLO - spl/u-boot-spl.bin with a GP image header prepended to it
  • u-boot.img - The full-fledged U-Boot image.

If you are booting from an SD card (as shipped from Critical Link), you can simply replace the MLO and u-boot.img files on the first partition of the SD card. This partition is a FAT partition and can be written to from linux or windows (or many others).

NAND in U-Boot

This section outlines the configuration of the NAND device in u-boot (which corresponds to the NAND MTD parts in the default Critical Link built Linux kernel).

For more information on the NAND layout for the 335x see UBIFS Nand Boot.

Reflashing U-Boot:

If you need to reflash the u-boot image to your board, you can follow the instructions below. WARNING: failure to perform this step correctly will "brick" your board. The procedure for recovering a bricked module is dependent on the carrier board setup (or you can return it to Critical Link for servicing).

If you are using the Critical Link dev board, u-boot and the MLO are stored on the SD card, and can simply be updated on the card. Check the TI AM335x U-Boot User's Guide if you are booting from flash or other external boot devices.

Writing to NAND:

U-Boot provides a whole set of commands for manipulating the NAND device on the MitySOM-335X SOM. The command

help nand

will detail its usage for you.

See UBIFS Nand Boot for full details on creating a full nand boot scenario on both the 256MB and 512MB Nand parts.

There are a number of different boot modes that the AM335X part supports that include booting from NAND. The commands illustrated herein have been checked out using the boot mode 001111100100. If you are using the Critical Link Development Kit baseboard, this corresponds to the BOOTCONFIG jumpers as follows

001001111100 (bit 0 on the left)
JJOJJOOOOOJJ (J = jumper, O = open)

U-Boot# dhcp

For the MLO:
U-Boot# mw.b 0x82000000 0xFF 0x20000
U-Boot# load 0x82000000 MLO
U-Boot# nand erase 0x0 0x20000
U-Boot# nand write.i 0x82000000 0x0 $filesize

For u-boot img:
U-Boot# mw.b 0x82000000 0xFF 0x80000
U-Boot# load 0x82000000 u-boot.img
U-Boot# nand erase 0x80000 0x80000
U-Boot# nand write.i 0x82000000 0x80000 $filesize

Note: This method will flash the MLO and u-boot.img in the SD card.

Linux Kernel

Configuring the Kernel Build Environment

Setup the MDK environment (Note: Your SDK path may differ):

source <MDK path>/environment-setup-cortexa8hf-neon-criticallink-linux-gnueabi

Building the Kernel

Clone the repository from Critical Link:

git clone git://support.criticallink.com/home/git/linux-mityarm-335x.git
cd linux-mityarm-335x
git checkout linux4.14

Configure the build for the Development Kit Baseboard

make mitysom-335x-devkit_defconfig

Optional: Customize the kernel

make menuconfig

Build the kernel image

make zImage

For a faster build, add "-j$(nproc)" to build with multiple threads, @$(nproc) will use as many threads as the building machine has cores.

Make the kernel modules

make modules
make INSTALL_MOD_PATH=../rootfs/ modules_install

This will build the selected kernel modules and then install them under ../rootfs/. You can change this path to change where the modules will install. For example, you may have the build install directly to an SD card. (Note: Make sure you include the INSTALL_MOD_PATH variable and do not run as root. The kernel Makefile will attempt to install these modules into your machine's root filesystem. You probably do NOT want this!)

Make device tree blobs (DTB)

make dtbs

You will find the compiled DTBs in arch/arm/boot/dts and the compiled dtbo under arch/arm/boot/dts/cl
Note: These will be in the same folder as the source files. Make sure to use the .dtb or .dtbo files and not the .dts, .dtsi or .dtso.

Install PowerVR SGX Graphic Modules

If you are building your own kernel and want to enable SGX graphics then you must add the modules to the filesystem manually.

Configuring the Build Environment:

Setup the MDK environment (Note: Your SDK path may differ):

source <MDK path>/environment-setup-cortexa8hf-neon-criticallink-linux-gnueabi

Clone the Git Repository:

Clone the repository from ti for the 4.14 Kernel:

git clone git://git.ti.com/graphics/omap5-sgx-ddk-linux.git
cd omap5-sgx-ddk-linux
git checkout ti-img-sgx/1.14.3699939/k4.14

Build the Modules:

cd eurasia_km/eurasiacon/build/linux2/omap_linux
make ARCH=arm TARGET_PRODUCT=ti335x KERNELDIR=../../linux-mityarm-335x

Where KERNELDIR points to the directory where you built your kernel.

make -C ${KERNELDIR} SUBDIRS=${PWD}/../../../binary2_omap_linux_release/target/kbuild INSTALL_MOD_PATH=../../rootfs modules_install

Where:

  • KERNELDIR is the directory where you built your kernel.
  • SUBDIRS points to the full path of the kbuild directory.
  • INSTALL_MOD_PATH points to the directory containing the root filesystem you are using.

The modules should have been installed under lib/modules/4.4.32-xxxxx/extra/ in your filesystem. The modules that should be in the extra directory are bc_example.ko and pvrsrvkm.ko.

Enabling the Modules:

At startup you can run the following modprobe command to enable the modules.

modprobe pvrsrvkm

Flattened Image Tree (FIT)

The 2019 May MDK provides a FIT. This FIT contains the devkit kernel and device tree.

Installing Mkimage

You must install the u-boot-tools package to build your own fitImage. To do so run:

sudo apt-get install u-boot-tools

Preparing the FIT source

Copy the FIT source to the kernel source directory

cd <work directory>/linux-mityarm-335x
cp <MDK path>/sources/fitImage.its ./

The FIT source is provided by Yocto and has a slightly different set up than the kernel source.

Open fitImage.its and change the following line:

data = /incbin/("linux.bin");

to
data = /incbin/("arch/arm/boot/zImage");

Building the FIT

Run mkimage

mkimage -f fitImage.its fitImage

Go to top
Add picture from clipboard (Maximum size: 600 MB)