OpenRex: How to start with Software

Here you will find some basic info about how to start with YOCTO and OpenRex. If you follow the steps below, you will be able to compile the source code by yourself.

In case you would like to know more about YOCTO & How To Use It, for example how to create, modify and compile it for your own board have a look at: How to develop your own software: uBoot, Linux, Filesystem, YOCTO

Prepare the environment

1) Prepare a linux host machine

If you are using windows or you are not a Linux user, you will need to prepare a Linux host machine. Here you will find instructions how to do it: How to prepare a Host machine for YOCTO

2) Install the repo utility

*Note: If you went through "How to prepare a Host machine for YOCTO", you don't have to run these steps.
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

3) Get the YOCTO project

*Note: If you went through "How to prepare a Host machine for YOCTO", you don't have to run these steps.
cd
mkdir fsl-community-bsp
cd fsl-community-bsp
PATH=${PATH}:~/bin
repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b jethro

4) Add openrex support - create manifest

cd ~/fsl-community-bsp/
mkdir -pv .repo/local_manifests/
Copy and paste this into your Linux host machine:
cat > .repo/local_manifests/imx6openrex.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <remote fetch="git://github.com/FEDEVEL" name="fedevel"/>

  <project remote="fedevel" revision="jethro" name="meta-openrex" path="sources/meta-openrex">
    <copyfile src="openrex-setup.sh" dest="openrex-setup.sh"/>
  </project>
</manifest>
EOF

5) Sync repositories

repo sync

6) Add OpenRex meta layer into BSP

source openrex-setup.sh

Building images

Currently Supported machines

Here is a list of "machine_names" which you can use to build OpenRex images. Use the "machine_name" based on the board you have:
  • imx6q-openrex
  • imx6s-openrex

Setup the environment

cd ~/fsl-community-bsp/
MACHINE=machine_name source setup-environment build-openrex
Replace "machine_name" with a name from the list above. For example if you would like to prepare files for OpenRex QUAD, run following command:
cd ~/fsl-community-bsp/
MACHINE=imx6q-openrex source setup-environment build-openrex
TIP:
In case your host Linux machine has more CPU cores, you may want to increase number of cores used during compilation. That will speed up the compilation quite a lot. After you run "source setup-environment" open bblayers.conf file:
gedit ~/fsl-community-bsp/build-openrex/conf/bblayers.conf
and add this line at the end:
BB_NUMBER_THREADS = "4"
It may look like this then:
LCONF_VERSION = "6"
 
BBPATH = "${TOPDIR}"
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"
 
BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/sources/poky/meta \
  ${BSPDIR}/sources/poky/meta-yocto \
  \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  \
  ${BSPDIR}/sources/meta-fsl-arm \
  ${BSPDIR}/sources/meta-fsl-arm-extra \
  ${BSPDIR}/sources/meta-fsl-demos \
  ${BSPDIR}/sources/meta-openrex \
"

BB_NUMBER_THREADS = "4"

Compile & Build a basic console image (no graphical interface)

Run this command to generate an image with uBoot, Kernel and basic filesystem:
MACHINE=machine_name bitbake core-image-base
Replace "machine_name" with a name from the list above. For example if you would like to prepare files for OpenRex QUAD, run following command:
MACHINE=imx6q-openrex bitbake core-image-base

Compile & Build a multimedia image (boots up into to a graphical interface)

This will generate an image which will boot up to GUI:
MACHINE=<machine name> bitbake fsl-image-multimedia

Creating SD card or SATA disk

Insert an SD card into your Linux host machine (or use SD card reader connected to your Linux host machine). In case you are creating SATA drive, you may need a docking station.

Note: Output directories and file names depend on what you build. Following example is based on running 'MACHINE=imx6q-openrex bitbake core-image-base'

