Quickstart Guide - phyCORE-i.MX 8 Alpha Kit (LAN-087e.A2)

Table of Contents

LAN-087e.A2 phyCORE-i.MX 8 Alpha Kit Quickstart Guide
Document TitleLAN-087e.A2 phyCORE-i.MX 8 Alpha Kit Quickstart Guide
Document TypeQuickstart Guide
Yocto PageL-813e_7 Yocto Reference Manual
Article NumberLAN-087e.A2
Release Date13.02.2020
Is Branch ofLAN-087e.Ax phyCORE-i.MX 8 Alpha Kit QS Guide Head

Introduction

This Quickstart guide describes the tools and provides the know-how to install and work with the Linux Board Support Package (BSP) for the phyCORE-i.MX 8Alpha Kit. This guide shows you how to do everything including installing the appropriate tools and sources, building custom kernels, and deploying the OS in order to operate the software and hardware.

This kit is currently in Alpha Status. There are several topics to keep in mind while working with this kit and guide:

  • The phyCORE-i.MX 8 will go through several functional changes during the Alpha Stage of development. Due to this, this Quickstart guide may change without any prior notice.
  • The phyCORE-i.MX 8 has some functionality that is not currently operational. Please be aware of this when working with the Alpha Kit.
  • This Quickstart guide is only for booting and starting the basic functionality of the phyCORE-i.MX 8. This guide does not qualify as a Hardware manual for the phyCORE-i.MX 8. The following manuals will be available in future releases of the phyCORE-i.MX 8:

     * Hardware Manual - provides a detailed description of all components and functions of the phyCORE-i.MX 8 and phyCORE-i.MX 8 Carrier Board

     * Yocto Reference Manual - provides information on Yocto, which is used with most PHYTEC products * Board Support Package (BSP) Manual - provides detailed instructions on running the tools which are used to build various software

     * Development Environment Guide - provides instructions to prepare and start the programs Eclipse and QT Creator, as well as setting up a Linux host system

  • For more information or details regarding the phyCORE-i.MX 8, please contact the PHYTEC Sales department.

Requirements

The following components and system requirements are necessary to successfully complete this Quickstart. Deviations from these requirements are possible but may require workarounds.

Hardware

Included in Kit

  1. phyCORE-i.MX 8 SOM with i.MX 8QuadMax processor (PCM-064)
  2. phyCORE-i.MX 8 carrier board (PCM-943)
  3. USB-A to Micro-USB Cable
  4. Power adapter supplying 24 V DC/ 2.5 A
  5. Ethernet Cable

phyCORE-i.MX 8 Alpha Kit Compete Assembly

phyCORE-i.MX8 Alpha Kit

phyCORE-i.MX 8 Alpha Kit

Additional Equipment

 USB-A to USB Micro Cable Ethernet Cable

Additional Equipment (not included in Alpha Kit)

  • An SD card and SD card reader operational under Linux.
  • Additional Serial null modem cable (RS-232) (optional)

Additional Kits for the phyCORE-i.MX 8

  • LCD-018-070-KAP.A3 - 7" Display Kit

Software

  • A modern Linux operating host system either natively or via a virtual machine.
  • Ubuntu 16.04 LTS 64-bit recommended. Other distributions will likely work but note that some setup information, as well as OS-specific commands and paths, may differ.
  • VMWare Workstation, VMWare Player, and VirtualBox are possible solutions if you want to use a virtual machine.
  • Root access to your Linux host PC. Some commands in this guide will not work if you do not have sudo access (e.g. package installation, formatting an SD card).
  • At least 40 GB to 50 GB of free space on the build partition of the host PC.
  • An active internet connection.

If you do not have SD card access under Linux on your host PC then formatting, copying the bootloader, and mounting the root file system on an SD card will not be possible.

phyCORE-i.MX 8 Carrier Board Components

The following pictures show the components of the phyCORE-i.MX 8 Carrier Board. The location of the components on the board have been highlighted for easy reference.

phyCORE i.XM8 Components (Top)

phyCORE-i.MX 8 Components (Top)

phyCORE-i.MX8 Components (Bottom)

phyCORE-i.MX 8 Components (Bottom)

As this is an Alpha Kit, there will be continuous revisions made to the phyCORE-i.MX 8 SOM and phyCORE-i.MX 8 Carrier Board. Due to this, components and features may not be available. Contact PHYTEC if there any questions regarding components and features for this Alpha Kit. To see which components are currently functional, refer to the i.MX 8release notes.

Connecting the phyCORE-i.MX 8 Carrier Board

There are 3 cables that need to be manually connected to the phyCORE-i.MX 8 in order for it to be operational

Connecting the USB Debug

If S1=ON, no boot is possible without connecting the Debug USB cable. Using the USB Micro head, connect the USB cable to the Debug USB component (X10). The other head should be connected to the development host. After switching On the power, 4 COM-Ports should show up.

  1. -M41 UART (not supported yet) 
  2. -M40 UART (not supported yet) 
  3. -SCU-UART (only output of the SCU) 
  4. -Debug-UART (default console) 

Connecting to the Ethernet

Connect one end of the Ethernet cable to the Ethernet ETH0 component (X8). Connect the other end to a suitable Ethernet source, as the development host will need to be able to communicate with the phyCORE-i.MX8M carrier board.

Powering the Board

Connect the power adapter to the Power-In component (X29 or X32). The Power Adapter included in this kit is a 2-pole barrel connector used with X29.

Please note the polarity of the Power components X29 and X32. Ensure that your power adapter is correctly set up to use the polarity as shown below.

phyCORE-i.MX8 Polarity

phyCORE-i.MX8 Polarity


Be aware that as soon as the phyCORE-i.MX 8 Carrier Board is supplied with power, the default eMMC boot sequence will begin. Ensure that all cables are connected and the desired boot mode is chosen before powering on the board!

Bootmode Switch

The i.MX 8QuadMax has 6 Boot-Pins. They are connected to Dip Switches on the carrier board. The following table shows the Dip Switch configurations for the available Boot-Sources. ON = 0 and OFF = 1 when Nr.8 of the Dipswitch is ON. 
BOOT_MODE [0] is Dipswitch Nr.1, BOOT_MODE [1] is Dipswitch Nr. 2, etc.

By default the Boot-Source is EMMC (Switch the right Dip-Switch (Nr.8 = Enable Overwrite) of the Bootswitches to "OFF" for default setting).


Boot ModeBoot_Mode[5]Boot_Mode[4]Boot_Mode[3]Boot_Mode[2]Boot_Mode[1]Boot_Mode[0]
USB Serial DownloadONONONOFFONON
eMMC0 BootONONOFFONONON
USDHC2 SD BootONONOFFOFFOFFON
FlexSPI BootONOFFOFFOFFOFFON
SATA BootOFFONONONOFFON

Building the BSP

This section will guide you through the general build process of the i.MX8 BSP using the phyLinux script.

If you want to use our software without phyLinux and the Repo tool managed environment instead, you can find all Git repositories on:

Used u-boot repository:

Our u-boot version is based on the u-boot-imx and adds only a few patches which will be sent upstream in future.

Used Linux kernel repository:

Our i.MX8 kernel is based on the linux-imx kernel.

To find out which tag is used for a specific board, have a look at your checked out BSP source folder under:

meta-phytec/dynamic-layers/fsl-bsp-release/recipes-bsp/u-boot/u-boot-imx_*.bbappend
meta-phytec/recipes-kernel/linux/linux-imx_*.bb

Get the BSP

  • Create a fresh project directory:
host$ mkdir ~/yocto
  • Download and run the phyLinux script on the manifest file:
host$ cd ~/yocto
host$ wget ftp://ftp.phytec.de/pub/Software/Linux/Yocto/Tools/phyLinux
host$ ./phyLinux init

Basic Set-up

There are a few important steps which have to be done before the main build process.

  • To set up the host, see Yocto Reference Manual, "Setting up the Host" and NXP's documentation i.MX Yocto Project User's Guide "Host Setup".
  • To set up the Git configuration, see Yocto Reference Manual "Git Configuration"

Finding the Right Software Platform

The i.MX 8 BSP is planned as a unified BSP, which means in the future it will support a set of different PHYTEC carrier boards (CB) with different Systems on Module (SOMs). However, this ALPHA BSP supports only one PHYTEC machine:

phycore-imx8-2

Selecting the Software Platform

  • To set the correct SoC, BSP version and platform, call:
host$ ./phyLinux init

Starting the Build Process

Now you should be in a sub-folder named build and you can start the first build process:

host$ bitbake fsl-image-qt5-validation-imx

BSP Images

All images generated by Bitbake are deployed to ~/yocto/build/tmp/deploy/images/<machine>.

The following list shows for example all files generated for the i.MX 8phycore-imx8-1 machine:

  • U-Boot: u-boot.bin
  • imx-boot: imx-boot-phycore-imx8-2-sd.bin
  • scfw: mx8qm-phycore-imx8-2-scfw-tcm.bin
  • Kernel: Image
  • Kernel device tree file: Image-phytec-imx8qm-phycore-rdk.dtb
  • Kernel configuration: Image.config
  • Root filesystem: fsl-image-qt5-validation-imx-phycore-imx8-2.tar.gz, fsl-image-qt5-validation-imx-phycore-imx8-2.manifest
  • SD card image: fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard

