Imx common » History » Version 44

« Previous - Version 44/65 (diff) - Next » - Current version
Matthias Tramm, 01/10/2017 03:23 PM


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

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
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

mmc part            # use if unsure which device/partition number to use
setenv mmcdev 0
setenv mmcpart 3    # <- dss20:3 / dss11e:5
run load_mmcscript
run mmcscript

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

./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/blob/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"