The output files will be located at "cd ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/". Check the time & date of the files, just to be sure you have just generated them and they are the recent files:
ls -la ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/
Insert an SD card or conenct your SATA HDD into your host PC. Check how it’s mounted, run: ‘dmesg | tail’.
fedevel@ubuntu:~$ dmesg | tail
[622632.386947] sd 33:0:0:0: Attached scsi generic sg3 type 0
[622632.408964] sd 33:0:0:0: [sdb] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
[622632.472466] sd 33:0:0:0: [sdb] Write Protect is off
[622632.472605] sd 33:0:0:0: [sdb] Mode Sense: 03 00 00 00
[622632.481326] sd 33:0:0:0: [sdb] No Caching mode page found
[622632.481333] sd 33:0:0:0: [sdb] Assuming drive cache: write through
[622632.664902]  sdb: sdb1 sdb2
[622632.712255] sd 33:0:0:0: [sdb] Attached SCSI removable disk
[623190.995120] sdb: detected capacity change from 7948206080 to 0
[646884.988206] hrtimer: interrupt took 11392215 ns
fedevel@ubuntu:~$ 
Use the correct "/dev/" (in our case "/dev/sdb") and copy the images to the SD card / SATA drive:
umount /dev/sdb?
gunzip -c ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard.gz > ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard
sudo dd if=~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard of=/dev/sdb
umount /dev/sdb?
This is a work around of fatwrite issue (if you are not sure if you should run these commands or not, just run them ... you will not do anything wrong). Re-format the fat partition and upload the zImage + dtb again:
sudo mkfs.vfat -F16 -s 2 /dev/sdb1 
# In case of "Warning: Not enough clusters ...":
# 1) run "sudo fdisk /dev/sdb" and delete all disk partitions, 
# 2) remove and then insert the SD card / SATA
# 3) run again "sudo dd if=~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard of=/dev/sdb"
# 4) remove and insert the SD card / SATA
# 5) run "sudo mkfs.vfat -F16 -s 2 /dev/sdb1", now is should pass ok
sudo mount /dev/sdb1 /media/fedevel/
sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.bin /media/fedevel/zImage
sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.dtb /media/fedevel/imx6q-openrex.dtb
sudo umount /media/fedevel
Extend root disk size to SD card / SATA drive size (default size of the root is very small):
fedevel@ubuntu:~/fsl-community-bsp/build-openrex$ sudo fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
4 heads, 32 sectors/track, 121280 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe9358ca2

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192       24575        8192    c  W95 FAT32 (LBA)
/dev/sdb2           24576      204799       90112   83  Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
4 heads, 32 sectors/track, 121280 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe9358ca2

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192       24575        8192    c  W95 FAT32 (LBA)

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (2048-15523839, default 2048): 24576
Last sector, +sectors or +size{K,M,G} (24576-15523839, default 15523839): 
Using default value 15523839

Command (m for help): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
4 heads, 32 sectors/track, 121280 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe9358ca2

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192       24575        8192    c  W95 FAT32 (LBA)
/dev/sdb2           24576    15523839     7749632   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
fedevel@ubuntu:~/fsl-community-bsp/build-openrex$
Note: As the First sector number use the same number where partition 2 originally started. In the example above, it's 24576.

Then run:
sudo e2fsck -f /dev/sdb2
# In case of any errors, try to delete all partitions (use "sudo fdisk /dev/sdb"), remove SD card / SATA disk, plug it in again and start from "sudo dd if=~/fsl-community-bsp/..."
sudo resize2fs /dev/sdb2
umount /dev/sdb?

Testing Kernel & Filesystem

Booting from SD card

To boot from SD card, insert it into your OpenRex board and press "RESET" button. Run following commands in uBoot:
setenv bootcmd 'run bootmmc';saveenv;reset

Booting from SATA drive

To boot from SATA drive, switch off your OpenRex board, connect the SATA drive which you have just created, connect the power and go to uBoot. Run following commands:
setenv bootcmd 'run bootsata';saveenv;reset
Important! Some filesytems may require additional settings in uBoot environmental variables. For example, for Jasbir's fileystem add "ip=dhcp" into uBoot (otherwise network will not be initialized automatically):
setenv sataargs 'setenv bootargs console=${console},${baudrate} root=${sataroot} ${video_args} ip=dhcp'
setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=${mmcroot} ${video_args} ip=dhcp'
saveenv

Testing uBoot (optional)

OpenRex always starts booting from SPI. If you would like to test the uBoot on SD card, go to uBoot and run following commands:
mw.l 0x020d8040 0x2840; mw.l 0x020d8044 0x10000000; reset

Updating OpenRex

In case you would like to update the source codes or adjust them for your hardware, see: How to edit, customize and test the uBoot, Kernel source codes and YOCTO meta layer