iMX platforms

for specific targets see DSS11-E or DSS20

Compilers

http://www.linaro.org/downloads/

https://releases.linaro.org/components/toolchain/binaries/latest-5.1/arm-linux-gnueabihf/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf.tar.xz
https://releases.linaro.org/components/toolchain/binaries/latest-5.1/arm-eabi/gcc-linaro-5.1-2015.08-x86_64_arm-eabi.tar.xz

for u-boot it's sufficient to use the bare metal compiler, for the kernel use the gnueabihf

U-Boot

https://git.digitalstrom.org/bsp/dss11e-u-boot/tree/dss_2016.01

Build and Install

dss11e: dss11e6q2g_config
dss20: dss20sdl1g_config

make dss11e6q2g_config
make -j4 u-boot.imx

Full documentation incl. flashing, documented here
https://git.digitalstrom.org/bsp/dss11e-u-boot/blob/dss_2016.01/README.md

From Linux command line on the target:

flash-u-boot.sh <imx file>

Default Environment

https://git.digitalstrom.org/bsp/dss11e-u-boot/blob/dss_2016.01/include/configs/dss11e6x.h#L166

#ignore the CONFIG_SYS_EXTRA_ICT
https://git.digitalstrom.org/bsp/dss11e-u-boot/blob/dss_2016.01/include/configs/dss20sdl.h#L316

Boot order

Boot option are tried in this order, read: option1 is tried first, then option2, and so on...

Always to inspect BOOTCMD variable to verify this table is up to date

dss11e dss20
1. rescue /dev/mmcblk0p3 /dev/mmcblk0p2
2. rootfs /dev/mmcblk0p5 /dev/mmcblk0p3
3. raw kernel /dev/mmcblk0p1 n/a
4. usb stick yes yes
5. tftp server yes yes

dsse:/dev/mmclk0p2 was used for rootfs-kernel, unused, not searched by u-boot

booting from rescue partition (option1):
  • check for boot.scr (rescue system)
  • check fur zImage/dtb file bin /boot (unused)
    -- hence it actually 2 options
booting from rootfs partition (option2):
  • check for boot.scr (unused)
  • check fur zImage/dtb file bin /boot (option)
    -- hence actually 2 options
booting from usb stick
  • check and execute for boot.scr
booting from tftp:
  • check and execute boot.scr

By-pass rescue-system and boot from rootfs directly

dSS> mmc dev 0           # <- dss11e:1
dSS> setenv mmcdev 0     # <- dss11e:1
dSS> setenv mmcpart 3    # <- dss20:3 / dss11e:5
dSS> run load_mmcscript
dSS> source

autocompletion works

dSS> mmc list
FSL_SDHC: 0
FSL_SDHC: 1
dSS> mmc dev 1 # <- active device
dSS> mmc part            # use if unsure which device/partition number to use

USB rescue-stick

$ wget https://git.digitalstrom.org/dss-oe/rescue-images/raw/master/dss11e/rescue-devel-initramfs-dss11e.cpio.gz.u-boot
$ wget https://git.digitalstrom.org/dss-oe/rescue-images/raw/master/dss11e/uImage-kernel--dtb-imx6q-dss11e-rescue.bin
$ mv rescue-devel-initramfs-dss11e.cpio.gz.u-boot initramfs
$ mv uImage-kernel--dtb-imx6q-dss11e-rescue.bin uImage

Create a boot.scr from the following script, see u-boot script howto

$ cat boot-script.txt
# from u-boot start with: run usb_script
echo ===== Starting rescue system from USB stick =====

setenv rd_addr 0x70000000

load usb 0:1 ${loadaddr} uImage 
load usb 0:1 ${rd_addr} initramfs

run mmcargs
bootm ${loadaddr} ${rd_addr}

Place the create boot.scr onto the usb stick, then reboot.

