SBC-AM57x Development Platform

This board is the development platform for the CL-SOM-AM57x system-on-module. It consists of a carrier for the module and a number of peripherals such as USB, SATA, ethernet, HDMI, GPIO, I2S, SPI breakouts, and power.  

This document outlines the process of a clean installation of the Debian stretch/sid for the TI 4.1 kernel as distributed by compulab. This includes installation of the operating system onto a 120GB mSATA drive, installation of most of the development packages needed to complete a build and any necessary customizations of the kernel. 

Note that this process is still in flux and is meant to be 100% repeatable for easy verification of the process on any new systems. 

These instructions assume that the host computer is a UNIX/Linux machine such as an macbook pro or similar and has available the typical command-line tools such as screen, rsync, and ssh. 


Booting from SD Card

  1. Connect a microUSB cable from your host computer to the serial/USB connector P7.

  2. If a new /dev/cu.* serial port does not appear, you may need to install the drivers from https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx. For More information, please see https://compulab.co.il/workspace/mediawiki/index.php5/SB-SOM:_HOWTO:_USB_Console.

  3. Download the most recent distribution package from CompuLab: http://www.compulab.co.il/workspace/mediawiki/index.php5/CL-SOM-AM57x_TI_AM57x_Linux

  4. Format an SD card of at least a few GB with FAT32 and copy the following files from the package directory images/ti-sdk-4.1
    1. am57xx-sbc-am57x.dtb
    2. zImage-cl-som-am57x

    Also, copy rootfs.tar.bz2 from the 4.1 kernel folder and the linux-4.1.13-cl-som-am57x-ti-3.2 patch for later use.

  5. Insert the SD card into the SD slot on the SBC and power on the SBC.

  6. Connect to the serial console with the following command: 

    $ screen /dev/cu.SLAB_USBtoUART 115200
  7. Terminate the boot process by pressing any key. This brings up the uboot interface.

  8. Type the following uboot commands to boot from the SD card:

    mmc dev 0
    mmc rescan
    load mmc 0 0x88000000 ramdisk.dtb && load mmc 0 0x82000000 kernel.img && load mmc 0 0x88080000 ramdisk.img
    setenv bootargs "root=/dev/ram0 rw ramdisk_size=16384 console=ttyO2,115200n8 vram=16M"
    bootz 0x82000000 0x88080000 0x88000000

    The install media will now boot and provide a prompt from which you can do any further work on the target machine. 

Initialize Drives

We now have access to three drives as follows:

DeviceMediaPurposeInstallation Mount PointsFormat
/dev/mmcblk0SOM eMMClocal storage of settings and user patches/media/emmc (mmcblk0p1)ext4
/dev/mmcblk1SD cardinstallation media and kernel module backups/media/sd (mmcblk1p1)FAT32
/dev/sdamSATA driveboot, operating system and all user-space storage/media/boot (sda1), /media/rootfs (sda2)FAT32, ext4

eMMC

fdisk /dev/mmcblk0 - Create a single partition for the entire eMMC space

mkfs.ext4 /dev/mmcblk0p1 - Format with ext4

SATA

# export SATA_DRIVE=/dev/sda
# echo -e "n\np\n1\n2048\n204800\na\n1\nt\nc\nn\np\n2\n204801\n\nw\neof\n" | fdisk -u ${SATA_DRIVE}
# mkfs.vfat -n boot ${SATA_DRIVE}1
# mkfs.ext4 ${SATA_DRIVE}2
# mkdir -p /media/boot && mount ${SATA_DRIVE}1 /media/boot
# mkdir -p /media/rootfs && mount ${SATA_DRIVE}2 /media/rootfs
# cp /media/mmcblk1p1/zImage-cl-som-am57x /media/mmcblk1p1/am57xx-sbc-am57x.dtb /media/boot && sync
# tar --numeric-owner -xvpjf /media/mmcblk1p1/rootfs.tar.bz2 -C /media/rootfs && sync

SATA - reinitialize