Booting the System

The default boot source for the i.MX 8 module phycore-imx8 is the eMMC.

Booting the eMMC

To boot from eMMC, switch S8 has to be set to OFF (which is the default setup).

To update the eMMC software, see Updating the Software.

Booting the SD Card

Booting from an SD card is useful in several situations, e.g. if the board does not start anymore due to a damaged bootloader. To boot from an SD card, switch S1, S5, S6 and S8 has to be set to ON.

There are two ways to create a bootable SD card. You can either use:
- a single prebuild SD card image, or
- the four individual images (imx-boot-, kernel- and device tree image, and root filesystem)

Using a Single, Prebuilt SD Card Image

The first possibility is to use the SD card image built by Bitbake, a tool integrated in Yocto. This image is zipped and has the ending *.sdcardand can be found under build/tmp/deploy/images/phycore-imx8-2/fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard. It contains all BSP files in correctly preformatted partitions and can be copied to the SD card easily using the single Linux command dd.


To create your bootable SD card with the dd command, you must have root privileges. Because of this, you must be very careful when selecting the destination device for the dd command! All files on the selected destination device will be erased immediately without any further query! Consequently, having selected the wrong device can also erase your hard drive!

To create your bootable SD card, you must first find out the correct device name of your SD card and possible partitions. Then unmount the partitions before you start copying the image to the SD card.

  • In order to get the correct device name, first remove your SD card and execute ls /dev.
  • Now insert your SD card and execute ls /dev again.
  • Compare the two outputs to find the new device name(s) listed in the second output. These are the device names of the SD card (device and partitions if the SD card is formatted).
  • In order to verify the device names found, execute the command dmesg. Within the last lines of its output, you should also find the device names, for example sde (depending on your system).

Now that you have the device name /dev/<your_device> (e.g. /dev/sde), you can see the partitions which must be unmounted if the SD card is formatted. In this case, you will also find /dev/<your_device> with an appended number (e.g. /dev/sde1) in the output. These represent the partition(s) that need to be unmounted.

  • Unmount all partitions with:
host$ umount/dev/<your_device><number>
  • After having unmounted all devices with an appended number (<your_device><number>), you can create your bootable SD card with:
host$ sudodd if=<IMAGENAME>-<MACHINE>.sdcard of=/dev/<your_device>bs=1MB conv=fsync status=progress

Using the device name (<your_device>) without appended number (e.g. sde) which stands for the whole device. The parameter conv=fsync forces a sync operation on the device before dd returns. This ensures that all blocks are written to the SD card and are not still in memory. The parameter status=progress will print out information on how much data is and still has to be copied until it is finished.

Using four individual Images (imx-boot, kernel- and device tree image, and root filesystem)

Option two usesimx-boot and a image (a kernel and device tree image together with the root filesystem) to create a bootable SD card manually.

For this method, a new card must be set up with 2 partitions and 8 MB of free space at the beginning of the card. Use the following procedure with fdisk under Linux:

  • Create a new FAT partition with partition id C. When creating the new partition, you must leave 8 MB of free space at the beginning of the card. When you go through the process of creating a new partition, fdisk lets you specify where the first sector starts. During this process, fdisk will tell you where the first sector on the disk begins. For example, if the first sector begins at 1000 and each sector is 512 bytes, then 8 MB / 512 bytes = 16384 sectors. This means your first sector should begin at 17384 to leave 8 MB of free space. The size of the FAT partition needs only be big enough to hold the Image, which is only a few megabytes. To be safe, we recommend a size of 64 MB.
  • Create a new Linux partition with partition id 83. Make sure you start this partition after the last sector of partition 1! By default, fdisk will try to use the first partition available on the disk, which in this example is 1000. However, this is our reserved space! You must use the remaining portion of the card for this partition.
  • Write the new partition to the SD card and exit fdisk.

Example:

  • Type:
 host$ sudofdisk-l/dev/sdc
  • You will receive:
 Disk /dev/sdc: 4025 MB, 4025483264 bytes
 4 heads, 32 sectors/track, 61424 cylinders, total 7862272 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: 0x26edf128
 
    Device Boot      Start         End      Blocks   Id  System
 /dev/sdc1            8192245758192    c  W95 FAT32 (LBA)/dev/sdc2           2457665535931539283  Linux
  • Remove and reinsert the card. Otherwise, Linux will not recognize the new partitions created in the previous step.
  • Create a file system on the partitions with (replace sde with your device):
 host$ sudo mkfs.vfat /dev/sde1
 host$ sudo mkfs.ext4 -L"rootfs"/dev/sde2

Now, the images need to be copied to the SD card.

  • Write the bootloader in front of the first partition (replace sde with your device):
 host$ ddif=imx-boot-phycore-imx8-2-sd.bin of=/dev/sde bs=1k seek=32conv=fsync
  • Mount the first partition (vfat) and copy the linuximage and oftree file to it:
 host$ sudomount/dev/sd<X>1/mnt


Make sure that the images are named exactly as previously mentioned as the bootloader expects them to be named as such.
  • In case you want to boot the whole Linux from the SD card, also mount the ext4 partition.
  • Then untar <IMAGENAME>-<MACHINE>.tar.gz rootfs image to it:
 host$ sudomount/dev/sd<X>2/media
 host$ sudotar jxf <IMAGENAME>-<MACHINE>.tar.gz -C/media/
  • Do not forget to properly unmount the SD card with:
 host$ sudoumount/media

Booting the Kernel from Network

Booting from network means loading the kernel over TFTP and the root filesystem over NFS. The bootloader itself must already be loaded from another boot device that is available.

Development Host Preparations

On the development host, a TFTP server must be installed and configured. The following tool will be needed to boot the Kernel from Ethernet:

  1. a TFTP server
  • For Ubuntu install:
 host$ sudoapt-get install tftpd-hpa

After the installation of the packages, you have to configure the TFTP server.

Setup for the TFTP Server

  • Edit /etc/default/tftpd-hpa.
TFTP_USERNAME="tftp"TFTP_DIRECTORY="/tftpboot"TFTP_ADDRESS=":69"TFTP_OPTIONS="--secure"
  • Create a directory to store the TFTP files:
 host$ sudomkdir/tftpboot
 host$ sudochmod-R777/tftpboot
 host$ sudochown-R nobody /tftpboot
  • Configure a static IP address for the appropriate interface:
 host$ ifconfig eth1

You will receive:

 eth1      Link encap:Ethernet  HWaddr 00:11:6b:98:e3:47  
           inet addr:192.168.3.10  Bcast:192.168.3.255  Mask:255.255.255.0
  • Restart the services to pick-up the configuration changes:
host$ sudo service tftpd-hpa restart
  • Now connect the ethernet port of the board to your host system, configure the board to network boot, and start it.

Usually, TFTP servers are using the /tftpboot directory to fetch files from. If you built your own images, please copy them from the BSP’s build directory to there.

We also need a network connection between the embedded board and the TFTP server. The server should be set to IP 192.168.3.10 and netmask 255.255.255.0.

After the installation of the TFTP server, an NFS server needs to be installed. The NFS server is not restricted to a certain file system location, so all we have to do on most distributions is to modify the file /etc/exports and export our root filesystem to the embedded network. In this example file, the whole work directory is exported and the ”lab network” address of the development host is 192.168.3.10. The IP addresses have to be adapted to the local needs:

/home/<user>/<rootfspath> 192.168.3.10/255.255.255.0(rw,no_root_squash,sync,no_subtree_check)

<user> must be replaced with your home directory name.

<rootfspath> can be set to a folder which contains a rootfs tar.gz image extracted with sudo.

Preparations on the Enbedded Board

  • To find out the Ethernet settings in the bootloader of the target, type:
 u-boot=> printenv
  • With your development host set to IP 192.168.3.10 and netmask 255.255.255.0, the target should return:
ipaddr=192.168.3.11
 netmask=255.255.255.0
 gateway=192.168.3.10
 serverip=192.168.3.10
 ethaddr=68:05:ca:1b:b5:cc
 ethprime=FEC
  • If you need to change something, type:
 u-boot=> editenv <parameter>
 edit: <value>
  • If ethaddr or ethprime is not set, you should add it by typing something similar to:
 u-boot=> setenv <parameter><value>

<parameter> should be one of ipaddr, netmask, gateway or serverip.

<value> will be the actual value of the chosen parameter.

Make your changes and hit 'Enter'.

The changes you made are temporary for now, so to save these we have to save them by typing:

 u-boot=> saveenv

You can also change the IP address to DHCP instead of using a static one. Just configure netargs:

netargs=setenv bootargs console=${console}root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp

Please note that these modifications will only affect the bootloader settings. For modifying the IP setting in Linux, refer to Section Network 

Booting the Embedded Board

  • To boot from network, call:
 u-boot=> run netboot

Updating the Software 

In this chapter, we explain how to use the u-boot bootloader on target or linux on target/host to update the images in eMMC.

Updating eMMC via Network

i.MX 8 boards have an Ethernet connector and can be updated over a network. Be sure to set up the development host correctly. The IP needs to be set to 192.168.3.10, the netmask to 255.255.255.0, and a TFTP server needs to be available.

