CM-FX6: Linux: Getting started

From Compulab Mediawiki
Jump to: navigation, search

Introduction

This article provides an introduction on how to install the Debian example root filesystem image on the CompuLab CM-FX6 System-on-Module / Computer-on-Module NAND or SSD.

Preparation steps

  • Obtain a PC workstation with a serial communication port.
  • For networked installation you need to install a TFTP server on the host PC. For Windows machines we recommend TFTPD32 included in the Linux package for CM-FX6 (link below).
  • Download the Linux package for CM-FX6 from CompuLab website. Unzip the package to a directory on your host workstation.
  • All image files mentioned below can be found in the images subdirectory.
  • Connect the host PC to the SB-FX6 base-board (connector P60) via the serial cable supplied with the evaluation kit.
  • Start the terminal emulation software on your PC. Set baud rate to 115200 bps, 8 bit per frame, 1 stop bit, no parity, no flow control.
  • Turn on the CM-FX6 evaluation system. The U-Boot boot-loader will start and you will get a command prompt.
Admolition note.png If the boot settings of your CM-FX6 are different than the default, you may need to press and hold Ctrl-C while turning the CM-FX6 on, in order to get command prompt.

Installation and Deployment Files

Installation media or TFTP export directory

  • kernel.img
  • imx6q-sbc-fx6.dtb
  • imx6dl-sbc-fx6.dtb
  • ramdisk.img
  • boot.scr

Installation media or NFS export directory

  • rootfs.tar.bz2
  • kernel.update.tar.bz2

Boot into the installation environment (ramdisk)

The first step in CM-FX6 Linux installation is starting the installation environment (Linux kernel and Ramdisk image). This can be done using the following media:

Using installation environment on MMC/SD card

The partition can be formatted as either ext2/3/4 or FAT file system.

  • Insert the MMC/SD card into the SD socket (P6) on the SB-FX6.
  • Use the following U-boot commands to boot the installation environment on the CM-FX6 quad/dual lite configuration:
CM-FX6 #
setenv loadaddr 0x10800000
mmc dev 2; mmc rescan
load mmc 2 ${loadaddr} boot.scr
source ${loadaddr}

Using installation environment on USB storage

The partition can be formatted as either ext2/3/4 or FAT file system.

  • Insert the USB storage into a USB socket on the SB-FX6.
  • Use the following U-boot commands to boot the installation environment on a CM-FX6 quad/dual lite configuration:
CM-FX6 #
setenv loadaddr 0x10800000
usb start
load usb 0 ${loadaddr} boot.scr
source ${loadaddr}

Using installation environment from TFTP server

  • Connect the CM-FX6 Ethernet port (connector P9 marked as "CM ETHERNET" on the SB-FX6) to your local network.
  • Copy files listed in Installation media or TFTT export directory from Linux package for CM-FX6 to a TFTP server export directory:
    - On Windows machine: copy files to the same folder and point the TFTP server to that folder
    - On Linux machine: copy files to the TFTP server root directory, usually /tftpboot or /tftproot.
  • You can use U-boot dhcp command to obtain IP address or manually set ipaddr environment variable:
CM-FX6 # setenv ipaddr <CM-FX6 ip address>
  • Set the serverip environment variable and save the new environment:
CM-FX6 # setenv serverip <tftp server host ip address>
CM-FX6 # saveenv
  • Set a correct value for the fdt_file variable:
  • Quad
CM-FX6 # setenv fdt_file imx6q-sbc-fx6.dtb
  • Dual
CM-FX6 # setenv fdt_file imx6dl-sbc-fx6.dtb
  • Use the following U-Boot commands to boot Linux on CM-FX6:
CM-FX6 #
setenv fdt_high 0xffffffff
setenv fdt_addr 0x15000000
setenv bootm_low 0x15000000
setenv bootm_size 0x20000000
setenv load_addr 0x10800000
setenv ramdisk_addr 0x12000000
setenv bootargs 'root=/dev/ram0 rw ramdisk_size=16384 console=ttymxc3,115200 ip=dhcp'
tftpboot ${load_addr} kernel.img && tftpboot ${fdt_addr} ${fdt_file} && tftpboot ${ramdisk_addr} ramdisk.img
bootz ${load_addr} ${ramdisk_addr} ${fdt_addr}

Install Kernel and Root Files System Images

After the ramdisk image is loaded the bash shell prompt shows up:

root@cl-ramdisk:/#

The next step is installing the kernel and Debian Linux images. The following media can be used as a source for installation:

Mount MMC/SD Card

  • Insert the MMC/SD card into the SD socket (P6) on the SB-FX6.
  • The MMC/SD card is mounted automatically under /media/mmcblk2pX. Where X is the partition number.
  • If for some reason the MMC/SD card hasn't been mounted automatically, use the following mount command:
root@cl-ramdisk:~# mkdir -p /media/mmcblk2pX && mount /dev/mmcblk2pX /media/mmcblk2pX

