Author: Sam Protsenko <semen.protsenko at linaro dot org>

Booting mainline Linux on DRA7XX EVM

Download toolchains

There are two toolchains will be needed to build following stuff:

  • ARM EABI toolchain: to build u-boot and kernel
  • ARM Linux toolchain: to build BusyBox rootfs.

I'm using 14.04 Linaro toolchains. Newer versions may be used as well.

Toolchains can be obtained using next links:

Unpack both archives to /opt:

# tar xjvf gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.bz2 -C /opt
# tar xjvf gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.bz2 -C /opt

u-boot

Download and checkout

Clone mainline u-boot from official repository:

$ git clone git://git.denx.de/u-boot.git
$ cd u-boot

Checkout to latest stable tag:

$ git checkout v2016.01

Configuring toolchain

$ export PATH=/opt/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH
$ export CROSS_COMPILE="arm-none-eabi-"
$ export ARCH=arm

Build u-boot

Configure:

$ make dra7xx_evm_defconfig

Build:

$ make

Output files:

 - MLO          first-stage bootloader
 - u-boot.img   second-stage bootloader

kernel

Download and checkout

We want Linux kernel v4.4, which is stable mainline for now, and it's also LTS release:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ git checkout v4.4

Configuring toolchain

See u-boot toolchain configuration above.

Kernel configuration

Create ti_config_fragments directory:

$ mkdir ti_config_fragments

Save dra7_only.cfg file to ti_config_fragments directory.

Create kernel configuration:

$ scripts/kconfig/merge_config.sh         \
    arch/arm/configs/omap2plus_defconfig  \
    ti_config_fragments/dra7_only.cfg
$ make oldconfig

Make sure that .config has console=ttyO0 in CONFIG_CMDLINE.

Build kernel

Build kernel and device tree blob:

$ make -j4 zImage
$ make dra7-evm.dtb

Output files:

 - arch/arm/boot/zImage               kernel image
 - arch/arm/boot/dts/dra7-evm.dtb     device tree blob

rootfs

Download and checkout

Download from official repository and checkout to last stable tag:

$ git clone git://git.busybox.net/busybox
$ git checkout 1_24_1

Configuring toolchain

$ export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin:$PATH
$ export CROSS_COMPILE="arm-linux-gnueabihf-"
$ export ARCH=arm

Build

Create BusyBox static configuration:

$ make defconfig
$ sed -i -e 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config

Build and install:

$ make -j4
$ make install

Prepare init files:

$ mkdir -p _install/{dev,sys,proc,debug,etc/init.d}
$ cat > _install/etc/init.d/rcS << EOF
#!/bin/sh
mount -t sysfs none /sys
mount -t proc none /proc
mount -t debugfs none /debug
mdev -s
EOF

$ chmod +x _install/etc/init.d/rcS
$ cd _install/
$ ln -s bin/busybox init
$ cd -

Output files will reside in _install/ directory.

Prepare SD card

For now mainline u-boot is missing fastboot/eMMC functionality for DRA7XX EVM, so we are going to use SD card to run kernel.

Format SD card

SD card needs to have 2 partitions on it: "boot" (FAT32) and "rootfs" (ext4).

I'm using 4GB micro-SD card.

Script below will partition and format SD card for you (making 100MB for "boot" partition and the rest of SD card for "rootfs").

