Message-ID: <339064690.5207.1711621517095.JavaMail.root@dns3> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_5206_636075008.1711621517095" ------=_Part_5206_636075008.1711621517095 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html SMARC-FiMX7-BSP-Sumo

SMARC-FiMX7-BSP-Sumo

=20 =20
=20 =20 = =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20
=20 =20
=20
=20
=20

Building NXP/Embedian=E2= =80=99s Yocto Sumo BSP Distribution

Eric Lee

version 1.0a, 11/08/2019

Introduction


 

This document describes how Embedian builds a customized version of NXP= =E2=80=99s i.MX7 official Yocto Sumo BSP release for Embedian's <= em>SMARC-FiMX7 product platform. The approach is to pull from Emb= edian's public facing GIT repository and build that using bitbake. The reas= on why we use this approach is that it allows co-development. The buil= d output is comprised of binary images, feed packages, and an SDK for = SMARC-FiMX7 specific development.

 

Freescale makes their i.MX series official bsp build scripts available=
 via the following GIT repository:
=20 =20

 

Freescale community BSP release build sc= ript is available via the following repository:  

 

=20 =20

It is this repository that actually p= ulls in the fsl-bsp-relea= se project to perform the Li= nux BSP builds for Freescale's i.MX7 ARM Cortext-A7 chips.  

Generating SSH Keys


 We recommend you use SSH= keys to establish a secure connection between your computer and Embedian G= itlab server. The steps below will walk you through generating an SSH key a= nd then adding the public key to our Gitlab account. 

Step 1. Check for SSH keys


First, we need to check for existing ssh keys on your computer. Open up&= nbsp;Git Bash and run: 

=20
$ cd ~/.ssh
$ ls
# Lists the files in your .ssh directory
=20

 Check the directory list= ing to see if you have a file named either id_rsa.pub&nbs= p;or id_dsa.pub. If you don't have either of those files = go to step 2. Otherwise, you already have an existing= keypair, and you can skip to step 3. 

Step 2. Generate a new SSH key


 To generate a new SSH ke= y, enter the code below. We want the default settings so when asked to ente= r a file in which to save the key, just press enter.

=20
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press en=
ter]
$ ssh-add id_rsa
=20

 Now you need to enter a = passphrase.

=20
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
=20

 Which should give you so= mething like this:

=20
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com=20

<= span style=3D"color: rgb(0,51,102);">Step 3. Add your SSH key to Embedian G= itlab Server


 Copy the key to your cli= pboard.

=20
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAABDAQABAAABAQDQUEnh8uGpfxaZVU6+uE4bsDrs/tEE5/BPW7j=
MAxak
6qgOh6nUrQGBWS+VxMM2un3KzwvLRJSj8G4TnTK2CSmlBvR+X8ZeXNTyAdaDxULs/StVhH+QRtF=
EGy4o
iMIzvIlTyORY89jzhIsgZzwr01nqoSeWWASd+59JWtFjVy0nwVNVtbek7NfuIGGAPaijO5Wnshr=
2uChB
Pk8ScGjQ3z4VqNXP6CWhCXTqIk7EQl7yX2GKd6FgEFrzae+5Jf63Xm8g6abbE3ytCrMT/jYy5OO=
j2XSg
6jlxSFnKcONAcfMTWkTXeG/OgeGeG5kZdtqryRtOlGmOeuQe1dd3I+Zz3JyT your_email@exa=
mple.c
om
=20

Go to Embedian Git Server. At Profile Setting --> SSH Keys --> Add SSH Key 

Paste your public key and press "Add Key" and your are done.

Overview of the meta-smarcfimx7-sumo = Yocto Layer


The supplied meta-smarcfimx7 Yocto compliant layer has the following organization:<= /p>=20

=20
=20