$ wget https://git.digitalstrom.org/bsp/dss11e-u-boot/raw/dss_2016.01/tools/pack_bootscr.sh
$ sh pack_bootscr.sh boot-script.txt
dSS > run usbscript
Loading from USB...
...
===== Starting rescue system from USB stick ====== 

U-Boot scripts

The compiled in default environment can be modified and extended by scripts. We don't modify it in our system at all. We only do when we need to modify the default boot order. For example want to load and boot self compiled kernel from tftp, see also TFTP example below

http://www.denx.de/wiki/view/DULG/UBootScripts

Step-by-step

1. create simple text file using u-boot commands

echo "echo \"Hello World\"" > test.txt

2. convert text file into u-boot script

basically adds header/checksum in front of the text

$ wget https://git.digitalstrom.org/bsp/dss11e-u-boot/raw/dss_2016.01/tools/pack_bootscr.sh
$ sh pack_bootscr.sh test.txt

this will produce a boot.scr in the same folder.
pack_bootscr.sh can be found here: https://git.digitalstrom.org/bsp/dss11e-u-boot/raw/dss_2016.01/tools/pack_bootscr.sh

Note that it require mkimage part of u-boot-tools on debian/ubuntu

3. copy the boot.scr file onto a usb stick or make it available from your tftp

from the u-boot cmdline start your script:

run usbscript

same for tftp:

run load_netscript && source

Tftp Script to boot custom kernel from tftp

echo "TFTP Script" 
# setenv image <name>
tftp $image
tftp ${fdt_addr} ${fdt_file}
run mmcargs
bootz ${loadaddr} - ${fdt_addr};

create the boot.scr and copy or link from the srv/tftp folder

tools/pack_bootscr.sh tftpboot.txt

Rewrite the u-boot standard bootcmd to boot from tftp script directly:

setenv bootcmd 'run load_netscript && source'
saveenv

When done, you can simply revert u-boot environment to the factory defaults:

env default -a
saveenv

Re-flash device using u-boot script

load usb 0:1 ${loadaddr} digitalstrom-image-dss20.dssimg
run fsz2s
mmc write ${loadaddr} 0 ${filesects}

load usb 0:1 ${loadaddr} digitalstrom-production-rootfs-dss20.ext3
#load usb 0:1 ${loadaddr} digitalstrom-fieldtest-rootfs-dss20.ext3
#load usb 0:1 ${loadaddr} digitalstrom-testing-rootfs-dss20.ext3
#load usb 0:1 ${loadaddr} digitalstrom-devel-rootfs-dss20.ext3

run fsz2s
mmc write ${loadaddr} C1800 ${filesects}
boot

Debugging

You can check the CRC of the created uImage from U-Boot cmdline

http://www.denx.de/wiki/view/DULG/UBootCmdGroupInfo#Section_5.9.1.4.

U-Boot > iminfo $rd_addr
## Checking Image at 1a000000 ...
   Legacy image found
   Image Name:   digitalstrom-rescue-initramfs-ds
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    6308330 Bytes = 6 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

Figure out RAM offsets:

U-Boot > bdinfo
# tbd

Kernel

Good source of information:
https://eewiki.net/display/linuxonarm/Wandboard#Wandboard-Debian8(pre-release)

Build

git clone ssh://git@git.digitalstrom.org:16022/bsp/linux.git
git checkout -b dSS origin/dSS

dss11e/dss20 share the kernel configuration, they only differ in device-tree file

make dss20_defconfig
make clean && make -j6 zImage
make imx6q-dss11e.dtb
make imx6dl-dss20.dtb

uImage with appended dtb

Creates a single file from kernel and device tree, protected by CRC.

Advantages:
- can be flashed into raw partition, for two files need a file system, or define offsets
- crc checks and be used in u-boot if-then-else conditions