NOTE: Be sure to use sfdisk 2.27.* or above. It was noticed that my script doesn't work with sfdisk 2.25.2.

   1 #!/bin/bash
   2 
   3 disk=""
   4 boot_part=""
   5 rootfs_part=""
   6 
   7 print_usage() {
   8         echo "Usage: $0 sd_card_device"
   9         echo
  10         echo "Example:"
  11         echo "    $0 /dev/mmcblk0"
  12 }
  13 
  14 parse_arguments() {
  15         if [ $# -ne 1 ]; then
  16                 echo "Error: Wrong arguments count ($#)" >&2
  17                 print_usage
  18                 exit 1
  19         fi
  20 
  21         disk=$1
  22         boot_part=${disk}p1
  23         rootfs_part=${disk}p2
  24 
  25         if [ $disk != "/dev/mmcblk0" ]; then
  26                 echo "PROTECTION!!! Use only /dev/mmcblk0 or modify script!" >&2
  27                 exit 1
  28         fi
  29 
  30         if [ ! -e $disk ]; then
  31                 echo "Error: $disk file not found" >&2
  32                 exit 1
  33         fi
  34 }
  35 
  36 create_partitions() {
  37         echo "---> Erase partition table/labels on micro-SD card..."
  38         sudo dd if=/dev/zero of=${disk} bs=1M count=1
  39 
  40         echo
  41         echo "---> Create partition layout..."
  42         sudo sfdisk ${disk} << EOF
  43                 2048,100M,0x0c,*
  44                 ,,L,-
  45 EOF
  46 
  47         if [ ! -e $boot_part ]; then
  48                 echo "Error: $boot_part file not found" >&2
  49                 exit 1
  50         fi
  51 
  52         if [ ! -e $rootfs_part ]; then
  53                 echo "Error: $rootfs_part file not found" >&2
  54                 exit 1
  55         fi
  56 
  57         echo
  58         echo "---> Format partitions..."
  59         echo "  --> Format partition 1 (boot)..."
  60         sudo mkfs.vfat -F 32 -n "boot" $boot_part
  61         echo "  --> Format partition 2 (rootfs)..."
  62         sudo mkfs.ext4 -F -L "rootfs" $rootfs_part
  63 }
  64 
  65 parse_arguments $*
  66 create_partitions

Copying files

"boot" partition

Copy next files to "boot" partition of your SD card:

 - MLO
 - u-boot.img

Also create uEnv.txt file with next content:

fdtfile=dra7-evm.dtb

"rootfs" partition

Copy "_install/*" files from BusyBox to "rootfs" partition of SD card. Also, create "boot/" directory on "rootfs" partition and copy next files there:

 - zImage
 - dra7-evm.dtb

Boot from SD card

SYSBOOT configuration

Be sure to configure SYSBOOT switches (SW2, SW3) to boot from SD card.

align="middle"

align="middle"

SYSBOOT[0-15] (SW2[1-8], SW3[1-8]):

position: 0  1  0  0  | 0  1  0  0 | 1  0  0  0  | 0  0  0  1
                      |            |             |
bit #:    0  1  2  3  | 4  5  6  7 | 8  9  10 11 | 12 13 14 15

Also check SW5 pins:

USERCONFIG[1-10] (SW5): 0010 1000 00 
O - OFF
1 - ON

See DRA7XX TRM (chapter 32 "Initialization", Table 32-6 "Booting Devices Order") and this link for details.

Boot

Insert prepared SD card and connect power plug into your board power socket.

Use default u-boot environment

You may need to reset your u-boot environment. On boot, press any key and get to u-boot shell. Now execute next commands:

=> env default -f -a
=> env save
=> reset

Booting mainline Linux + Android Linux on DRA7XX EVM

Previously described stuff

kernel

Download and checkout

We want Linux kernel v4.4, which is stable mainline for now, and it's also LTS release:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ git checkout v4.4

Create integrated Android branch

Now let's create integrated branch by merging Android branch to mainline k4.4. Android branch of k4.4 is here.

$ git checkout -b linux-4.4
$ git remote add android https://android.googlesource.com/kernel/common
$ git fetch --all
$ git checkout experimental/android-4.4
$ git checkout linux-4.4
$ git checkout -b android-4.4
$ git merge --no-ff experimental/android-4.4

Kernel configuration

Create ti_config_fragments directory:

$ mkdir ti_config_fragments

Save next files to ti_config_fragments directory:

Change console to ttyO0 in android_omap.cfg:

$ sed -i -e 's/ttyS0/ttyO0/g' ti_config_fragments/android_omap.cfg

Create kernel configuration:

$ scripts/kconfig/merge_config.sh           \
    arch/arm/configs/omap2plus_defconfig    \
    android/configs/android-base.cfg        \
    android/configs/android-recommended.cfg \
    ti_config_fragments/dra7_only.cfg       \
    ti_config_fragments/android_omap.cfg
$ make oldconfig

Make sure that .config has console=ttyO0 in CONFIG_CMDLINE.

Build kernel

Build kernel and device tree blob:

$ make -j4 zImage
$ make -j4 uImage LOADADDR=0x80008000
$ make dra7-evm.dtb

Output files:

 - arch/arm/boot/uImage               kernel image for u-boot
 - arch/arm/boot/dts/dra7-evm.dtb     device tree blob

AFS

Download AFS images from here (these are pre-built images for 6AL1.2 release).

Unpack:

$ tar xzvf 6AL_1_2-P1_emmc.tgz

Prepare files for SD card boot, using script provided in archive (as it's described here):

$ ./mk_sd_bin.sh .

Prepare SD card

How to format SD card -- see in this section.

Copying files

"boot" partition

Copy next files to "boot" partition of your SD card:

  • from u-boot you built:
    • MLO
    • u-boot.img
  • from kernel you built:
    • uImage
    • dra72-evm.dtb

"rootfs" partition

Copy all files from sd/fs directory (from pre-built AFS you unpacked before):

$ cp -R sd/fs/. /media/mmcblk0p2
$ sync

Boot from SD card

Power on your board and go to u-boot shell. Run next commands (from here) to load kernel to RAM and run it:

fatload mmc 0:1 0x80300000 uImage
fatload mmc 0:1 0x82f80000 dra7-evm.dtb
part uuid mmc 0:2 uuid
setenv bootargs root=PARTUUID=${uuid}
bootm 0x80300000 - 0x82f80000

Known issues

bad magic

If after reboot you see something like this in u-boot output:

Trying to boot from MMC
bad magic
bad magic
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Just try to disconnect and connect power plug.

bad root

If kernel crashes with message like this:

[    4.258810] VFS: Cannot open root device "PARTUUID=2a94c813-02" or
unknown-block(0,0): error -6
[    4.268210] Please append a correct "root=" boot option; here are
the available partitions:

probably kernel cmdline is wrong. Make sure you have CONFIG_CMDLINE_EXTEND=y option in your kernel .config file.

Debugging tips

early printk

To enable early printk feature in kernel:

1. Add to earlyprintk param to CONFIG_CMDLINE option (for example, in .config file)

2. Enable CONFIG_DEBUG_LL in menuconfig

3. Select CONFIG_DEBUG_OMAP2UART1 as early serial console

4. Enable CONFIG_EARLY_PRINTK in menuconfig

5. [optional]: Enable CONFIG_EARLY_PRINTK_DIRECT in menuconfig

Boards/DRA7EVM (last modified 2017-08-31 12:05:05)