Note: If you are rebuilding a system that's gone wrong for some reason (happens when trying to work out the ideal set of versions of compilers and so forth) You may boot into the install drive and then perform the following set of commands to re-initialize only the rootfs partition. This assumes that you've backed up your custom kernel modules to the SD card before wiping the drive!
# export SATA_DRIVE=/dev/sda
# umount /media/sda2
# mkfs.ext4 ${SATA_DRIVE}2
# mkdir -p /media/rootfs && mount ${SATA_DRIVE}2 /media/rootfs
# tar --numeric-owner -xvpjf /media/mmcblk1p1/rootfs.tar.bz2 -C /media/rootfs && sync
# mv /media/rootfs/lib/modules/4.1.13-cl-som-am57x-ti-3.2 /media/rootfs/lib/modules/4.1.13-cl-som-am57x-ti-3.2.orig
# cp -R /media/mmcblk1p1/modules/* /media/rootfs/lib/modules

Boot into Target OS

At this point you may simply

# reboot

Configure uboot for SATA boot

When the system comes up, interrupt the boot process once more by pressing any key. In the uboot environment, issue the following commands in order to program the device to boot from the SATA:

setenv unreset_pcie 'i2c dev 4; pca953x output 1 1'
setenv loadimage 'load scsi 0 ${loadaddr} ${kernel} && load scsi 0 ${fdtaddr} ${fdtfile}'
sete bootargs 'root=/dev/sda2 rootfstype=ext4 rw rootwait console=ttyO2,115200n8'
setenv bootcmd 'run unreset_pcie; run loadimage; fdt addr ${fdtaddr}; setenv fdtaddr 88000000; run set_display; run bootkernel'
saveenv
boot


You will now boot onto the target OS. The default credentials are as follows:

username: root
password: 111111

Initial System Configuration

Set root password

If desired, set the root password to something more secure than '111111'


# passwd

Hostname

# echo 'nw2s-0001' > /etc/hostname
# echo '' > /etc/motd


Ethernet

Add the following text to /etc/network/interfaces

auto eth1
iface eth1 inet dhcp


# echo -e '\nauto eth1\niface eth1 inet dhcp\n' >> /etc/network/interfaces

Then run the following commands to disable IPv6

# sysctl -w net.ipv6.conf.all.disable_ipv6=1
# sysctl -w net.ipv6.conf.default.disable_ipv6=1


User

Create the default non-privelidged user 'nw2s'

# adduser nw2s
# adduser nw2s sudo
# adduser nw2s audio


Finish Up

Make sure sudo is installed and after that, you can reboot and continue working via ssh.

# apt-get update
# apt-get install sudo
# reboot

Initial Package Setup

The following steps will walk you through the initial package setup

$ sudo apt-get install wget
$ sudo apt-get install rsync
$ sudo apt-get install unzip
$ sudo apt-get install git
$ sudo apt-get install screen
$ sudo apt-get install rsyslog

$ sudo apt-get install build-essential
$ sudo apt-get install gcc-5 g++-5
$ sudo apt-get install cmake
$ sudo apt-get install bc
$ sudo apt-get install python2.7
$ sudo apt-get install pkg-config
$ sudo apt-get install python-setuptools
$ sudo apt-get install python-dev
$ sudo apt-get install python-pyrex
$ sudo apt-get install cython
$ sudo apt-get install libncurses5-dev
$ sudo apt-get install python-numpy
$ sudo apt-get install python-scipy
$ sudo apt-get install libelf-dev
$ sudo apt-get install libsqlite3-dev
$ sudo apt-get install libusb-dev
$ sudo apt-get install libusb++-dev
$ sudo apt-get install libusb-1.0-0-dev
$ sudo apt-get install libasound2-dev
$ sudo apt-get install libffi-dev
$ sudo apt-get install libloki-dev
$ sudo apt-get install libboost-dev
$ sudo apt-get install libboost-python-dev
$ sudo apt-get install libao-dev
$ sudo apt-get install libsndfile-dev
$ sudo apt-get install python-klein
$ sudo apt-get install python-sysv-ipc
$ sudo apt-get install nginx
$ sudo apt-get install 