http://update.aizo.com/feeds/digitalstrom-devel-eglibc/images/dss11e/uImage-dtb-imx6q-dss11e6x.bin
https://git.digitalstrom.org/dss-oe/dss-oe/blob/master/yocto/dS/meta-digitalstrom-devel/recipes-kernel/linux/linux-astralix_4.1.0.bb
https://git.digitalstrom.org/dss-oe/dss-oe/blob/master/yocto/dS/meta-digitalstrom-devel/recipes-kernel/linux/dtb-append.inc

manual creation:

ZRELADDR=0x12000000
VERSION=4.1.0-rc4
DTB=imx6q-dss11e6x.dtb

make zImage
make $DTB

# http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091457.html
cat arch/arm/boot/zImage arch/arm/boot/dts/$DTB > zImage.tmp
mkimage -A arm -O linux -C none -T kernel -a $ZRELADDR -e $ZRELADDR -n Linux-${VERSION} -d zImage.tmp uImage-dtb-dss11e1g

OTP programming

https://community.freescale.com/thread/354654

https://git.digitalstrom.org/bsp/fsl-otp-tool

mac address in one-time-programmable(OTP) area

iMX6 expects the MAC address in the OTP Area. U-boot and kernel fetch it from there. You can check the OTP content with fsl-otp-tool. Compare its output with MAC address printed on the device.

opkg install fsl-otp-tool
fsl-otp-tool

Currently enabled for dss11e minor effort needed for dss20

Appendix

pack_bootscr.sh

#!/bin/sh

PROG=$(basename $0 .sh)

usage() {
    echo "Usage:" 
    echo "  $PROG [-d output] script" 
    echo "Options:" 
    echo "  -o output    optional, default is boot.scr" 
    echo "" 
    echo "Packs given script into uImage format" 
    echo "" 
}

AUTORUN=boot.scr

while getopts ":ho:" option; do
    case $option in
        o)
            AUTORUN="$OPTARG" 
            ;;
        h)
            usage
            exit 0
            ;;
        ?)
            usage
            exit 1
            ;;
    esac
done

shift $(($OPTIND - 1))

if [ $# -ne 1 ]; then
    usage
    exit 1
fi

INPUT="$1" 

echo
echo "Packing $INPUT into uImage: $AUTORUN" 
echo

mkimage -T script -C none -n 'Autorun Script' -d "$INPUT" "$AUTORUN" 

Manual install of rescue-system from rescue-system

Fetch latest rescue:

# wget http://update.aizo.com/feeds/digitalstrom-rescue-devel/images/dss20/rescue-devel-update-dss20.swu
# cpio -it < rescue-devel-update-dss20.swu
sw-description
rescue-system-20180327013022.tar.gz
# cpio -i rescue-system-20180327013022.tar.gz < rescue-devel-update-dss20.swu
# mount /dev/mmcblk0p2 /mnt  # <- check sw-description if unsure about mmc partition
# tar xzf rescue-system-20180327013022.tar.gz -C /mnt
# cd /mnt
# rm rescue-system; ln -s rescue-system-20180327013022 rescue-system
# ln -sf rescue-system/boot.scr boot.scr
root@dSS20:/mnt/rescue# ls -l
lrwxrwxrwx    1 root     root            22 Mar 28 10:31 boot.scr -> rescue-system/boot.scr
lrwxrwxrwx    1 root     root            28 Mar 28 10:31 rescue-system -> rescue-system-20180327013022
drwxr-xr-x    3 1001     1001          1024 Mar 28 03:30 rescue-system-20180327013022

If unsure you can verify checksums:

root@dSS20:/mnt/rescue/rescue-system-20180327013022# sha256sum -c meta/checksums 
./boot.scr: OK
./initrd: OK
./meta/feed: OK
./meta/pkg-format: OK
./meta/version: OK
./rescue-devel-initramfs-dss20.cpio.gz.u-boot: OK
./uImage: OK
./uImage-kernel--dtb-imx6dl-dss20-rescue.bin: OK