.
|-- conf
|&nbs= p;  |-- layer.conf
|   |-- site.conf
| = ;  |-- machine
|       |-- imx= 7dsmarc.conf
|       |-- imx7ssmarc= .conf
|   |   `-- imx7d2gsmarc.conf
|-- READM= E
|-- recipes-bsp
|   |-- u-boot
|   &= nbsp;   `-- u-boot-smarcfimx7_2017.03.bb
| &= nbsp; |-- pm-utils
|    &nb= sp;  `-- pm-utils_%.bbappend

|-- recipes-core
|   |-- base-files
= |      =  `-- base-files_%.bbappend
|       |   |-- ba= se-files
|  &nb= sp;    |   |   |-- eth.ne= twork
|   =     |   |   `-- wlan= .network
|   |--&= nbsp;psplash
|  = ;     `-- psplash_git.bbappend
|       |=    |-- files
|       |   | &nb= sp; `-- psplash-poky-img.h
|   |-- udev
|       `-- udev-rules-imx.= bbappend
|  &nb= sp;    |   |-- files
|       |=    |   `-- usb-power.rules
=

|   |-- busybox
|   &n= bsp;   `-- busybox_%.bbappend
|    =    |   |-- busybox
|   &n= bsp;   |   |   |-- ftpget.cfg<= br />|       |   | &= nbsp; `-- defconfig
|   |-- packagegroup= s
|       `-- packagegroup-cor= e-tools-testapps.bbappend
|-- recipes-multimedia

|   |-- gst-plugins-goo= d
|   |   |-- files
|   =         `-- increase_min_buffers.pa= tch
|   |-- pulseaudio
|  = |   |-- pulseaudio
|    &nb= sp;  |   |   |-- default.pa
|       |   | &n= bsp; |-- init
|       |&= nbsp;  |   |-- pulseaudio-bluetooth.conf
|       |   | &nbs= p; |-- pulseaudio.service
|       |   | &nbs= p; `-- system.pa