From a high-level point of view, an eMMC device is like an SD card. Therefore, it is possible to flash the image <name>.sdcard  from the Yocto build system directly to the eMMC. The image contains the imx-boot, kernel, device trees, and root filesystem.

Updating eMMC via network in u-boot on target

This steps will show how to update the eMMC via a network, but they only work if the size of the image file is less then 1GB. If the image file is larger, go to the chapter Updating eMMC via network in Linux on target. Configure the boot switch to boot from SD Card (Switch S1 is ON) and put in an SD card. Power on the board and stop in u-boot.

A working network is necessary!
  • Load your image via network to RAM:
 u-boot=> tftp ${loadaddr}${serverip}:small_test-image.sdcard
 Using ethernet@30be0000 device
 TFTP from server 192.168.3.1; our IP address is 192.168.3.3
 Filename 'small_test-image.sdcard'.
 Load address: 0x40480000
 Loading: ###################################################################################################################################################################################################
          ...
          ...
          ...
          ########################################################################################################################################################20.3 MiB/s
 done
 Bytes transferred = 524288000(1f400000 hex)
  • Write the image to the eMMC:
 u-boot=> mmc dev 0
 switch to partitions #0, OK
 mmc0(part 0) is current device
 u-boot=> mmc write${loadaddr} 0x0 0xFA000                                         number of blocks to write. In this case524288000 bytes /512 = 0xFA000
 
 MMC write: dev # 0, block # 0, count 1024000 ... 1024000 blocks written: OK

Updating eMMC via network in Linux on Target

You can update the eMMC from your target.

A working network is necessary!
  • Take an uncompressed or compressed image on host and send it with ssh through the network to the eMMC of the target with an one-line command:
target$ ssh<USER>@192.168.3.1 "dd if=<path_to_file>/fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard"|ddof=/dev/mmcblk0 status=progress

Updating eMMC via network in Linux on host

It is also possible to update the eMMC from your Linux host. As before, you need a complete image on your host.

A working network is necessary!
  • Show your available image-files on host:
host$ ls
fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard
  • Uncompress and send image with dd command combined with ssh through network to the eMMC of your device:
host$ ddif=fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard status=progress |ssh root@192.168.3.3 "dd of=/dev/mmcblk0"

Updating eMMC from SD card

Even if there is no network available, you can update the eMMC. For that, you only need a ready-to-use image file (*.sdcard) located on SD card. Because the image file is quite large, you have to enlarge your SD card to use its full space (if it was not enlarged before). To enlarge your SD card, seeResize the ext4 Filesystem.

Updating eMMC from SD card in u-boot on target

Configure SD Card for Flashing

First, we create a new partition on the SD card to store the image in it.

  • On your host insert the SD card and see in dmesg, which one it is:
host$ dmesg|tail
...
[30436.175412] sd 4:0:0:0: [sdb]62453760512-byte logical blocks: (32.0 GB/29.8 GiB)[30436.179846]  sdb: sdb1 sdb2
...
  • Create a new partition with sudo fdisk /dev/sd<x>:
host$ sudofdisk/dev/sdb
Welcome to fdisk(util-linux 2.27.1).                                                  
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
Command (m forhelp): p
Disk /dev/sdb: 29,8 GiB, 31976325120 bytes, 62453760 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
Disklabel type: dos
Disk identifier: 0xd28c31b9
 
Device     Boot Start     End Sectors  Size Id Type
/dev/sdb1       163848191965536   32M  c W95 FAT32 (LBA)/dev/sdb2       81920337510332931841,6G 83 Linux
 