$ sudo apt-get install alsa-base
$ sudo apt-get install alsa-utils

Setup Kernel Build

The following commands are run as the user 'nw2s'. 

Download Kernel Snapshot (Kernel 4.1, SDK 2.00.01) (OLD - USE 4.4 in next step)

Note that we're using the screen program to be able to disconnect from the ssh session if necessary without killing the build process. The kernel compilation takes a bit of time and if you are disconnected accidentally, you can reconnect to the virtual session that screen creates.

$ sudo mkdir /media/sd
$ sudo mount /dev/mmcblk1p1 /media/sd


$ mkdir workarea
$ wget https://git.ti.com/processor-sdk/processor-sdk-linux/archive-tarball/processor-sdk-linux-02.00.01
$ tar -xvf processor-sdk-linux-02.00.01
$ mv processor-sdk-processor-sdk-linux linux-cl-som-am57x-ti
$ cd linux-cl-som-am57x-ti/
$ patch -p1 < /media/sd/linux-4.1.13-cl-som-am57x-ti-3.2.patch
$ screen


$ export ARCH=arm
$ make cl-som-am57x_defconfig && make menuconfig

Alternative git (TI Kernel 4.4, SDK 3.01.00)

Testing the TI Kernel 4.4 with Compulab patches to see what we can get working

