# Compulab CL-SOM-iMX6

**URL:** <https://hub.mender.io/t/compulab-cl-som-imx6/138>\
**Category:** Yocto Project\
**Tags:** yocto, nxp, morty\
**Created:** [November 26, 2018, 2:08pm UTC](https://hub.mender.io/t/compulab-cl-som-imx6/138 "2018-11-26T14:08:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 26, 2018, 2:08pm UTC](https://hub.mender.io/t/compulab-cl-som-imx6/138/1 "2018-11-26T14:08:53Z")

</div>

The official [Mender documentation](https://docs.mender.io/) explains how Mender works. This is simply a board-specific complement to the official documentation.

# Board description

The Compulab CL-SOM-iMX6 platform is a System on Modules (SoM) based on the NXP i.MX6 chip. The evaluation kit comes with a SB-FX6 baseboard.

![](https://yyz2.discourse-cdn.com/flex036/uploads/mender/original/1X/21543e90ac1dde38e1ef88d93e1258e6a899160d.jpeg)

URL:

- [Hardware Guide](https://mediawiki.compulab.com/w/index.php?title=CL-SOM-iMX6:_Evaluation_Kit:_Hardware_Guide)
- [Product Overview](https://www.compulab.com/products/computer-on-modules/cm-fx6/)

# Test results

The Yocto Project releases in the table below have been tested by the Mender community. Please update it if you have tested this integration on other [Yocto Project releases](https://wiki.yoctoproject.org/wiki/Releases?target=_blank):

| Yocto Project | Build | Runtime |
| --- | --- | --- |
| morty (2.2) | :test_works: | :test_works: |

**Build** Means that the Yocto Project build using this Mender integration completes without errors and outputs images.  
**Runtime** Means that Mender has been verified to work on the board. For U-Boot-based boards, the [integration checklist](https://docs.mender.io/system-updates-yocto-project/board-integration/bootloader-support/u-boot/integration-checklist?target=_blank) has been verified.

# Getting started

## Prerequisites

- A supported Linux distribution and dependencies installed on your workstation/laptop as described in the [Yocto Mega Manual](https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#detailed-supported-distros)
  - NOTE. Instructions depend on which Yocto version you intend to use.

- Google repo tool [installed](https://hub.mender.io/t/google-repo/58/2) and in your `PATH`.

## Configuring the build

### Setup Yocto environment

Set the Yocto Project branch you are building for:

```auto
# set to your branch, make sure it is supported (see table above)
export BRANCH="morty"

```

Create a directory for your `mender-compulab` setup to live in and clone the  
meta information.

```auto
mkdir mender-compulab && cd mender-compulab

```

Initialize repo manifest:

```auto
repo init \
           -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git \
           -m imx-4.1.33-7ulp_beta.xml \
           -b imx-morty
mkdir .repo/local_manifests
cd .repo/local_manifests/
wget https://raw.githubusercontent.com/mendersoftware/meta-mender-community/morty/meta-mender-compulab/scripts/manifest-compulab-local-manifest.xml
wget https://raw.githubusercontent.com/mendersoftware/meta-mender-community/morty/scripts/mender-local-manifest.xml
cd -

```

Fetch layers in manifest:

```auto
repo sync
cd .repo/local_manifests/
ln -sf ../../sources/meta-mender-community/meta-mender-compulab/scripts/manifest-compulab-local-manifest.xml .
ln -sf ../../sources/meta-mender-community/scripts/mender-local-manifest.xml .
cd -

```

## Setup build environment

Initialize the build environment:

```auto
source fsl-setup-release.sh -b build
source ../sources/meta-compulab/bb-tools/setup-compulab-env
cat ../sources/meta-mender-community/meta-mender-compulab/templates/bblayers.conf.append >> conf/bblayers.conf
cat ../sources/meta-mender-community/templates/local.conf.append >> conf/local.conf
cat ../sources/meta-mender-community/meta-mender-compulab/templates/local.conf.append >> conf/local.conf

```

### Building the image

You can now proceed with building an image:

```auto
MACHINE=cl-som-imx6 bitbake core-image-base

```

Replace `core-image-base` with your desired image target.

### Using the build output

Provision an SD Card with the image produced by bitbake. **WARNING** , make sure you use the correct device node as the _of=_ parameter to avoid overwriting the wrong device:

```auto
sudo dd if=tmp/deploy/images/cl-som-imx6/compulab-eval-image-cl-som-imx6.sdimg of=<SDCARD-DEVICE-NODE> conv=notrunc status=progress

```

Create a U-Boot binary suitable for deploying to SPI flash:

```auto
dd if=/dev/zero count=500 bs=1K | tr '\000' '\377' > cm-fx6-firmware
dd if=tmp/deploy/images/cl-som-imx6/u-boot.imx of=cm-fx6-firmware bs=1K seek=1 conv=notrunc

```

Add the images to the SD Card so we can copy them to the eMMC on the target. This assumes the SD Card created in step 2 was enumerated in your system as _/dev/mmcblk0_:

```auto
sudo mount /dev/mmcblk0p5 /mnt/  
sudo cp --sparse=always tmp/deploy/images/cl-som-imx6/core-image-full-cmdline-cl-som-imx6.sdimg cm-fx6-firmware /mnt
sudo umount /mnt

```

The image generated above assumes it is running from the eMMC (enumerated as _/dev/mmcblk3_ on the target). We will manually modify this to boot from the SD Card, and from that environment, we will provision the onboard eMMC with the unmodified image:

```auto
sudo mount /dev/mmcblk0p2 /mnt
sudo cat /mnt/etc/fstab | grep -v mmcblk3 > fstab.new
sudo mv fstab.new /mnt/etc/fstab
sudo umount /mnt

```

Now, remove the SD Card from your build host and insert it into the target. Configure your board to boot from SD Card by pressing _SW5_ as you power it on, or by attaching jumper _E2_. As the board boots to U-Boot, press a key to stop the autoboot process.

Write the U-Boot binary to the SPI flash:

```auto
sf probe 0
sf erase 0 80000
load mmc 2:5 10800000 /cm-fx6-firmware
sf write 10800000 0 80000

```

Now, remove the SD Card and power cycle your board. As the board boots to U-Boot, press a key to stop the autoboot process. Note from the log that it is now booting U-Boot off of SPI:

```auto
U-Boot SPL 2015.07-cl-som-imx6-1.0 (Nov 16 2018 - 12:50:44)
Dual/Quad CPU detected
Trying to boot from MMC
Card did not respond to voltage select!
spl: mmc init failed with error: -17
Trying to boot from SPI

U-Boot 2015.07-cl-som-imx6-1.0 (Nov 16 2018 - 12:50:44 +0000)

CPU: Freescale i.MX6D rev1.5 996 MHz (running at 792 MHz)
Reset cause: POR
Board: SOM-iMX6-Mender
I2C: ready
DRAM: 3.7 GiB
NAND: 0 MiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2, FSL_SDHC: 3
SF: Detected W25Q16CL with page size 256 Bytes, erase size 4 KiB, total 2 MiB
Display: HDMI (1024x768)
In: serial
Out: vga
Err: vga
PCB: 1.0
Net: FEC
Hit any key to stop autoboot: 0

```

Setup the default U-Boot environment. Note that running _saveenv_ twice here ensures that the redundant U-Boot environment blocks are synchronized. It is not strictly necessary to do this:

```auto
env default -a -f
saveenv
saveenv

```

Insert the SD Card into your board and boot Linux from there. Unfortunately the buffering in UBoot seems to be unable to handle the speed of copy/paste so these commands may need to be typed manually:

```auto
setenv bootargs root=/dev/mmcblk2p2 console=ttymxc3,115200 vmalloc=256M cma=384M dmfc=3
mmc dev 2
load mmc 2:2 0x15000000 /boot/imx6q-sbc-imx6-hdmi.dtb
load mmc 2:2 0x10800000 /boot/zImage
bootz 0x10800000 - 0x15000000

```

Once Linux has booted, log in as root with no password. Then verify that the root filesystem is _/dev/mmcblk2p2_ which is on the SD Card:

```auto
NXP i.MX Release Distro 4.1.33-7ulp_beta cl-som-imx6 ttymxc3

cl-som-imx6 login: root
root@cl-som-imx6:~# mount | head -1
/dev/mmcblk2p2 on / type ext4 (rw,relatime,data=ordered)

```

Provision the eMMC device with the original sdimg file:

```auto
mount /dev/mmcblk2p5 /mnt
dd if=/mnt/core-image-full-cmdline-cl-som-imx6.sdimg of=/dev/mmcblk3 conv=notrunc status=progress
shutdown -h now

```

Now remove the SD Card and power cycle the board. It will boot from eMMC and Mender will connect to the server configured in your local.conf file.

On the other hand, if you already have Mender running on your device and want to deploy a rootfs update using this build, you should use the [Mender Artifact](https://docs.mender.io/overview/artifact) files, which have `.mender` suffix. You can either deploy this Artifact in managed mode with the Mender server (upload it under Releases in the server UI) or by using the Mender client [standalone mode](https://docs.mender.io/artifact-creation/standalone-deployment).

# References

- The Compulab CL-SOM-iMX6 template files can be found in [meta-mender-community](https://github.com/mendersoftware/meta-mender-community/tree/morty/meta-mender-compulab).

* * *

_If this post was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!_

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [August 15, 2019, 8:23am UTC](https://hub.mender.io/t/compulab-cl-som-imx6/138/2 "2019-08-15T08:23:53Z")

</div>

4 posts were split to a new topic: [Simplify Compulab CL-SOM-IMX6 flashing instructions](https://hub.mender.io/t/simplify-compulab-cl-som-imx6-flashing-instructions/928)