|     = ;  `-- pulseaudio_%.bbappend
`-- recipes-kernel
|   |-- linux
| &nbs= p;     `-- linux-smarcfimx7_4.9.88.bb
=

=20
=20
=20


Notes on 
meta-smarcfimx6-sumo layer content

conf/machine/*

This folder contains the machine definiti= ons for the imx7dsma= rc|imx7ssmarc|imx72dsmarc platform and backup rep= ository in Embedian. These select the associated kernel, kernel config, u-b= oot, u-boot config, and tar.bz2 image settings.

recipes-bsp/u-boot/*

This folder contains recipes used to buil= d DAS U-boot for imx7dsmarc|imx7ssmarc|imx72dsmarc platform.

recipes-core/busybox/*

This folder remove telnetd from bysybox f= or imx7dsmarc|imx7ss= marc|imx72dsmarc platform.  

recipes-core/base-files/*<= /code>

This folder adds network configurations f= or imx7dsmarc|imx7ss= marc|imx72dsmarc platform.

recipes-core/psplash/*

This folder adds boot splash screen = for imx7dsmarc|imx7= ssmarc|imx72dsmarc platform.

recipes-core/udev/*=  

This folder adds udev rules  for imx7dsmarc|imx7ssmarc|i= mx72dsmarc platform.

recipes-kernel/linux/*

Contains the recipes needed to build the&= nbsp;imx7dsmarc|imx7ssmarc|imx72dsmarc Linux= kernels.

Setting Up the Tools and Build Environment<= /span>


To build the latest Freescale i.MX7 fsl-bsp-release, you first need an Ubu= ntu 16.04 LTS installation. Since bitbake does not accept building images u= sing root privileges, please do not login as a r= oot user when performing the instructions in this section. 

Once you have Ubuntu 16.04 LTS running, install the additional required su= pport packages using the following console command:

=20
=20
=20

$ sudo apt-get install gawk = wget git-core diffstat unzip texinfo build-essential chrpath libsdl1.2-dev = xterm python-m2crypto bc  =20

=20
=20

If you are using a 64-bit Linux, then= you'd also need to install 32-bit support libraries, needed by the pre-bui= lt Linaro toolchain and other binary tools.

=20
=20
=20

$ sudo dpkg --add-architectu= re i386
$ sudo apt-get update
$ sudo apt-get install curl g++-mul= tilib gcc-multilib lib32z1-dev libcrypto++9:i386 libcrypto++-dev:i386 liblz= o2-dev:i386 libusb-1.0-0:i386 libusb-1.0-0-dev:i386 uuid-dev:i386

=20
=20
=20
=20
=20 Icon=20
=20

If you saw error like the following after running "sudo dpkg --add-architecture i386"

pkg: error: unknown option --add-architecture

make sure the only file present in /etc/dpkg/dpkg.cfg.d/ is "multia= rch"

ls /etc/dpkg/dpkg.cfg.d/

if output is

multiarch

execute the following commands as it is else replace "multiarch&quo= t; with the name of file present in that directory.

$ sudo sh -c "echo 'foreign-architecture i386' > /etc/dp=
kg/dpkg.cfg.d/multiarch"

The above command will add i386 architecture.

=20
=20
=20


To get the BSP you need to have 'repo' installed and use it as:

Install the 'repo' utility:

=20
=20
=20

$ mkdir ~/bin
$ curl http://commondatastorage.googleapis.com= /git-repo-downloads/repo
> ~/bin/repo
$ ch= mod a+x ~/bin/repo
$ PATH=3D${PATH}:~/bin 

=20
=20
=20

Download the BSP Yocto Project Environme= nt.
=20
=20
=20
$ mkdir ~/smarc-fimx7-sumo-release
$ cd ~/smarc-fimx7-sumo-release
$ repo init -u https://source.codeaurora.org/ex=
ternal/imx/imx-manifest -b imx-linux-sumo -m imx-4.14.98-2.0.0_ga.xm=
l
$ repo sync
=20
=20
=20

Download the Embedian Yocto build script= and meta layer.

=20
=20
=20
$ wget ftp://ftp.embedian.com/public/dev/minfs/smarc-fimx7-bsp-release=
/fsl-smarcfimx7-sumo-setup-release.sh
$ chmod 444 fsl-smarcfimx7-sumo-setup-release.sh
$ cd sources
$ git clone git@git.embedian= .com:developer/meta-smarcfimx7-sumo.git
$ cd ~/smarc-fimx7-sumo-release
$ DISTRO=3Dfsl-imx-fb MACHINE=3Dimx7dsmarc source fsl= -smarcfimx7-sumo-setup-release.sh -b imx7d-qt5fb 
=20
=20
=20

This scri= pt will create and bring you to 
~/smarc-fimx7-sumo-release/imx7= d-qt5fb directory.

=20
=20

Note

=20 Icon=20
=20

The last line of the above script

$ DISTRO=3D<distro name> MACHINE=3D<machine name> source f=
sl-smarcfimx7-sumo-setup-release.sh -b <build dir>
  1. <distro name> 
    • fsl-imx-x11 - Only X11 graphics
    • fsl-imx-wayland - Wayland weston graphics
    • fsl-imx-xwayland - Wayland graphics and X11. X11 applications usin=
      g EGL are not supported
    • fsl-imx-fb - Frame Buffer graphics - no X11 or Wayland
  2. <machine name>
    • imx7dsmarc - if your SMARC-FiMX7 is a dual core CPU
    • imx7ssmarc - if your SMARC-FiMX7 is a solo core CPU
    • imx7d2gsmarc - if your SMARC-FiMX7 is dual core with 2GB DDR3L

The default console debug port is SER3.

In this document, we will use imx7dsmarc as the example of machine name. Users need to change diff= erent machine name if you have different SMARC card variants.=

=20
=20
=20  
Building the target platforms

  To build Embedian/Freescale Yocto BSP,&n= bsp; use the following commands:
=20
=20
=20

$ MACHINE=3Dimx7dsmarc bitbake -k fsl-image-qt5-validation-imx
or
$ MACHINE= =3Dimx7dsmarc bitbake -k fsl-image-validation-imx
=20

=20
=20


=20
=20

Note

=20 Icon=20
=20
fsl-image-validation-imx provides a gui image without QT5.
 
fsl-image-qt5-validation-imx provides a Qt5 image for X11, wayland or =
FB backends depending on your distro name.
 
If your machine name is imx7dsmarc and your gui image is without QT5 ,=
 the following command gives you as an example.
 
$ MACHINE=3Dimx7dsmarc bitbake -k fsl-image-validation-imx
 
The first build takes time. 
=20
=20
=20

 

Once it done, you can find all required images under ~/smarc-fimx7-bsp-release/<build direc=
tory>/tmp/deploy/images/<machine name>/

You may want to build programs that aren=E2=80=99t installed into a root= file system so you can make them available via a feed site (described belo= w.) To do this you can build the package directly and then build the packag= e named package-index&nbs= p;to add the new package to the feed site.

 

The following example builds the minicom program and makes it available on the feed site:=20

=20
=20
$ MACHINE=3Dimx7dsmarc bitbake tcpdump 
$ MACHINE=3Dimx7dsmarc bi= tbake package-index
=20
=20
=20

Once the build(s) are completed you=E2= =80=99ll find the resulting images, rpm and licenses in folder  ~/smarc-fimx7-bsp-release/&= lt;build directory>/tmp/deploy .

deploy/images/<machine name>/* 

This folder contains the binary images for = the root file system and the Embedian SMARC-FiMX7 specif= ic version of the u-boot, zImage and device tree file. Specifically the ima= ges are:

deploy/images/<machine name>/u-boot.imx<= span style=3D"color: rgb(0,51,102);"> 

This u-boot bootloader binary for = SMARC-FiMX7

deploy/images/<machine name>/zImage

The k= ernel zImage for SMARC-FiMX7. =  

deploy/images/<machine name>/imx7d-smarcfimx7.dtb

The d= evice tree binary file for S= MARC-FiMX7 Dual core. <= /p>

 deploy/images/&= lt;machine name>/imx7s-smarcfimx7.dtb 

The d= evice tree binary file for S= MARC-FiMX7 Solo core. <= /p>

deploy/images/<machine name>/fsl-image-validation-imx-<machine name>.*

Embedian root file system images for softwa= re development on Embedian=E2=80=99s SMARC-FiMX7  platfo= rms without QT5.

deploy/images/<machine name>/fsl-image-qt5-validation-= imx-<machine name>.*

Embedian root file system images for softwa= re development on Embedian=E2=80=99s SMARC-FiMX7  with Q= T5.


deploy/rpm/*
=

 This folder contains all the p= ackages used to construct the root file system images. They are in rpm format (similar format to Fedora package= s) and can be dynamically installed on the target platform via a properly &= nbsp;constructed feed=  file. Here is an examp= le of the feed file (named imx7d_qt5fb_update.repo) that is used internally at Embedian to install upgrades onto a imx7dsmarc QT5 platform directly on = framebuffer without reflashing the file system:

=20
=20
=20

[noarch]
type =3D rpm-md
baseurl =3D http://www.embedian.com/s= marcfimx7-yocto-sumo-feed/imx7dsmarc/fb/qt5/noarch
[cortexa7hf_neon]
type =3D rpm-md
baseurl =3D http://www.embedian.com/sm= arcfimx7-yocto-sumo-feed/imx7dsmarc/fb/qt5/cortexa7hf_neon
[cortexa7hf_neon_mx7d]

type =3D rpm-md

baseurl =3D http://www.em= bedian.com/smarcfimx7-yocto-sumo-feed/imx7dsmarc/fb/qt5/cortexa7hf_neon_mx7= d
[imx7dsmarc]
type =3D rpm-md
baseurl =3D http:= //www.embedian.com/smarcfimx7-yocto-sumo-feed/imx7dsmarc/fb/qt5/imx7dsmarc<= /em>

=20
=20
=20

deploy/licenses/* 
A = database of all licenses used in all packages built for the system.<= /span>

Setup SD Card


For these instruction, we are assuming: DISK=3D/dev/mmcblk0, "lsblk= " is very useful for determining the device id.

=20
=20
=20
$ export DISK=3D/dev/mmcblk0
=20
=20
=20

Erase SD card:

=20
=20
=20

$ sudo = dd if=3D/dev/zero of=3D${DISK} bs=3D1M count=3D16

=20
=20
=20

Create Partitions:

=20
=20

sfdisk >=3D2.26.x

=20 Icon=20
=20
$ sudo sfdisk ${DISK} <<-__EOF__
1M,48M,0x83,*
,,,-__EOF__
=20
=20
=20
=20

sfdisk <=3D2.25

=20 Icon=20
=20
$ sudo sfdisk --in-order --Linux --=
unit M ${DISK} <<-__EOF__
1,48,0x83,*
,,,-
__EOF__=20
=20
=20

Format Partitions:

=20
=20
=20
for: DISK=3D/dev/mmcblk0
$ sudo mkf= s.vfat -F 16 ${DISK}p1 -n boot
$ sudo mkf= s.ext4 ${DISK}p2 -L rootfs
 
for: DISK=3D/dev/sdX
$ sudo mkf= s.vfat -F 16 ${DISK}1 -n boot
$ sudo mkf= s.ext4 ${DISK}2 -L rootfs
=20
=20
=20

Mount Partitions:

On some systems, these partitions may be auto-mounted...

=20
=20
=20
$ sudo mkd= ir -p /media/boot/
$ sudo mkd= ir -p /media/rootfs/
 
for: DISK=3D/dev/mmcblk0
$ sudo mou= nt ${DISK}p1 /media/boot/
$ sudo mou= nt ${DISK}p2 /media/rootfs/
 
for: DISK=3D/dev/sdX
$ sudo mou= nt ${DISK}1 /media/boot/
$ sudo mou= nt ${DISK}2 /media/rootfs/
=20
=20
=20

Install Bootloader

If SPI NOR Flash is not empty

The u-boot.imx is pre-= installed in SPI NOR flash at factory default. SMARC-FiMX7 is designed= to always boot up from SPI NOR flash and to load zImage, device tree blob = and root file systems based on the setting of BOOT_SEL. If us= ers need to fuse their own u-boot or perform u-boot upgrade. This section w= ill instruct you how to do that.

 Copy u-boot.imx to the first boot p= artition of your SD card.

=20
=20

~/smarc-fimx7-morty-release/<build dir>/tmp/deploy= /images/<machine name>/

=20
=20

$ sudo cp = -v u-boot.imx /media/boot/u-boot.imx
=20
=20
=20

Fuse u-boot.imx to the SPI NOR flash.

Stop at U-Boot command prompt (Press any = key when booting up). Copy and Paste the following script under u-boot comm= and prompt.

=20
=20

u-boot command prompt

=20
=20
U-Boot# mmc rescan; mmc dev; load mmc 0:1 0x90800000 u-boot.imx; sf pr=
obe; sleep 2; sf erase 0 0xc0000; sf write 0x90800000 0x400 c0000
=20
=20
=20

If SPI NOR Flash is empty

In some cases, when SPI NOR flash is eras= ed or the u-boot is under development, we need a way to boot from SD card f= irst. Users need to shunt cross the TEST# pin to ground. In this way,=  SMARC-FiMX7 will always boot up from SD card. 

 Copy u-boot.imx to the SD card

= =20
=20

~/smarc-fimx7-morty-release/<build dir>/tmp/deploy= /images/<machine name>/

=20
=20

$ sudo= dd if=3Du-boot.imx of=3D${DISK} bs=3D512 seek=3D2 
=20
=20
=20
=20 Icon=20
=20
  1. If your u-boot hasn't been fin= alized and still under development, it is recommended to shunt cross the te= st pin and boot directly from SD card first. Once your u-boot is fully test= ed and finalized, you can fuse your u-boot to SPI NOR flash.
  2. When TEST# pin of SMA= RC-FiMX7 is not shunt crossed, it will always boot up from SPI NOR flash. U= -boot will read the BOOT_SEL configuration and determine where it = should load zImage and device tree blob. When TEST# is shunt crossed (pull = low), it will always boot up from SD card.
=20
=20
=20

uEnv.txt based bootscript

Create "uEnv.txt" boot script: ($ vim uEnv.txt)

=20
=20

~/uEnv.txt

=20
=20
console=3Dttymxc2,115200
mmcdev=3D0
mmcpart=3D1
image= =3DzImage
loadaddr=3D0x80800000
fdt_addr=3D0x83000000
mmcroo= t=3D/dev/mmcblk0p2 ro
mmcrootfstype=3Dext4 rootwait fixrtc
netdev= =3Deth0
ethact=3DFEC0
ipaddr=3D192.168.1.150
serverip=3D192.= 168.1.53
gatewayip=3D192.168.1.254
mmcargs=3Dsetenv bootargs cons= ole=3D${console} root=3D${mmcroot} rootfstype=3D${mmcrootfstype} ${optargs}=
uenvcmd=3Drun loadzimage; run loadfdt; run mmcboot
=20
=20
=20

Copy uEnv.txt to the boot partition:

=20
=20

~/

=20
=20
$ sudo cp -v ~/uEnv.txt /media/boot/
=20
=20
=20

Install Kernel zImage

Copy zImage to the boot partition:

=20
=20

~/smarc-fimx7-rocko-release/<build dir>/tmp/deploy= /images/<machine name>/

=20
=20
$ sudo cp -v zImage /media/boot
=20
=20
=20

Install Kernel Device Tree Binary

=20
=20

~/smarc-fimx7-rocko-release/<build dir>/tmp/deploy= /images/<machine name>/

=20
=20
$ sudo mkdir -p /media/boot/dtbs
$ sudo cp -v imx7d-smarcfimx7.dtb /media/boot/dtbs/imx7d-smarcfimx7.dt=
b
$ sudo cp -v imx7s-smarcfimx7.dtb /media/boot/dtbs/imx7s-smarcfimx7.dt=
b
=20
=20
=20

Install Root File System


Copy Root File System:

Yocto Built Rootfs:

=20
=20

~/smarc-fimx7-rocko-release/<build dir>/tmp/deploy= /images/<machine name>/

=20
=20
$ sudo tar jxvf <filename.tar.bz2> -C /media/rootfs
=20
=20
=20
=20

Note

=20 Icon=20
=20
  1. SMARC-FiMX7 always boots up to SPI flash first. The firm= ware in SPI flash is factory pre-installed from Embedian. It will read the = BOOT_SEL configuration that defined by SMARC specification on your= carrier board and load u-boot.bin from the partition one of the device (co= uld be SD card, eMMC, GBE,..etc) that you selected to memory.
  2. MAC address is factory pre-installed at on board I2C EEPROM at of= fset 60 bytes. It starts with Embedian's vendor code 10:0D:32. u-b= oot will read it and pass this parameter to kernel.
  3. The kernel modules is included in the Yocto rootfs.
=20
=20
=20

Remove SD card:

=20
=20
=20
$ sync
$ sudo umo= unt /media/boot
$ sudo umo= unt /media/rootfs
=20
=20
=20

Feed Packages 


The following procedure can be used o= n a Embedian SMARC-FiMX7 device to download and utilize = the feed file show above to install the tcpdump&n= bsp;Ethernet packet analyzer program:

=20
=20
=20
$ smart channel -y --add http://=
www.embedian.com/smarcfimx7-yocto-sumo-feed/imx7d_qt5fb_update.repo<=
/pre>
$ smart update
$ smart install tcpdump=20
=20
=20

 

Writing Bitbake Recipes


In order to package your application and include it in the root filesyst= em image, you must write a BitBake recipe for it.

When starting from scratch, it is easiest to learn by example from exist= ing recipes. 

Examp= le HelloWorld recipe using autotools

For software that uses autotools (./configure; make; make install), writ= ing recipes can be very simple:

 

DESCRIPTION =3D  "Hello World Recipe using autotools"
HOMEPAGE =3D  "http://www.embedian.com/"
SECTION =3D  "console/utils"
PRIORITY =3D  "optional"
LICENSE =3D  "GPL"
PR =3D  "r0"
  
S =3D  "${WORKDIR}/git"
  
inherit autotools

 

SRC_URI sp= ecifies the location to download the source from. It can take the form of a= ny standard URL using http://, ftp://, etc. It can also fetch from SCM syst= ems, such as git in the example above.

PR is the = package revision variable. Any time a recipe is updated that should require= the package to be rebuilt, this variable should be incremented.

inherit autotools brings in support for the package to be built using autotools, and = thus no other instructions on how to compile and install the software are n= eeded unless something needs to be customized.

S is the s= ource directory variable. This specifies where the source code will exist a= fter it is fetched from SRC_URI and unpacked. The default value is ${WORKDIR}/${PN}-${PV}, where PN&n= bsp;is the package name and PV is the package version. Both PN and PV are set by default using the = filename of the recipe, where the filename has the format PN_PV.bb.

Example HelloWorld recipe using a single source file

This example shows a simple case of building a helloworld.c file directl= y using the default compiler (gcc). Since it isn=E2=80=99t using autotools = or make, we have to tell BitBake how to build it explicitly.

 

DESCRIPTION =3D  "HelloWorld"
SECTION =3D  "examples"
LICENSE =3D  "GPL"
  
SRC_URI =3D  "file://helloworld.c"
  
S =3D  "${WORKDIR}"
  
do_compile() {
     ${CC} ${CFLAGS} ${LDFLAGS} helloworld.c -o hellow= orld
}
  
do_install() {
     install -d ${D}${bindir}
     install -m 0755 helloworld ${D}${bindir}
}

 

In this case, SRC_URI specifies a file that must exist locally with the recipe. = Since there is no code to download and unpack, we set S to WORKDIR since that is where he= lloworld.c will be copied to before it is built.

WORKDIR is= located at ${OETREE}/<= build directory>/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/<package= name and version> for most packages. If the package = is machine-specific (rather than generic for the cortexa7hf architecture), = it may be located in the imx7dsmarc-poky-linux-gnueabi subdirectory de= pending on your hardware (this applies to kernel packages, images, etc).

do_compile = ;defines how to compile the source. In this case, we just call gcc directly= . If it isn=E2=80=99t defined, do_compile runs make in the source directory by default.

do_install = ;defines how to install the application. This example runs install to create a bin = directory where the application will be copied to and then copies the appli= cation there with permissions set to 755.

D is the d= estination directory where the application is installed to before it is pac= kaged.

${bindir} = is the directory where most binary applications are installed, typically&nb= sp;/usr/bin.

For a more in-depth explanation of BitBake recipes, syntax, and variable= s, see the Recipe Ch= apter of the OpenEmbedded User Manual.

Setup eMMC


Setting up eMMC usually is the last step at development stage after the = development work is done at your SD card or NFS environments. From software= point of view, eMMC is nothing but a non-removable SD card on board. For&n= bsp;SMARC-FiMX7, the SD card is always emulated as /dev/mmcblk0 an= d on-module eMMC is always emulated as /dev/mmcblk2. Setting up eMMC now is= nothing but changing the device descriptor. 

This section gives a step-by-step procedure to setup eMMC flash. Users c= an write a shell script your own at production to simplify the steps.

First, we need to backup the final firmware from your SD card or NFS.

Prepare for eMMC binaries from SD card = (or NFS):

Insert SD card into your Linux PC. For these instructions, we are assumi= ng: DISK=3D/dev/mmcblk0, "lsblk" is very useful for determining t= he device id.

For these instruction, we are assuming: DISK=3D/dev/mmcblk0, "lsblk= " is very useful for determining the device id.

=20
=20
=20
$ export DISK=3D/dev/mmcblk0
=20
=20
=20

Mount Partitions:

On some systems, these partitions may be auto-mounted...

=20
=20
=20
$ sudo mkd= ir -p /media/boot/
$ sudo mkd= ir -p /media/rootfs/
 
for: DISK=3D/dev/mmcblk0
$ sudo mou= nt ${DISK}p1 /media/boot/
$ sudo mou= nt ${DISK}p2 /media/rootfs/
 
for: DISK=3D/dev/sdX
$ sudo mou= nt ${DISK}1 /media/boot/
$ sudo mou= nt ${DISK}2 /media/rootfs/
=20
=20
=20

 

Copy zImage to rootfs p= artition:

=20
=20

~/smarc-fimx7-rocko-release/<build dir>/tmp/deploy= /images/<machine name>

=20
=20
$ sudo cp -v zImage /media/rootf=
s/home/root
=20
=20
=20

Copy uEnv.txt to rootfs= partition:

Copy and paste the following contents to /media/rootfs/home/root ($ sudo= vim /media/rootfs/home/root/uEnv.txt)

=20
=20
=20
console=3Dttymxc2,115200
mmcdev=3D1
mmcpart=3D1
image= =3DzImage
loadaddr=3D0x80800000
fdt_addr=3D0x83000000
mmcroo= t=3D/dev/mmcblk2p2 ro
mmcrootfstype=3Dext4 rootwait fixrtc
netdev= =3Deth0
ethact=3DFEC0
ipaddr=3D192.168.1.150
serverip=3D192.= 168.1.53
gatewayip=3D192.168.1.254
mmcargs=3Dsetenv bootargs cons= ole=3D${console} root=3D${mmcroot} rootfstype=3D${mmcrootfstype} ${optargs}=
uenvcmd=3Drun loadzimage; run loadfdt; run mmcboot
=20
=20
=20

Copy device tree blob t= o rootfs partition:

=20
=20

~/smarc-fimx7-rocko-release/<build dir>/tmp/deploy= /images/<machine name>

=20
=20
$ sudo cp -v imx7d-smarcfimx7.dt=
b /media/rootfs/home/root/imx7d-smarcfimx7.dtb
$ sudo cp -v imx7s-smarcfimx7.dtb /media/rootfs/home/= root/imx7s-smarcfimx7.dtb 
=20
=20
=20

Copy real rootfs to roo= tfs partition:

=20
=20
=20
$ pushd /media/rootfs
$ sudo tar cvfz ~/smarcfimx7-emm=
c-rootfs.tar.gz .
$ sudo mv ~/smarcfimx7-emmc-root=
fs.tar.gz /media/rootfs/home/root
$ popd
=20
=20
=20

Remove SD card:

=20
=20
=20
$ sync
$ sudo umo= unt /media/boot
$ sudo umo= unt /media/rootfs
=20
=20
=20

Copy Binaries to eMMC from SD card:

Insert this SD card into your SMARC-FiMX7 device.

Now it will be almost the same as you did when setup your SD card, but t= he eMMC device descriptor is /dev/mmcblk2 now.

=20
=20
=20
$ export DISK=3D/dev/mmcblk2
=20
=20
=20

Erase SD card:

=20
=20
=20

$ sudo = dd if=3D/dev/zero of=3D${DISK} bs=3D1M count=3D16

=20
=20
=20

Create Partition Layout:

=20
=20
=20
$ sudo sfd= isk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,48,0x83,*
,,,-
__EOF__
=20
=20
=20

Format Partitions:

=20
=20
=20
$ sudo mkfs.vfat -F 16 ${DISK}p1 -n boot
$ sudo mkfs.ext4 ${DISK}p2 -L rootfs
=20
=20
=20

Mount Partitions:

=20
=20
=20
$ sudo mkd= ir -p /media/boot/
$ sudo mkd= ir -p /media/rootfs/
$ sudo mou= nt ${DISK}p1 /media/boot/
$ sudo mou= nt ${DISK}p2 /media/rootfs/
=20
=20
=20

Install binaries for partition 1

Copy uEnv.txt/zImage/*.dtb to the boot partition

=20
=20
=20

$ sudo cp = -v zImage uEnv.txt /media/boot/
=20
=20
=20

Install Kernel Device Tree Binary

=20
=20
=20
$ sudo mkdir -p /media/boot/dtbs=
$ sudo cp -v imx7d-smarcfimx7.dt=
b imx7s-smarcfimx7.dtb /media/boot/dtbs
=20
=20
=20

Install Root File System


=20
=20
=20
$ sudo tar -zxvf smarcfimx7-emmc=
-rootfs.tar.gz -C /media/rootfs
=20
=20
=20

 

Unmount eMMC:

=20
=20
=20
$ sync
$ sudo umo= unt /media/boot
$ sudo umo= unt /media/rootfs
=20
=20
=20

 

Switch your Boot Select to eMMC and you will be able to boot up from eMM= C now.


version 1.0a, 11/08/2019

Last updated 2019-11-08

------=_Part_5206_636075008.1711621517095--