Mount USB Storage Device

  • Plug the USB storage device to the lower port on the dual USB host connector P13 of the SB-FX6.
  • The USB device is mounted automatically under /media/sdXY. Where X is the device letter and Y is the partition number.
  • If for some reason the USB storage device hasn't been mounted automatically, use the following mount command:
root@cl-ramdisk:~# mkdir -p /media/sdXY && mount /dev/sdXY /media/sdXY

Mount NFS drive

  • Connect the CM-FX6 Ethernet port (connector P9 marked as "CM ETHERNET" on the SB-FX6) to your local network.
  • Copy files listed in Installation media or NFS export directory from Linux package for CM-FX6 to an NFS server export directory.
  • Obtain an IP address for the CM-FX6:
    • Using DHCP:
      root@cl-ramdisk:~# ifup `basename /sys/devices/platform/enet.0/net/eth?`
    • If you do not have a DHCP server, you can set a static IP address using ifconfig:
      root@cl-ramdisk:~# ifconfig `basename /sys/devices/platform/enet.0/net/eth?` <ip address>
  • Mount the NFS share containing the kernel.update.tar.bz2 and the rootfs.tar.bz2 files:
root@cl-ramdisk:~# mount -o nolock <host ip>:/path/to/nfs/share /mnt/net

Install Images

Once the ramdisk image is loaded and the media containing the CM-FX6 Kernel and Debian Linux images is mounted, the installation can be done on either of the following:

Install on the NAND flash

  • In this subsection the term /mount/point can be:
    • /mnt/net if NFS is used
    • /media/mmcblk2pX if an MMC/SD card is used, where X is the partition number.
    • /media/sdXY if a USB storage is used, where X is the USB drive letter and Y is the partition number.
rootfs/mtd4
  • Format the NAND flash root filesystem partition:
root@cl-ramdisk:~# ubiformat --yes /dev/mtd4
  • Attach the NAND flash root filesystem partition:
root@cl-ramdisk:~# ubiattach -m 4 -d 0
  • Create a ubi volume and name it "rootfs":
root@cl-ramdisk:~# ubimkvol /dev/ubi0 -m -N rootfs
  • Mount the ubi volume:
root@cl-ramdisk:~# mkdir -p /media/rootfs && mount -t ubifs ubi0:rootfs /media/rootfs
  • Extract the content of rootfs.tar.bz2 onto the /media/rootfs:
root@cl-ramdisk:~# tar -xvpjf /mount/point/rootfs.tar.bz2 -C /media/rootfs && sync
  • Extract the content of kernel.update.tar.bz2 onto the /media/rootfs:
root@cl-ramdisk:~# tar -xvpjf /mount/point/kernel.update.tar.bz2 -C /media/rootfs && sync
Kernel/mtd3
  • Select a correct device tree file that meets the configuration requirements:
  • Quad
 root@cl-ramdisk:~# export fdt_file=imx6q-sbc-fx6.dtb 
  • Dual
 root@cl-ramdisk:~# export fdt_file=imx6dl-sbc-fx6.dtb 
  • Format the NAND flash kernel partition and write the kernel image onto it:
root@cl-ramdisk:~#
flash_erase /dev/mtd3 0 0
nandwrite -p /dev/mtd3 /media/rootfs/boot/zImage-cm-fx6
nandwrite -p /dev/mtd3 -s 0x780000 /media/rootfs/boot/${fdt_file}
  • Unmount the ubi volume:
root@cl-ramdisk:~# umount /media/rootfs

Install on the SSD Disk-on-Chip

Admolition note.png The below procedure will work only on empty SSD Disk-on-Chip. If you have already used the SSD, please delete all the partitions before proceeding.
  • In this subsection the term /mount/point can be:
    • /mnt/net if NFS is used
    • /media/mmcblk2pX if an MMC/SD card is used, where X is the partition number.
    • /media/sdXY if USB storage is used, where X is the USB drive letter and Y is the partition number.
  • Create two partitions for the Linux kernel (EXT4 100M) and root file system (EXT4 the rest of the disk) on the SSD:
root@cl-ramdisk:~# echo -e "n\np\n1\n\n+100M\na\n1\nt\nc\nn\np\n2\n\n\nw\neof\n" | fdisk /dev/sda
  • Format 1-st boot-partition with EXT4 file system:
root@cl-ramdisk:~# mkfs.ext4 -L boot /dev/sda1
  • Format 2-d rootfs-partition with EXT4 file system:
root@cl-ramdisk:~# mkfs.ext4 -L rootfs /dev/sda2
  • Mount both partitions:
root@cl-ramdisk:~# mkdir -p /media/rootfs && mount /dev/sda2 /media/rootfs
root@cl-ramdisk:~# mkdir -p /media/rootfs/boot && mount /dev/sda1 /media/rootfs/boot
  • Extract the content of rootfs.tar.bz2 onto the second partition:
root@cl-ramdisk:~# tar -xvpjf /mount/point/rootfs.tar.bz2 -C /media/rootfs && sync
  • Extract the content of kernel.update.tar.bz2 onto the second partition:
root@cl-ramdisk:~# tar -xvpjf /mount/point/kernel.update.tar.bz2 -C /media/rootfs && sync
  • Unmount both SSD partitions:
root@cl-ramdisk:~# umount /dev/sda1
root@cl-ramdisk:~# umount /dev/sda2

After Installation

Admolition note.png If the boot settings of the CM-FX6 are different than default, you may need to press and hold Ctrl-C while turning the CM-FX6 on, in order to get command prompt.

Boot Environment

Common Environment Variables

CM-FX6 #
setenv bootdelay 3
setenv loadaddr 0x10800000
setenv fdt_high 0xffffffff
setenv fdt_addr 0x15000000
setenv bootm_low 0x15000000
setenv bootm_size 0x20000000
setenv zImage zImage-cm-fx6

Board Dependent Environment Variables

CM-FX6 has two different SoC modifications: quad and dual lite.
The U-Boot has to read the SoC revision number in order to make use of a correct device tree blob.

  • Get and save board revision board_rev:
CM-FX6 # setenv get_board_rev '\
mw.b ${loadaddr} 0x61;\
if cmp.b ${loadaddr} 0x020C8262 1;\ 
then;\
        setenv board_rev 'dl';\
else;\
        mw.b ${loadaddr} 0x63;\
        if cmp.b ${loadaddr} 0x020C8262 1;\ 
        then;\
                setenv board_rev 'q';\
        else;\
                setenv board_rev;\
        fi;\
fi;'
CM-FX6 # run get_board_rev; printenv board_rev && saveenv
  • Validate board_rev:
Admolition note.png Make sure that it is q or dl
CM-FX6 # echo ${board_rev}
  • Set default value for fdt_file:
CM-FX6 # setenv fdt_file imx6${board_rev}-sbc-fx6.dtb

Display Options

CM-FX6 evaluation platform has six video output interfaces: LCD, DVI, HDMI, 2xLVDS and MIPI.
Only four of them can be configured at the same time. The default configuration is: LCD, HDMI and 2xLVDS.

Mapping Default Video Output

Using a correct device tree file and a kernel video parameter allows changing the default (mxcfb0) mapping.

  • LCD, SB-FX6 P50 connector
CM-FX6 # setenv fdt_file imx6${board_rev}-sbc-fx6.dtb
  • DVI, SB-FX6 J6 connector
CM-FX6 # setenv video video=mxcfb0:dev=lcd,1920x1080M-32@50,if=RGB32 
CM-FX6 # setenv fdt_file imx6${board_rev}-sbc-fx6.dtb
  • HDMI, SB-FX6 J6 connector
CM-FX6 # setenv fdt_file imx6${board_rev}-sbc-fx6-hdmi.dtb
  • MIPI, SB-FX6 P19 connector
CM-FX6 # setenv fdt_file imx6${board_rev}-sbc-fx6-mipi.dtb 

SSD/SATA Boot Parameters

CM-FX6 #
setenv set_media 'setenv satadev 0; sata init'
setenv set_args 'setenv bootargs console=ttymxc3,115200 root=/dev/sda2 rootfstype=ext4 rw rootwait'
setenv load_kernel 'load sata ${satadev} ${loadaddr} ${zimage}'
setenv load_dtb 'load sata ${satadev} ${fdt_addr} ${fdt_file}'

MMC Boot Parameters

CM-FX6 #
setenv set_media 'setenv mmcdev 2; mmc dev ${mmcdev}'
setenv set_args 'setenv bootargs console=ttymxc3,115200 root=/dev/mmcblk2p2 rootfstype=ext4 rw rootwait'
setenv load_kernel 'load mmc ${mmcdev} ${loadaddr} ${zimage}'
setenv load_dtb 'load mmc ${mmcdev} ${fdt_addr} ${fdt_file}'

NAND Boot Parameters

CM-FX6 #
setenv set_media 'echo nand is ready'
setenv set_args 'setenv bootargs console=ttymxc3,115200 root=ubi0:rootfs rw rootfstype=ubifs ubi.mtd=rootfs'
setenv load_kernel 'nand read ${loadaddr} 0 800000'
setenv load_dtb 'nand read ${fdt_addr} 780000 10000'

Boot Command

  • Extra boot parameters
CM-FX6 # setenv set_args+ 'setenv bootargs ${bootargs} ${video} vmalloc=256M cma=384M ip=dhcp'
  • Default boot command
CM-FX6 #
setenv set_boot 'run set_media; run set_args; run set_args+; run load_kernel; run load_dtb;'
setenv bootcmd 'run set_boot; bootz ${loadaddr} - ${fdt_addr}'

See also