Command (m forhelp): n
Partition type
   p   primary (2 primary, 0 extended, 2free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (2048-62453759, default 2048): 3440640
Last sector, +sectors or +size{K,M,G,T,P}(3440640-62453759, default 62453759): 

Created a new partition 3 of type'Linux' and of size28,1 GiB.

Command (m forhelp): t
Partition number (1-3, default 3): 3
Partition type(type L to list all types): c
 
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
 
Command (m forhelp): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  • Give the new partition a name and mount it:
host$ sudo mkfs.vfat -n"data"/dev/sdb3 
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
host$ sudomount/dev/sdb3 /mnt
  • Copy your image to the new partition and unmount it afterwards:
host$ sudocp fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard /mnt/ ; sync

Flash eMMC from u-boot

This step only works if the size of the image file is less then 1GB. If the image file is larger, have a look at Updating eMMC from SD card in linux on target.

  • Configure the boot switch to boot from the SD Card (Switch S1 is ON) and insert the SD card.
  • Power on the board and stop in u-boot.
  • Flash your <YOUR_IMAGE>.sdcard image from the SD card to eMMC. This will partition the card and copyimx-boot,Image, dtb, and root filesystem to eMMC. (small_test-image.sdcard for example):
u-boot=> fatload mmc 1:3${loadaddr} small_test-image.sdcard
reading small_test-image.sdcard
524288000 bytes readin22334 ms (22.4 MiB/s)
 
u-boot=> mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
u-boot=> mmc write${loadaddr} 0x0 0xFA000                                         number of blocks to write. In this case524288000 bytes /512 = 0xFA000

MMC write: dev # 0, block # 0, count 1024000 ... 1024000 blocks written: OK
  • Reset the board.
  • Stop in u-boot again and check that the partition table for eMMC is as expected:
u-boot=> reset	  
...	  
u-boot=> mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
u-boot=> mmc part	 
Partition Map for MMC device 0--   Partition Type: DOS
 
Part    Start Sector    Num Sectors          UUID        Type
  11638465536           c4792a6c-01     0c
  2819203506176         c4792a6c-02     83

Updating eMMC from SD card in Linux on Target

You can also update the eMMC under Linux. You only need a complete image saved on the SD card (e.q. fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard).

  • Show your saved image files on the SD card:
target$ ls
fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard
  • Show list of available mmc devices:
target$ ls/dev |grep mmc
mmcblk0
mmcblk0boot0
mmcblk0boot1
mmcblk0p1
mmcblk0p2
mmcblk0rpmb
mmcblk2
mmcblk1p1
mmcblk1p2
  • Write the image to the eMMC of phycore imx8 (mmc device 0 WITHOUT partition):
target$ ddif=fsl-image-qt5-validation-imx-phycore-imx8-2.sdcard of=/dev/mmcblk0 status=progress
  • After a complete write, your board can boot from eMMC. Before this will work, you need to toggle switch S1 to OFF. If you don't, the board will boot from SD card again.

Device Tree (DT)

Introduction

The following text briefly describes the Device Tree and can be found in the Linux kernel (linux/Documentation/devicetree/usage-model.txt).

"The "Open Firmware Device Tree", or simply Device Tree (DT), is a data structure and language for describing hardware. More specifically, it is a description of hardware that is readable by an operating system so that the operating system doesn't need to hardcode details of the machine.

Structurally, the DT is a tree or acyclic graph with named nodes, and nodes may have an arbitrary number of named properties encapsulating arbitrary data. A mechanism also exists to create arbitrary links from one node to another outside of the natural tree structure.

Conceptually, a common set of usage conventions called 'bindings', is defined for how data should appear in the tree to describe typical hardware characteristics including data busses, interrupt lines, GPIO connections, and peripheral devices."

The kernel is a really good source for a DT introduction. An overview of the device tree data format can be found on the device tree usage page at devicetree.org.

PHYTEC i.MX 8 BSP Device Tree Concept

The following sections explain some rules we have defined on how to set up device trees in first place for our i.MX 8SoC based boards.

DT Structure

Extension Board Device Tree Structure

The module includes file Modul .dtsi which contains all devices which are mounted on the module, such as PMIC and RAM. Devices which come from the i.MX 8 SoC but are just routed down to the carrier board are not part of the Module .dtsi. These devices are included in the Carrierboard .dtsi. The Board .dts includes the carrier board and module nodes. It also adds partition tables and enables all hardware configurable nodes of the carrier board or the module (i.e. the Board .dts shows the special characteristics of the board configuration). For example, there are phyCORE-i.MX 8 SOMs which may or may not have a Octa-SPI Flash mounted. The Octa-SPI is enabled (if available) in the Board .dts and not in the Module .dtsi.

Accessing Peripherals

To find out which boards and modules are supported by the release of PHYTEC’s i.MX 8 BSP described here, visit our web page at http://www.phytec.de/produkte/software/yocto/phytec-unified-yocto-bsp-releases/ and click the corresponding BSP release. Here you can find all hardware supported in the columns "Hardware Article Number" and the correct machine name in the corresponding cell under "Machine Name". (BSP-Yocto_Machines)

For information about all our supported i.MX8 variants, visit our web page at http://www.phytec.de/produkte/nxp/imx-8/.

To achieve maximum software re-use, the Linux kernel offers a sophisticated infrastructure which layers software components into board specific parts. The BSP tries to modularize the kit features as far as possible. This means that when a customized baseboard or even a customer-specific module is developed, most of the software support can be re-used without error-prone copy-and-paste. The kernel code corresponding to the boards can be found in device trees (DT) under linux/arch/arm64/boot/dts/freescale/*.dts*.

In fact, software re-use is one of the most important features of the Linux kernel, especially of the ARM implementation which always has to fight with an insane number of possibilities of the System-on-Chip CPUs.

The whole board specific hardware is described in DTs and is not part of the kernel image itself. The hardware description is in its own separate binary, called the Device Tree Blob (DTB) (section Device Tree (DT)).

Please read section PHYTEC i.MX 8 BSP Device Tree Concept to get an understanding of our i.MX 8 BSP device tree model.

The following sections provide an overview of the supported hardware components and their operating system drivers on the i.MX8 platform.

Further changes can be ported upon customer request.

i.MX 8 Pin Muxing

The i.MX 8 SoC contains many peripheral interfaces. In order to reduce package size and lower overall system cost while maintaining maximum functionality, many of the i.MX 8 terminals can multiplex up to eight signal functions. Although there are many combinations of pin multiplexing that are possible, only a certain number of sets called IO sets, are valid due to timing limitations. These valid IO sets were carefully chosen to provide many possible application scenarios for the user.

Please refer to the NXP i.MX 8 Reference Manual for more information about the specific pins and the muxing capabilities:
TODO

The IO set configuration, also called muxing, is done in the Device Tree. The driver pinctrl-single reads the DT's node fsl,pins and does the appropriate pin muxing.

The following is an example of the pin muxing of the UART0 device in phytec-imx8qm-pcm-043.dtsi:

pinctrl_lpuart0: lpuart0grp {
        fsl,pins = <
                SC_P_UART0_RX_DMA_UART0_RX              0x06000020
                SC_P_UART0_TX_DMA_UART0_TX              0x06000020
         >;
};

The first part of the string SC_P_UART0_RX_DMA names the pad (in this example UART0_RX_DMA). The second part of the string (UART0_RX ) is the desired muxing option for this pad.

There is currently no documentation from NXP for pad setting value (hex value on the right).

Network

A gigabit ethernet is provided by our module and board. All interfaces offer a standard Linux network port which can be programmed using the BSD socket interface. The whole network configuration is handled by the systemd-networkd daemon. The relevant configuration files can be found on the target in /lib/systemd/network/ and also in the BSP in meta-freescale/recipes-core/init-ifupdown/init-ifupdown/qoriq/interfaces. IP addresses can be configured within *.network files. The default IP address and netmask for eth0 is:

eth0: 192.168.3.11/24

The DT Ethernet setup might be split into two files depending on your hardware configuration: the module DT and the board specific DT.

Module DT, arch/arm64/boot/dts/freescale/phytec-imx8qm-phycore-som.dtsi:

[…]
#include <dt-bindings/net/ti-dp83867.h>
[…]

&fec1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_fec1>;
        phy-mode = "rgmii-id";
phy-handle = <&ethphy0>; fsl,magic-packet;
fsl,mii-exclusive;
phy-reset-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>; status = "okay"; mdio { #address-cells = <1>; #size-cells = <0>; ethphy0: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; interrupt-parent = <&gpio1>; interrupts = <2 IRQ_TYPE_EDGE_FALLING>; ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>; ti,tx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>; ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>; enet-phy-lane-no-swap; }; }; }; […] &iomuxc { imx8qm-phytec-phycore-som { pinctrl_fec1: fec1grp { fsl,pins = < SC_P_ENET0_MDC_CONN_ENET0_MDC 0x06000020 SC_P_ENET0_MDIO_CONN_ENET0_MDIO 0x06000020 SC_P_ENET0_RGMII_TX_CTL_CONN_ENET0_RGMII_TX_CTL 0x06000020 SC_P_ENET0_RGMII_TXC_CONN_ENET0_RGMII_TXC 0x06000020 SC_P_ENET0_RGMII_TXD0_CONN_ENET0_RGMII_TXD0 0x06000020 SC_P_ENET0_RGMII_TXD1_CONN_ENET0_RGMII_TXD1 0x06000020 SC_P_ENET0_RGMII_TXD2_CONN_ENET0_RGMII_TXD2 0x06000020 SC_P_ENET0_RGMII_TXD3_CONN_ENET0_RGMII_TXD3 0x06000020 SC_P_ENET0_RGMII_RXC_CONN_ENET0_RGMII_RXC 0x06000020 SC_P_ENET0_RGMII_RX_CTL_CONN_ENET0_RGMII_RX_CTL 0x06000020 SC_P_ENET0_RGMII_RXD0_CONN_ENET0_RGMII_RXD0 0x06000020 SC_P_ENET0_RGMII_RXD1_CONN_ENET0_RGMII_RXD1 0x06000020 SC_P_ENET0_RGMII_RXD2_CONN_ENET0_RGMII_RXD2 0x06000020 SC_P_ENET0_RGMII_RXD3_CONN_ENET0_RGMII_RXD3 0x06000020
SC_P_SCU_GPIO0_05_LSIO_GPIO1_IO01 0x00000021
SC_P_SCU_GPIO0_06_LSIO_GPIO1_IO02 0x00000021 >; }; }; […] };

Board specific DT, arch/arm64/boot/dts/freescale/phytec-imx8qm-pcm-943.dtsi:

Board specific DT

&fec2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fec2>;
phy-mode = "rgmii-id";
phy-handle = <&ethphy1>;
phy-reset-gpios = <&gpio3 25 GPIO_ACTIVE_LOW>;
fsl,magic-packet;
fsl,mii-exclusive;
status = "okay";

mdio@1 {
#address-cells = <1>;
#size-cells = <0>;

ethphy1: ethernet-phy@3 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <3>;
interrupt-parent = <&gpio3>;
interrupts = <26 IRQ_TYPE_EDGE_FALLING>;
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>;
ti,tx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>;
ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>;
enet-phy-lane-no-swap;
};
};
};

[…]

&iomuxc {
imx8mqm-pcm-943 {

[…]

pinctrl_fec2: fec2grp {
                fsl,pins = <
                                SC_P_ENET1_MDC_CONN_ENET1_MDC 0x06000020
                                SC_P_ENET1_MDIO_CONN_ENET1_MDIO 0x06000020
                                SC_P_ENET1_RGMII_TX_CTL_CONN_ENET1_RGMII_TX_CTL 0x06000020
                                SC_P_ENET1_RGMII_TXC_CONN_ENET1_RGMII_TXC 0x06000020
                                SC_P_ENET1_RGMII_TXD0_CONN_ENET1_RGMII_TXD0 0x06000020
                                SC_P_ENET1_RGMII_TXD1_CONN_ENET1_RGMII_TXD1 0x06000020
                                SC_P_ENET1_RGMII_TXD2_CONN_ENET1_RGMII_TXD2 0x06000020
                                SC_P_ENET1_RGMII_TXD3_CONN_ENET1_RGMII_TXD3 0x06000020
                              SC_P_ENET1_RGMII_RXC_CONN_ENET1_RGMII_RXC 0x06000020
                                SC_P_ENET1_RGMII_RX_CTL_CONN_ENET1_RGMII_RX_CTL 0x06000020
                                SC_P_ENET1_RGMII_RXD0_CONN_ENET1_RGMII_RXD0 0x06000060
                                SC_P_ENET1_RGMII_RXD1_CONN_ENET1_RGMII_RXD1 0x06000060
                               SC_P_ENET1_RGMII_RXD2_CONN_ENET1_RGMII_RXD2 0x06000060
SC_P_ENET1_RGMII_RXD3_CONN_ENET1_RGMII_RXD3 0x06000060
SC_P_MLB_SIG_LSIO_GPIO3_IO26 0x00000021
SC_P_ADC_IN7_LSIO_GPIO3_IO25 0x00000021
>;
};
};

[…]

};

CAN Bus

The i.MX 8 alpha provides a Controller Area Network (CAN) interface, which is supported by drivers using the proposed Linux standard CAN framework SocketCAN. Using this framework, CAN interfaces can be programmed with the BSD socket API.

The CAN bus offers a low-bandwidth, prioritized message fieldbus for serial communication between microcontrollers. Unfortunately, CAN was not designed with the ISO/OSI layer model in mind, so most CAN APIs available throughout the industry do not support a clean separation between the different logical protocol layers, for example, known from Ethernet.

The SocketCAN framework for Linux extends the BSD socket API concept towards CAN bus. Because of that, using this framework, the CAN interfaces can be programmed with the BSD socket API and behaves like an ordinary Linux network device, with some additional features special to CAN.

  • Use:

Can use

target$ ip link

To see if the interface is up or down, but the given MAC and IP addresses are arbitrary and obsolete.

  • To get the information on can0 such as bit rate and error counters, type:

can0 information

target$ ip -d -s link show can0

The information for can0 will look like:

2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10

link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point 0.875
tq 50 prop-seg 17 phase-seg1 17 phase-seg2 5 sjw 1
flexcan: tseg1 2..64 tseg2 1..32 sjw 1..32 brp 1..1024 brp-inc 1
flexcan: dtseg1 1..39 dtseg2 1..8 dsjw 1..8 dbrp 1..1024 dbrp-inc 1
clock 40000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0

The output contains a standard set of parameters also shown for Ethernet interfaces, so not all of these are necessarily relevant for CAN (for example the MAC address). The following output parameters contain useful information:

FieldDescription
can0Interface Name
NARPCan cannot use ARP protocol
MTUMaximum Transfer Unit
RX packetsNumber of Received Packets
TX packetsNumber of Transmitted Packets
RX bytesNumber of Received Bytes
TX bytesNumber of Transmitted Bytes
errors...Bus Error Statistics

The can0/can1 interface is started after boot by default with default value. To use canfd, you have to set it up the correct way:

target$ ifconfig can0 down
target$ sudo ip link set can0 up type can bitrate 500000 sample-point 0.75 dbitrate 4000000 dsample-point 0.8 fd on


You can send messages with cansend or receive messages with candump:

target$ cansend can0 123##1.223344
target$ candump can0

See cansend --help and candump --help help messages for further information on options and usage. The corresponding kernel part can be found within the board specific DT, e.g. phytec-imx8qm-pcm-943.dtsi:

&flexcan1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan1>;
xceiver-supply = <&reg_can_en>;
status = "okay";
};

&flexcan2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan2>;
xceiver-supply = <&reg_can_en2>;
status = "okay";
};

&iomuxc {
imx8qm-pcm-943 {

                […]

pinctrl_flexcan1: flexcan0grp {
fsl,pins = <
SC_P_FLEXCAN0_TX_DMA_FLEXCAN0_TX 0x21
SC_P_FLEXCAN0_RX_DMA_FLEXCAN0_RX 0x21
SC_P_SAI1_RXFS_LSIO_GPIO3_IO14 0x21
>;
};

pinctrl_flexcan2: flexcan1grp {
fsl,pins = <
SC_P_FLEXCAN1_TX_DMA_FLEXCAN1_TX 0x21
SC_P_FLEXCAN1_RX_DMA_FLEXCAN1_RX 0x21
SC_P_SAI1_TXC_LSIO_GPIO3_IO15 0x21
>;
};

                […]

};
};

SD / MMC Card

The i.MX 8 alpha release kit supports a slot for Secure Digital Cards and Multi Media Cards to be used as general purpose block devices. These devices can be used in the same way as any other block device. 

These kinds of devices are hot-pluggable. Nevertheless, you must ensure not to unplug the device while it is still mounted. This may result in data loss!

After inserting an MMC/SD card, the kernel will generate new device nodes in /dev. The full device can be reached via its /dev/mmcblk0 device node. MMC/SD card partitions will show up in the following way:

/dev/mmcblk0p<Y>

<Y> counts as the partition number starting from 1 to the max. count of partitions on this device. The partitions can be formatted with any kind of file system and also handled in a standard manner, e.g. the mount and umount command work as expected.

These partition device nodes will only be available if the card contains a valid partition table (”hard disk” like handling). If it does not contain one, the whole device can be used as a file system (”floppy” like handling). In this case, /dev/mmcblk0 must be used for formatting and mounting.      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The cards are always mounted as being writable.

DT configuration for the MMC (SD card slot) interface in arch/arm64/boot/dts/freescale/phytec-imx8qm-pcm-943.dtsi:

[…]

&usdhc3 {
       pinctrl-names = "default", "state_100mhz", "state_200mhz";
       pinctrl-0 = <&pinctrl_usdhc3>, <&pinctrl_usdhc3_gpio>;
       pinctrl-1 = <&pinctrl_usdhc3_100mhz>, <&pinctrl_usdhc3_gpio>;
       pinctrl-2 = <&pinctrl_usdhc3_200mhz>, <&pinctrl_usdhc3_gpio>;
       bus-width = <4>;
       cd-gpios = <&gpio4 12 GPIO_ACTIVE_LOW>;
       vmmc-supply = <&reg_usdhc3_vmmc>;
no-1-8-v; status = "okay"; […] &iomuxc { imx8qm-pcm-943 { […] pinctrl_usdhc3_gpio: usdhc3grpgpio { fsl,pins = < SC_P_USDHC2_CD_B_LSIO_GPIO4_IO12 0x00000021 SC_P_USDHC2_RESET_B_LSIO_GPIO4_IO09 0x00000021 >; }; pinctrl_usdhc3: usdhc3grp { fsl,pins = < SC_P_USDHC2_CLK_CONN_USDHC2_CLK 0x06000041 SC_P_USDHC2_CMD_CONN_USDHC2_CMD 0x00000021 SC_P_USDHC2_DATA0_CONN_USDHC2_DATA0 0x00000021 SC_P_USDHC2_DATA1_CONN_USDHC2_DATA1 0x00000021 SC_P_USDHC2_DATA2_CONN_USDHC2_DATA2 0x00000021 SC_P_USDHC2_DATA3_CONN_USDHC2_DATA3 0x00000021 SC_P_USDHC2_VSELECT_CONN_USDHC2_VSELECT 0x00000021 >; }; pinctrl_usdhc3_100mhz: usdhc3grp100mhz { fsl,pins = < SC_P_USDHC2_CLK_CONN_USDHC2_CLK 0x06000040 SC_P_USDHC2_CMD_CONN_USDHC2_CMD 0x00000020 SC_P_USDHC2_DATA0_CONN_USDHC2_DATA0 0x00000020 SC_P_USDHC2_DATA1_CONN_USDHC2_DATA1 0x00000020 SC_P_USDHC2_DATA2_CONN_USDHC2_DATA2 0x00000020 SC_P_USDHC2_DATA3_CONN_USDHC2_DATA3 0x00000020 SC_P_USDHC2_VSELECT_CONN_USDHC2_VSELECT 0x00000020 >; }; pinctrl_usdhc3_200mhz: usdhc3grp200mhz { fsl,pins = < SC_P_USDHC2_CLK_CONN_USDHC2_CLK 0x06000040 SC_P_USDHC2_CMD_CONN_USDHC2_CMD 0x00000020 SC_P_USDHC2_DATA0_CONN_USDHC2_DATA0 0x00000020 SC_P_USDHC2_DATA1_CONN_USDHC2_DATA1 0x00000020 SC_P_USDHC2_DATA2_CONN_USDHC2_DATA2 0x00000020 SC_P_USDHC2_DATA3_CONN_USDHC2_DATA3 0x00000020 SC_P_USDHC2_VSELECT_CONN_USDHC2_VSELECT 0x00000020 >; }; […] }; };

DT configuration for the MMC interface in arch/arm64/boot/dts/freescale/phytec-imx8qm-phycore-som.dtsi:

[…]

&usdhc1 {
        pinctrl-names = "default", "state_100mhz", "state_200mhz";
        pinctrl-0 = <&pinctrl_usdhc1>;
        pinctrl-1 = <&pinctrl_usdhc1_100mhz>;
        pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
        bus-width = <8>;
        non-removable;
        status = "okay";
};

[…]

&iomuxc {
        imx8qm-phytec-phycore-som {

                […]

                pinctrl_usdhc1: usdhc1grp {
                       fsl,pins = <
                               SC_P_EMMC0_CLK_CONN_EMMC0_CLK           0x06000041
                               SC_P_EMMC0_CMD_CONN_EMMC0_CMD           0x00000021
                               SC_P_EMMC0_DATA0_CONN_EMMC0_DATA0       0x00000021
                               SC_P_EMMC0_DATA1_CONN_EMMC0_DATA1       0x00000021
                               SC_P_EMMC0_DATA2_CONN_EMMC0_DATA2       0x00000021
                               SC_P_EMMC0_DATA3_CONN_EMMC0_DATA3       0x00000021
                               SC_P_EMMC0_DATA4_CONN_EMMC0_DATA4       0x00000021
                               SC_P_EMMC0_DATA5_CONN_EMMC0_DATA5       0x00000021
                               SC_P_EMMC0_DATA6_CONN_EMMC0_DATA6       0x00000021
                               SC_P_EMMC0_DATA7_CONN_EMMC0_DATA7       0x00000021
                               SC_P_EMMC0_STROBE_CONN_EMMC0_STROBE     0x06000041
                               SC_P_EMMC0_RESET_B_CONN_EMMC0_RESET_B   0x00000021
                       >;
               };

                pinctrl_usdhc1_100mhz: usdhc1grp100mhz {
                       fsl,pins = <
                               SC_P_EMMC0_CLK_CONN_EMMC0_CLK           0x06000040
                               SC_P_EMMC0_CMD_CONN_EMMC0_CMD           0x00000020
                               SC_P_EMMC0_DATA0_CONN_EMMC0_DATA0       0x00000020
                               SC_P_EMMC0_DATA1_CONN_EMMC0_DATA1       0x00000020
                               SC_P_EMMC0_DATA2_CONN_EMMC0_DATA2       0x00000020
                               SC_P_EMMC0_DATA3_CONN_EMMC0_DATA3       0x00000020
                               SC_P_EMMC0_DATA4_CONN_EMMC0_DATA4       0x00000020
                               SC_P_EMMC0_DATA5_CONN_EMMC0_DATA5       0x00000020
                               SC_P_EMMC0_DATA6_CONN_EMMC0_DATA6       0x00000020
                               SC_P_EMMC0_DATA7_CONN_EMMC0_DATA7       0x00000020
                               SC_P_EMMC0_STROBE_CONN_EMMC0_STROBE     0x06000040
                               SC_P_EMMC0_RESET_B_CONN_EMMC0_RESET_B   0x00000020
                       >;
               };

                 pinctrl_usdhc1_200mhz: usdhc1grp200mhz {
                       fsl,pins = <
                               SC_P_EMMC0_CLK_CONN_EMMC0_CLK           0x06000040
                               SC_P_EMMC0_CMD_CONN_EMMC0_CMD           0x00000020
                               SC_P_EMMC0_DATA0_CONN_EMMC0_DATA0       0x00000020
                               SC_P_EMMC0_DATA1_CONN_EMMC0_DATA1       0x00000020
                               SC_P_EMMC0_DATA2_CONN_EMMC0_DATA2       0x00000020
                               SC_P_EMMC0_DATA3_CONN_EMMC0_DATA3       0x00000020
                               SC_P_EMMC0_DATA4_CONN_EMMC0_DATA4       0x00000020
                               SC_P_EMMC0_DATA5_CONN_EMMC0_DATA5       0x00000020
                               SC_P_EMMC0_DATA6_CONN_EMMC0_DATA6       0x00000020
                               SC_P_EMMC0_DATA7_CONN_EMMC0_DATA7       0x00000020
                               SC_P_EMMC0_STROBE_CONN_EMMC0_STROBE     0x06000040
                               SC_P_EMMC0_RESET_B_CONN_EMMC0_RESET_B   0x00000020
                       >;
               };

               […]

        };
};

eMMC Devices

PHYTEC modules like phyCORE-i.MX 8 are populated with an eMMC memory chip as main storage. eMMC devices contain raw MLC memory cells (section Enable Pseudo-SLC Mode) combined with a memory controller that handles ECC and wear leveling. They are connected via an MMC/SD interface to the i.MX 8 and are represented as block devices in the Linux kernel like SD cards, flash drives, or hard disks.

The electric and protocol specifications are provided by JEDEC (https://www.jedec.org/standards-documents/technology-focus-areas/flash-memory-ssds-ufs-emmc/e-mmc). The eMMC manufacturer's datasheet is relatively short and meant to be read together with the supported version of the JEDEC eMMC standard.

PHYTEC currently utilizes the eMMC chips:

eMMC ChipSizeJEDEC Version
MTFC8GAKAJCN-4M IT8 GB5.0

Extended CSD Register

eMMC devices have an extensive amount of extra information and settings that are available via the Extended CSD registers. For a detailed list of the registers, see manufacturer datasheets and the JEDEC standard.

  • In the Linux user space, you can query the registers with:
 target$ mmc extcsd read/dev/mmcblk0

You will see:

 =============================================
   Extended CSD rev1.7(MMC 5.0)
 =============================================
 
 Card Supported Command sets [S_CMD_SET: 0x01][...]

Enable Background Operations (BKOPS)

In contrast to raw NAND Flash, an eMMC device contains a Flash Transfer Layer (FTL) that handles the wear leveling, block management, and ECC of the raw MLC cells. This requires some maintenance tasks (for example erasing unused blocks) that are performed regularly. These tasks are called Background Operations (BKOPS).

By default (which depends on the chip), the background operations may or may not be executed periodically which impacts the worst-case read and write latency.

The JEDEC Standard has specified a method since version v4.41 that the host can issue BKOPS manually. See the JEDEC Standard chapter Background Operations and the description of registers BKOPS_EN (Reg: 163) and BKOPS_START (Reg: 164) in the eMMC datasheet for more details.

Meaning of Register BKOPS_EN (Reg: 163) Bit MANUAL_EN (Bit 0):

  • Value 0: The host does not support manual trigger of BKOPS. Device write performance suffers.
  • Value 1: The host does support manual trigger of BKOPS. It will issue BKOPS from time to time when it does not need the device.

The mechanism to issue background operations has already been implemented in the Linux kernel since v3.7. You only have to enable BKOPS_EN on the eMMC device (see below for details).

The JEDEC standard v5.1 introduces a new automatic BKOPS feature. It frees the host to trigger the background operations regularly because the device starts BKOPS itself when it is idle (see the description of bit AUTO_EN in register BKOPS_EN (Reg: 163)).

eMMC chips deployed by PHYTEC do not currently support the new standard v5.1. Neither the Linux kernel nor userspace tool mmc support this feature.

  • To check whether BKOPS_EN is set, execute:
target$ mmc extcsd read/dev/mmcblk0 |grep BKOPS_EN

The example output will be:

 Enable background operations handshake [BKOPS_EN]: 0x01
 #OR
 Enable background operations handshake [BKOPS_EN]: 0x00

Where value 0x00 means BKOPS_EN is disabled and device write performance suffers. Where value 0x01 means BKOPS_EN is enabled and the host will issue background operations from time to time.

  • To set the BKOPS_EN bit execute:
 target$ mmc bkops enable/dev/mmcblk0
  • To ensure that the new setting is taken over and the kernel triggers BKOPS by itself, shut down the system with:
target$ poweroff

and perform a power cycle.

The BKOPS_EN bit is one-time-programmable only. It cannot be reversed.

Enable Pseudo-SLC Mode

eMMC devices use MLC memory cells (https://en.wikipedia.org/wiki/Multi-level_cell) to store the data. Compared with SLC memory cells used in NAND Flash, MLC memory cells have a lower reliability and a higher error rate at lower costs.

If you prefer reliability over storage capacity, you can enable the pseudo-SLC or SLC mode. The method used here employs the enhanced attribute, which is described in the JEDEC standard and can be set for continuous regions of the device. The JEDEC standard does not specify the implementation details and the guarantees of the enhanced attribute. This is left of the chipmaker. For the Micron chips, the enhanced attribute increases the reliability but also halves the capacity.

When enabling the enhanced attribute on the device, all data will be lost.

The following sequence shows how to enable the enhanced attribute.

  • First obtain the current size of the eMMC device with:
target$ fdisk-l/dev/mmcblk0
  • You will receive:
Disk /dev/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 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
Disklabel type: dos
Disk identifier: 0xc4792a6c

As you can see, this device has 7818182656 Byte = 7818182 KiB = 7264.0 MiB = 7.3 GiB (rounded).

  • To get the maximum size of the device after pseudo-SLC is enabled use:
target$ mmc extcsd read/dev/mmcblk0 |grep ENH_SIZE_MULT -A1
  • which shows, for example:
 Max Enhanced Area Size [MAX_ENH_SIZE_MULT]: 0x0001c6 i.e. 3719168 KiB
 --
 Enhanced User Data Area Size [ENH_SIZE_MULT]: 0x000000 i.e. 0 KiB

Here, the maximum size is 3719168 KiB = 3632 MiB.

  • Now, you can set enhanced attribute for the whole device (example 3719168 KiB) by typing:
target$ mmc enh_area set-y03719168/dev/mmcblk0
  • You will get:
Done setting ENH_USR area on /dev/mmcblk0 
Setting OTP PARTITION_SETTING_COMPLETED!
Setting OTP PARTITION_SETTING_COMPLETED on /dev/mmcblk0 SUCCESS
Device power cycle needed for settings to take effect.
Confirm that PARTITION_SETTING_COMPLETED bit is set using 'extcsd read' after power cycle
  • To ensure that the new setting is taken over, shut down the system with:
target$ poweroff
  • and perform a power cycle.

It is recommended that you verify the settings now.

  • First, check the value of ENH_SIZE_MULT which must be 3719168 KiB:
targe$ mmc extcsd read/dev/mmcblk0 |grep ENH_SIZE_MULT  -A1
  • Now you can flash your new image.

Further reference: https://www.micron.com/support/faqs/products/managed-nand/emmc (chapter "What are the enhanced technology features mentioned in JEDEC specification, and what are the benefits?")

eMMC (boot-) partitions

An eMMC device contains four different hardware partitions: user, boot1, boot2 and rpmb.

The user partition is called the User Data Area in the JEDEC standard and is the main storage partition. The partitions boot1 and boot2 can be used to host the bootloader and are more reliable. Which partition the i.MX 8 uses to load the bootloader is controlled by the boot configuration of the eMMC device. The partition rpmb is a small partition and can only be accessed via trusted mechanism.

Furthermore, the user partition can be divided into four user-defined General Purpose Area Partitions. An explanation of this feature exceeds the scope of this document. For further information, see the JEDEC Standard chapter "7.2 Partition Management".

Do not confuse eMMC partitions with partitions of a DOS, MBR, or GPT partition table.

There are two ways to flash the bootloader to one of the two boot partitions and to switch the boot device: via bootloader or via userspace commands, as shown in the following examples.The current PHYTEC BSP does not use the extra partitioning feature of eMMC devices. The u-boot is flashed at the beginning of the user partition. The u-boot environment is placed at a fix location after the u-boot. An MBR partition table is used to create two partitions, a FAT32 boot, and ext4 rootfs partition. They are located right after the u-boot and the u-boot environment. The FAT32 boot partition contains the kernel and device tree.

1. Via bootloader

  • First, detect the eMMC if not already done:
bootloader$ mmc rescan
  • Second, list all detected mmc devices:
bootloader$ mmc list
FSL_SDHC: 0(eMMC)
FSL_SDHC: 1(SD)
  • Select eMMC device:
bootloader$ mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
  • Now, query some information about the eMMC device:
bootloader$ mmc info
  • The output will look like this:
Device: FSL_SDHC
Manufacturer ID: 11
OEM: 100
Name: 008G3 
Bus Speed: 200000000
Mode : HS400ES (200MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 8-bit DDR
Erase Group Size: 512 KiB
HC WP Group Size: 4 MiB
User Capacity: 7.3 GiB WRREL
Boot Capacity: 8 MiB ENH
RPMB Capacity: 4 MiB ENH
  • Load the bootloader file over ethernet:
bootloader$ tftp ${loadaddr}${serverip}:imx-boot-phycore-imx8-2-sd.bin
  • Write the new bootloader into the eMMC device:
bootloader$ mmc write${loadaddr} 0x20 0x990D

- assumed bootloader file size 638910 Bytes = 0x9BFBE
- assumed block length of eMMC 512 Bytes = 0x200
-> size to write to eMMC should be <bootloader file size>/<block length> = 0x9BFBE/0x200 = 0x4E0 (rounded)
-> as wrote before, offset to write bootloader should be 32 blocks = 0x20

2. Via user space commands:

  • Flash the bootloader to the beginning of eMMC:
target$ ddif=<path to bootloader>/imx-boot-phycore-imx8-2-sd.binof=/dev/mmcblk0 bs=1k seek=32

Reliable Write

There are two different Reliable Write options:

  • Reliable Write option for a whole eMMC device/partition.
  • Reliable Write for single write transactions.
Do not confuse eMMC partitions with partitions of a DOS, MBR, or GPT partition table (see previous section).
  • The first Reliable Write option can be enabled with the mmc tool:
target$ mmc --help
 
[...]
mmc write_reliability set<-y|-n><partition><device>

The second Reliable Write option is the configuration bit Reliable Write Request parameter (bit 31) in command CMD23. It has been used in the kernel since v3.0 by file systems, e.g. ext4 for the journal and user space applications such as fdisk for the partition table. In the Linux kernel source code, it is handled via flag REQ_META.

Conclusion: ext4 file system with mount option data=journal should be safe against power cuts. The file system check can recover the file system after a power failure, but data that was written just before the power cut may be lost. In any case, a consistent state of the file system can be recovered. To ensure data consistency for the files of an application, the system functions fdatasync, or fsync should be used in the application.

Resize the ext4 Root Filesystem

fdisk can be used to expand the root filesystem. The example works for any block device such as eMMC, SD card, or hard disk.

  • Get the current device size:
target$ fdisk-l/dev/mmcblk0
  • The output looks like:
Disk /dev/mmcblk0: 3.6 GiB, 3808428032 bytes, 7438336 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
Disklabel type: dos
Disk identifier: 0xbfdf196d
 
Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1      163848191965536   32M  c W95 FAT32 (LBA)/dev/mmcblk0p2      8192034406393358720  1.6G 83 Linux
  • Now use fdisk to delete and create a partition with max size of device:
target$ fdisk/dev/mmcblk0
 
Welcome to fdisk(util-linux 2.28.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
Command (m forhelp): p
Disk /dev/mmcblk0: 3.6 GiB, 3808428032 bytes, 7438336 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
Disklabel type: dos
Disk identifier: 0xbfdf196d
 
Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1      163848191965536   32M  c W95 FAT32 (LBA)/dev/mmcblk0p2      8192034406393358720  1.6G 83 Linux

Command (m forhelp): d
Partition number (1,2, default 2): 2
 
Partition 2 has been deleted.
 
Command (m forhelp): p
Disk /dev/mmcblk0: 3.6 GiB, 3808428032 bytes, 7438336 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
Disklabel type: dos
Disk identifier: 0xbfdf196d

Device         Boot Start   End Sectors Size Id Type
/dev/mmcblk0p1      163848191965536  32M  c W95 FAT32 (LBA)
 
Command (m forhelp): n
Partition type
  p   primary (1 primary, 0 extended, 3free)
  e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-7438335, default 2048): 81920 
Last sector, +sectors or +size{K,M,G,T,P}(81920-7438335, default 7438335): 
 
 Created a new partition 2 of type'Linux' and of size3.5 GiB.
 
Command (m forhelp): p
Disk /dev/mmcblk0: 3.6 GiB, 3808428032 bytes, 7438336 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
Disklabel type: dos
Disk identifier: 0xbfdf196d
 
Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1      163848191965536   32M  c W95 FAT32 (LBA)/dev/mmcblk0p2      8192074383357356416  3.5G 83 Linux

Command (m forhelp): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
 
target$

Increasing the file system size can be done while it is mounted. An on-line resizing operation is performed. But you can also boot the board from an SD card and then resize the file system on the eMMC partition while it is not mounted.

Furthermore, the board has to be rebooted so that the new partition table will be read.

Erase the Device

It is possible to erase the eMMC device directly rather than overwriting it with zeros. The eMMC block management algorithm will erase the underlying MLC memory cells or mark these blocks as discard. The data on the device is lost and will be read back as zeros.

  • After booting from SD card execute:
target$ blkdiscard --secure/dev/mmcblk0

The option --secure ensures that the command waits until the eMMC device has erased all blocks.

dd if=/dev/zero of=/dev/mmcblk0 also destroys all information on the device, but this command is bad for wear leveling and takes much longer!

GPIOs

The PCM-943 has a set of pins specially dedicated as user I/Os. Those pins are connected directly to i.MX 8 pins and are muxed as GPIOs. They are directly usable in Linux user space. The processor has organized its GPIOs into seven banks of 32 GPIOs each (GPIO0 – GPIO6). gpiochip0, gpiochip32, gpiochip64, gpiochip96 and gpiochip128 are the sysfs representation of these internal i.MX 8 GPIO banks GPIO0 – GPIO6.

The GPIOs are identified as GPIO<X>_<Y> (e.g. GPIO5_07). <X> identifies the GPIO bank and counts from 1 to 5, while <Y> stands for the GPIO within the bank. <Y> is being counted from 0 to 31 (32 GPIOs on each bank).

By contrast, the Linux kernel uses a single integer to enumerate all available GPIOs in the system. The formula to calculate the right number is:

Linux GPIO number: <N> = (<X> - 1) * 32 + <Y>

Accessing GPIOs from user space will be done using the sysfs path /sys/class/gpio/.

  • First you have to register the GPIO that you want to use by writing its numbers into the file export:
target$ echo<N>>/sys/class/gpio/export

This will create a new subdirectory gpio<N> (for GPIO<X>_<Y> of the controller). The two files direction and value in the new subdirectory allow the processor to control the GPIO.

Example:

  • To use the GPIO <N> as input, execute the following commands:
target$ echo out >/sys/class/gpio/gpio<N>/direction
target$ cat/sys/class/gpio/gpio<N>/value
  • To use the newly created GPIO 135 as output and to toggle it, execute:
target$ echo135>/sys/class/gpio/export
target$ echo out >/sys/class/gpio/gpio135/direction
target$ echo1>/sys/class/gpio/gpio135/value
target$ echo0>/sys/class/gpio/gpio135/value

Pinmuxing of some GPIO pins in the device tree phytec-imx8qm-phycore-som.dtsi:

                pinctrl_gpio_leds: gpioledsgrp {
                        fsl,pins = <
                               SC_P_MIPI_DSI1_GPIO0_00_LSIO_GPIO1_IO22 0x00000021
                        >;
                };

USB Host Controller

The USB controller of the i.MX 8 SoC provides a low-cost connectivity solution for numerous consumer portable devices by providing a mechanism for data transfer between USB devices with a line/bus speed up to 5 Gbps (SuperSpeed 'SS'). The USB subsystem has two independent USB controller cores. Both cores are On-The-Go (OTG) controller cores and capable of acting as a USB peripheral device or a USB host. Each is connected to a USB 2.0 PHY and a USB 3.0 PHY macrocell and supports USB Type-C connectors.

The unified BSP includes support for mass storage devices and keyboards. Other USB related device drivers must be enabled in the kernel configuration on demand.

Due to udev, all mass storage devices connected get unique IDs and can be found in /dev/disks/by-id. These IDs can be used in /etc/fstab to mount the different USB memory devices in different ways.

User USB1 (host) configuration is in the kernel device tree phytec-imx8qm-pcm-943.dtsi:

&usbotg3 {
       dr_mode = "host";
       status = "okay";
};

USB OTG

USB OTG 2.0 is a Dual-Role Device controller, which supports both device and host functions and is fully compliant with OTG Supplement to USB2.0 specification, and support high-speed (480Mbps), full-speed (12Mbps), low-speed (1.5Mbps) transfer.

Most Phytec boards support USB OTG.

  • To activate USB OTG as device you need to load an appropriate module with modprobe, e.g. the Ethernet gadget g_ether:

USB OTG

target$ modprobe g_ether

For using USB OTG as host, please load the module g_zero.

User USB OTG configuration in the kernel device treephytec-imx8qm-pcm-943.dtsi:

&iomuxc {[…]
                pinctrl_usbotg1: usbotg1 {
                        fsl,pins =<
                                SC_P_USB_SS3_TC0_CONN_USB_OTG1_PWR              0x00000021>;};
 
[…]};
 
&usbotg1 {
        pinctrl-names ="default";
        pinctrl-0=<&pinctrl_usbotg1>;
        srp-disable;
        hnp-disable;
        adp-disable;
        power-polarity-active-high;
        disable-over-current;
        status ="okay";};

PCIe

The phyCORE-i.MX8 has one Mini-PCIe and one PCIe slot.

In general, PCIe autodetects new devices on the bus. After connecting the device and booting up the system, you can use the command lspci to see all PCIe devices recognized.

  • Type:
target$ lspci-v
  • You will receive:
 00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01)(prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 209
        Memory at 20000000(32-bit, non-prefetchable)[size=1M]
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        Memory behind bridge: 20100000-201fffff
        [virtual] Expansion ROM at 20200000[disabled][size=64K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable+ 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] L1 PM Substates
        Kernel driver in use: pcieport
 
 01:00.0 Network controller: Intel Corporation WiFi Link 5100
        Subsystem: Intel Corporation WiFi Link 5100 AGN
        Flags: fast devsel, IRQ 241
        Memory at 20100000(64-bit, non-prefetchable)[size=8K]
        Capabilities: [c8] Power Management version 3
        Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [e0] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-24-d6-ff-ff-84-0d-1e
        Kernel modules: iwlwifi

In this example, the PCIe device is the Intel Corporation WiFi Link 5100.

For PCIe devices, you have to enable the correct driver in the kernel configuration. This WLAN card, for example, is manufactured by IntelKconfig. The option for the driver, which must be enabled, is named CONFIG_IWLWIFI and can be found under Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimat in the kernel configuration.

  • In order to activate the driver use:
host$ bitbake virtual/kernel -c menuconfig

For some devices like this WLAN card additional binary firmware blobs are needed. These firmware blobs have to be placed in /lib/firmware/ before the device can be used.

  • Type:
host$ scp-r<firmware> root@192.168.3.11:/lib/firmware
  • For example, if you try to bring up the network interface with:
target$ ip linkset up wlp1s0
  • You will get the following output on the serial console:
[58.682104] iwlwifi 0000:01:00.0: L1 Disabled - LTR Disabled
[58.690822] iwlwifi 0000:01:00.0: L1 Disabled - LTR Disabled
[58.696577] iwlwifi 0000:01:00.0: Radio type=0x1-0x2-0x0
[58.831022] iwlwifi 0000:01:00.0: L1 Disabled - LTR Disabled
[58.839679] iwlwifi 0000:01:00.0: L1 Disabled - LTR Disabled
[58.845435] iwlwifi 0000:01:00.0: Radio type=0x1-0x2-0x0
[58.902797] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready

Some PCIe devices, e.g. this Ethernet card, may function properly even if no firmware blob could be loaded from /lib/firmware/ and you received an error message as shown in the first line of the output above. This is because some manufacturers provide the firmware as fall-back on the card itself. In this case, the behavior and output depend strongly on the manufacturer's firmware.

CPU Core Management

The i.MX 8 SoC can have multiple processor cores on the die. The i.MX 8, for example, has 4 ARM Cores which can be turned on and off individually at runtime.

  • To see all available cores in the system, execute:
target$ ls /sys/devices/system/cpu  -1

This will show, for example:

cpu0    cpu1   cpu2   cpu3   cpufreq
[...]

Here the system has four processor cores.

By default, all available cores in the system are enabled to get maximum performance.

  • To switch off a single core, execute:
target$ echo 0 > /sys/devices/system/cpu/cpu3/online
  • As confirmation, you will see:
[  110.502295] CPU3: shutdown
[  110.505012] psci: CPU3 killed.

Now the core is powered down and no more processes are scheduled on this core.

  • You can use top to see a graphical overview of the cores and processes:
target$ top
  • To power up the core again, execute:
target$ echo 1 > /sys/devices/system/cpu/cpu3/online

Use of the kernel boot parameter maxcpus allows the processor to limit the number of cores the system is using at runtime (https://www.kernel.org/doc/Documentation/kernel-parameters.txt).

Thermal Management

The Linux kernel has an integrated thermal management which is capable of monitoring SoC temperatures, reducing the CPU frequency, driving fans, advising other drivers to reduce the power consumption of devices, and – worst case – shutting down the system gracefully (https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt).

This section describes how the thermal management kernel API is used for the i.MX8M SoC platform.

The i.MX8 has internal temperature sensors for the SoC.

  • The current temperature can be read in millicelsius with:
target$ cat /sys/class/thermal/thermal_zone0/temp
  • You will get, for example:
49000

There are two trip points registered by the imx_thermal kernel driver:

  1. trip_point_0: 85 °C type: passive
  2. trip_point_1: 127 °C type: critical

(see kernel sysfs folder /sys/class/thermal/thermal_zone0/)

These trip points are used by the kernel thermal management to trigger events and change the cooling behavior.

The following thermal policies (also named thermal governors) are available in the kernel:Step Wise, Fair Share, Bang Bang and User space.

The default policy used in the BSP is step_wise.

If the value of the SoC temperature in the sysfs file temp is above trip_point_0 (greater than 85 °C), the CPU frequency is set to the lowest CPU frequency. When the SoC temperature drops below trip_point_0 again, the throttling is released.

If the SoC temperature reaches 127 °C, the thermal management of the kernel shuts down the systems.

WLAN

For wlan and bluetooth support we use the sterling-lwb module from lsr. This module supports 2,4 GHz bandwith and can be run in several modes, like client mode, Access Point (AP) mode using WEP, WPA and WPA2 encryption and so on. More information about the module can be found at https://www.lsr.com/downloads/products/330-0190.pdf

Enabling WLAN

The firmware should be loaded by the kernel automaticaly and you should see an output in your console similar to the following:

 brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43430-sdio.bin for chip 0x00a9a6(43430) rev 0x1

 brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 11 2018 09:22:09 version 7.45.98.65 (r707f

brcmfmac: brcmf_sdio_ulp_preinit: ulp_sdioctrl iovar returned err = -23

Wlan is not present at this time. You first have to configure the country, where you want use it: (Worldwide acceptance: FCC (USA), IC (Canada), ETSI(Europe), Giteki (Japan), and RCM(AU/NZ))

target$ vi/lib/firmware/brcm/brcmfmac43430-sdio.txt
...
ccode=<country>
...

Now you are able to bring the wlan up.

target$ ifconfig wlan0 up
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

Wireless_Network_Configuration

Bluetooth

The bluetooth is connected with UART1 interface. More information about the module can be found at https://www.lsr.com/downloads/products/330-0190.pdf

The firmware will not be selected from the Linux kernel automatically. To use bluetooth you have to load the firmware manually:

brcm_patchram_plus -d --patchram /lib/firmware/brcm/4343w.hcd --enable_hci --no2bytes --tosleep 1000 /dev/ttyLP1 &

option patchram with arg /lib/firmware/brcm/4343w.hcd
option enable_hci
option no2bytes
option tosleep with arg 1000
/dev/ttyLP1
writing
01 03 0c 00
received 7
04 0e 04 01 03 0c 00
writing
01 2e fc 00
received 7
04 0e 04 01 2e fc 00
writing
01 4c fc 46 10 18 21 00 42 52 43 4d 63 66 67 53
00 00 00 00 32 00 00 00 01 01 04 18 92 00 00 00
03 06 ac 1f 12 a1 43 43 00 01 1c 52 18 21 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 fe 00 00
...
received 7
04 0e 04 01 4c fc 00
writing
01 4e fc 04 ff ff ff ff
received 7
04 0e 04 01 4e fc 00
writing
01 03 0c 00
received 7
04 0e 04 01 03 0c 00
Done setting line discpline

target$
hciconfig
hci0: Type: Primary Bus: UART BD Address: 00:25:CA:11:50:C8 ACL MTU: 1021:8 SCO MTU: 64:1 DOWN RX bytes:668 acl:0 sco:0 events:34 errors:0 TX bytes:423 acl:0 sco:0 commands:34 errors:0

target$ hciconfig hci0 up

hci0:   Type: Primary  Bus: UART
        BD Address: 00:25:CA:11:50:C8  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN 
        RX bytes:1378 acl:0 sco:0 events:74 errors:0
        TX bytes:1186 acl:0 sco:0 commands:74 errors:0

target$
hciconfig -a

hci0:   Type: Primary  Bus: UART
        BD Address: 00:25:CA:11:50:C8  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING 
        RX bytes:1378 acl:0 sco:0 events:74 errors:0
        TX bytes:1186 acl:0 sco:0 commands:74 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH SNIFF 
        Link mode: SLAVE ACCEPT 
        Name: 'BlueZ 5.49'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous, 
        HCI Version: 4.1(0x7)  Revision: 0x60
        LMP Version: 4.1(0x7)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)

Now you can scan your environment for visible bluetooth devices. Your bluetooth is not visible at standard.

target$ hcitool scan
Scanning ...
       XX:XX:XX:XX:XX:XX       <SSID>

Visibility

To activate visibility:

target$ hciconfig hciX piscan

To disable visibility:

target$ hciconfig hciX noscan

Change Class Property

target$ hciconfig hci0 class <hexzahl>

class-of-device-bluetooth-cod-list-in-binary-and-hexConnect

arget$ bluetoothctl
[bluetooth]# discoverable on
Changing discoverable on succeeded
[bluetooth]# pairable on
Changing pairable on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent 
Default agent request successful
[bluetooth]# scan on[NEW] Device XX:XX:XX:XX:XX:XX <name>[bluetooth]# connect XX:XX:XX:XX:XX:XX