$ cd ~/workarea
$ git clone git://git.ti.com/processor-sdk/processor-sdk-linux.git linux-cl-som-am57x-ti-git
$ cd linux-cl-som-am57x-ti-git/
$ git checkout -b cl-som-am57x-dev-ti-2.00.01 origin/processor-sdk-linux-02.00.01
$ git am ~/transfer/patches/*.patch
$ git remote add nw2s git@github.com:nw2s/b2-dsp-linux.gi
$ git push -u nw2s
-- merge with 3.01

$ git checkout -b cl-som-am57x-dev-ti-3.01.00
$ git merge processor-sdk-linux-03.01.00
$ git status
-- cry a little bit
-- start resolving conflicts

Note that the merged kernel is now located at https://github.com/nw2s/b2-dsp-linux - It works pretty well. No Wifi, but otherwise, the DSP is working.


Configure Kernel

There are currently only two modifications to the default CL-SOM kernel as follows:


Enable 'Sequencer Support' as a compiled feature ( * ) within the Sound card support Device Drivers section:

Select 1000Hz Timer Frequency in the Kernel Features page.

Configure gcc/g++ Versions

When configuring alternatives, choose v5 for each.

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 20
$ sudo update-alternatives --config gcc
$ sudo update-alternatives --config g++

Backup Original Kernel and Modules

Note: Do this only the first time. Once you've backed up the default modules and default kernel, that's enough to get you through a bad build.

$ sudo mount /dev/sda1 /boot
$ sudo cp /boot/am57xx-sbc-am57x.dtb /boot/am57xx-sbc-am57x.dtb.orig
$ sudo cp /boot/zImage-cl-som-am57 /boot/zImage-cl-som-am57.orig
$ sudo cp -R /lib/modules/4.1.13-cl-som-am57x-ti-3.2 /lib/modules/4.1.13-cl-som-am57x-ti-3.2.orig


Build Kernel, Modules, Device Tree

The first make command will take a while.

$ make
$ make zImage
$ make am57xx-sbc-am57x.dtb

Install Kernel, Modules, Device Tree

$ sudo make modules_install
$ sudo cp arch/arm/boot/zImage /boot/zImage-cl-som-am57x
$ sudo cp arch/arm/boot/dts/am57xx-sbc-am57x.dtb /boot/am57xx-sbc-am57x.dtb

cmem Kernel Module

$ cd ~/workarea
$ git clone git://git.ti.com/ipc/ludev.git
$ cd ~/workarea/ludev/src/cmem/module/
$ make KERNEL_INSTALL_DIR=/home/nw2s/workarea/linux-cl-som-am57x-ti ARCH=arm TOOLCHAIN_PREFIX= 
$ sudo mkdir /lib/modules/4.1.13-cl-som-am57x-ti-3.2/extra
$ sudo cp cmemk.ko /lib/modules/4.1.13-cl-som-am57x-ti-3.2/extra/
$ su
# echo -e "\ncmemk\n" >> /etc/modules
# depmod -a
# echo 'KERNEL=="cmem", MODE="0777"' >> /etc/udev/rules.d/99-nw2s.rules
# logout
$ sudo modprobe cmemk

Reboot

To make sure everything works, reboot

$ sudo reboot

Copy Pre-built TI Binaries

We need to overlay the pre-built TI OpenCL and related binaries

$ sudo cp -Rv /media/sd/cl-som-am57x/lib/firmware/* /lib/firmware/
$ sudo ln -s /lib/firmware/dra7-dsp1-fw.xe66.opencl-monitor /lib/firmware/dra7-dsp1-fw.xe66
$ sudo ln -s /lib/firmware/dra7-dsp2-fw.xe66.opencl-monitor /lib/firmware/dra7-dsp2-fw.xe66


$ sudo cp -Rv /media/sd/cl-som-am57x/usr/bin/* /usr/bin/
$ sudo cp -Rv /media/sd/cl-som-am57x/usr/include/* /usr/include/
$ sudo cp -Rv /media/sd/cl-som-am57x/usr/lib/* /usr/lib/
$ sudo cp -Rv /media/sd/cl-som-am57x/usr/share/* /usr/share/


$ sudo ln -s /usr/lib/libOpenCL.so.1.1.10 /usr/lib/libOpenCL.so.1.1
$ sudo ln -s /usr/lib/libOpenCL.so.1.1 /usr/lib/libOpenCL.so.1
$ sudo ln -s /usr/lib/libOpenCL.so.1 /usr/lib/libOpenCL.so
$ sudo ln -s /usr/lib/libticmem.so /usr/lib/libticmem.so.1
$ sudo ln -s /usr/lib/libtiipcutils.so /usr/lib/libtiipcutils.so.1


Test to see what's working

$ /usr/bin/ti-llvm3.6/arm-linux-gnueabi-llc --version

LLVM (http://llvm.org/):
  LLVM version 3.6.0
  Optimized build.
  Built Oct  3 2016 (17:45:55).
  Default target: arm-unknown-linux-gnueabi
  Host CPU: cortex-a15

  Registered Targets:
    arm     - ARM
    armeb   - ARM (big endian)
    c6000   - C6000
    msp430  - MSP430 [experimental]
    thumb   - Thumb
    thumbeb - Thumb (big endian)




Here is some old stuff that I'm keeping for now, but redoing:

 Click here to expand...

Development Libraries and Tools

LLVM/clang

If you thought the kernel took a while, building clang is rough. It'll be a few hours.

$ git clone git://git.ti.com/opencl/llvm.git llvm-build
$ mkdir ~/build-tools-3.6
$ cd llvm-build
$ git checkout release_36_ti
$ cd tools
$ git clone git://git.ti.com/opencl/clang.git
$ cd clang
$ git checkout release_36_ti
$ cd ../..
$ ./configure  --enable-optimized --disable-docs --prefix=$HOME/build-tools-3.6 --enable-targets=host,arm,c6000
$ screen
$ make
$ make install

IPCdev

$ cd ~/workarea
$ git clone git://git.ti.com/ipc/ipcdev.git
$ cd ipcdev/
$ ./configure --with-sysroot=/home/nw2s/build-tools --prefix=/home/nw2s/build-tools
$ make
$ sudo make install

ludev

$ cd ~/workarea
$ git clone git://git.ti.com/ipc/ludev.git
$ cd ludev/
$ ./configure
$ make
$ sudo make install


cmem Kernel Module

$ cd ~/workarea
$ git clone git://git.ti.com/ipc/ludev.git
$ cd ~/workarea/ludev/src/cmem/module/
$ make KERNEL_INSTALL_DIR=/home/nw2s/workarea/linux-cl-som-am57x-ti ARCH=arm TOOLCHAIN_PREFIX= 
$ sudo mkdir /lib/modules/4.1.13-cl-som-am57x-ti-3.2/extra
$ sudo cp cmemk.ko /lib/modules/4.1.13-cl-som-am57x-ti-3.2/extra/
$ su
# echo -e "\ncmemk\n" >> /etc/modules
# depmod -a
# echo 'KERNEL=="cmem", MODE="0777"' >> /etc/udev/rules.d/99-nw2s.rules
# logout
$ sudo modprobe cmemk


Code Generators

$ cd ~/workarea
$ wget http://software-dl.ti.com/codegen/esd/cgt_public_sw/C6000/8.1.2/ti_cgt_c6000_8.1.2_armlinuxa8hf_busybox_installer.sh
$ ./ti_cgt_c6000_8.1.2_armlinuxa8hf_busybox_installer.sh --prefix /home/nw2s/build-tools --temp /tmp/cgt
$ cd ~/build-tools/
$ mv usr/bin/* bin/
$ mv usr/share/ti share/
$ rm -rf usr/


TI OpenCL dsp.lib

This one's a doozy too

$ cd ~/workarea
$ git clone http://git.ti.com/git/opencl/ti-opencl.git

$ cd ti-opencl
$ cd builtins
$ screen
$ make BUILD_AM57=1 ARM_LLVM_DIR=~/build-tools TI_OCL_CGT_INSTALL=~/build-tools

TI OpenCL host

$ cd ~/workarea/ti-opencl/host
$ export CPATH=/home/nw2s/build-tools/include
$ make BUILD_AM57=1 ARM_LLVM_DIR=~/build-tools TI_OCL_CGT_INSTALL=~/build-tools
$ sudo make BUILD_AM57=1 ARM_LLVM_DIR=~/build-tools TI_OCL_CGT_INSTALL=~/build-tools install/local
$ cp lib/* ~/build-tools/lib/
$ cp -R /usr/include/CL ~/build-tools/include/


libm.lib

## add -I/home/nw2s/build-tools/share/ti/cgt-c6x/include to makefile c args
$ make BUILD_AM57=1 ARM_LLVM_DIR=~/build-tools TI_OCL_CGT_INSTALL=~/build-tools
$ cp libm.lib ~/build-tools/share/ti/


Upate ld.so.conf

$ sudo echo '/home/nw2s/build-tools/lib' > /etc/ld.so.conf.d/nw2s.conf
$ sudo ldconfig


TI /usr/share

$ sudo ln -s /home/nw2s/build-tools/share/ti /usr/share/ti


Co-processor Firmware

$ ln -s /home/nw2s/build-tools/lib/firmware/dra7-dsp1-fw.xe66.opencl-monitor lib/firmware/dra7-dsp1-fw.xe66
$ ln -s /home/nw2s/build-tools/lib/firmware/dra7-dsp2-fw.xe66.opencl-monitor lib/firmware/dra7-dsp2-fw.xe66
$ sudo ln -s /home/nw2s/build-tools/lib/firmware/dra7-dsp1-fw.xe66 /lib/firmware/
$ sudo ln -s /home/nw2s/build-tools/lib/firmware/dra7-dsp2-fw.xe66 /lib/firmware/


TODO: make lad run at boot

sudo ./lad_dra7xx -l lad.txt -p 777


TODO: build and run test program

CPATH=/home/nw2s/build-tools/include LIBRARY_PATH=/usr/lib:/usr/lib/arm-linux-gnueabihf:~/build-tools/lib make


sudo cp ~/build-tools/lib/firmware/ti-connectivity/wl18xx-conf.bin /lib/firmware/ti-connectivity/