Welcome to Amarula Wiki!

About

This wiki is for documenting an information in the field of Embedded Linux and related opensource ecosystem projects based on our Amarula experience.

We keep updating this based on our expertise on respective domains along with knowledge required for Embedded Linux aspirers.

Feel free to write for any corrections and updates to

Jagan Teki <jagan@amarulasolutions.com>
Michael Trimarchi <michael@amarulasolutions.com>

Open Source Activities

Amarula Solutions is an active open source participant and maintainer for many subsystems Linux and related open source projects.

Key project areas:

Boot Firmware - U-Boot, Secure boot
Embedded Linux, BSP, Boards
Linux Kernel device drivers
Linux Multimedia - Display, Camera, coders
Build, packaging - Yocto, Buildroot
OTA - swupdate, mender

See our open source activities so far.

Mainatiners

Linux Kernel

Key areas: Linux Kernel Memory Consistency Model (LKMM), Kernel drivers, display panels, display bridges.

Links: :

U-Boot

Key areas: BSP code, SoC’s, Boards, Drivers, tools in i.MX, Allwinner, Rockchip SoCs.

Links: :

Buildroot

Key areas: Boards, configurations, many packages

Links: :

Yocto

Key areas: meta BSP, boards, configurations

Link: :

Contributions

Linux Kernel

Contributions on Linux kernel Memory model, Board designs from customer, SBC vendors, Kernel drivers, Devicetrees, bug fixes. see our contributions

U-Boot

Contributions on SoCs, BSPs, Common Code, Drivers, Devicetrees, Boards, configurations, tools, scripts, bug fixes. see our contributions

Buildroot

Contributions on Packages, Boards, configurations, bug fixes. see our contributions

Yocto

Contributions on Meta BSPs, Boards, configurations. see our contributions

Conferences

Amarula Solutions have enough record of sponsering, participating, speaking and showcasing our work at international conferences.

2019, Linaro Connect:

Talk: State of ARM U-Boot Development

2019, Embedded World:

Showcase: Amarula at Embedded World

2019, FOSDEM:

Talk: U-Boot from scratch

2018, Linux Plumbers Conference:

Talk: Concurrency with tools/memory-model

2018, Buildroot Developers Meeting:

Sponsor: Amarula sponsor Buildroot

2018, OSFC:

Talk: U-Boot from scratch

2017, ELCE:

Showcase: Amarula at ELCE

Technical Showcase

Amarula Solutions have enough record of sponsering, participating, speaking and showcasing our work at international conferences.

2019, ELC: Open Source Graphics Demo

i.MX6
Mainline Linux kernel Display interface: RGB/LVDS Graphic drivers: Mesa 13, Etnaviv Graphic libraries: OpenGL, OpenGL ES Graphic applications: Qt5, glmark2
Allwinner
Mainline Linux kernel Display interface: MIPI-DSI Graphic drivers: Mali-400 MP Graphic libraries: OpenGL Graphic applications: Qt5
Rockchip RK3399
Mainline Linux kernel Display interface: eDP Graphic drivers: Mali-T860 raphic libraries: OpenGL, OpenGL ES, libdrm Graphic applications: Qt5, glmark2
_images/2019_elc.png

2017, ELCE:

Showcase: `Amarula at ELCE <>

Team Amarula Wiki.

News

Update ChatGpt Gerrit plugin to version 2.1.0

_images/chatgpt-news.png


Amarula Solutions S.R.O updates the https://amarula.github.io/chatgpt-code-review-website/ to version 2.1.0

Major updates:

  • Introduced voting capability, allowing ChatGPT to assign a score to the Change Sets.
  • Implemented comment visibility filtering based on scores, with a default focus on displaying negative feedback, customizable to user preference.
  • Transitioned to treating Patch Set review comments as separate entities, moving away from compiling them into a single list.
  • Implemented a complete lifecycle for review comment resolution. Each comment starts from an unresolved state, with options for users to agree, discuss alternatives, or dispute ChatGPT’s suggestions, influencing the Change Set score.
  • Blocked the display of duplicate and conflicting comments.
  • Enabled processing of commands via comments. Command /review triggers full Change Set reviews and /review_last targets the latest Patch Set.

Behavior change:

  • Reviews of commit messages are now enabled by default.

Minor changes and fixes:

  • Excluded WIP Change Sets from automated review.
  • Fine-tuned the temperature settings differentiating between comment queries and Patch Set reviews.
  • Reduced the size of the message history data payload.
  • Fixed rendering issues of ChatGPT comments in the Gerrit UI.
  • Fixed various issues with detecting code snippets in ChatGPT responses.
  • Fixed review posting issue with out-of-bounds line numbers from ChatGPT.

Stay tuned! https://www.amarulasolutions.com/quotation/

Amarula Solutions India Exhibiting at EmbeddedWorldChina2023

_images/amarula_ewch2023.png

(Hyderabad, India - May, 2023) Amarula Solutions India, which specialized in developing innovative open-source technologies and solutions in various areas within the Free/Libre Open Source Software(FLOSS) community while covering a wide set of Linux-enabled hardware platforms is hosting the live demonstration and technical showcase of our hardware enablements and Linux multimedia work at Embedded World China 2023 in Shanghai between 14 - 16 June 2023, Start-up Pavillion, Booth A310.

Event:

Event: EmbeddedWorldChina2023
Booth: Start-up Pavillion, Booth A310
Time: 14th to 16th June, 2023
Place: Shanghai, China

Stay tuned!

Runtime display switching in a Linux System (1xn)

Due to rapid graphical industrial evolution, display interface providers are coming up with display bridges to address the mismatch between application-specific display interfaces vs on-chip display controllers (like from SoC, MCU). This simplifies the on-chip solution provider to concentrate on a single display interface so that the application can choose a direct interface or any other interface by using a display bridge.

Display bridges are linear and one-to-one display interface convertors however the display interface provider makes the further complexity to these bridges and came up with a display switch that can take a single display interface input and convert more than one display interface output.

This kind of display switch has a variety of use cases in industrial and consumer graphic applications. A couple of display switch designs are available in the market via conventional mux with display bridges and a complete converter bridge chip with a one-to-two interface.

As the Linux DRM subsystem progresses toward DRM bridges, these display switches are well suited to be part of DRM bridges. Supporting display switches in Linux DRM is complex and new as DRM bridges are linear in architecture. In order to operate display switches via drm bridge, it requires a pipeline to non-linear and tree structure as switch operate more than one output.

Detailed information at: https://indico.freedesktop.org/event/2/contributions/76/

Engicam i.Core MX8M Mini Mainline Linux-5.13, U-Boot-2021-04

_images/eng-imx8mm.png

Amarula Solutions has partnered with Engicam Srl and started a project to push Engicam SOM’s and Carrier board’s BSP onto Mainline U-Boot, Linux Kernel, Yocto/Buildroot and Multimedia Open source projects.

Here is that we mainlined i.Core MX8M Mini SoM, which is a NXP i.MX8MM based SoM along with two of its carrier boards namely EDIMM 2.2 and CTouch 2.0.

Along with Mainlining, we are also providing Ubuntu 20.04 (Focal Fossa) Distribution running flawlessly on their Carrier Boards.

_images/eng-imx8mm-focal.jpg

Supported features:

NXP i.MX8MM SoC
i.Core MX8M Mini SoM
EDIMM2.2 Starter kit
C.TOUCH 2.0 with 10" Open Frame board
Mainline Linux 5.13.0-rc1
Mainline U-Boot v2021-04
TPL/SPL bootflow
EFI booting
eMMC boot tested via fastboot, ums
Ethernet
USB Host/OTG
LVDS
Buildroot
Ubuntu Focal 20.04

Implementing Linux DRM drivers for DLPC3433 MIPI DSI Projectors

_images/dlpc3433.png

DLP-based projector technology has been evolved in multiple areas of applications since it provides sharp, high-quality projections with the potential for 3D capabilities.

Most of them are Texas Instrument chipsets based on optical micro-electro-mechanical technology that uses a digital micromirror device.

DLPC3433 is one of the newer DPL-based MIPI DSI projectors which uses most industrial and consumer electronics.

_images/dlpc3433-block.png

DLPC3433 block has three key sets of subsystems,

  1. DLPC3433, interfaced from front-end SoC or other chipsets via Parallel, DSI for video, and I2C, SPI for configurations.
  2. DLPA3000 is PMIC and High-CurrentLED driver
  3. DMD, digital mirror device for Sub-LVDS output optics generation.

All the above subsystems are required to implement on respective Linux DRM driver stacks to function properly.

Note: This blog will help you to understand the basic information on DLP-based projectors implementations. If you have any specific questions or help, please reach us.

Engicam MicroGEA STM32MP1 Linux-5.10, U-Boot-2021-01-rc2

_images/eng-microgea-stm32mp1.png

Amarula Solutions has partnered with Engicam Srl and started a project to push Engicam SOM’s and Carrier board’s BSP onto Mainline U-Boot, Linux Kernel, Yocto/Buildroot, and Multimedia Open source projects.

We have supported PX30-Core in Mainline as posted before PX30-Core, now we have another project-based STMicroelectronics STM32MP1 SoM, Engicam MicroGEAM STM32MP1

For this specific SoM, Engicam is providing a Capacitive Carrier board and a 7” LVDS interfaced Open Frame board

Now, both these combinations are running Linux-5.10 and U-Boot-2021-01-rc2 and ready to send upstream patches.

U-Boot:

git clone https://github.com/openedev/u-boot
cd u-boot
git checkout -b stm32mp1 stm32mp1/icore-microgea
make stm32mp15_microgea_stm32mp1_defconfig
make

Linux:

git clone https://github.com/openedev/linux
cd linux
git checkout -b stm32mp1 stm32mp1/icore-microgea
make ARCH=arm multi_v7_defconfig
make ARCH=arm zImage dtbs -j 16

DTB:

stm32mp157c-microgea-stm32mp1-cap.dtb
stm32mp157c-microgea-stm32mp1-cap-of7.dtb

SD:

sudo sgdisk -o /dev/sdx
sudo sgdisk --resize-table=128 -a 1 \
> -n 1:34:545 -c 1:fsbl1 \
> -n 2:546:1057 -c 2:fsbl2 \
> -n 3:1058:5153 -c 3:ssbl \
> -n 4:5154: -c 4:rootfs \
> -p /dev/sdx
cd u-boot
sudo dd if=spl/u-boot-spl.stm32 of=/dev/sdx1
sudo dd if=spl/u-boot-spl.stm32 of=/dev/sdx2
sudo dd if=u-boot.img of=/dev/sdx3
sudo sync

extlinux:

label Engicam MicroGEA STM32MP1 Linux-5.10
  kernel /boot/zImage
  devicetree /boot/stm32mp157c-microgea-stm32mp1-cap-of7.dtb
  append console=tty0 console=ttySTM0,115200n8 root=PARTUUID=8ed1d778-39ec-4a73-82f5-cbb3c5480e63 rootwait rw

Amarula Solutions Speaking at Live Embedded Event 2020

_images/lee-2020.png

As an Engineering Technology Company, Amarula Solutions is always looking forward to being part of the latest technology ecosystems. RISC-V ecosystem development is one of our portfolios where our Open Source Engineer already started hands-on with real RISC-V platforms.

Our Engineer (Jagan Teki) is part of the community with the development of Standardized boot flow for RISC-V platforms. With our previous blog, we have demonstrated how the community achieved to produce Standardized boot flow on RISC-V, On that basis, we are going to speak the same topic at LEE 2020.

Event:

Event: Live Embedded Event 2020
Topic: Standardizing Linux Boot process for RISC-V platforms
Time: 3rd, December 09.30 CET
Speaker: `Jagan Teki <https://www.linkedin.com/in/jaganteki/>`_
_images/lee-2020-jagan.png

Wiki:

https://wiki.amarulasolutions.com/bsp/riscv/sifive/hifive-unleashed.html

Looking forward to speaking at the conference.

Type-C Power Delivery with Altmode Display Port in Linux-5.10

Hardware:

SoC: Rockchip RK3399
SBC: ROC-RK3399-PC

Amarula Solutions has partnered with Libretech and started a project to push Libre Computer Boards onto Mainline U-Boot, Linux Kernel, Buildroot and Multimedia Open source projects.

The first success was that we mainlined full functional ROC-RK3399-PC(Renegade Elite) along with community developers.

Along with Mainlining, we are also providing Ubuntu 20.04 (Focal Fossa) Distribution running flawlessly on their SBC’s.

Here is the Type C Power Delivery with Altmode Display Port support in Linux-5.10. The Type-C chip FUSB302 still using Linux extcon framework and the real work is yet to push on Mainline.

_images/roc-typec-pd.png

Wiki:

https://wiki.amarulasolutions.com/bsp/rockchip/rk3399/roc-rk3399-pc.html

ROCK Pi 4A/B/C Mainline Linux-5.10, U-Boot-2020-10

_images/rock-pi-4-post.png

Amarula Solutions has partnered with Radxa Limited and started a project to push ROCK Pi Boards onto Mainline U-Boot, Linux Kernel, Yocto/Buildroot and Multimedia Open source projects.

The first success was that we mainlined full functional ROCK PI 4 boards.

Along with Mainlining, we are also providing Ubuntu 20.04 (Focal Fossa) Distribution running flawlessly on their SBC’s.

_images/rock-pi-4-dual-display.jpg

Supported features:

ROCKPi 4A/B/C
Mainline Linux 5.10.0-rc1
Mainline U-Boot v2020-10
TPL/SPL bootflow
EFI booting
eMMC boot tested via fastboot, ums
Ethernet
USB Host 2.0/3.0
USB OTG 2.0/3.0
Wifi/BT
HDMI
DisplayPort (Mailing-list)
PCIe, M.2
Audio Out (WIP)
Buildroot
Ubuntu Focal 20.04

Wiki:

https://wiki.amarulasolutions.com/bsp/rockchip/rk3399/rockpi-4.html

Engicam PX30.Core Mainline Linux-5.10, U-Boot-2020-10

_images/eng-px30-post.jpg

Amarula Solutions has partnered with Engicam Srl and started a project to push Engicam SOM’s and Carrier board’s BSP onto Mainline U-Boot, Linux Kernel, Yocto/Buildroot and Multimedia Open source projects.

The first success was that we mainlined PX30-Core, which is a Rockchip PX30 based SOM along with two of its carrier boards namely EDIMM 2.2 and CTouch 2.0.

Along with Mainlining, we are also providing Ubuntu 20.04 (Focal Fossa) Distribution running flawlessly on their Carrier Boards.

_images/eng-px30.jpg

Supported features:

PX30.Core SOM
EDIMM2.2 Starter kit
C.TOUCH 2.0 with 10" Open Frame board
Mainline Linux 5.10.0-rc1
Mainline U-Boot v2020-10
TPL/SPL bootflow
EFI booting
eMMC boot tested via fastboot, ums
Ethernet
USB Host/OTG
Wifi/BT
LVDS
Buildroot
Ubuntu Focal 20.04

Wiki:

https://wiki.amarulasolutions.com/bsp/rockchip/px30/index.html

Embedded Linux Developer (BSP, U-Boot, Kernel)

Job Type:

Up to 3Years
Full Time

Post Date:

03 July, 2020

About the Amarual Solutions(India):

Amarula Solutions India is a start-up with its Main branch located
in Amsterdam, The Netherlands. The company has been co-founded by
Mr. Jagan Teki, who is the current CEO, a well known personality
in the open source community and Maintainer of code bases in Linux
Kernel, U-Boot, Buildroot and Yocto.

Amarula Solutions India has started operations in the year 2019.
Office premises are located at Defence colony, Chandanagar, a residential
area in Hyderabad, Telangana. It is roughly 6Kms from Miyapur Metro
Station and 2Kms from Chandanagar bus stop.

Responsibilities:

Implementation of Board support packages, drivers.
Mainline U-Boot, Linux kernel, Buildroot and Yocto.
Implementation of Build Systems, Package Management.
Active community proactiveness like mailing lists, IRC Channels.
Active customer proactiveness like status updates, bugs.

Requirements:

Good understanding in hardware schematics.
Good understanding in Scripting languages.
Good knowledge of Git.
Excellent C knowledge.
Experience in U-Boot, Linux kernel.
Experience in ARM/x86 SoC’s.
Able to communicate over Mailing list, IRC channels.
Ability to learn and adapt quickly.
Self-motivation to deliver according to a schedule.

Please contact us if you would like to be part of Amarula, jagan@amarulasolutions.com

Embedded Linux Intern (BSP, Buildroot/Yocto)

Job Type:

Intern
6 to 12 months

Post Date:

03 July, 2020

About the Amarual Solutions(India):

Amarula Solutions India is a start-up with its Main branch located
in Amsterdam, The Netherlands. The company has been co-founded by
Mr. Jagan Teki, who is the current CEO, a well known personality
in the open source community and Maintainer of code bases in Linux
Kernel, U-Boot, Buildroot and Yocto.

Amarula Solutions India has started operations in the year 2019.
Office premises are located at Defence colony, Chandanagar, a residential
area in Hyderabad, Telangana. It is roughly 6Kms from Miyapur Metro
Station and 2Kms from Chandanagar bus stop.

Responsibilities:

Implementation of Board support packages, drivers.
Implementation of Build Systems, Package Management.
Working with Buildroot, Yocto, SWUpdate.
Integration of Graphics, Video packaging on to build systems tools.

Requirements:

Good knowledgw of C.
Good knowledgw of Scripting languages.
Knowledge of Git.
Knowledge of U-Boot, Linux kernel.
Knowledge of ARM/x86 SoC’s.
Able to communicate over Mailing list, IRC channels.
Ability to learn and adapt quickly.
Self-motivation to deliver according to a schedule.

Note: The responsibilities would change once you prompted to full time employment.

Please contact us if you would like to be part of Amarula, jagan@amarulasolutions.com

Open Source Projects

U-Boot

U-Boot

Measurement

Tool Procedure Normal mode Falcon mode Vyasa-RK3288 Timings i.CoreM6 RQS Duallite/Solo Normal Mode mmc Falcon Mode emmc Falcon Mode Is.IoT eMMC mmc Normal Tool Grabserial - Get log and timestamp console output

bash> git clone https://github.com/tbird20d/grabserialbash> sudo grabserial/grabserial /usr/local bin
bash> grabserial

Procedure Normal mode

bash> grabserial -v -d /dev/ttyUSB0 -b 115200 -w 8 -p N -s 1 -e 30 -t -m "Starting kernel.*"
Opening serial port /dev/ttyUSB0115200:8N1:xonxoff=0:rtscts=0
Program will end in 30 seconds
Printing timing information for each line
Matching pattern 'Starting kernel.*' to set base time
Use Control-C to stop...
[0.000002 0.000002]
[0.001344 0.001342] U-Boot TPL 2017.09-rc2-13373-g2cffd0d-dirty (Aug 31 2017 - 20:41:14)
[0.005975 0.004631] Trying to boot from BOOTROM
[0.008394 0.002419] Returning to boot ROM...
[0.216735 0.208341]
[0.217195 0.000460] U-Boot SPL 2017.09-rc2-13373-g2cffd0d-dirty (Aug 31 2017 - 20:41:14)
[0.223097 0.005902] Trying to boot from MMC1[0.262093 0.038996] Expected Linux image is not found. Trying to start U-boot
[0.436129 0.174036]
[0.436416 0.000287]
[0.436696 0.000280] U-Boot 2017.09-rc2-13373-g2cffd0d-dirty (Aug 31 2017 - 20:41:14 +0530)
[0.442273 0.005577][0.442369 0.000096] Model: Amarula Vyasa-RK3288
[0.444854 0.002485] DRAM:  2 GiB
[0.479422 0.034568] MMC:   dwmmc@ff0c0000: 1
[0.627295 0.147873] *** Warning - bad CRC, using default environment
[0.631527 0.004232]
[0.635980 0.004453] In:    serial@ff690000
[0.637982 0.002002] Out:   serial@ff690000
[0.640004 0.002022] Err:   serial@ff690000
[0.642244 0.002240] Model: Amarula Vyasa-RK3288
[0.644783 0.002539] Net:   Net Initialization Skipped
[0.647824 0.003041] No ethernet found.
[0.651954 0.004130] Hit any key to stop autoboot:  0
[0.772503 0.120549] switch to partitions #0, OK
[0.774802 0.002299] mmc1 is current device
[1.069762 0.294960] Scanning mmc 1:1...
[1.312386 0.242624] Found /boot/extlinux/extlinux.conf
[1.315209 0.002823] Retrieving file: /boot/extlinux/extlinux.conf
[1.353460 0.038251] 145 bytes read in 28 ms (4.9 KiB/s)
[1.356412 0.002952] 1:    Vyasa Linux-4.13
[1.358237 0.001825] Retrieving file: /boot/uImage
[1.740753 0.382516] 7836344 bytes read in 375 ms (19.9 MiB/s)
[1.744302 0.003549] append: console=ttyS2,115200n8 root=/dev/mmcblk0p1 rootwait quiet
[1.750086 0.005784] Retrieving file: /boot/rk3288-vyasa.dtb
[1.786952 0.036866] 36291 bytes read in 28 ms (1.2 MiB/s)
[1.789950 0.002998] ## Booting kernel from Legacy Image at 02000000 ...
[1.794524 0.004574]    Image Name:   Linux-4.13.0-rc4-next-20170810-0
[1.799040 0.004516]    Image Type:   ARM Linux Kernel Image (uncompressed)
[1.803818 0.004778]    Data Size:    7836280 Bytes = 7.5 MiB
[1.807426 0.003608]    Load Address: 02000000
[1.809776 0.002350]    Entry Point:  02000000
[1.812097 0.002321]    Verifying Checksum ... OK
[1.945372 0.133275] ## Flattened Device Tree blob at 01f00000
[1.948106 0.002734]    Booting using the fdt blob at 0x1f00000
[1.951715 0.003609]    Loading Kernel Image ... OK
[1.968363 0.016648]    Loading Device Tree to 0fff4000, end 0ffffdc2 ... OK
[1.974709 0.006346]
[1.974911 0.000202] Starting kernel ...
[0.002243 0.002243]
[1.273396 1.271153] [    0.090111] dmi: Firmware registration failed.
[1.617881 0.344485] [    0.581926] EXT4-fs (mmcblk0p1): couldn't mount as ext3 due to feature incompatibilities
[1.627592 0.009711] [    0.592177] EXT4-fs (mmcblk0p1): couldn't mount as ext2 due to feature incompatibilities
[4.596400 2.968808] Starting logging: OK
[4.610216 0.013816] Initializing random number generator... done.
[4.622379 0.012163] Starting network: OK
[4.746329 0.123950]
[4.748163 0.001834] Welcome to VYASA RK3288!
[4.750725 0.002562] vyasa-rk3288 login:

Falcon mode

bash> grabserial -v -d /dev/ttyUSB0 -b 115200 -w 8 -p N -s 1 -e 30 -t -m "Starting kernel.*"
Opening serial port /dev/ttyUSB0115200:8N1:xonxoff=0:rtscts=0
Program will end in 30 seconds
Printing timing information for each line
Matching pattern 'Starting kernel.*' to set base time
Use Control-C to stop...
[0.000001 0.000001]
[0.001135 0.001134] U-Boot TPL 2017.09-rc2-13373-g2cffd0d-dirty (Aug 31 2017 - 20:41:14)
[0.005690 0.004555] Trying to boot from BOOTROM
[0.008221 0.002531] Returning to boot ROM...
[0.196488 0.188267]
[0.196704 0.000216] U-Boot SPL 2017.09-rc2-13373-g2cffd0d-dirty (Aug 31 2017 - 20:41:14)
[0.202759 0.006055] Trying to boot from MMC1
[1.879613 1.676854] [    0.090151] dmi: Firmware registration failed.
[2.287880 0.408267] [    0.645755] EXT4-fs (mmcblk0p1): couldn't mount as ext3 due to feature incompatibilities
[2.301935 0.014055] [    0.660209] EXT4-fs (mmcblk0p1): couldn't mount as ext2 due to feature incompatibilities
[2.425052 0.123117] Starting logging: OK
[2.440868 0.015816] Initializing random number generator... done.
[2.452302 0.011434] Starting network: OK
[2.580451 0.128149]
[2.584354 0.003903] Welcome to VYASA RK3288!
[2.586697 0.002343] vyasa-rk3288 login:

Vyasa-RK3288 Timings

Mode of Boot Bootloader (sec) Linux (sec) Total Boot time (sec) Remarks
Normal Boot 1.974909 2.775814 4.753287  
Falcon Boot 0.208814 2.380226 2.58904 ~54.56% reduction in boot time compared to Normal mode boot

i.CoreM6 RQS Duallite/Solo

Mode of Boot Total Boot Time (sec) Remarks
Normal Boot 3.582790  
mmc Falcon Boot 4.436016  
emmc Falcon Boot 3.358925  

Normal Mode

bash> grabserial -v -d /dev/ttyUSB0 -b 115200 -w 8 -p N -s 1 -e 30 -t
Opening serial port /dev/ttyUSB0
115200:8N1:xonxoff=0:rtscts=0
Program will end in 30 seconds
Printing timing information for each line
Use Control-C to stop...
[0.000001 0.000001]
[0.463108 0.463107] U-Boot SPL 2018.03-rc3-00088-gd231182441d2-dirty (Mar 09 2018 - 15:33:18 +0530)
[0.494895 0.031787] Trying to boot from MMC1
[0.648928 0.154033] Expected Linux image is not found. Trying to start U-boot
[0.809112 0.160184]
[0.809201 0.000089]
[0.809261 0.000060] U-Boot 2018.03-rc3-00088-gd231182441d2-dirty (Mar 09 2018 - 15:33:18 +0530)
[0.814423 0.005162]
[0.814462 0.000039] CPU:   Freescale i.MX6DL rev1.3 at 792 MHz
[0.815548 0.001086] Reset cause: POR
[0.820317 0.004769] Model: Engicam i.CoreM6 DualLite/Solo RQS Starter Kit
[0.822997 0.002680] DRAM:  512 MiB
[0.872900 0.049903] MMC:   FSL_SDHC: 1, FSL_SDHC: 2
[0.902445 0.029545] Loading Environment from MMC... OK
[1.002036 0.099591] In:    serial
[1.002604 0.000568] Out:   serial
[1.003187 0.000583] Err:   serial
[1.088991 0.085804] switch to partitions #0, OK
[1.089517 0.000526] mmc1 is current device
[1.089980 0.000463] Net:   No ethernet found.
[1.097563 0.007583] Hit any key to stop autoboot:  0
[1.098690 0.001127] Booting from mmc ...
[1.196918 0.098228] ** Unable to read file boot.scr **
[1.209813 0.012895] ** Unable to read file fit.itb **
[1.547007 0.337194] 6560488 bytes read in 329 ms (19 MiB/s)
[1.573893 0.026886] 36829 bytes read in 16 ms (2.2 MiB/s)
[1.574753 0.000860] ## Booting kernel from Legacy Image at 12000000 ...
[1.579472 0.004719]    Image Name:   Linux-4.16.0-rc1-next-20180215-0
[1.585049 0.005577]    Image Type:   ARM Linux Kernel Image (uncompressed)
[1.589958 0.004909]    Data Size:    6560424 Bytes = 6.3 MiB
[1.590683 0.000725]    Load Address: 10008000
[1.593919 0.003236]    Entry Point:  10008000
[1.594299 0.000380]    Verifying Checksum ... OK
[1.673030 0.078731] ## Flattened Device Tree blob at 18000000
[1.673681 0.000651]    Booting using the fdt blob at 0x18000000
[1.678218 0.004537]    Loading Kernel Image ... OK
[1.715904 0.037686]    Using Device Tree in place at 18000000, end 1800bfdc
[1.716830 0.000926]
[1.716849 0.000019] Starting kernel ...
[1.719020 0.002171]
[2.471013 0.751993] [    0.332029] fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
[2.481794 0.010781] [    0.343118] mdio_bus 2188000.ethernet-1: MDIO device at address 0 is missing.
[2.962948 0.481154] [    0.824062] EXT4-fs (mmcblk1p2): couldn't mount as ext3 due to feature incompatibilities
[3.271957 0.309009] Starting logging: OK
[3.324930 0.052973] Initializing random number generator... done.
[3.367783 0.042853] Starting network: OK
[3.561869 0.194086]
[3.579876 0.018007] Welcome to Engicam i.CoreM6 Quad/Dual/DualLite/Solo RQS Starter Kit
[3.582790 0.002914] buildroot login:

mmc Falcon Mode

$ grabserial -v -d /dev/ttyUSB0 -b 115200 -w 8 -p N -s 1 -e 30 -t
Opening serial port /dev/ttyUSB0
115200:8N1:xonxoff=0:rtscts=0
Program will end in 30 seconds
Printing timing information for each line
Use Control-C to stop...
[0.000000 0.000000]
[0.000057 0.000057] U-Boot SPL 2018.03-rc3-00088-gd231182441d2-dirty (Mar 09 2018 - 11:37:43 +0530)
[0.031834 0.031777] Trying to boot from MMC1
[3.384035 3.352201] [    0.328707] fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
[3.391705 0.007670] [    0.339778] mdio_bus 2188000.ethernet-1: MDIO device at address 0 is missing.
[4.127913 0.736208] Starting logging: OK
[4.185913 0.058000] Initializing random number generator... done.
[4.223928 0.038015] Starting network: OK
[4.415099 0.191171]
[4.432932 0.017833] Welcome to Engicam i.CoreM6 Quad/Dual/DualLite/Solo RQS Starter Kit
[4.436016 0.003084] buildroot login:

emmc Falcon Mode

bash> grabserial -v -d /dev/ttyUSB0 -b 115200 -w 8 -p N -s 1 -e 30 -t
Opening serial port /dev/ttyUSB0
115200:8N1:xonxoff=0:rtscts=0
Program will end in 30 seconds
Printing timing information for each line
Use Control-C to stop...
[0.000001 0.000001]
[0.655035 0.655034] U-Boot SPL 2018.03-rc3-00088-gd231182441d2-dirty (Mar 09 2018 - 15:33:18 +0530)
[0.686997 0.031962] Trying to boot from MMC2
[1.870018 1.183021] [ 0.326646] fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
[1.878300 0.008282] [ 0.337702] mdio_bus 2188000.ethernet-1: MDIO device at address 0 is missing.
[3.088918 1.210618] Starting logging: OK
[3.142994 0.054076] [ 1.599852] EXT2-fs (mmcblk2p1): error: ext2_lookup: deleted inode referenced: 95087
[3.150190 0.007196] read-only file system detected...done
[3.163792 0.013602] Starting network: OK
[3.346881 0.183089]
[3.355940 0.009059] Welcome to Engicam i.CoreM6 Quad/Dual/DualLite/Solo RQS Starter Kit
[3.358925 0.002985] buildroot login:

Is.IoT eMMC mmc Normal 3.714112

mmc Falcon

emmc Falcon

Nand mmc Normal

$ sudo grabserial -v -d /dev/ttyUSB0 -b 115200 -w 8 -p N -s 1 -e 30 -t
Opening serial port /dev/ttyUSB0
115200:8N1:xonxoff=0:rtscts=0
Program will end in 30 seconds
Printing timing information for each line
Use Control-C to stop...
[0.000000 0.000000] - 19:13:25 +0530)
[0.013855 0.013855] Trying to boot from MMC1
[0.220067 0.206212]
[0.220117 0.000050]
[0.220146 0.000029] U-Boot 2018.03-rc3-00088-gd231182441d2-dirty (Mar 13 2018 - 19:13:25 +0530)
[0.226245 0.006099]
[0.226272 0.000027] CPU: Freescale i.MX6UL rev1.1 528 MHz (running at 396 MHz)
[0.232175 0.005903] CPU: Industrial temperature grade (-40C to 105C) at 41C
[0.258167 0.025992] Reset cause: POR
[0.258616 0.000449] Model: Engicam Is.IoT MX6UL eMMC Starterkit
[0.261050 0.002434] DRAM: 128 MiB
[0.301016 0.039966] MMC: FSL_SDHC: 0, FSL_SDHC: 1
[0.337436 0.036420] Loading Environment from MMC... *** Warning - bad CRC, using default environment
[0.455263 0.117827]
[0.466979 0.011716] Failed (-5)
[0.467455 0.000476] In: serial
[0.467939 0.000484] Out: serial
[0.468417 0.000478] Err: serial
[0.538150 0.069733] switch to partitions #0, OK
[0.539125 0.000975] mmc0 is current device
[0.539859 0.000734] Net: No ethernet found.
[0.551962 0.012103] Hit any key to stop autoboot: 0
[0.553081 0.001119] Booting from mmc ...
[0.628995 0.075914] ** Unable to read file boot.scr **
[0.642894 0.013899] ** Unable to read file fit.itb **
[0.988019 0.345125] 6875712 bytes read in 337 ms (19.5 MiB/s)
[1.014014 0.025995] 20839 bytes read in 16 ms (1.2 MiB/s)
[1.014736 0.000722] ## Booting kernel from Legacy Image at 82000000 ...
[1.019656 0.004920] Image Name: Linux-4.11.5
[1.020205 0.000549] Image Type: ARM Linux Kernel Image (uncompressed)
[1.025803 0.005598] Data Size: 6875648 Bytes = 6.6 MiB
[1.030385 0.004582] Load Address: 80008000
[1.030872 0.000487] Entry Point: 80008000
[1.035195 0.004323] Verifying Checksum ... OK
[1.200143 0.164948] ## Flattened Device Tree blob at 87800000
[1.200792 0.000649] Booting using the fdt blob at 0x87800000
[1.205454 0.004662] Loading Kernel Image ... OK
[1.224963 0.019509] Using Device Tree in place at 87800000, end 87808166
[1.226014 0.001051]
[1.226036 0.000022] Starting kernel ...
[1.228339 0.002303]
[2.077080 0.848741] [ 0.008752] /cpus/cpu@0 missing clock-frequency property
[2.517077 0.439997] [ 0.897731] cpu cpu0: dev_pm_opp_get_opp_count: OPP table not found (-19)
[2.673071 0.155994] [ 1.053370] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[3.188012 0.514941] Starting logging: OK
[3.306131 0.118119] Initializing random number generator... done.
[3.437959 0.131828] Starting network: OK
[3.692050 0.254091]
[3.709005 0.016955] Welcome to Engicam Is.IoT eMMC Starter Kit
[3.714112 0.005107] buildroot login:

Falcon Mode

Falcon Mode is introduced to speed up the booting process, allowing to boot a Linux kernel (or whatever image) without a full blown U-Boot. See doc/README.falcon for more details.

Engicam i.MX6Q
Partitions
Start KB (blocks) Size KB (Blocks) Usage
0 1KB (2) Partition Table etc
1KB (0x2) 68KB (0x88) SPL
1MB (0x800) 1MB (0x800) args/dtb
2MB (0x1000) 8M (0x4000) kernel
10M (0x5000) partitions rootfs
69KB (0x8a) 640KB (0x500) U-Boot
709KB (0x58a) 256KB (0x512) env (redundant)
965KB 59KB unused

Built the images from Image Build

Configure SD

Create Falcon partition and Insert the SD on host

$ cd /path/to/
$ dd if=SPL of=/dev/mmcblk0 bs=1k seek=1
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
$ git clone https://github.com/openedev/rootfs-imx6q
$ cp -rf rootfs-imx6q/* /media/jagan/rootfs
$ cp /path/to/linux-next/arch/arm/boot/uImage /media/jagan/rootfs
$ cp arch/arm/boot/dts/imx6q-icore.dtb /media/jagan/rootfs
$ sync && sudo umount /dev/mmcblk0*
Configure Falcon

Insert the SD and power-on the board.

# load kernel from rootfs
icorem6qdl> ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
6449304 bytes read in 376 ms (16.4 MiB/s)

# write kernel at 2MB offset
icorem6qdl> mmc write ${loadaddr} 0x1000 0x4000

MMC write: dev # 0, block # 4096, count 16384 ... 16384 blocks written: OK

# setup kernel bootargs
icorem6qdl> setenv bootargs 'console=ttymxc3,115200 root=/dev/mmcblk0p1 rootfstype=ext4 rootwait rw'

# load device-tree from rootfs
icorem6qdl> ext4load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
37081 bytes read in 43 ms (841.8 KiB/s)

# prepare args
icorem6qdl> spl export fdt ${loadaddr} - ${fdt_addr}
## Booting kernel from Legacy Image at 12000000 ...
   Image Name:   Linux-4.14.0-rc2-next-20170929
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    6449240 Bytes = 6.2 MiB
   Load Address: 10008000
   Entry Point:  10008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Using Device Tree in place at 18000000, end 1800c0d8
subcommand not supported
subcommand not supported
   Using Device Tree in place at 18000000, end 1800f0d8
Argument image is now in RAM: 0x18000000

# write args 1MB data (0x800 sectors) to 1MB offset (0x800 sectors)
icorem6qdl> mmc write 18000000 0x800 0x800

MMC write: dev # 0, block # 2048, count 2048 ... 2048 blocks written: OK
Boot Linux using Falcon

Reset the board and see Linux booting, Pressing ‘C’ will prevent Linux boot and moved to U-Boot.

U-Boot SPL 2017.11-00056-g3751590 (Nov 20 2017 - 23:14:20)
Trying to boot from MMC1
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.0-rc2-next-20170929 (root@jagan-XPS-13-9350) (gcc version 6.4.0 (Buildroot 2017.11-git-00570-ged6f079)) #1 SMP Tue Oct 3 15:15:58 IST 2017
[    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Engicam i.CoreM6 Quad/Dual Starter Kit
RK3288 Vyasa
Partition Table
Start KB (blocks) Size KB (Blocks) Usage
0 4K Partition Table etc
4K 32KB TPL
32K 100K SPL
8M 1024K - 256K 1MB U-Boot env (redundant)
16MB 1MB (0x800) args
17MB 8MB (0x4000) kernel
30MB partitions rootfs
Build
bash> git clone git://git.denx.de/u-boot.git
bash> cd u-boot
bash> make vyasa-rk3288_defconfig
bash> make -j 4
Create SD

Create Falcon partition and Insert the SD on host and Built the images from Image Build

$ cd /path/to/u-boot
$./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out
$ dd if=out of=/dev/mmcblk0 seek=64
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=16384
$ git clone https://github.com/openedev/rfs-rk3288
$ cd /path/to/rfs-rk3288
$ cp -rf * /path/to/rfs-rk3288
$ mkdir /path/to/rfs-rk3288/boot
$ cd /path/to/linux-next
$ cp arch/arm/boot/uImage /path/to/rfs-rk3288
$ cp arch/arm/boot/dts/rk3288-vyasa.dtb /path/to/rfs-rk3288
$ sync && sudo umount /media/rfs-rk3288
Configure Falcon

Now insert the SD and configure the falcon and restart

U-Boot TPL 2017.11-rc4-00029-gb142d38-dirty (Nov 10 2017 - 17:04:00)

Trying to boot from BOOTROM

Returning to boot ROM...


U-Boot SPL 2017.11-rc4-00029-gb142d38-dirty (Nov 10 2017 - 17:04:00)

Trying to boot from MMC1

Expected Linux image is not found. Trying to start U-boot



U-Boot 2017.11-rc4-00029-gb142d38-dirty (Nov 10 2017 - 17:04:00 +0530)


Model: Amarula Vyasa-RK3288

DRAM:  2 GiB

MMC:   dwmmc@ff0c0000: 1

*** Warning - bad CRC, using default environment


In:    serial@ff690000

Out:   serial@ff690000

Err:   serial@ff690000

Model: Amarula Vyasa-RK3288

Net:   Net Initialization Skipped

No ethernet found.

Hit any key to stop autoboot:  0

=> mmc dev 1

switch to partitions #0, OK

mmc1 is current device

=> ext4load mmc 1:1 $kernel_addr_r /boot/uImage

8143432 bytes read in 378 ms (20.5 MiB/s)

=> mmc write $kernel_addr_r 0x8800 0x4000

MMC write: dev # 1, block # 34816, count 16384 ... 16384 blocks written: OK

=> ext4load mmc 1:1 $fdt_addr_r /boot/rk3288-vyasa.dtb

37307 bytes read in 23 ms (1.5 MiB/s)

=> setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p1 rootwait'

=> spl export fdt $kernel_addr_r - $fdt_addr_r

## Booting kernel from Legacy Image at 02000000 ...

   Image Name:   Linux-4.14.0-rc4-next-20171013-0

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    8143368 Bytes = 7.8 MiB

   Load Address: 02000000

   Entry Point:  02000000

   Verifying Checksum ... OK

## Flattened Device Tree blob at 01f00000

   Booting using the fdt blob at 0x1f00000

   Loading Kernel Image ... OK

   Loading Device Tree to 0fff3000, end 0ffff1ba ... OK

subcommand not supported

subcommand not supported

   Loading Device Tree to 0ffe3000, end 0fff21ba ... OK

Argument image is now in RAM: 0x0ffe3000

=> mmc write 0x0ffe3000 0x8000 0x800


MMC write: dev # 1, block # 32768, count 2048 ... 2048 blocks written: OK
Falcon mode

Reset or Power on board with SD, Ctr+C will boot U-Boot and/or Linux boot normally

U-Boot TPL 2017.11-rc4-00029-gb142d38-dirty (Nov 10 2017 - 17:11:25)

Trying to boot from BOOTROM

Returning to boot ROM...


U-Boot SPL 2017.11-rc4-00029-gb142d38-dirty (Nov 10 2017 - 17:11:25)

Trying to boot from MMC1

[    0.000000] Booting Linux on physical CPU 0x500
[    0.000000] Linux version 4.14.0-rc4-next-20171013-00012-gd26a4df (root@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #2 SMP Mon Oct 23 01:00:23 7
[    0.000000] CPU: ARMv7 Processor [410fc0d1] revision 1 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Amarula Vyasa-RK3288

Image Boot

Boot Linux on Engicam i.MX6

This tutorial describe possible ways of booting Image like Linux and detailed documents are 1 2

Build the images here, and setup SD card with Single and Dual partitions here

bootm
Ramdisk

Create Single partition and Insert the SD on host and Built the images from Image Build

$ cd /path/to/u-boot
$ dd if=SPL of=/dev/mmcblk0 bs=1k seek=1
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
$ cd /path/to/linux-next
$ cp arch/arm/boot/uImage /media/jagan/rootfs
$ cp arch/arm/boot/dts/imx6q-icore.dtb /media/jagan/rootfs
$ cp uarm_ramdisk.image.gz /media/jagan/rootfs
$ sync
$ umount /dev/mmcblk0p1

JM3 Closed

Connect the Serial cable between the Starter Kit and the PC for the console (J28 is the Linux Serial console connector)

Insert the micro SD card in the board, power it up.

U-Boot SPL 2017.09-00371-gcf42f39-dirty (Oct 05 2017 - 14:28:57)

Trying to boot from MMC1

Expected Linux image is not found. Trying to start U-boot


U-Boot 2017.09-00371-gcf42f39-dirty (Oct 05 2017 - 14:28:57 +0530)


CPU:   Freescale i.MX6Q rev1.2 at 792MHz

CPU:   Industrial temperature grade (-40C to 105C) at 31C

Reset cause: POR

Model: Engicam i.CoreM6 Quad/Dual Starter Kit

DRAM:  512 MiB

MMC:   FSL_SDHC: 0

*** Warning - bad CRC, using default environment


No panel detected: default to Amp-WD

Display: Amp-WD (800x480)

In:    serial

Out:   serial

Err:   serial

switch to partitions #0, OK

mmc0 is current device

Net:

Error: ethernet@02188000 address not set.

No ethernet found.

Hit any key to stop autoboot:  0

icorem6qdl>

icorem6qdl> ext4load mmc 0:1 ${loadaddr} uImage

7085712 bytes read in 372 ms (18.2 MiB/s)

icorem6qdl> ext4load mmc 0:1 0x83000000 uarm_ramdisk.image.gz

691373 bytes read in 89 ms (7.4 MiB/s)

icorem6qdl> ext4load mmc 0:1 ${fdt_addr} imx6q-icore.dtb

37085 bytes read in 45 ms (804.7 KiB/s)

icorem6qdl> printenv mmcargs

mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}

icorem6qdl> printenv mmcroot

mmcroot=/dev/mmcblk0p2 rootwait rw

icorem6qdl> setenv mmcroot '/dev/ram rw earlycon'

icorem6qdl> run mmcargs

icorem6qdl> printenv bootargs

bootargs=console=ttymxc3,115200 root=/dev/ram rw earlycon

icorem6qdl> bootm ${loadaddr} 0x83000000 ${fdt_addr}

## Booting kernel from Legacy Image at 12000000 ...

   Image Name:   Linux-4.14.0-rc2-next-20170929-0

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    7085648 Bytes = 6.8 MiB

   Load Address: 10008000

   Entry Point:  10008000

   Verifying Checksum ... OK

## Loading init Ramdisk from Legacy Image at 13000000 ...

   Image Name:

   Image Type:   ARM Linux RAMDisk Image (gzip compressed)

   Data Size:    691309 Bytes = 675.1 KiB

   Load Address: 00000000

   Entry Point:  00000000

   Verifying Checksum ... OK

## Flattened Device Tree blob at 18000000

   Booting using the fdt blob at 0x18000000

   Loading Kernel Image ... OK

   Loading Ramdisk to 2eed2000, end 2ef7ac6d ... CACHE: Misaligned operation at range [2eed2000, 2ef7ac6d]

OK

   Using Device Tree in place at 18000000, end 1800c0dc


Starting kernel ...
Rootfs
Monolithic
FIT
vmlinux.bin
$ arm-linux-gnueabi-objcopy -O binary /to/path/linux-next-imx/vmlinux vmlinux.bin

$ gzip vmlinux.bin
FIT Input

FIT input for Linux and FDT, here and Linux, FDT and Ramdisk, here

/dts-v1/;

/ {

    description = "FIT image with single Linux kernel and FDT blob";

    #address-cells = <1>;


    images {

        kernel@1 {

            description = "i.MX6Q Linux kernel";

            data = /incbin/("./vmlinux.bin.gz");

            type = "kernel";

            arch = "arm";

            os = "linux";

            compression = "gzip";

            load = <0x10008000>;

            entry = <0x10008000>;

            hash@1 {

                algo = "md5";

            };

            hash@2 {

                algo = "sha1";

            };

        };


        fdt@1 {

            description = "i.CoreM6 Quad/Dual Devicetree blob";

            data = /incbin/("./imx6q-icore.dtb");

            type = "flat_dt";

            arch = "arm";

            compression = "none";

            hash@1 {

                algo = "md5";

            };

            hash@2 {

                algo = "sha1";

            };

        };

    };

    configurations {

        default = "conf@1";

        conf@1 {

            description = "Boot Linux kernel and FDT blob";

            kernel = "kernel@1";

            fdt = "fdt@1";

        };

    };

};
FIT Output
$ /to/path/u-boot/tools/mkimage -f kernel_fdt.its fit.itb
$ cp fit.itb /media/jagan/BOOT
FIT Boot
Hit any key to stop autoboot:  0

Booting from mmc ...

reading boot.scr

** Unable to read file boot.scr **

reading fit.itb

6485068 bytes read in 335 ms (18.5 MiB/s)

Booting FIT image from mmc ...

## Loading kernel from FIT Image at 12000000 ...

   Using 'conf@1' configuration

   Verifying Hash Integrity ... OK

   Trying 'kernel@1' kernel subimage

     Description:  i.MX6Q Linux kernel

     Type:         Kernel Image

     Compression:  gzip compressed

     Data Start:   0x120000e4

     Data Size:    6446108 Bytes = 6.1 MiB

     Architecture: ARM

     OS:           Linux

     Load Address: 0x10008000

     Entry Point:  0x10008000

     Hash algo:    md5

     Hash value:   1580c77b97e137d81d4ad804fba3065c

     Hash algo:    sha1

     Hash value:   e699babcc853bf0be519eedbba173e5795a8941b

   Verifying Hash Integrity ... md5+ sha1+ OK

## Loading fdt from FIT Image at 12000000 ...

   Using 'conf@1' configuration

   Trying 'fdt@1' fdt subimage

     Description:  i.CoreM6 Quad/Dual Devicetree blob

     Type:         Flat Device Tree

     Compression:  uncompressed

     Data Start:   0x12625e38

     Data Size:    37081 Bytes = 36.2 KiB

     Architecture: ARM

     Hash algo:    md5

     Hash value:   7e01cb60cef8d98d018aaf0d4455b970

     Hash algo:    sha1

     Hash value:   4ecef92ce375160d11ee7363aebc8058c1e02878

   Verifying Hash Integrity ... md5+ sha1+ OK

   Booting using the fdt blob at 0x12625e38

   Uncompressing Kernel Image ... OK

   Using Device Tree in place at 12625e38, end 12631f10


Starting kernel ...
Verified Boot
vmlinux.bin
$ arm-linux-gnueabi-objcopy -O binary vmlinux vmlinux.bin

$ gzip vmlinux.bin

$ cp imx6q-icore-rqs.dtb imx6q-icore-rqs-pubkey.dtb
FIT input
kernel_fdt.its

/* Simple U-Boot uImage source file containing a single kernel and FDT blob */

/dts-v1/;

/ {

    description = "Verified RSA image with single Linux kernel and FDT blob";

    #address-cells = <1>;

    images {

        kernel@1 {

            description = "i.MX6 Linux kernel";

            data = /incbin/("./vmlinux.bin.gz");

            type = "kernel";

            arch = "arm";

            os = "linux";

            compression = "gzip";

            load = <0x10008000>;

            entry = <0x10008000>;

            hash@1 {

                algo = "md5";

            };

            hash@2 {

                algo = "sha1";

            };

            signature@1 {

                algo = "sha1,rsa2048";

                key-name-hint = "eng";

            };

        };

        fdt@1 {

            description = "Engicam i.CoreM6 Quad/Dual RQS Starter Kit Devicetree blob";

            data = /incbin/("./imx6q-icore-rqs.dtb");

            type = "flat_dt";

            arch = "arm";

            compression = "none";

            hash@1 {

                algo = "md5";

            };

            hash@2 {

                algo = "sha1";

            };

            signature@1 {

                algo = "sha1,rsa2048";

                key-name-hint = "eng";

            };

        };

    };

    configurations {

        default = "conf@1";

        conf@1 {

            description = "Boot Linux kernel with FDT blob";

            kernel = "kernel@1";

            fdt = "fdt@1";

        };

    };

};
RSA key
- Create RSA key pair
$ mkdir mykeys
$ openssl genrsa -F4 -out mykeys/eng.key 2048

- Create a certificate contains public key

$ openssl req  -batch -new -x509 -key mykeys/eng.key -out mykeys/eng.crt
FIT output
$ ./mkimage -f kernel_fdt.its -K imx6q-icore-rqs-pubkey.dtb -k mykeys/ -r fit.itb
Build U-Boot Public key
$ .make DEV_TREE_BIN=../imx6q-icore-rqs-pubkey.dtb
VerifiedBoot
U-Boot SPL 2017.01-rc2-00010-gb42d823 (Dec 21 2016 - 11:13:46)
Trying to boot from MMC1

U-Boot 2017.01-rc2-00010-gb42d823 (Dec 21 2016 - 11:13:46 +0100)

CPU:   Freescale i.MX6D rev1.2 at 792 MHz
Reset cause: POR
Model: Engicam i.CoreM6 Quad/Dual RQS Starter Kit
DRAM:  512 MiB
MMC:   FSL_SDHC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
reading boot.scr
** Unable to read file boot.scr **
reading fit.itb
6167494 bytes read in 335 ms (17.6 MiB/s)
Booting FIT image from mmc ...
## Loading kernel from FIT Image at 12000000 ...
   Using 'conf@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@1' kernel subimage
     Description:  i.MX6 Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x120000f0
     Data Size:    6130148 Bytes = 5.8 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x10008000
     Entry Point:  0x10008000
     Hash algo:    md5
     Hash value:   b975a202ea2963c53c53f527329930cd
     Hash algo:    sha1
     Hash value:   78b93fe404b795de8c837af27d67f4df9b96083a
     Sign algo:    sha1,rsa2048:eng
     Sign value:   4288ce2c7380a90b7b7b9c000760f086fe67560d16fb5ea85bc792ff3ed70e381956bbff99c514213e00e3d21838650ada0eb68439e253ef493e3e0098e0d47109d3e
   Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
## Loading fdt from FIT Image at 12000000 ...
   Using 'conf@1' configuration
   Trying 'fdt@1' fdt subimage
     Description:  Engicam i.CoreM6 Quad/Dual RQS Starter Kit Devicetree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x125d8dbc
     Data Size:    35298 Bytes = 34.5 KiB
     Architecture: ARM
     Hash algo:    md5
     Hash value:   4371a4dfe55127c2fda8a9feb4d3b313
     Hash algo:    sha1
     Hash value:   e34a9326b5e7fd43557753ef980fe67326f82ea1
     Sign algo:    sha1,rsa2048:eng
     Sign value:   94cebd60a6ff2e123ed763760b88c026b74b12eb9c37a97d73eec1a25e01d6e29284f393c5ca20951a605378bf8b547bdc0ce0aae16e069e6db0c5af7f00d4cfc6c94
   Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
   Booting using the fdt blob at 0x125d8dbc
   Uncompressing Kernel Image ... OK
   Using Device Tree in place at 125d8dbc, end 125e479d

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.9.0-next-20161216-dirty (root@jagan-XPS-13-9350) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG linaro-1.13.1-206
[    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt:Machine model: Engicam i.CoreM6 Quad SOM
[    0.000000] cma: Reserved 64 MiB at 0x2c000000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 14 pages/cpu @dbb9d000 s26816 r8192 d22336 u57344
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttymxc3,115200 root=/dev/mmcblk0p2 rootwait rw
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)

[    3.750068]   #0: imx-audio-sgtl5000
[    3.765128] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[    3.807473] usb 1-1: device descriptor read/64, error -71
[    4.020338] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    4.028685] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    4.038301] devtmpfs: mounted
[    4.044169] Freeing unused kernel memory: 1024K
INIT: [    4.177458] usb 1-1: device descriptor read/64, error -71
version 2.88 booting
[    4.437640] usb 1-1: new full-speed USB device number 3 using ci_hdrc
mount: mount point /mnt/.psplash does not exist
[    4.677537] usb 1-1: device descriptor read/64, error -71
Starting udev
Boot Linux on Vyasa RK3288

Build the images here, and setup SD card with Single partition here

bootm
Ramdisk

Create Single partition and Insert the SD on host and Built the images from Image Build

$ cd /path/to/u-boot
$./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out
$ dd if=out of=/dev/mmcblk0 seek=64
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=256
$ cd /path/to/linux-next
$ cp arch/arm/boot/uImage /media/jagan/rootfs/boot
$ cp arch/arm/boot/dts/rk3288-vyasa.dtb /media/jagan/rootfs/boot
$ cp arm_ramdisk.image /media/jagan/rootfs
$ sync
$ umount /dev/mmcblk0p1

Close JP4 and Insert the SD card and power-on the board.

U-Boot TPL 2017.11-rc1-00238-g26f9184 (Oct 13 2017 - 21:15:23)

Trying to boot from BOOTROM

Returning to boot ROM...


U-Boot SPL 2017.11-rc1-00238-g26f9184 (Oct 13 2017 - 21:15:23)

Trying to boot from MMC1

Expected Linux image is not found. Trying to start U-boot



U-Boot 2017.11-rc1-00238-g26f9184 (Oct 13 2017 - 21:15:23 +0530)


Model: Amarula Vyasa-RK3288

DRAM:  2 GiB

MMC:   dwmmc@ff0c0000: 1

*** Warning - bad CRC, using default environment


In:    serial@ff690000

Out:   serial@ff690000

Err:   serial@ff690000

Model: Amarula Vyasa-RK3288

Net:   Net Initialization Skipped

No ethernet found.

Hit any key to stop autoboot:  0

=> setenv bootargs 'console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0x03000000,16M ramdisk_size=16384'

=> ext4load mmc 0:1 ${kernel_addr_r} uImage

=> ext4load mmc 0:1 ${fdt_addr_r} rk3288-vyasa.dtb

=> ext4load mmc 0:1 0x03000000 arm_ramdisk.image

=> bootm ${kernel_addr_r} - ${fdt_addr_r}

reading uImage

7343688 bytes read in 537 ms (13 MiB/s)

reading rk3288-vyasa.dtb

34632 bytes read in 9 ms (3.7 MiB/s)

reading arm_ramdisk.image

16777216 bytes read in 1212 ms (13.2 MiB/s)

## Booting kernel from Legacy Image at 02000000 ...

   Image Name:   Linux-4.11.0-00003-gb75686b-dirt

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    7343624 Bytes = 7 MiB

   Load Address: 02000000

   Entry Point:  02000000

   Verifying Checksum ... OK

## Flattened Device Tree blob at 01f00000

   Booting using the fdt blob at 0x1f00000

   Loading Kernel Image ... OK

   Loading Device Tree to 0fff4000, end 0ffff747 ... OK


Starting kernel ...
Rootfs

Create Single partition and Insert the SD on host and Built the images from Image Build

$ cd /path/to/u-boot

$./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out
$ dd if=out of=/dev/mmcblk0 seek=64
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=256
$ cp -rf rfs-rk3288/* /media/jagan/rootfs
$ cd /path/to/linux-next
$ cp arch/arm/boot/uImage /media/jagan/rootfs/boot
$ cp arch/arm/boot/dts/rk3288-vyasa.dtb /media/jagan/rootfs/boot

Create extlinux script

$ cat /mnt/boot/extlinux/extlinux.conf

label Vyasa kernel-4.13

        kernel /boot/uImage

        devicetree /boot/rk3288-vyasa.dtb

        append console=ttyS2,115200n8 root=/dev/mmcblk0p1 rootwait

$ sync
$ umount /dev/mmcblk0p1

Close JP4 and Insert the SD card and power-on the board.

Hit any key to stop autoboot:  0

switch to partitions #0, OK

mmc1 is current device

Scanning mmc 1:1...

Found /extlinux/extlinux.conf

Retrieving file: /extlinux/extlinux.conf

reading /extlinux/extlinux.conf

128 bytes read in 7 ms (17.6 KiB/s)

1:      Vyasa kernel-4.13

Retrieving file: /boot/uImage

reading /boot/uImage

7836888 bytes read in 575 ms (13 MiB/s)

append: console=ttyS2,115200n8 root=/dev/mmcblk0p2 rootwait

Retrieving file: /boot/rk3288-vyasa.dtb

reading /boot/rk3288-vyasa.dtb

36283 bytes read in 12 ms (2.9 MiB/s)

## Booting kernel from Legacy Image at 02000000 ...

   Image Name:   Linux-4.13.0-rc4-next-20170810-0

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    7836824 Bytes = 7.5 MiB

   Load Address: 02000000

   Entry Point:  02000000

   Verifying Checksum ... OK

## Flattened Device Tree blob at 01f00000

   Booting using the fdt blob at 0x1f00000

   Loading Kernel Image ... OK

   Loading Device Tree to 0fff4000, end 0ffffdba ... OK


Starting kernel ...
Monolithic
FIT
Verified Boot
Redundant Boot with U-Boot
Verified Boot on i.MX6
Create vmlinux.bin
$ arm-linux-gnueabi-objcopy -O binary vmlinux vmlinux.bin

$ gzip vmlinux.bin

$ cp imx6q-icore-rqs.dtb imx6q-icore-rqs-pubkey.dtb
FIT input
kernel_fdt.its

/* Simple U-Boot uImage source file containing a single kernel and FDT blob */

/dts-v1/;

/ {

    description = "Verified RSA image with single Linux kernel and FDT blob";

    #address-cells = <1>;

    images {

        kernel@1 {

            description = "i.MX6 Linux kernel";

            data = /incbin/("./vmlinux.bin.gz");

            type = "kernel";

            arch = "arm";

            os = "linux";

            compression = "gzip";

            load = <0x10008000>;

            entry = <0x10008000>;

            hash@1 {

                algo = "md5";

            };

            hash@2 {

                algo = "sha1";

            };

            signature@1 {

                algo = "sha1,rsa2048";

                key-name-hint = "eng";

            };

        };

        fdt@1 {

            description = "Engicam i.CoreM6 Quad/Dual RQS Starter Kit Devicetree blob";

            data = /incbin/("./imx6q-icore-rqs.dtb");

            type = "flat_dt";

            arch = "arm";

            compression = "none";

            hash@1 {

                algo = "md5";

            };

            hash@2 {

                algo = "sha1";

            };

            signature@1 {

                algo = "sha1,rsa2048";

                key-name-hint = "eng";

            };

        };

    };

    configurations {

        default = "conf@1";

        conf@1 {

            description = "Boot Linux kernel with FDT blob";

            kernel = "kernel@1";

            fdt = "fdt@1";

        };

    };

};
RSA key generation
- Create RSA key pair
$ mkdir mykeys
$ openssl genrsa -F4 -out mykeys/eng.key 2048

- Create a certificate contains public key

$ openssl req  -batch -new -x509 -key mykeys/eng.key -out mykeys/eng.crt
FIT output
$ ./mkimage -f kernel_fdt.its -K imx6q-icore-rqs-pubkey.dtb -k mykeys/ -r fit.itb
Build U-Boot with Public key
$ .make DEV_TREE_BIN=../imx6q-icore-rqs-pubkey.dtb
Boot VerifiedBoot
U-Boot SPL 2017.01-rc2-00010-gb42d823 (Dec 21 2016 - 11:13:46)
Trying to boot from MMC1

U-Boot 2017.01-rc2-00010-gb42d823 (Dec 21 2016 - 11:13:46 +0100)

CPU:   Freescale i.MX6D rev1.2 at 792 MHz
Reset cause: POR
Model: Engicam i.CoreM6 Quad/Dual RQS Starter Kit
DRAM:  512 MiB
MMC:   FSL_SDHC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
reading boot.scr
** Unable to read file boot.scr **
reading fit.itb
6167494 bytes read in 335 ms (17.6 MiB/s)
Booting FIT image from mmc ...
## Loading kernel from FIT Image at 12000000 ...
   Using 'conf@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@1' kernel subimage
     Description:  i.MX6 Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x120000f0
     Data Size:    6130148 Bytes = 5.8 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x10008000
     Entry Point:  0x10008000
     Hash algo:    md5
     Hash value:   b975a202ea2963c53c53f527329930cd
     Hash algo:    sha1
     Hash value:   78b93fe404b795de8c837af27d67f4df9b96083a
     Sign algo:    sha1,rsa2048:eng
     Sign value:   4288ce2c7380a90b7b7b9c000760f086fe67560d16fb5ea85bc792ff3ed70e381956bbff99c514213e00e3d21838650ada0eb68439e253ef493e3e0098e0d47109d3e
   Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
## Loading fdt from FIT Image at 12000000 ...
   Using 'conf@1' configuration
   Trying 'fdt@1' fdt subimage
     Description:  Engicam i.CoreM6 Quad/Dual RQS Starter Kit Devicetree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x125d8dbc
     Data Size:    35298 Bytes = 34.5 KiB
     Architecture: ARM
     Hash algo:    md5
     Hash value:   4371a4dfe55127c2fda8a9feb4d3b313
     Hash algo:    sha1
     Hash value:   e34a9326b5e7fd43557753ef980fe67326f82ea1
     Sign algo:    sha1,rsa2048:eng
     Sign value:   94cebd60a6ff2e123ed763760b88c026b74b12eb9c37a97d73eec1a25e01d6e29284f393c5ca20951a605378bf8b547bdc0ce0aae16e069e6db0c5af7f00d4cfc6c94
   Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
   Booting using the fdt blob at 0x125d8dbc
   Uncompressing Kernel Image ... OK
   Using Device Tree in place at 125d8dbc, end 125e479d

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.9.0-next-20161216-dirty (root@jagan-XPS-13-9350) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG linaro-1.13.1-206
[    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt:Machine model: Engicam i.CoreM6 Quad SOM
[    0.000000] cma: Reserved 64 MiB at 0x2c000000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 14 pages/cpu @dbb9d000 s26816 r8192 d22336 u57344
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttymxc3,115200 root=/dev/mmcblk0p2 rootwait rw
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)

[    3.750068]   #0: imx-audio-sgtl5000
[    3.765128] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[    3.807473] usb 1-1: device descriptor read/64, error -71
[    4.020338] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    4.028685] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    4.038301] devtmpfs: mounted
[    4.044169] Freeing unused kernel memory: 1024K
INIT: [    4.177458] usb 1-1: device descriptor read/64, error -71
version 2.88 booting
[    4.437640] usb 1-1: new full-speed USB device number 3 using ci_hdrc
mount: mount point /mnt/.psplash does not exist
[    4.677537] usb 1-1: device descriptor read/64, error -71
Starting udev
Verified Boot on SUNXI64

U-Boot supports an image verification method called “Verified Boot”. This tutorial will show the details of verified-boot on SUNXI64 platform with Orangepi A64 board.

See here for more documentation of verified-boot - doc/uImage.FIT directory

Generate RSA key to sign
# Create RSA key pair
$ mkdir keys
$ openssl genpkey -algorithm RSA -out keys/dev.key -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537

# Create a certificate contains public key
$ openssl req -batch -new -x509 -key keys/dev.key -out keys/dev.crt
Build Linux

See this page for building linux

FIT Input

kernel_fdt.its

/dts-v1/;

/ {

    description = "FIT image with single Linux kernel, FDT blob";

    #address-cells = <1>;


    images {

        kernel@0 {

            description = "ARM64 Linux kernel";

            data = /incbin/("./Image.gz");

            type = "kernel";

            arch = "arm64";

            os = "linux";

            compression = "gzip";

            load = <0x50080000>;

            entry = <0x50080000>;

            hash@1 {

                algo = "sha256";

            };

        };


        fdt@0 {

            description = "Orangepi Win/Win+ Devicetree blob";

            data = /incbin/("./sun50i-a64-orangepi-win.dtb");

            type = "flat_dt";

            arch = "arm64";

            compression = "none";

            hash@1 {

                algo = "sha256";

            };

        };

    };


    configurations {

        default = "conf@0";


        conf@0 {

            description = "Boot Linux kernel, FDT blob";

            kernel = "kernel@0";

            fdt = "fdt@0";

            signature@0 {

                algo = "sha256,rsa2048";

                key-name-hint = "dev";

                sign-images = "kernel", "fdt";

            };

        };

    };

};

You need to change the two ‘/incbin/’ lines, depending on the location of your kernel image, devicetree blob. The “load” and “entry” properties also need to be adjusted if you want to change the physical placement of the kernel.

The “key-name-hint” must specify the key name you have created in the “Generate RSA key to sign” step

Build U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_win_defconfig
$ make menuconfig
[ enable CONFIG_FIT, CONFIG_FIT_SIGNATURE and CONFIG_FIT_VERBOSE ]
$ make
FIT Output
$ tools/mkimage -f kernel_fdt.its -k keys -K dts/dt.dtb -r -F fitImage

    => k options for specifying keys directory from "Generate RSA key to sign" step
    => dts/dt.dtb from U-Boot
    => The public key needed for the run-time verification is stored in "dts/dt.dtb"
Build Signed-U-Boot

“dt.dtb” has been updated in above step, you need to re-compile the U-Boot.

$ make

The re-compiled “u-boot.bin” is appended with DTB that contains the public key.

Verified Boot
U-Boot SPL 2017.11-rc4-dirty (Nov 08 2017 - 00:11:54)

DRAM: 1024 MiB

Trying to boot from MMC1

NOTICE:  BL3-1: Running on A64/H64 (1689) in SRAM A2 (@0x44000)

NOTICE:  Configuring SPC Controller

NOTICE:  BL3-1: v1.0(debug):aa75c8d

NOTICE:  BL3-1: Built : 23:14:48, Nov  4 2017

NOTICE:  Configuring AXP PMIC

NOTICE:  PMIC: setup successful

INFO:    BL3-1: Initializing runtime services

INFO:    BL3-1: Preparing for EL3 exit to normal world

INFO:    BL3-1: Next image address: 0x4a000000, SPSR: 0x3c9


U-Boot 2017.11-rc4-dirty (Nov 08 2017 - 00:11:54 +0530) Allwinner Technology


CPU:   Allwinner A64 (SUN50I)

Model: OrangePi Win/Win Plus

DRAM:  1 GiB

MMC:   SUNXI SD/MMC: 0

*** Warning - bad CRC, using default environment


In:    serial

Out:   serial

Err:   serial

Net:   No ethernet found.

starting USB...

USB0:   USB EHCI 1.00

USB1:   USB OHCI 1.0

scanning bus 0 for devices... 1 USB Device(s) found

       scanning usb for storage devices... 0 Storage Device(s) found

Hit any key to stop autoboot:  0

switch to partitions #0, OK

mmc0 is current device

Scanning mmc 0:1...

Found /boot/extlinux/extlinux.conf

Retrieving file: /boot/extlinux/extlinux.conf

185 bytes read in 274 ms (0 Bytes/s)

1:      Opi Win/Win+

Retrieving file: /boot/fitImage

6895614 bytes read in 607 ms (10.8 MiB/s)

append: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait

## Loading kernel from FIT Image at 40080000 ...

   Using 'conf@0' configuration

   Verifying Hash Integrity ... OK

   Trying 'kernel@0' kernel subimage

     Description:  ARM64 Linux kernel

     Type:         Kernel Image

     Compression:  gzip compressed

     Data Start:   0x400800e4

     Data Size:    6884659 Bytes = 6.6 MiB

     Architecture: AArch64

     OS:           Linux

     Load Address: 0x50080000

     Entry Point:  0x50080000

     Hash algo:    sha256

     Hash value:   6808fe51ea3c15f31c4510d2701d4707b56d20213c9da05bce79fb53bf108f1a

   Verifying Hash Integrity ... sha256+ OK

## Loading fdt from FIT Image at 40080000 ...

   Using 'conf@0' configuration

   Trying 'fdt@0' fdt subimage

     Description:  Orangepi Win/Win+ Devicetree blob

     Type:         Flat Device Tree

     Compression:  uncompressed

     Data Start:   0x40710f24

     Data Size:    9032 Bytes = 8.8 KiB

     Architecture: AArch64

     Hash algo:    sha256

     Hash value:   ca3d874cd10466633ff133cc0156828d48c8efb96987fa45f885761d22a25dc1

   Verifying Hash Integrity ... sha256+ OK

   Booting using the fdt blob at 0x40710f24

   Uncompressing Kernel Image ... OK

   Loading Device Tree to 0000000049ffa000, end 0000000049fff347 ... OK

Cannot setup simplefb: node not found


Starting kernel ...


[    0.000000] Booting Linux on physical CPU 0x0

Image Build

Allwinner SUNXI32

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Banana Pi BPI-M1 board.

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make bananapi_m1_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

$ cd linux-next
$ make mrproper
$ ARCH=arm make sunxi_defconfig
$ ARCH=arm make -j 4 zImage dtbs
Rootfs
$ git clone https://github.com/openedev/rfs-rk3288

$ dd if=/dev/zero of=arm_ramdisk.image bs=1k count=16384

$ mke2fs -F -m0 arm_ramdisk.image

$ mount -t ext4 arm_ramdisk.image /mnt -o loop

$ cp -rf rfs-rk3288/* /mnt

$ umount /mnt
Allwinner SUNXI64

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Banana Pi BPI-M64 board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make bananapi_m64_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Engicam i.MX6

Image building need host to ready with all necessary tools ready, refer here Below are the details of Image build for Engicam i.CoreM6 Quad board

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make imx6qdl_icore_mmc_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ ARCH=arm make imx_v6_v7_defconfig
$ ARCH=arm make LOADADDR=0x10008000 uImage dtbs
Ramdisk
$ git clone https://github.com/openedev/rootfs-imx6q.git

$ dd if=/dev/zero of=arm_ramdisk.image bs=1k count=16384

$ mke2fs -F -m0 arm_ramdisk.image

$ mount -t ext4 arm_ramdisk.image /mnt -o loop

$ cp -rf rootfs-imx6q/* /mnt

$ umount /mnt

$ gzip arm_ramdisk.image

$ mkimage -A arm -T ramdisk -C gzip -d arm_ramdisk.image.gz uarm_ramdisk.image.gz

Image Name:

Created:      Thu Oct  5 14:18:23 2017

Image Type:   ARM Linux RAMDisk Image (gzip compressed)

Data Size:    691309 Bytes = 675.11 kB = 0.66 MB

Load Address: 00000000

Entry Point:  00000000
Rockchip RK3288

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Vyasa RK3288 board.

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make vyasa-rk3288_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

$ cd linux-next
$ make mrproper
$ ARCH=arm make multi_v7_defconfig
$ ARCH=arm make -j 4 LOADADDR=0x02000000 uImage dtbs
$ ARCH=arm make modules -j 4
$ ARCH=arm make modules_install -j 4
Rootfs
$ git clone https://github.com/openedev/rfs-rk3288

$ dd if=/dev/zero of=arm_ramdisk.image bs=1k count=16384

$ mke2fs -F -m0 arm_ramdisk.image

$ mount -t ext4 arm_ramdisk.image /mnt -o loop

$ cp -rf rfs-rk3288/* /mnt

$ umount /mnt

Secure Boot

i.MX6 HABv4
About this

This tutorial describe the information and usage about i.MX Secure Architecture.

i.MX Security

Verify the loaded software to ensure that it is authorized during runtime is usually termed as Verified or Secure or Trusted system mechanism.

i.MX Trust Architecture - Overview _images/imx_trust_arch.png

Below are the threats that are identified and processed with trusted architecture.

Malware:

  • Rootkits, trojans, viruses, worms, keyloggers, bots
  • Risk enhanced by rich & open OS
  • Countermeasures: trusted execution, high assurance boot

Hacking

  • Reverse engineering, brute force
  • Countermeasures: secure storage, secure debug, encryption

Physical attack

  • Bus snooping, glitching,
  • Countermeasures: secure storage, tamper detection
i.MX Trust Architecture - Features

Trusted Execution:

TrustZone Secure & Normal Worlds (processor modes)

Isolates execution of critical SW from possible malware

Hardware firewalls between CPU & DMA masters and memory & peripherals

High Assurance Boot:

Authenticate/Signed boot: prevent unauthorized software execution

Encrypted boot: protects software confidentiality

Signature checks embedded in on-chip boot ROM

Run every time processor reset

Cryptographic Accelerators:

i.MX family dependent

Symmetric: AES-128, AES-256, 3DES, ARC4

Message Digest & HMAC: SHA-1, SHA-256, MD-5

Secure Storage:

Protects data confidentiality and integrity

HW-only keys: no SW access

Off-chip: cryptographic protection including device binding

On-chip: self-clearing Secure RAM (CAAM)

HW Random Number Generation:

Ensures strong keys and protects against protocol replay

On-chip entropy generation

Cryptographically secure deterministic RNG (NIST compliant)

SNVS Secure Clock:

Provides reliable time source

On-chip, separately-powered real-time clock

Protection from SW tampering

Secure Debug:

Three security levels + complete JTAG disable

Protects against HW debug (JTAG) exploitation for Security circumvention and Reverse engineering

Tamper Detection:

Protects against run-time tampering

Monitoring of various alarm sources

Debug activation

External alarm (e.g. cover seal)

SW integrity checks

SW alarm flags

High Assurance Boot (HAB)

Below are the recommend acronyms related to this tutorial.

Boot ROM: Small piece of one-time programmable firmware written in on-chip read-only memory location and the very first unsigned-software which is executed by the processor on power-on or reset.

Secure Boot ROM: Similar to Boot ROM, but capable of running signed-software using secure libraries.

HAB Library: Secure software library executed in i.MX Boot ROM, using Signing and Encryption processes.

Signed Software/Image: Software Image further padded or processed using Signature that can capable to run only on secure environment.

Signature: Legally binding secure attributes to Signed Image, these attributes can be Private/Public keys, HAB data, Certificate, Secrete keys etc which is understandable by the HAB.

CSF: Command Sequence File, a binary data structure interpreted by the HAB to guide signing and/or decryption process.

CST: Code Signing Tool, like OpenSSL an application running on a build host to generate PKI tree, SRK table along with associated CSF file.

PKI tree: Public Key Infrastructure, a hierarchy of public key certificates in which each certificate (except the root certificate) can be verified using the public key above it.

RSA: Public key cryptography algorithm used for Signing or Authentication process.

SRK: Super Root Key, an RSA key pair which forms the start of the boot time authentication chain. The hash of the SRK public key is embedded in the processor using OTP hardware(e-fuse). The SRK private key is held by the Signature generation for software image.

DEK: Data Encryption Key (DEK), is the key that will be used to actually encrypt the image.

DEK Blob: Encryption of DEK using OTPMK with the help of CAAM HW

OTPMK: AES-256 key burned to fuses by NXP before the IC is shipped. This is unique per chip and only CAAM can access the key.

Secret Key: Generally an outcome key of DEK Blob key used to encrypt and decrypt.

AES: Advanced Encryption Standard used for Encryption process

HAB Secure Boot chain _images/hab-secure-boot.png

Upon reset i.MX Boot ROM reads the efuse to determine the security configuration of the SoC and the type of the boot device.

The ROM then loads the bootloader image(signed-image) to DDR memory. The image contains both the bootloader itself and signature data and public key certificate data which are collectively called CSF data.

Once the bootloader is loaded, execution is then passed to the HAB library which will verify the signatures of the bootloader stage.

If signature verification fails, execution is not allowed to leave the ROM for securely configured SoCs, also called “closed” devices

If signature verification pass, execution is allowed to leave the ROM for securely configured SoCs, also called “open” devices

HAB Overview
  • HAB support Signing and Encryption process, where later one change the software-data into unreadable random gibberish using secrete key.
  • HABv4 is the version supported by i.MX6
  • HAB interfaces with SNVS and CAAM secure boot components.
  • CAAM accelerate SHA-256 operation during signature verification and AES-128 operation during decryption boot operation.
  • HAB support X.509 Public key certificate, in CMS signature format.
HAB - Signed Boot
Signed Boot Flow _images/hab-sign.png

During Signing, host need to generate PKI tree, Super Root Keys, or SRK, are components of the PKI tree, then the table of public SRK should burn to E-Fuse and finally signed image can be generated using table of public SRK plus private SRKs by defining them in a format of CSF.

During Verification, HAB evaluates the SRK table included in the signature by hashing it and comparing the result to the SRK fuse values.

If the SRK verification is successful, this establishes the root of trust, and the remainder of the signature can be processed to authenticate the image.

Image Signer Flow _images/Image_Sign.png
Signed Boot - Usage
Signed Image Format (U-Boot) _images/format-signed-image.png

The below procedure will describe an example on how signed boot has been done with Engicam i.CoreM6 Quad board.

Download cryptographic tool
$ tar xvf cst-2.3.2.tar.gz
$ cd cst-2.3.2/keys
Generate PKI tree (Private keys)

serial - 8-digit OpenSSL uses the contents of this file for the certificate serial numbers.

key_pass.txt - Contains your pass phrase that will protect the HAB code signing private keys.

$ echo "42424242" > serial
$ echo "Amarual357" > key_pass.txt

$ echo "Amarual357" >> key_pass.txt
$ ./hab4_pki_tree.sh


    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    This script is a part of the Code signing tools for Freescale's

    High Assurance Boot.  It generates a basic PKI tree.  The PKI

    tree consists of one or more Super Root Keys (SRK), with each

    SRK having two subordinate keys:

        + a Command Sequence File (CSF) key

        + Image key.

    Additional keys can be added to the PKI tree but a separate

    script is available for this.  This this script assumes openssl

    is installed on your system and is included in your search

    path.  Finally, the private keys generated are password

    protectedwith the password provided by the file key_pass.txt.

    The format of the file is the password repeated twice:

        my_password

        my_password

    All private keys in the PKI tree are in PKCS #8 format will be

    protected by the same password.


    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Do you want to use an existing CA key (y/n)?: n

Do you want to use Elliptic Curve Cryptography (y/n)?: n

Enter key length in bits for PKI tree: 2048

Enter PKI tree duration (years): 10

How many Super Root Keys should be generated? 4

Do you want the SRK certificates to have the CA flag set? (y/n)?: y

Private keys will generate on keys directory and corresponding Certificates are placed in the crts directory.

Generate SRK table (Public keys)
$ cd ../crts

$ ../linux64/srktool \

> -h 4 \

> -t SRK_1_2_3_4_table.bin \

> -e SRK_1_2_3_4_fuse.bin \

> -d sha256 \

> -c ./SRK1_sha256_2048_65537_v3_ca_crt.pem,\

> ./SRK2_sha256_2048_65537_v3_ca_crt.pem,\

> ./SRK3_sha256_2048_65537_v3_ca_crt.pem,\

> ./SRK4_sha256_2048_65537_v3_ca_crt.pem \

> -f 1

SRK_1_2_3_4_table.bin - SRK table contents with HAB data SRK_1_2_3_4_fuse.bin - contains SHA256 result to be burned to fuse

Build Secure-enabled U-Boot
u-boot> git clone https://github.com/openedev/u-boot-amarula.git -b hab

u-boot> make imx6q_icore_mmc_defconfigu-boot> make
u-boot> cat u-boot-dtb.imx.log

Image Type:   Freescale IMX Boot Image

Image Ver:    2 (i.MX53/6/7 compatible)

Mode:         DCD

Data Size:    536576 Bytes = 524.00 KiB = 0.51 MiB

Load Address: 177ff420

Entry Point:  17800000

HAB Blocks:   177ff400 00000000 00082c00

DCD Blocks:   00910000 0000002c 00000328
Generate Signature for U-Boot Image
$ cd ~/cst-2.3.2/linux64
$ cat U-Boot.CST

[Header]

Version = 4.1

Security Configuration = Open

Hash Algorithm = sha256

Engine Configuration = 0

Certificate Format = X509

Signature Format = CMS

Engine = CAAM


[Install SRK]

File = "../crts/SRK_1_2_3_4_table.bin"

Source index = 0


[Install CSFK]

File = "../crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem"


[Authenticate CSF]


[Install Key]

# Key slot index used to authenticate the key to be installed

Verification index = 0


# Key to install

Target index = 2

File = "../crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem"


[Authenticate Data]

Verification index = 2

Blocks = 0x177ff400 0x0 0x82c00 "u-boot-dtb.imx"

$ cp u-boot/u-boot-dtb.imx .
$ ./cst --o U-Boot_CSF.bin --i U-Boot.CSF

CSF Processed successfully and signed data available in U-Boot_CSF.bin
Create Signed U-Boot
$ objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 U-Boot_CSF.bin U-Boot_CSF_pad.bin
$ cat u-boot-dtb.imx U-Boot_CSF_pad.bin > u-boot-dtb-signed.imx
$ dd if=u-boot-dtb-signed.imx of=/dev/sda bs=1K seek=1 && sync

<< Put SD card and power-on the board >>

Burn e-fuse with SRK
efuse dump

$ cd ../crts

$ hexdump -e '/4 "0x"' -e '/4 "%X""\n"' < SRK_1_2_3_4_fuse.bin

0x67C7506F

0x7D51EFD0

0x9E450811

0x74ED8483

0xB774A2A

0xD33FF045

0x3343F187

0xC86DDA92
Burn on efuse

U-Boot 2017.05-rc2-00058-g7d6c4ef (Apr 25 2017 - 11:30:36 +0530)


CPU:   Freescale i.MX6Q rev1.2 at 792MHz

CPU:   Industrial temperature grade (-40C to 105C) at 53C

Reset cause: POR

Model: Engicam i.CoreM6 Quad/Dual Starter Kit

DRAM:  2 GiB

MMC:   FSL_SDHC: 0

*** Warning - bad CRC, using default environment


No panel detected: default to Amp-WD

Display: Amp-WD (800x480)

In:    serial

Out:   serial

Err:   serial

switch to partitions #0, OK

mmc0 is current device

Net:

Error: ethernet@02188000 address not set.

No ethernet found.

Hit any key to stop autoboot:  0
icorem6qdl> fuse prog -y 3 0 0x67C7506F

Programming bank 3 word 0x00000000 to 0x67c7506f...

icorem6qdl> fuse prog -y 3 1 0x7D51EFD0

Programming bank 3 word 0x00000001 to 0x7d51efd0...

icorem6qdl> fuse prog -y 3 2 0x9E450811

Programming bank 3 word 0x00000002 to 0x9e450811...

icorem6qdl> fuse prog -y 3 3 0x74ED8483

Programming bank 3 word 0x00000003 to 0x74ed8483...

icorem6qdl> fuse prog -y 3 4 0xB774A2A

Programming bank 3 word 0x00000004 to 0x0b774a2a...

icorem6qdl> fuse prog -y 3 5 0xD33FF045

Programming bank 3 word 0x00000005 to 0xd33ff045...

icorem6qdl> fuse prog -y 3 6 0x3343F187

Programming bank 3 word 0x00000006 to 0x3343f187...

icorem6qdl> fuse prog -y 3 7 0xC86DDA92

Programming bank 3 word 0x00000007 to 0xc86dda92...
Check HAB isn’t finding ERRORS?
icorem6qdl> hab_status


Secure boot disabled


HAB Configuration: 0xf0, HAB State: 0x66

No HAB Events Found!

HAB authentication works fine, and the hab_status show ‘No HAB Events Found!’ So the device is open now try to close for enabling Secure boot

Enable Secure boot

Be careful with this step and if you’re sure with all steps above and hab_status should show ‘No HAB Events Found!’ Once this setup executed, chip will only boot an image signed with the keys that match the SRK blown fuses.

icorem6qdl> fuse prog 0 6 0x2

Programming bank 0 word 0x00000006 to 0x00000002...

Warning: Programming fuses is an irreversible operation!

         This may brick your system.

         Use this command only if you are sure of what you are doing!


Really perform this fuse programming? <y/N>

y

icorem6qdl> reset

resetting ...


U-Boot 2017.05-rc2-00058-g5c41464-dirty (Apr 25 2017 - 13:11:59 +0530)


CPU:   Freescale i.MX6Q rev1.2 at 792MHz

CPU:   Industrial temperature grade (-40C to 105C) at 49C

Reset cause: WDOG

Model: Engicam i.CoreM6 Quad/Dual Starter Kit

DRAM:  2 GiB

MMC:   FSL_SDHC: 0

*** Warning - bad CRC, using default environment


No panel detected: default to Amp-WD

Display: Amp-WD (800x480)

In:    serial

Out:   serial

Err:   serial

switch to partitions #0, OK

mmc0 is current device

Net:

Error: ethernet@02188000 address not set.

No ethernet found.

Hit any key to stop autoboot:  0

icorem6qdl> hab_

  hab_auth_img hab_status

icorem6qdl> hab_status


Secure boot enabled


HAB Configuration: 0xcc, HAB State: 0x99

No HAB Events Found!
HAB - Encrypted boot
Encrypted Boot Flow _images/hab-encrypt.png

During Encryption, host need to follow similar steps as Signing process for ‘Header’ of Software Data. then the table of public SRK should burn to E-Fuse and finally payload cab be encrypted using table of public SRK, private SRKs, and DEK_blob(secret key) by defining them in a format of CSF.

DEK(dek.bin) is generated by cst_encrypt during encryption process but

The problem then is how do we protect the DEK since it is required on the IC to decrypt the image at boot time? The solution is to create a DEK blob.

How to generate DEK_blob? Target will encrypt the DEK using OTPMK from CAAM.

During Decryption, First HAB evaluates the SRK table included in the signature by hashing it and comparing the result to the SRK fuse values like Verification process and HAB evaluates secrete key by decrypt the DEK_blob using OTPMK and encrypted payload is further decrypt using secrete key ie generated before.

Image Encrypt Flow _images/Image_Encrypt.png
Encrypted boot - Usage
Encrypted Image Format (U-Boot) _images/format-encrypted-image.png

The below procedure will describe an example on how encrypted boot has been done with Engicam i.CoreM6 Quad board.

See the same steps in Signed Boot - Usage PKI tree, SRK table and E-fuse burn.

Generate Signature for U-Boot Image

CST from NXP doesn’t allow to use encryption, so you need to build a new binary

$ cd ~/cst-2.3.2/code/back_end/src
$ gcc -o cst_encrypt -I ../hdr -L ../../../linux64/lib *.c -lfrontend -lcrypto
$ cp cst_encrypt ../../../linux64/
$ cd ~/cst-2.3.2/linux64
$ cat U-Boot.CST

[Header]

Version = 4.1

Hash Algorithm = SHA256

Engine Configuration = 0

Certificate Format = X509

Signature Format = CMS

Engine = CAAM


[Install SRK]

File = "../../crts/SRK_1_2_3_4_table.bin"

Source index = 0


[Install CSFK]

File = "../../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate CSF]


[Unlock]

Engine = CAAM

Features = RNG


[Install Key]

# Key slot index used to authenticate the key to be installed

Verification index = 0

# Key to install

Target index = 2

File = "../../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate Data]

Verification index = 2

Blocks = 0x177ff400 0x0 0xC00 "u-boot-dtb.imx"


#Encrypt the boot image and create a DEK

[Install Secret Key]

Verification Index = 0

Target Index = 0

Key = "dek.bin"

Key Length = 128

Blob Address = 0x17883FB8


#Provide DEK blob location to decrypt

[Decrypt Data]

Verification Index = 0

Mac Bytes = 16

Blocks = 0x17800000 0x00000C00 0x82000 "u-boot-dtb.imx"

$ cp u-boot/u-boot-dtb.imx .
$ ./cst_encrypt --o U-Boot_CSF.bin --i U-Boot.CSF

CSF Processed successfully and signed data available in U-Boot_CSF.bin
Create DEK_blob

Once dek.bin generated by cst_encrypt need to protect the dek.bin by creating DEK_blob.bin at target

icorem6qdl>

fatload mmc 0:1 0x10800000 dek.bin

reading dek.bin

16 bytes read in 11 ms (1000 Bytes/s)

icorem6qdl> dek_blob 0x10800000 0x10801000 128

SEC0: RNG instantiated


Encapsulating provided DEK to form blob

DEK Blob

8100484166551000307CB52A999D6D9191D4D7C479DE7DF60A13C0EA7D9ACF92D9491CEA82B91C6F194EC134D9B63005
36F20FFD063C8700F4513BE57F7C7BE43E038C1133138757

icorem6qdl> fatwrite mmc 0 0x10801000 DEK_blob.bin 0x48

writing DEK_blob.bin

72 bytes written
Create Encrypted U-Boot
$ objcopy -I binary -O binary --pad-to=0x1FB8 --gap-fill=0x00 U-Boot_CSF.bin U-Boot_CSF_pad.bin
$ cat cat u-boot-dtb.imx U-Boot_CSF_pad.bin DEK_blob.bin > u-boot-dtb-encrypte.imx
$ dd if=u-boot-dtb-encrypted.imx of=/dev/sda bs=1K seek=1 && sync
HAB - Signed uImage

Now that your bootloader image is properly authenticated/encrypted and that your device is secured, you can sign your kernel image so U-Boot ensures to load a known version.

Here are the details of Signing uImage from linux-next.

Signed uImage Format

See uImage format, which built from linux-next tree

$ mkimage -l uImage

Image Name:   Linux-4.11.0-next-20170510

Created:      Wed May 10 21:27:58 2017

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    6940664 Bytes = 6777.99 kB = 6.62 MB

Load Address: 10008000

See the same uImage is fitting on memory after proper signed, just numerical understanding nevertheless same procedure as with “HAB - Signed Boot”

_images/Signed-uImage-format.png
Signed uImage Creation

Use the same PKI tree and SRK keys that been tested with U-Boot and proceed with “Image Signer Flow” of U-Boot except the numerical difference, nevertheless the same procedure.

4K PAD

Since Linux follows 4K pagesize format for Image process, So pad the built uImage to nearest 4K padding. here the actual uImage size is 0x69E838 after nearest 4K padding it becomes 0x69F000.

$ objcopy -I binary -O binary --pad-to=0x69F000 --gap-fill=0x00 uImage uImage-pad.bin
Generate IVT

By default imx header attach the IVT for U-Boot (u-boot-dtb.imx), but Linux we need to explicitly attach the IVT based on the perl script as below.

Size of the IVT is 0x20 bytes

Self pointer size is the uImage size once padded to 4K

CSF pointer size is Self pointer + 0x20

$ cat genIVT

#! /usr/bin/perl -w

use strict;

open(my $out, '>:raw', 'ivt.bin') or die "Unable to open: $!";

print $out pack("V", 0x412000D1); # IVT Header

print $out pack("V", 0x10801000); # Jump Location

print $out pack("V", 0x0); # Reserved

print $out pack("V", 0x0); # DCD pointer

print $out pack("V", 0x0); # Boot Data

print $out pack("V", 0x10E9F000); # Self Pointer

print $out pack("V", 0x10E9F020); # CSF Pointer

print $out pack("V", 0x0); # Reserved

close($out);
Create IVT uImage

Build the genIVT that should create ivt.bin

$ perl genIVT

Attach ivt.bin to padded uImage

$ cat uImage-pad.bin ivt.bin > uImage-pad-ivt.bin
Create CSF uImage

Create uImage.CSF file and build the binary.

$ cat uImage.CSF

[Header]

Version = 4.1

Security Configuration = Open

Hash Algorithm = sha256

Engine Configuration = 0

Certificate Format = X509

Signature Format = CMS

Engine = CAAM


[Install SRK]

File = "../../crts/SRK_1_2_3_4_table.bin"

Source index = 0



[Install CSFK]

File = "../../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate CSF]


[Install Key]

# Key slot index used to authenticate the key to be installed

Verification index = 0

# Key to install

Target index = 2

File = "../../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate Data]

Verification index = 2

Blocks = 0x10800000 0x0 0x69F020 "uImage-pad-ivt.bin"
$ ./cst --o uImage_CSF.bin --i uImage.CSF

CSF Processed successfully and signed data available in uImage_CSF.bin

Attach uImage_CSF.bin with padded ivt uImage

$ cat uImage-pad-ivt.bin uImage_CSF.bin > uImage-pad-ivt-csf.bin
Create Signed uImage
$ objcopy -I binary -O binary --pad-to=0x6A1020 --gap-fill=0x00 uImage-pad-ivt-csf.bin uImage-signed.bin

That’s it, you can now modify your U-Boot bootcmd so it includes the HAB command that checks the kernel,

Signed uImage CHECK??
icorem6qdl> fatload mmc 0:1 0x10800000 uImage-signed.bin

reading uImage-signed.bin

6950944 bytes read in 351 ms (18.9 MiB/s)

icorem6qdl> hab_auth_img 0x10800000 0x69F000


Authenticate image from DDR location 0x10800000...


Secure boot enabled


HAB Configuration: 0xcc, HAB State: 0x99

No HAB Events Found!
SPL HABv4

Since, the i.MX6 Secure Boot used u-boot-dtb.imx but this tutorial describe the Secure Boot(HAB) for SPL as well as a singable version of the U-Boot image.

The signature can be verified through High Assurance Boot (HAB).

Build
bash> git clone https://github.com/openedev/u-boot-amarula.git -b falcon-hab

bash> cd u-boot-amarula

bash> make imx6dl_icore_mmc_defconfig

bash> make


bash> cat SPL.log

Image Type:   Freescale IMX Boot Image

Image Ver:    2 (i.MX53/6/7 compatible)

Mode:         DCD

Data Size:    53248 Bytes = 52.00 KiB = 0.05 MiB

Load Address: 00907420

Entry Point:  00908000

HAB Blocks:   00907400 00000000 0000ac00

DCD Blocks:   00910000 0000002c 00000004

bash> cat u-boot-ivt.img.log

Image Name:   U-Boot 2017.05-00002-g5ab54f3 fo

Created:      Tue Jul  4 13:55:05 2017

Image Type:   ARM U-Boot Firmware with HABv4 IVT (uncompressed)

Data Size:    417728 Bytes = 407.94 KiB = 0.40 MiB

Load Address: 17800000

Entry Point:  00000000

HAB Blocks:   0x177fffc0   0x0000   0x00064020
Generate Signed SPL

First create PKI keys from here and proceed with below steps

bash> cd ~/cst-2.3.2/linux64

# Create csf
bash> cat SPL.CSF

[Header]

Version = 4.1

Security Configuration = Open

Hash Algorithm = sha256

Engine Configuration = 0

Certificate Format = X509

Signature Format = CMS

Engine = CAAM


[Install SRK]

File = "../crts/SRK_1_2_3_4_table.bin"

Source index = 0


[Install CSFK]

File = "../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate CSF]


[Install Key]

# Key slot index used to authenticate the key to be installed

Verification index = 0


# Key to install

Target index = 2

File = "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate Data]

Verification index = 2

Blocks = 0x00907400 0x0 0x0ac00 "SPL"


# Create csf bin
bash> ./cst --o SPL_CSF.bin --i SPL.CSF

CSF Processed successfully and signed data available in SPL_CSF.bin

# Attach the 0x2000 pad
bash> objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 SPL_CSF.bin SPL_CSF_pad.bin

# Create signed SPL
bash> cat SPL SPL_CSF_pad.bin > SPL-signed
Generate U-Boot-IVT
bash> cd ~/cst-2.3.2/linux64

# Create csf
bash> cat u-boot-ivt.CSF

[Header]

Version = 4.1

Security Configuration = Open

Hash Algorithm = sha256

Engine Configuration = 0

Certificate Format = X509

Signature Format = CMS

Engine = CAAM


[Install SRK]

File = "../crts/SRK_1_2_3_4_table.bin"

Source index = 0


[Install CSFK]

File = "../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate CSF]


[Install Key]

# Key slot index used to authenticate the key to be installed

Verification index = 0


# Key to install

Target index = 2

File = "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"


[Authenticate Data]

Verification index = 2

Blocks = 0x177fffc0 0x0 0x00064020 "u-boot-ivt.img"


# Create csf bin
bash> ./cst --o u-boot-ivt_CSF.bin --i u-boot-ivt.CSF

CSF Processed successfully and signed data available in u-boot-ivt_CSF.bin

# Attach the 0x2000 pad
bash> objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 u-boot-ivt_CSF.bin u-boot-ivt_CSF_pad.bin

# Create signed U-Boot
bash> cat u-boot-ivt.img u-boot-ivt_CSF_pad.bin > u-boot-ivt-signed.img
Write on SD
bash> DEV=/dev/mmcblk0
bash> sudo dd if=/dev/zero of=$DEV count=1 bs=1M oflag=sync status=none && sync
bash> sudo dd if=SPL-signed of=$DEV bs=1K seek=1 oflag=sync status=none && sync
bash> sudo dd if=u-boot-ivt-signed.img of=$DEV bs=1K seek=69 oflag=sync status=none && sync
Read e-FUSE
bash> cd ~/cst-2.3.2/crts

bash> hexdump -e '/4 "0x"' -e '/4 "%X""\n"' < SRK_1_2_3_4_fuse.bin

0xBB64EF1F

0x7C21ED82

0x7D9E255A

0xD9D3A409

0x879E0CFB

0xB3D7202D

0xEC8D7223

0xEA226AAD
Write e-FUSE
U-Boot SPL 2017.05-00002-g5ab54f3 (Jul 04 2017 - 13:54:49)

>>spl:board_init_r()

spl_early_init()

Trying to boot from MMC1

spl: payload image: U-Bo load addr: 0x177fffc0 size: 417792

Jumping to U-Boot

loaded - jumping to U-Boot...

hab fuse not enabled


U-Boot 2017.05-00002-g5ab54f3 (Jul 04 2017 - 13:54:49 +0530)


CPU:   Freescale i.MX6SOLO rev1.3 at 792MHz

CPU:   Industrial temperature grade (-40C to 105C) at 38C

Reset cause: POR

Model: Engicam i.CoreM6 DualLite/Solo Starter Kit

DRAM:  256 MiB

MMC:   FSL_SDHC: 0

*** Warning - bad CRC, using default environment


No panel detected: default to Amp-WD

Display: Amp-WD (800x480)

In:    serial

Out:   serial

Err:   serial

Net:

Error: ethernet@02188000 address not set.

No ethernet found.

Hit any key to stop autoboot:  0

icorem6qdl> fuse prog -y 3 0 0xBB64EF1F

Programming bank 3 word 0x00000000 to 0xbb64ef1f...

icorem6qdl> fuse prog -y 3 1 0x7C21ED82

Programming bank 3 word 0x00000001 to 0x7c21ed82...

icorem6qdl> fuse prog -y 3 2 0x7D9E255A

Programming bank 3 word 0x00000002 to 0x7d9e255a...

icorem6qdl> fuse prog -y 3 3 0xD9D3A409

Programming bank 3 word 0x00000003 to 0xd9d3a409...

icorem6qdl> fuse prog -y 3 4 0x879E0CFB

Programming bank 3 word 0x00000004 to 0x879e0cfb...

icorem6qdl> fuse prog -y 3 5 0xB3D7202D

Programming bank 3 word 0x00000005 to 0xb3d7202d...

icorem6qdl> fuse prog -y 3 6 0xEC8D7223

Programming bank 3 word 0x00000006 to 0xec8d7223...

icorem6qdl> fuse prog -y 3 7 0xEA226AAD

Programming bank 3 word 0x00000007 to 0xea226aad...
Close device
icorem6qdl> hab_status

Secure boot disabled

HAB Configuration: 0xf0, HAB State: 0x66

No HAB Events Found!

icorem6qdl> fuse prog 0 6 0x2

Programming bank 0 word 0x00000006 to 0x00000002...

Warning: Programming fuses is an irreversible operation!

         This may brick your system.

         Use this command only if you are sure of what you are doing!


Really perform this fuse programming? <y/N>

y

icorem6qdl> reset

resetting ...


U-Boot SPL 2017.05-00002-g5ab54f3 (Jul 04 2017 - 13:54:49)

>>spl:board_init_r()

spl_early_init()

Trying to boot from MMC1

spl: payload image: U-Bo load addr: 0x177fffc0 size: 417792

Jumping to U-Boot

loaded - jumping to U-Boot...


Authenticate image from DDR location 0x177fffc0...


U-Boot 2017.05-00002-g5ab54f3 (Jul 04 2017 - 13:54:49 +0530)


CPU:   Freescale i.MX6SOLO rev1.3 at 792MHz

CPU:   Industrial temperature grade (-40C to 105C) at 60C

Reset cause: POR

Model: Engicam i.CoreM6 DualLite/Solo Starter Kit

DRAM:  256 MiB

MMC:   FSL_SDHC: 0

*** Warning - bad CRC, using default environment


No panel detected: default to Amp-WD

Display: Amp-WD (800x480)

In:    serial

Out:   serial

Err:   serial

Net:

Error: ethernet@02188000 address not set.

No ethernet found.

Hit any key to stop autoboot:  0

icorem6qdl> hab_status


Secure boot enabled


HAB Configuration: 0xcc, HAB State: 0x99

No HAB Events Found!
I.MX8MM Secure Boot using High Assurance Boot v4
Introduction

This tutorial describes the information and usage on how to secure boot i.MX8MM chipsets using HABv4. The platform used in this tutorial is an Engicam Ctouch 2.0 based on i.M8M Mini chipset.

This tutorial is an addon to an already existing i.MX6 Secure Boot tutorial. The boot process for i.MX 8M family (including i.MX 8MQ, i.MX 8M Mini, i.MX 8M Nano and i.MX 8M Plus) is little different compared to older i.MX6/7 platforms which will be outlined in this tutorial.

For practical purposes and to make this tutorial more understandable, i.MX8M Mini based CTouch2.0 carrier board is used.

Why Secure Boot

To prevent unauthorized software execution during the device boot sequence, there should be a mechanism and the HABv4 secure boot feature uses digital signatures to prevent unauthorized software execution. For instance if a malware takes control of the boot sequence, sensitive data, services and network can be impacted.

HABv4 Secure Boot Architecture

The i.MX family of applications processors provides the High Assurance Boot (HAB) feature in the on-chip ROM. The ROM is responsible for loading the initial program image (U-Boot) from the boot media and HAB enables the ROM to authenticate and/or decrypt the program image by using cryptography operations.

The main features supported by the HABv4 are:

  • Authentication of software loaded from any boot device supported, including the Serial Download Protocol (SDP).
  • Authenticated USB download fail-over on any security failure.
  • Interface with the SNVS to guarantee the system security state.
  • Initialization of security components.
  • X.509 public key certificate support.
  • CMS signature format support.
  • 1024, 2048, 3072, and 4096 bits RSA keys length support.
  • p256, p384, p521 ECC keys support.
  • SHA-256 message digest operations accelerated by hardware.
  • Manufacturing protection private key generation in supported devices.
  • Super Root Key (SRK) revocation support.
_images/secure_boot.png

Figure I: HABv4 Secure Boot architecture[I]

The above Figure 1 can be understood in two parts: Code signing part which does the signing of images. The authentication part which checks whether the image to be booted is not tampered and if the verification is successful the root of trust is passed to the next image to be booted.

_images/secure_boot1.png

Figure II: HABv4 Secure Boot flow[II]

HABv4 authentication is based on public key cryptography using the RSA or ECDSA algorithms in which image data(for instance u-boot binary) is signed offline using a series of private keys. The resulting signed image data is then verified on the i.MX8M processor using the corresponding public keys.

This key structure is known as a Public Key Infrastructure(PKI) tree. Super Root Keys, or SRK, are components of the PKI tree. HABv4 relies on a table of the public SRKs to be hashed and placed in fuses on the target.

The i.MX Code SigningTool (CST) is used in this guide to generate the HABv4 signatures for images using the PKI tree data and SRK table. On the target, HABv4 evaluates the SRK table included in the signature by hashing it and comparing the result to the SRK fuse values. If the SRK verification is successful, the root of trust is established, and the remainder of the signature can be processed to 1authenticate the image.

The U-Boot image to be programmed into the boot media needs to be properly constructed i.e. it must contain a proper Command Sequence File (CSF).

The CSF is a binary data structure interpreted by the HAB to guide authentication process, this is generated by the Code Signing Tool[1]. The CSF structure contains the commands, SRK table, signatures and certificates.

i.MX8M Boot Flow

The boot flow on i.MX 8M family devices are slightly different when compared with i.MX 6, i.MX 7 series device. The boot flow changes are due to the different architecture, multiple firmware and software components required to initialize the device[I].

_images/imx8mm_bootflow.png

Figure III: i.MX8M Boot Flow[I]

  • NOTE: for i.MX8M mini hdmi/dp firmware is not required in the boot process

On reset, ROM code reads the efuse to determine the security configuration of the SoC and the type of the boot device. The ROM then locates flash.bin, layout shown in Figure IV.

_images/imx8mm_flash.png

Figure IV: i.MX8M Boot Flow[I]

The above Figure shows 2 CSF binaries required, one per verification stage:

  • CSF SPL that is used by Boot ROM to authenticate SPL + DDR FW
  • CSF FIT that is used by SPL (through HAB APIs) to authenticate FIT components

The ROM code first reads the Image Vector Table(IVT) and identifies the CSF location. It verifies and loads Second Program Loader (SPL) and DDR firmware onto OCRAM. It verifies the authenticity of the SPL binary both in memory and flash against the signature embedded in the CSF. This can be seen as the first stage verification. If signature verification fails, execution is not allowed to leave the ROM for securely configured SoCs, also called “closed” devices.

For an open device (meaning the fuse related to configuring SOC is not yet programmed), even if signature verification fails one will be able to see HAB events which will tell the programmer if the image would pass the authentication process.

During Verification, HAB evaluates the SRK table included in the signature by hashing it and comparing the result to the SRK fuse values. If the SRK verification is successful, this establishes the root of trust, and the remainder of the signature can be processed to authenticate the image.

If it succeeds (or if the device is open), the ROM code goes loads and jumps to SPL. SPL initializes the clocks, PMIC, LPDDR4 and UART. SPl then loads and verifies the rest of the components using the HAB APIs to extend the root of trust.

A FIT image is used to package all the components rtequired for i.MX8M mini which are:

  • U-Boot binary + device tree blob (dtb)
  • ARM Trusted Firmware (ATF)
  • OP-TEE binary (TrustZone - optional)

Once the DDR is available, the SPL code verifies and loads all the images included in the FIT structure to their specific execution addresses. This is the second stage and if the verification succeeds, ATF is executed which will in turn execute U-Boot.

The HABv4 APIs can be used to extend the root of trust additionally tothe Linux Kernel and Cortex-M images and can be authenticated at bootloader level.

i.MX8M Signed Image
_images/image_flash_mem.png

The below procedure outlines on how signed secure boot has been created with Engicam i.CoreMX8M MINI CTouch2.0 board.

Download NXP Code Signing tool
$ git clone https://www.nxp.com/webapp/Download?colCode=IMX_CST_TOOL_NEW
$ tar xzf cst-3.3.1.tar.gz
$ cd cst-3.3.1/keys
Generate PKI tree (Private keys)

Create a serial file with an 8-digit content. OpenSSL uses the contents of this file for the certificate serial numbers.

Create key_pass.txt which contains your pass phrase that will protect the HAB code signing private keys.

$ echo "42424242" > serial

$ echo "Amarual357" > key_pass.txt
$ echo "Amarual357" >> key_pass.txt
$ ./hab4_pki_tree.sh


    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    This script is a part of the Code signing tools for Freescale's

    High Assurance Boot.  It generates a basic PKI tree.  The PKI

    tree consists of one or more Super Root Keys (SRK), with each

    SRK having two subordinate keys:

        + a Command Sequence File (CSF) key

        + Image key.

    Additional keys can be added to the PKI tree but a separate

    script is available for this.  This this script assumes openssl

    is installed on your system and is included in your search

    path.  Finally, the private keys generated are password

    protectedwith the password provided by the file key_pass.txt.

    The format of the file is the password repeated twice:

        my_password

        my_password

    All private keys in the PKI tree are in PKCS #8 format will be

    protected by the same password.


    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Do you want to use an existing CA key (y/n)?: n

Do you want to use Elliptic Curve Cryptography (y/n)?: n

Enter key length in bits for PKI tree: 2048

Enter PKI tree duration (years): 10

How many Super Root Keys should be generated? 4

Do you want the SRK certificates to have the CA flag set? (y/n)?: y

Private keys will generate on keys directory and corresponding Certificates are placed in the crts directory.

Generate SRK table (Public keys)
$ cd ../crts

$ ../linux64/bin/srktool \

> -h 4 \

> -t SRK_1_2_3_4_table.bin \

> -e SRK_1_2_3_4_fuse.bin \

> -d sha256 \

> -c ./SRK1_sha256_2048_65537_v3_ca_crt.pem,\

> ./SRK2_sha256_2048_65537_v3_ca_crt.pem,\

> ./SRK3_sha256_2048_65537_v3_ca_crt.pem,\

> ./SRK4_sha256_2048_65537_v3_ca_crt.pem

SRK_1_2_3_4_table.bin - SRK table contents with HAB data SRK_1_2_3_4_fuse.bin - contains SHA256 result to be burned to fuse

Build ARM Trusted firmware:
$ git clone https://source.codeaurora.org/external/imx/imx-atf -b  imx_4.19.35_1.0.0
$ make PLAT=imx8mm bl31
Get the ddr firmware
$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.0.bin
$ chmod +x firmware-imx-8.0.bin
$ ./firmware-imx-8.0
Build U-Boot with HAB enabled
u-boot> git clone https://github.com/sunielmahesh/u-boot-cam-imx.git -b imx_v2020.04_5.4.70_2.3.0

$ export ATF_LOAD_ADDR=0x920000
$ make imx8mm_ctouch_defconfig
$ make ARCH=arm menuconfig

enable CONFIG_IMX_HAB=y

$ make CROSS_COMPILE=aarch64-buildroot-linux-gnu- flash.bin V=1
Preparing the FIT Image

Download imx-mkimage tool and copy ATF, ddr binaries, u-boot-nodtb.bin u-boot-spl.bin and dtb files. After the process flash.bin is created.

$ git clone https://github.com/sunielmahesh/imx-mkimage-imx8mm.git
$ cd imx-mkimage-imx8mm/iMX8M
$ cp ~atf/build/imx8mm/release/bl31.bin ./
$ cp ~firmware-imx-8.0/firmware/ddr/synopsys/lpddr4*.bin ./
$ cp ~u-boot/u-boot-nodtb.bin ./
$ cp ~u-boot/arch/arm/dts/imx8mm-ctouch.dtb ./
$ cp ~u-boot/spl/u-boot-spl.bin ./
$ cp ~uboot/tools/mkimage ./mkimage_uboot

$ make SOC=iMX8MM flash_ctouch_spl_uboot

Compiling mkimage_imx8
PLAT=imx8mm HDMI=no
Compiling mkimage_imx8
cc -O2 -Wall -std=c99 -static mkimage_imx8.c -o mkimage_imx8 -lz
19802+0 records in
19802+0 records out
79208 bytes (79 kB, 77 KiB) copied, 0.0230843 s, 3.4 MB/s
./../scripts/pad_image.sh tee.bin
Pad file tee.bin NOT found
./../scripts/pad_image.sh bl31.bin
./../scripts/pad_image.sh u-boot-nodtb.bin ctouch.dtb
DEK_BLOB_LOAD_ADDR=0x40400000 TEE_LOAD_ADDR=0xbe000000 ATF_LOAD_ADDR=0x00920000 ./mkimage_fit_atf.sh ctouch.dtb > u-boot.its
bl31.bin size:
37216
u-boot-nodtb.bin size:
580784
ctouch.dtb size:
29936
./mkimage_uboot -E -p 0x3000 -f u-boot.its u-boot.itb
u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/uboot@1 has a unit name, but no reg property
u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/fdt@1 has a unit name, but no reg property
u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/atf@1 has a unit name, but no reg property
u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /configurations/config@1 has a unit name, but no reg property
FIT description: Configuration to load ATF before U-Boot
Created:         Sat Mar 13 02:04:05 2021
 Image 0 (uboot@1)
 Description:  U-Boot (64-bit)
 Created:      Sat Mar 13 02:04:05 2021
 Type:         Standalone Program
 Compression:  uncompressed
 Data Size:    580784 Bytes = 567.17 KiB = 0.55 MiB
 Architecture: AArch64
 Load Address: 0x40200000
 Entry Point:  unavailable
Image 1 (fdt@1)
 Description:  ctouch
 Created:      Sat Mar 13 02:04:05 2021
 Type:         Flat Device Tree
 Compression:  uncompressed
 Data Size:    29936 Bytes = 29.23 KiB = 0.03 MiB
 Architecture: Unknown Architecture
Image 2 (atf@1)
 Description:  ARM Trusted Firmware
 Created:      Sat Mar 13 02:04:05 2021
 Type:         Firmware
 Compression:  uncompressed
 Data Size:    37216 Bytes = 36.34 KiB = 0.04 MiB
 Architecture: AArch64
  OS:           Unknown OS
 Load Address: 0x00920000
 Default Configuration: 'config@1'
Configuration 0 (config@1)
 Description:  ctouch
 Kernel:       unavailable
 Firmware:     uboot@1
 FDT:          fdt@1
 Loadables:    atf@1
./mkimage_imx8 -version v1 -fit -loader u-boot-spl-ddr.bin 0x7E1000 -second_loader u-boot.itb 0x40200000 0x60000 -out flash.bin
Platform:       i.MX8M (mScale)
ROM VERSION:    v1
Using FIT image
LOADER IMAGE:   u-boot-spl-ddr.bin start addr: 0x007e1000
SECOND LOADER IMAGE:    u-boot.itb start addr: 0x40200000 offset: 0x00060000
Output:         flash.bin
========= IVT HEADER [HDMI FW] =========
header.tag:             0x0
header.length:          0x0
header.version:         0x0
entry:                  0x0
reserved1:              0x0
dcd_ptr:                0x0
boot_data_ptr:          0x0
self:                   0x0
csf:                    0x0
reserved2:              0x0
boot_data.start:        0x0
boot_data.size:         0x0
boot_data.plugin:       0x0
========= IVT HEADER [PLUGIN] =========
header.tag:             0x0
header.length:          0x0
header.version:         0x0
entry:                  0x0
reserved1:              0x0
dcd_ptr:                0x0
boot_data_ptr:          0x0
self:                   0x0
csf:                    0x0
reserved2:              0x0
boot_data.start:        0x0
boot_data.size:         0x0
boot_data.plugin:       0x0
========= IVT HEADER [LOADER IMAGE] =========
header.tag:             0xd1
header.length:          0x2000
header.version:         0x41
entry:                  0x7e1000
reserved1:              0x57c00
dcd_ptr:                0x0
boot_data_ptr:          0x7e0fe0
self:                   0x7e0fc0
csf:                    0x808bc0
reserved2:              0x0
boot_data.start:        0x7e0bc0
boot_data.size:         0x2a060
boot_data.plugin:       0x0
========= OFFSET dump =========
Loader IMAGE:
header_image_off       0x0
dcd_off                0x0
image_off              0x40
csf_off                0x27c00
spl hab block:         0x7e0fc0 0x0 0x27c00

Second Loader IMAGE:
sld_header_off         0x57c00
sld_csf_off            0x58c20
sld hab block:         0x401fcdc0 0x57c00 0x1020
Creating the CSF description files

The CSF description file sample is provided at u-boot/doc/imx/habv4/csf_examples

There are two files since we have two stage bootloader, csf_spl.txt and csf_fit.txt. Create a directory csf and copy both the files from u-boot/doc/imx/habv4/csf_examples.

For csf_spl.txt, in the Authenticate Data section replace Blocks with spl hab block content above:

Blocks = 0x7e0fc0 0x0 0x27c00 "flash.bin"

Adjust necessary paths.

For csf_fit.txt, in the Authenticate Data section replace the first line in Blocks with sld hab block content above and the next three lines by the output provided by the below command:

imx-mkimage$ make SOC=iMX8MM print_fit_hab
./../scripts/dtb_check.sh imx8mm-ctouch.dtb ctouch.dtb
Use u-boot DTB: imx8mm-ctouch.dtb
./../scripts/pad_image.sh tee.bin
Pad file tee.bin NOT found
./../scripts/pad_image.sh bl31.bin
./../scripts/pad_image.sh u-boot-nodtb.bin ctouch.dtb
u-boot-nodtb.bin + ctouch.dtb are padded to 610720
TEE_LOAD_ADDR=0xbe000000 ATF_LOAD_ADDR=0x00920000 VERSION=v1 ./print_fit_hab.sh 0x60000 ctouch.dtb
0x40200000 0x5AC00 0x8DCB0
0x4028DCB0 0xE88B0 0x74F0
0x920000 0xEFDA0 0x9160

The resulting Authenticate Data section in csf_fit.txt should be:

Blocks = 0x401fcdc0 0x57c00 0x01020 "flash.bin", \
             0x40200000 0x5AC00 0x8DCB0 "flash.bin", \
             0x4028DCB0 0xE88B0 0x074F0 "flash.bin", \
             0x00920000 0xEFDA0 0x09160 "flash.bin"

Adjust necessary paths in both csf_spl.txt and csf_fit.txt.

Signing and Asembling the flash.bin binary
csf$ ../cst-3.3.1/linux64/bin/cst -i csf_spl.txt -o csf_spl.bin
Install SRK
Install CSFK
Authenticate CSF
Install key
Authenticate data
CSF Processed successfully and signed data available in csf_spl.bin

csf$ ../cst-3.3.1/linux64/bin/cst -i csf_fit.txt -o csf_fit.bin
Install SRK
Install CSFK
Authenticate CSF
Install key
Authenticate data
CSF Processed successfully and signed data available in csf_fit.bin

csf$ copy flash.bin from imx-mkimage/IMX8M to csf directory
csf$ cp flash.bin signed_flash.bin

csf$ dd if=csf_spl.bin of=signed_flash.bin seek=$((0x27c00)) bs=1 conv=notrunc
the seek above is csf_off

csf$ dd if=csf_fit.bin of=signed_flash.bin seek=$((0x58c20)) bs=1 conv=notrunc
the seek above is sld_csf_off
Flashing and Power on:

Flash signed_flash.bin onto SD card and power-on the board

$ sudo dd if=signed_flash.bin of=/dev/sdX bs=1024 seek=33
$ sync

U-Boot SPL 2020.04-00035-g7807920922 (Mar 12 2021 - 22:25:59 +0530)
Can't find PMIC:PCA9450
DDRINFO: start DRAM init
DDRINFO: DRAM rate 3000MTS
DDRINFO:ddrphy calibration done
DDRINFO: ddrmix config done
Normal Boot
Trying to boot from MMC1
hab fuse not enabled

Authenticate image from DDR location 0x401fcdc0...


U-Boot 2020.04-00035-g7807920922 (Mar 12 2021 - 22:25:59 +0530)

CPU:   i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 38C
Reset cause: POR
Model: Engicam i.Core MX8M Mini C.TOUCH 2.0
DRAM:  2 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 2
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial

 BuildInfo:
  - ATF da29a16
  - U-Boot 2020.04-00035-g7807920922

switch to partitions #0, OK
mmc0 is current device
Net:
Error: ethernet@30be0000 address not set.

Error: ethernet@30be0000 address not set.
No ethernet found.

Normal Boot
Hit any key to stop autoboot:  0
u-boot=>
u-boot=>
u-boot=>
u-boot=> hab_status

Secure boot disabled

HAB Configuration: 0xf0, HAB State: 0x66
No HAB Events Found!

The above is the bootlog and hab status doesnt show any HAB events meaning the signed images generated are as per procedure and each stage has verified the other successsully without any errors.

Programming e-fuse with SRK Hash
efuse dump

$ cd ../crts

$ hexdump -e '/4 "0x"' -e '/4 "%X""\n"' < ../cst-3.3.1/crts/SRK_1_2_3_4_fuse.bin
0x44DF5F5B
0xF82E1DA5
0x4DEC9AC4
0x8D48E35C
0x7D33FEC0
0xD267E7B6
0xF80E67B4
0xF69365A3

The fuse table generated in the above process is what needs to be flashed to the device. U-Boot fuse command can be used for programming eFuses.

Once the eFuses are programmed check for any errors using hab_status command. If there are no HAB events then we can close the device implies Secure Boot is enabled.

References

Sandbox

Sandbox is good example to familiar with U-Boot and related functionalities.

Build
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make sandbox_defconfig all NO_SDL=1
Run
$ ./u-boot

U-Boot 2017.09-00364-g05eb54a-dirty (Oct 04 2017 - 23:12:50 +0530)


DRAM:  128 MiB

MMC:

Using default environment


In:    serial

Out:   serial

Err:   serial

SCSI:  Net:   No ethernet found.

IDE:   Bus 0: not available

=> bdinfo

boot_params = 0x00000000

DRAM bank   = 0x00000000

-> start    = 0x00000000

-> size     = 0x08000000

ethaddr     = 00:00:11:22:33:44

IP addr     = 1.2.3.4

With Sandbox approach, we can further emulate the SPI, Disk, I2C etc., See board/sandbox/README.sandbox for more details.

Test

Sandbox drivers can be available in each peripheral area for basic sanity, below is the procedure to test the same.

Configure
$ cd /path/to/u-boot
$ sudo apt-get install python python-virtualenv
$ virtualenv venv
$ . ./venv/bin/activate
$ pip install pytest

To test sandbox

$ ./test/py/test.py --bd sandbox --build

To test driver model test in sandbox

$ ./test/py/test.py --bd sandbox --build -k ut_dm

U-BOOT Watchdog and Redundant Boot

Watchdog Testing
Testing via Linux kernel crash

introduce a BUG() somewhere in kernel code path Kernel Crash causing code

--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -695,6 +695,8 @@ static void __init build_mem_type_table(void)
        pr_info("Memory policy: %sData cache %s\n",
                ecc_mask ? "ECC enabled, " : "", cp->policy);

+       BUG();
+
        for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
                struct mem_type *t = &mem_types[i];
                if (t->prot_l1)
Testing via invalid Rootfs device mounting

Pass invalid rootfs device in kernel boot arguments from u-boot

setenv bootargs console=${console},${baudrate} root=/dev/invalid_device rootwait rw
Testing via U-BOOT command prompt

Use invalid load address

ext4load mmc 0:1 0x400000000 zImage
Redundant Boot
Steps
Step1. Enable hardware watchdog
Step2. Enable Bootcount, bootlimit and related variables
Step3. Add altbootcmd for recovery or redundant boot. Incase of failure of default boot altbootcmd
       would be used after bootcount exceeds configured value of bootlimit


For Example see imx6qdl_icore_mmc_defconfig use.
Here is the demo log. See altbootcmd in the logs
U-Boot SPL 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)
Trying to boot from MMC1
Expected Linux image is not found. Trying to start U-boot


U-Boot 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)

CPU:   Freescale i.MX6Q rev1.2 at 792MHz
CPU:   Industrial temperature grade (-40C to 105C) at 23C
Reset cause: POR
Model: Engicam i.CoreM6 Quad/Dual Starter Kit
       Watchdog enabled
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to Amp-WD
Display: Amp-WD (800x480)
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:
Error: ethernet@02188000 address not set.
eth-1: ethernet@02188000
Hit any key to stop autoboot:  0
Booting from mmc ...
** Unrecognized filesystem type **
** Unrecognized filesystem type **
** Unrecognized filesystem type **
icorem6qdl> setenv mycmd 'run mmcargs; ext2load mmc 0:1 ${loadaddr} ${image} ; ext2load mmc 0:1 ${fdt_addr} ${fdt_file}; bootm ${loada'
icorem6qdl> run mycmd
8932424 bytes read in 463 ms (18.4 MiB/s)
37834 bytes read in 10 ms (3.6 MiB/s)
## Booting kernel from Legacy Image at 12000000 ...
   Image Name:   Linux-5.0.0-rc3-00053-g333478a7e
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8932360 Bytes = 8.5 MiB
   Load Address: 10008000
   Entry Point:  10008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Using Device Tree in place at 18000000, end 1800c3c9

Starting kernel ...


U-Boot SPL 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)
Trying to boot from MMC1
Expected Linux image is not found. Trying to start U-boot


U-Boot 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)

CPU:   Freescale i.MX6Q rev1.2 at 792MHz
CPU:   Industrial temperature grade (-40C to 105C) at 44C
Reset cause: WDOG
Model: Engicam i.CoreM6 Quad/Dual Starter Kit
       Watchdog enabled
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to Amp-WD
Display: Amp-WD (800x480)
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:
Error: ethernet@02188000 address not set.
eth-1: ethernet@02188000
Hit any key to stop autoboot:  0
Booting from mmc ...
** Unrecognized filesystem type **
** Unrecognized filesystem type **
** Unrecognized filesystem type **
icorem6qdl> setenv mycmd 'run mmcargs; ext2load mmc 0:1 ${loadaddr} ${image} ; ext2load mmc 0:1 ${fdt_addr} ${fdt_file}; bootm ${loada'
icorem6qdl> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
icorem6qdl> run mycmd
8932424 bytes read in 465 ms (18.3 MiB/s)
37834 bytes read in 10 ms (3.6 MiB/s)
## Booting kernel from Legacy Image at 12000000 ...
   Image Name:   Linux-5.0.0-rc3-00053-g333478a7e
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8932360 Bytes = 8.5 MiB
   Load Address: 10008000
   Entry Point:  10008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Using Device Tree in place at 18000000, end 1800c3c9

Starting kernel ...


U-Boot SPL 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)
Trying to boot from MMC1
Expected Linux image is not found. Trying to start U-boot


U-Boot 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)

CPU:   Freescale i.MX6Q rev1.2 at 792MHz
CPU:   Industrial temperature grade (-40C to 105C) at 48C
Reset cause: WDOG
Model: Engicam i.CoreM6 Quad/Dual Starter Kit
       Watchdog enabled
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Loading Environment from MMC... OK
No panel detected: default to Amp-WD
Display: Amp-WD (800x480)
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:
Error: ethernet@02188000 address not set.
eth-1: ethernet@02188000
Hit any key to stop autoboot:  0
Booting from mmc ...
** Unrecognized filesystem type **
** Unrecognized filesystem type **
** Unrecognized filesystem type **
icorem6qdl> run m
  mmcargs mmcautodetect mmcboot mmcdev mmcpart mmcroot modeboot mycmd
icorem6qdl> run mycmd
8932424 bytes read in 463 ms (18.4 MiB/s)
37834 bytes read in 10 ms (3.6 MiB/s)
## Booting kernel from Legacy Image at 12000000 ...
   Image Name:   Linux-5.0.0-rc3-00053-g333478a7e
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8932360 Bytes = 8.5 MiB
   Load Address: 10008000
   Entry Point:  10008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Using Device Tree in place at 18000000, end 1800c3c9

Starting kernel ...


U-Boot SPL 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)
Trying to boot from MMC1
Expected Linux image is not found. Trying to start U-boot


U-Boot 2019.01-00357-gc9632fd11e10-dirty (Feb 06 2019 - 12:35:24 +0530)

CPU:   Freescale i.MX6Q rev1.2 at 792MHz
CPU:   Industrial temperature grade (-40C to 105C) at 52C
Reset cause: WDOG
Model: Engicam i.CoreM6 Quad/Dual Starter Kit
       Watchdog enabled
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Loading Environment from MMC... OK
No panel detected: default to Amp-WD
Display: Amp-WD (800x480)
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:
Error: ethernet@02188000 address not set.
eth-1: ethernet@02188000
\*\* Warning: Bootlimit (3) exceeded. Using altbootcmd. \*\*
Hit any key to stop autoboot:  0
Recovery Boot from mmc ...
8931720 bytes read in 459 ms (18.6 MiB/s)
37834 bytes read in 10 ms (3.6 MiB/s)
## Booting kernel from Legacy Image at 12000000 ...
   Image Name:   Linux-5.0.0-rc3-00055-gcfeb525f4
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8931656 Bytes = 8.5 MiB
   Load Address: 10008000
   Entry Point:  10008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Using Device Tree in place at 18000000, end 1800c3c9

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.0.0-rc3-00055-gcfeb525f403f-dirty (shyam@debian) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) 9
[    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Engicam i.CoreM6 Quad/Dual Starter Kit
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 64 MiB at 0x2c000000
[    0.000000] random: get_random_bytes called from start_kernel+0x8c/0x478 with crng_init=0
[    0.000000] percpu: Embedded 18 pages/cpu @(ptrval) s42088 r8192 d23448 u73728
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttymxc3,115200 root=/dev/mmcblk0p2 rootwait rw
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 427728K/524288K available (11264K kernel code, 931K rwdata, 3928K rodata, 1024K init, 7588K bss, 31024K reserve)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (12256 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 932 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   (7589 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] Running RCU self tests
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU lockdep checking is enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] L2C-310 errata 752271 769419 enabled
[    0.000000] L2C-310 enabling early BRESP for Cortex-A9
[    0.000000] L2C-310 full line of zeros enabled for Cortex-A9
[    0.000000] L2C-310 ID prefetch enabled, offset 16 lines
[    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
[    0.000000] L2C-310 cache controller enabled, 16 ways, 1024 kB
[    0.000000] L2C-310: CACHE_ID 0x410000c7, AUX_CTRL 0x76470001
[    0.000000] Switching to timer-based delay loop, resolution 333ns
[    0.000008] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
[    0.000036] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
[    0.001504] Console: colour dummy device 80x30
[    0.001546] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.001564] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.001580] ... MAX_LOCK_DEPTH:          48
[    0.001597] ... MAX_LOCKDEP_KEYS:        8191
[    0.001613] ... CLASSHASH_SIZE:          4096
[    0.001628] ... MAX_LOCKDEP_ENTRIES:     32768
[    0.001644] ... MAX_LOCKDEP_CHAINS:      65536
[    0.001660] ... CHAINHASH_SIZE:          32768
[    0.001676]  memory used by lock dependency info: 4591 kB
[    0.001692]  per task-struct memory footprint: 1536 bytes
[    0.001779] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
[    0.001808] pid_max: default: 32768 minimum: 301
[    0.002147] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.002179] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.004573] CPU: Testing write buffer coherency: ok
[    0.004655] CPU0: Spectre v2: using BPIALL workaround
[    0.005873] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.008041] Setting up static identity map for 0x10100000 - 0x10100078
[    0.008575] rcu: Hierarchical SRCU implementation.
[    0.010759] smp: Bringing up secondary CPUs ...
[    0.013085] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.013095] CPU1: Spectre v2: using BPIALL workaround
[    0.015688] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[    0.015698] CPU2: Spectre v2: using BPIALL workaround
[    0.017734] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[    0.017744] CPU3: Spectre v2: using BPIALL workaround
[    0.018117] smp: Brought up 1 node, 4 CPUs
[    0.018142] SMP: Total of 4 processors activated (24.00 BogoMIPS).
[    0.018161] CPU: All CPU(s) started in SVC mode.
[    0.021099] devtmpfs: initialized
[    0.044521] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.046699] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.046764] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    0.050710] pinctrl core: initialized pinctrl subsystem
[    0.055218] NET: Registered protocol family 16
[    0.076855] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.079993] cpuidle: using governor menu
[    0.080245] CPU identified as i.MX6Q, silicon rev 1.2
[    0.098164] vdd1p1: supplied by regulator-dummy
[    0.099863] vdd3p0: supplied by regulator-dummy
[    0.101079] vdd2p5: supplied by regulator-dummy
[    0.102258] vddarm: supplied by regulator-dummy
[    0.103531] vddpu: supplied by regulator-dummy
[    0.104724] vddsoc: supplied by regulator-dummy
[    0.126853] No ATAGs?
[    0.127298] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.127409] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.130289] imx6q-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
[    0.191353] mxs-dma 110000.dma-apbh: initialized
[    0.198047] vgaarb: loaded
[    0.199043] SCSI subsystem initialized
[    0.200375] usbcore: registered new interface driver usbfs
[    0.200583] usbcore: registered new interface driver hub
[    0.200814] usbcore: registered new device driver usb
[    0.201111] usb_phy_generic usbphynop1: usbphynop1 supply vcc not found, using dummy regulator
[    0.201505] usb_phy_generic usbphynop1: Linked as a consumer to regulator.0
[    0.201911] usb_phy_generic usbphynop2: usbphynop2 supply vcc not found, using dummy regulator
[    0.202112] usb_phy_generic usbphynop2: Linked as a consumer to regulator.0
[    0.205384] i2c i2c-0: IMX I2C adapter registered
[    0.205425] i2c i2c-0: can't use DMA, using PIO instead.
[    0.206623] i2c i2c-1: IMX I2C adapter registered
[    0.206659] i2c i2c-1: can't use DMA, using PIO instead.
[    0.207878] i2c i2c-2: IMX I2C adapter registered
[    0.207917] i2c i2c-2: can't use DMA, using PIO instead.
[    0.208201] media: Linux media interface: v0.10
[    0.208305] videodev: Linux video capture interface: v2.00
[    0.208742] pps_core: LinuxPPS API ver. 1 registered
[    0.208764] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.208821] PTP clock support registered
[    0.209711] Advanced Linux Sound Architecture Driver Initialized.
[    0.212954] Bluetooth: Core ver 2.22
[    0.213058] NET: Registered protocol family 31
[    0.213079] Bluetooth: HCI device and connection manager initialized
[    0.213186] Bluetooth: HCI socket layer initialized
[    0.213223] Bluetooth: L2CAP socket layer initialized
[    0.213356] Bluetooth: SCO socket layer initialized
[    0.215407] clocksource: Switched to clocksource mxc_timer1
[    0.774786] VFS: Disk quotas dquot_6.6.0
[    0.774955] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.801135] NET: Registered protocol family 2
[    0.803249] tcp_listen_portaddr_hash hash table entries: 256 (order: 1, 10240 bytes)
[    0.803328] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.803426] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)
[    0.804005] TCP: Hash tables configured (established 4096 bind 4096)
[    0.804485] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    0.804606] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    0.805075] NET: Registered protocol family 1
[    0.807225] RPC: Registered named UNIX socket transport module.
[    0.807305] RPC: Registered udp transport module.
[    0.807327] RPC: Registered tcp transport module.
[    0.807346] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.810042] hw perfevents: no interrupt-affinity property for /pmu, guessing.
[    0.810684] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
[    0.814986] Initialise system trusted keyrings
[    0.815833] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.832211] NFS: Registering the id_resolver key type
[    0.832357] Key type id_resolver registered
[    0.832439] Key type id_legacy registered
[    0.832610] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    0.833999] fuse init (API version 7.28)
[    0.859230] Key type asymmetric registered
[    0.859370] Asymmetric key parser 'x509' registered
[    0.859549] io scheduler mq-deadline registered
[    0.859576] io scheduler kyber registered
[    0.866067] pwm-backlight backlight-lvds: backlight-lvds supply power not found, using dummy regulator
[    0.866303] pwm-backlight backlight-lvds: Linked as a consumer to regulator.0
[    0.872051] imx-sdma 20ec000.sdma: Direct firmware load for imx/sdma/sdma-imx6q.bin failed with error -2
[    0.872154] imx-sdma 20ec000.sdma: Falling back to syfs fallback for: imx/sdma/sdma-imx6q.bin
[    0.880744] imx-pgc-pd imx-pgc-power-domain.0: DMA mask not set
[    0.881134] imx-pgc-pd imx-pgc-power-domain.0: Linked as a consumer to 20dc000.gpc
[    0.881266] imx-pgc-pd imx-pgc-power-domain.1: DMA mask not set
[    0.881554] imx-pgc-pd imx-pgc-power-domain.1: Linked as a consumer to regulator.5
[    0.881947] PU : no governor for states
[    0.881998] imx-pgc-pd imx-pgc-power-domain.1: Linked as a consumer to 20dc000.gpc
[    0.885223] 21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 67, base_baud = 5000000) is a IMX
[    1.810837] printk: console [ttymxc3] enabled
[    1.836668] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops)
[    1.842877] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops)
[    1.849055] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops)
[    1.854749] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108
[    1.876268] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007
[    1.897970] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215
[    1.904099] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0
[    1.912886] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0
[    1.923751] imx-ipuv3 2400000.ipu: IPUv3H probed
[    1.931085] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.937832] [drm] No driver support for vblank timestamp query.
[    1.945181] imx-drm display-subsystem: bound imx-ipuv3-crtc.2 (ops ipu_crtc_ops)
[    1.952935] imx-drm display-subsystem: bound imx-ipuv3-crtc.3 (ops ipu_crtc_ops)
[    1.960684] imx-drm display-subsystem: bound imx-ipuv3-crtc.6 (ops ipu_crtc_ops)
[    1.968408] imx-drm display-subsystem: bound imx-ipuv3-crtc.7 (ops ipu_crtc_ops)
[    1.976921] imx-drm display-subsystem: bound ldb (ops imx_ldb_ops)
[    1.985330] [drm] Initialized imx-drm 1.0.0 20120507 for display-subsystem on minor 1
[    2.056674] Console: switching to colour frame buffer device 100x30
[    2.075519] imx-drm display-subsystem: fb0: DRM emulated frame buffer device
[    2.083101] imx-ipuv3 2800000.ipu: IPUv3H probed
[    2.110558] brd: module loaded
[    2.142326] loop: module loaded
[    2.165809] random: fast init done
[    2.171104] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xdc
[    2.177542] nand: Micron MT29F4G08ABAEAH4
[    2.181575] nand: 512 MiB, SLC, erase size: 256 KiB, page size: 4096, OOB size: 224
[    2.191704] Bad block table found at page 131008, version 0x01
[    2.198203] Bad block table found at page 130944, version 0x01
[    2.210939] gpmi-nand 112000.gpmi-nand: driver registered.
[    2.220473] libphy: Fixed MDIO Bus: probed
[    2.225909] CAN device driver interface
[    2.230367] flexcan 2090000.flexcan: Linked as a consumer to regulator.9
[    2.238724] flexcan 2090000.flexcan: device registered (reg_base=(ptrval), irq=30)
[    2.246863] flexcan 2094000.flexcan: Linked as a consumer to regulator.9
[    2.254876] flexcan 2094000.flexcan: device registered (reg_base=(ptrval), irq=31)
[    2.264681] fec 2188000.ethernet: 2188000.ethernet supply phy not found, using dummy regulator
[    2.273612] fec 2188000.ethernet: Linked as a consumer to regulator.0
[    2.284032] pps pps0: new PPS source ptp0
[    2.289205] fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
[    2.299213] fec 2188000.ethernet (unnamed net_device) (uninitialized): Using random MAC address: 8e:87:3f:4d:42:ea
[    2.317041] libphy: fec_enet_mii_bus: probed
[    2.322321] fec 2188000.ethernet eth0: registered PHC device 0
[    2.329728] usbcore: registered new interface driver r8152
[    2.335322] usbcore: registered new interface driver lan78xx
[    2.341164] usbcore: registered new interface driver asix
[    2.346720] usbcore: registered new interface driver ax88179_178a
[    2.352920] usbcore: registered new interface driver cdc_ether
[    2.358927] usbcore: registered new interface driver smsc95xx
[    2.364771] usbcore: registered new interface driver net1080
[    2.370572] usbcore: registered new interface driver cdc_subset
[    2.376640] usbcore: registered new interface driver zaurus
[    2.382317] usbcore: registered new interface driver MOSCHIP usb-ethernet driver
[    2.389903] usbcore: registered new interface driver cdc_ncm
[    2.395633] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    2.402179] ehci-pci: EHCI PCI platform driver
[    2.406770] ehci-mxc: Freescale On-Chip EHCI Host driver
[    2.412807] usbcore: registered new interface driver usb-storage
[    2.422221] imx_usb 2184000.usb: Linked as a consumer to regulator.11
[    2.435459] ci_hdrc ci_hdrc.0: EHCI Host Controller
[    2.440653] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[    2.475472] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[    2.482127] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.00
[    2.490622] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.497918] usb usb1: Product: EHCI Host Controller
[    2.502818] usb usb1: Manufacturer: Linux 5.0.0-rc3-00055-gcfeb525f403f-dirty ehci_hcd
[    2.510795] usb usb1: SerialNumber: ci_hdrc.0
[    2.518141] hub 1-0:1.0: USB hub found
[    2.522161] hub 1-0:1.0: 1 port detected
[    2.529858] imx_usb 2184200.usb: Linked as a consumer to regulator.10
[    2.540605] ci_hdrc ci_hdrc.1: EHCI Host Controller
[    2.545615] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2
[    2.575437] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
[    2.581377] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.00
[    2.589739] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.597041] usb usb2: Product: EHCI Host Controller
[    2.601942] usb usb2: Manufacturer: Linux 5.0.0-rc3-00055-gcfeb525f403f-dirty ehci_hcd
[    2.609931] usb usb2: SerialNumber: ci_hdrc.1
[    2.615644] hub 2-0:1.0: USB hub found
[    2.619510] hub 2-0:1.0: 1 port detected
[    2.633709] input: max11801_ts as /devices/soc0/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-0048/input/input0
[    2.651584] snvs_rtc 20cc000.snvs:snvs-rtc-lp: registered as rtc0
[    2.658056] i2c /dev entries driver
[    2.670660] imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
[    2.677260] Bluetooth: HCI UART driver ver 2.3
[    2.681731] Bluetooth: HCI UART protocol H4 registered
[    2.687381] Bluetooth: HCI UART protocol LL registered
[    2.693884] sdhci: Secure Digital Host Controller Interface driver
[    2.700145] sdhci: Copyright(c) Pierre Ossman
[    2.704521] sdhci-pltfm: SDHCI platform and OF driver helper
[    2.711506] sdhci-esdhc-imx 2190000.usdhc: Got CD GPIO
[    2.753031] mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
[    2.767363] caam 2100000.caam: Entropy delay = 3200
[    2.772382] caam 2100000.caam: Instantiated RNG4 SH0
[    2.833144] caam 2100000.caam: Instantiated RNG4 SH1
[    2.838177] caam 2100000.caam: device ID = 0x0a16010000000000 (Era 4)
[    2.844640] caam 2100000.caam: job rings = 2, qi = 0
[    2.882755] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.892941] caam algorithms registered in /proc/crypto
[    2.901530] mmc0: new high speed SDHC card at address aaaa
[    2.908475] caam_jr 2101000.jr0: registering rng-caam
[    2.911092] mmcblk0: mmc0:aaaa SS08G 7.40 GiB
[    2.915632] usbcore: registered new interface driver usbhid
[    2.923794] usbhid: USB HID core driver
[    2.927955]  mmcblk0: p1 p2
[    2.933263] imx-media: subdev ipu1_vdic bound
[    2.937996] imx-media: subdev ipu2_vdic bound
[    2.942764] imx-media: subdev ipu1_ic_prp bound
[    2.948688] ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video0
[    2.956126] imx-media: subdev ipu1_ic_prpenc bound
[    2.961451] ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video1
[    2.968525] imx-media: subdev ipu1_ic_prpvf bound
[    2.973390] imx-media: subdev ipu2_ic_prp bound
[    2.978481] ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video2
[    2.985679] imx-media: subdev ipu2_ic_prpenc bound
[    2.990989] ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video3
[    2.997993] imx-media: subdev ipu2_ic_prpvf bound
[    3.004315] ipu1_csi0: Registered ipu1_csi0 capture as /dev/video4
[    3.005488] usb 2-1: new high-speed USB device number 2 using ci_hdrc
[    3.010585] imx-media: subdev ipu1_csi0 bound
[    3.021738] imx-ipuv3 2400000.ipu: driver could not parse port@1/endpoint@0 (-22)
[    3.029581] imx-ipuv3-csi: probe of imx-ipuv3-csi.1 failed with error -22
[    3.036639] imx-ipuv3 2800000.ipu: driver could not parse port@0/endpoint@0 (-22)
[    3.044202] imx-ipuv3-csi: probe of imx-ipuv3-csi.4 failed with error -22
[    3.051842] ipu2_csi1: Registered ipu2_csi1 capture as /dev/video5
[    3.058116] imx-media: subdev ipu2_csi1 bound
[    3.070591] sgtl5000 2-000a: Linked as a consumer to regulator.7
[    3.077157] sgtl5000 2-000a: Dropping the link to regulator.7
[    3.083902] sgtl5000 2-000a: Linked as a consumer to regulator.8
[    3.090251] sgtl5000 2-000a: Linked as a consumer to regulator.9
[    3.097285] sgtl5000 2-000a: Linked as a consumer to regulator.7
[    3.104665] sgtl5000 2-000a: Error reading chip id -6
[    3.110044] sgtl5000 2-000a: Dropping the link to regulator.8
[    3.116653] sgtl5000 2-000a: Dropping the link to regulator.9
[    3.122627] sgtl5000 2-000a: Dropping the link to regulator.7
[    3.134079] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    3.147485] NET: Registered protocol family 10
[    3.155610] Segment Routing with IPv6
[    3.159514] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    3.167454] NET: Registered protocol family 17
[    3.171951] can: controller area network core (rev 20170425 abi 9)
[    3.178404] NET: Registered protocol family 29
[    3.182941] can: raw protocol (rev 20170425)
[    3.187399] can: broadcast manager protocol (rev 20170425 t)
[    3.193101] can: netlink gateway (rev 20170425) max_hops=1
[    3.199045] Key type dns_resolver registered
[    3.205418] cpu cpu0: Linked as a consumer to regulator.4
[    3.211047] cpu cpu0: Linked as a consumer to regulator.5
[    3.216726] cpu cpu0: Linked as a consumer to regulator.6
[    3.227044] usb 2-1: New USB device found, idVendor=0424, idProduct=2514, bcdDevice= b.b3
[    3.227450] Registering SWP/SWPB emulation handler
[    3.235528] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.241787] Loading compiled-in X.509 certificates
[    3.249392] hub 2-1:1.0: USB hub found
[    3.256644] hub 2-1:1.0: 4 ports detected
[    3.328359] imx_thermal tempmon: Industrial CPU temperature grade - max:105C critical:100C passive:95C
[    3.343738] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01T00:00:00 UTC (0)
[    3.353184] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    3.366857] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    3.374891] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    3.375477] ALSA device list:
[    3.383687] platform regulatory.0: Falling back to syfs fallback for: regulatory.db
[    3.386727]   No soundcards found.
[    3.428373] EXT4-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommended
[    3.445686] EXT4-fs (mmcblk0p2): mounted filesystem without journal. Opts: (null)
[    3.453314] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    3.472516] devtmpfs: mounted
[    3.479006] Freeing unused kernel memory: 1024K
[    3.506235] Run /sbin/init as init process
mount: mounting proc on /proc failed: No such file or directory
mount: can't read '/proc/mounts': No such file or directory
mount: mounting proc on /proc failed: No such file or directory
mount: mounting tmpfs on /tmp failed: No such file or directory
mount: mounting sysfs on /sys failed: No such file or directory
Starting logging: OK
Jan  1 00:00:03 buildroot syslog.info syslogd started: BusyBox v1.27.2
Jan  1 00:00:03 buildroot kern.notice kernel: klogd started: BusyBox v1.27.2 (2017-10-05 13:33:52 IST)
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Booting Linux on physical CPU 0x0
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000] Linux version 5.0.0-rc3-00055-gcfeb525f403f-dirty (shyam@debian) (gcc ver9
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] OF: fdt: Machine model: Engicam i.CoreM6 Quad/Dual Starter Kit
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Memory policy: Data cache writealloc
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] cma: Reserved 64 MiB at 0x2c000000
Jan  1 00:00:03 buildroot kern.debug kernel: [    0.000000] On node 0 totalpages: 131072
Jan  1 00:00:03 buildroot kern.debug kernel: [    0.000000]   Normal zone: 1024 pages used for memmap
Jan  1 00:00:03 buildroot kern.debug kernel: [    0.000000]   Normal zone: 0 pages reserved
Jan  1 00:00:03 buildroot kern.debug kernel: [    0.000000]   Normal zone: 131072 pages, LIFO batch:31
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000] random: get_random_bytes called from start_kernel+0x8c/0x478 with crng_in0
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] percpu: Embedded 18 pages/cpu @(ptrval) s42088 r8192 d23448 u73728
Jan  1 00:00:03 buildroot kern.debug kernel: [    0.000000] pcpu-alloc: s42088 r8192 d23448 u73728 alloc=18*4096
Jan  1 00:00:03 buildroot kern.debug kernel: [    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000] Kernel command line: console=ttymxc3,115200 root=/dev/mmcblk0p2 rootwait w
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Memory: 427728K/524288K available (11264K kernel code, 931K rwdata, 3928K r)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000] Virtual kernel memory layout:
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (12256 kB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 932 kB)
Jan  1 00:00:03 buildroot kern.notice kernel: [    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   (7589 kB)
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] Running RCU self tests
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] rcu: Hierarchical RCU implementation.
Jan  1 00:00:03 buildroot kern.info kernel: [    0.000000] rcu:         RCU event tracing is enabled.
Jan  1 00:00:03 buildroot kern.info Jan  1 00:00:03 buildroot kern.wJan  1 00:00:03 buildroot kern.iJan  1 00:00:03 buildroot kern.iJa)
done.
Jan  1 00:00:04 buildroot kern.notice kernel: [    4.200491] random: dd: uninitialized urandom read (512 bytes read)
Starting network: OK
Jan  1 00:00:04 buildroot daemon.info : starting pid 261, tty '/dev/ttymxc3': '/sbin/getty -L  ttymxc3 0 vt100 '

Welcome to Engicam i.CoreM6 Quad/Dual/DualLite/Solo Starter Kit
buildroot login:

OP-TEE

Optee on IMX6QDL ICORE

Optee OS
Optee_os Configs
$ git clone https://github.com/OP-TEE/optee_os.git
$ cd optee_os
$ cat > optee_imx6q-icore.patch
diff --git a/core/arch/arm/plat-imx/conf.mk b/core/arch/arm/plat-imx/conf.mk
index 3e6d61f371a9..23603a8ddbcf 100644
--- a/core/arch/arm/plat-imx/conf.mk
+++ b/core/arch/arm/plat-imx/conf.mk
@@ -92,9 +92,9 @@ CFG_NS_ENTRY_ADDR ?= 0x12000000
 endif

 ifneq (,$(filter $(PLATFORM_FLAVOR),mx6qsabrelite mx6dlsabrelite))
-CFG_DDR_SIZE ?= 0x40000000
-CFG_NS_ENTRY_ADDR ?= 0x12000000
-CFG_UART_BASE ?= UART2_BASE
+CFG_DDR_SIZE ?= 0x1E200000
+CFG_NS_ENTRY_ADDR ?= 0x10800000
+CFG_UART_BASE ?= UART4_BASE
 endif

 ifneq (,$(filter $(PLATFORM_FLAVOR),mx6sxsabreauto))

$ git apply -v  optee_imx6q-icore.patch
$ export CROSS_COMPILE=arm-linux-gnueabi
$ export PATH=~/gcc-linaro-6.3.1-2017.02-i686_arm-linux-gnueabi/bin:$PATH
$ make PLATFORM=imx-mx6qsabrelite ARCH=arm CFG_BUILT_IN_ARGS=y CFG_PAGEABLE_ADDR=0 CFG_NS_ENTRY_ADDR=0x12000000 CFG_DT_ADDR=0x18000000 CFG_DT=y CFG_PSCI_ARM32=y DEBUG=y CFG_TEE_CORE_LOG_LEVEL=4 CFG_BOOT_SYNC_CPU=n CFG_BOOT_SECONDARY_REQUEST=y
U-Boot configs for optee
$ cd /path/to/u-boot
$ cat > uboot-optee-imx6q-icore.patch
diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index 5dccb17cb271..1272c845f943 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -12,7 +12,7 @@
 #include "board.h"

 DECLARE_GLOBAL_DATA_PTR;
-
+#define CONFIG_TEE_RAM_SIZE 0x01e00000
 #ifdef CONFIG_ENV_IS_IN_MMC
 static void mmc_late_init(void)
 {
@@ -109,7 +109,7 @@ int board_init(void)

 int dram_init(void)
 {
- gd->ram_size = imx_ddr_size();
+ gd->ram_size = imx_ddr_size() - CONFIG_TEE_RAM_SIZE;

 return 0;
 }
diff --git a/configs/imx6qdl_icore_mmc_defconfig b/configs/imx6qdl_icore_mmc_defconfig
index cb81a7a68290..e0b5172901e2 100644
--- a/configs/imx6qdl_icore_mmc_defconfig
+++ b/configs/imx6qdl_icore_mmc_defconfig
@@ -12,6 +12,10 @@ CONFIG_DEBUG_UART_BASE=0x021f0000
 CONFIG_DEBUG_UART_CLOCK=24000000
 CONFIG_SPL_LIBDISK_SUPPORT=y
 # CONFIG_CMD_BMODE is not set
+
+CONFIG_TEE_RAM_SIZE=0x01e00000
+CONFIG_CMD_BOOTZ=y
+
 CONFIG_DEBUG_UART=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_FIT=y

$ git apply -v uboot-optee-imx6q-icore.patch
$ build imx6qdl for u-boot

# Get -a and -e value from /path/to/optee_os/out/arm-plat-imx/conf.mk
# CFG_TZDRAM_SIZE=0x01e00000
# This will give -e value CFG_TZDRAM_START=(0x10000000 - 0x02000000 + 0x1E200000)
# For -a value we need to substract 0x1C(optee header size) from -e value
$ ./tools/mkimage -A arm -O linux -C none -a 0x2C1FFFE4 -e 0x2C200000 -d /path to/optee_os/out/arm-plat-imx/core/tee.bin uTee
$  sudo cp -vf uTee /media/cdrom/
Linux steps

Before build disable CAAM and Outer Cache

Cryptographic API —> [ ] Hardware crypto devices

System Type —> [ ] Enable the L2x0 outer cache controller

$ ARCH=arm make menuconfig
$ ARCH=arm make LOADADDR=0x10008000 uImage dtbs -j4
$ sudo cp -vf arch/arm/boot/zImage /media/cdrom/
$ sudo cp -vf arch/arm/boot/dts/imx6q-icore.dtb /media/cdrom/
$ sync
$ sudo umount /media/cdrom
Final Steps

Insert sd card and Turn on the board, and get into u-boot command prompt by pressing enter.

Environment size: 1615/131068 bytes
icorem6qdl> ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} zImage
8229304 bytes read in 397 ms (19.8 MiB/s)
icorem6qdl> ext4load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
37450 bytes read in 10 ms (3.6 MiB/s)
icorem6qdl> #ext4load mmc ${mmcdev}:${mmcpart} 0x20000000 uTee;
icorem6qdl> setenv bootargs console=${console},${baudrate} root=/dev/mmcblk0p1 rootwait rw earlycon
icorem6qdl> ext4ls mmc 0:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 bin
<DIR>       4096 dev
<DIR>       4096 etc
<DIR>       4096 lib
<SYM>          3 lib32
<SYM>         11 linuxrc
<DIR>       4096 media
<DIR>       4096 mnt
<DIR>       4096 opt
<DIR>       4096 proc
<DIR>       4096 root
<DIR>       4096 run
<DIR>       4096 sbin
<DIR>       4096 sys
<DIR>       4096 tmp
<DIR>       4096 usr
<DIR>       4096 var
         8229368 uImage
         8229304 zImage
           37450 imx6q-icore.dtb
          266980 uTee
icorem6qdl> ext4load mmc ${mmcdev}:${mmcpart} 0x20000000 uTee;
266980 bytes read in 21 ms (12.1 MiB/s)
icorem6qdl>  bootm 0x20000000 - ${fdt_addr};
## Booting kernel from Legacy Image at 20000000 ...
   Image Name:
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    266916 Bytes = 260.7 KiB
   Load Address: 2c1fffe4
   Entry Point:  2c200000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Using Device Tree in place at 18000000, end 1800c249

Starting kernel ...

D/TC:0 0 add_phys_mem:539 TEE_SHMEM_START type NSEC_SHM 0x2e000000 size 0x00200000
D/TC:0 0 add_phys_mem:539 TA_RAM_START type TA_RAM 0x2c300000 size 0x01d00000
D/TC:0 0 add_phys_mem:539 VCORE_UNPG_RW_PA type TEE_RAM_RW 0x2c241000 size 0x000bf000
D/TC:0 0 add_phys_mem:539 VCORE_UNPG_RX_PA type TEE_RAM_RX 0x2c200000 size 0x00041000
D/TC:0 0 add_phys_mem:539 ROUNDDOWN(PL310_BASE, CORE_MMU_DEVICE_SIZE) type IO_SEC 0x00a00000 size 0x00100000
D/TC:0 0 add_phys_mem:539 ROUNDDOWN(IRAM_BASE, CORE_MMU_DEVICE_SIZE) type TEE_COHERENT 0x00900000 size 0x00100000
D/TC:0 0 add_phys_mem:539 AIPS3_BASE type IO_SEC 0x02200000 size 0x00100000
D/TC:0 0 add_phys_mem:539 AIPS2_BASE type IO_SEC 0x02100000 size 0x00100000
D/TC:0 0 add_phys_mem:539 AIPS1_BASE type IO_SEC 0x02000000 size 0x00100000
D/TC:0 0 add_phys_mem:539 ANATOP_BASE type IO_SEC 0x02000000 size 0x00200000
D/TC:0 0 add_phys_mem:552 Physical mem map overlaps 0x2000000
D/TC:0 0 add_phys_mem:539 GIC_BASE type IO_SEC 0x00a00000 size 0x00100000
D/TC:0 0 add_phys_mem:552 Physical mem map overlaps 0xa00000
D/TC:0 0 add_phys_mem:539 CONSOLE_UART_BASE type IO_NSEC 0x02100000 size 0x00200000
D/TC:0 0 add_phys_mem:539 PL310_BASE type IO_SEC 0x00a00000 size 0x00200000
D/TC:0 0 add_phys_mem:552 Physical mem map overlaps 0xa00000
D/TC:0 0 add_phys_mem:539 SRC_BASE type IO_SEC 0x02000000 size 0x00200000
D/TC:0 0 add_phys_mem:552 Physical mem map overlaps 0x2000000
D/TC:0 0 verify_special_mem_areas:477 No NSEC DDR memory area defined
D/TC:0 0 add_va_space:578 type RES_VASPACE size 0x00a00000
D/TC:0 0 add_va_space:578 type SHM_VASPACE size 0x02000000
D/TC:0 0 dump_mmap_table:711 type TEE_RAM_RX   va 0x2c200000..0x2c240fff pa 0x2c200000..0x2c240fff size 0x00041000 (small)
D/TC:0 0 dump_mmap_table:711 type TEE_RAM_RW   va 0x2c241000..0x2c2fffff pa 0x2c241000..0x2c2fffff size 0x000bf000 (small)
D/TC:0 0 dump_mmap_table:711 type SHM_VASPACE  va 0x2c300000..0x2e2fffff pa 0x00000000..0x01ffffff size 0x02000000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type IO_SEC       va 0x2e300000..0x2e3fffff pa 0x02200000..0x022fffff size 0x00100000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type RES_VASPACE  va 0x2e400000..0x2edfffff pa 0x00000000..0x009fffff size 0x00a00000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type TEE_COHERENT va 0x2ee00000..0x2eefffff pa 0x00900000..0x009fffff size 0x00100000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type TA_RAM       va 0x2ef00000..0x30bfffff pa 0x2c300000..0x2dffffff size 0x01d00000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type NSEC_SHM     va 0x30c00000..0x30dfffff pa 0x2e000000..0x2e1fffff size 0x00200000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type IO_NSEC      va 0x30e00000..0x30ffffff pa 0x02100000..0x022fffff size 0x00200000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type IO_SEC       va 0x31000000..0x311fffff pa 0x00a00000..0x00bfffff size 0x00200000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type IO_SEC       va 0x31200000..0x313fffff pa 0x02000000..0x021fffff size 0x00200000 (pgdir)
D/TC:0 0 dump_mmap_table:711 type IO_SEC       va 0x31400000..0x314fffff pa 0x02100000..0x021fffff size 0x00100000 (pgdir)
D/TC:0 0 core_mmu_alloc_l2:238 L2 table used: 1/4
I/TC:
D/TC:0 0 init_canaries:164 #Stack canaries for stack_tmp[0] with top at 0x2c2709b8
D/TC:0 0 init_canaries:164 watch *0x2c2709bc
D/TC:0 0 init_canaries:164 #Stack canaries for stack_tmp[1] with top at 0x2c2710f8
D/TC:0 0 init_canaries:164 watch *0x2c2710fc
D/TC:0 0 init_canaries:164 #Stack canaries for stack_tmp[2] with top at 0x2c271838
D/TC:0 0 init_canaries:164 watch *0x2c27183c
D/TC:0 0 init_canaries:164 #Stack canaries for stack_tmp[3] with top at 0x2c271f78
D/TC:0 0 init_canaries:164 watch *0x2c271f7c
D/TC:0 0 init_canaries:165 #Stack canaries for stack_abt[0] with top at 0x2c26a938
D/TC:0 0 init_canaries:165 watch *0x2c26a93c
D/TC:0 0 init_canaries:165 #Stack canaries for stack_abt[1] with top at 0x2c26b178
D/TC:0 0 init_canaries:165 watch *0x2c26b17c
D/TC:0 0 init_canaries:165 #Stack canaries for stack_abt[2] with top at 0x2c26b9b8
D/TC:0 0 init_canaries:165 watch *0x2c26b9bc
D/TC:0 0 init_canaries:165 #Stack canaries for stack_abt[3] with top at 0x2c26c1f8
D/TC:0 0 init_canaries:165 watch *0x2c26c1fc
D/TC:0 0 init_canaries:167 #Stack canaries for stack_thread[0] with top at 0x2c26e238
D/TC:0 0 init_canaries:167 watch *0x2c26e23c
D/TC:0 0 init_canaries:167 #Stack canaries for stack_thread[1] with top at 0x2c270278
D/TC:0 0 init_canaries:167 watch *0x2c27027c
I/TC: OP-TEE version: 3.3.0-dev #19 Wed Oct 24 12:34:53 UTC 2018 arm
D/TC:0 0 tee_ta_register_ta_store:534 Registering TA store: 'REE' (priority 10)
D/TC:0 0 tee_ta_register_ta_store:534 Registering TA store: 'Secure Storage TA' (priority 9)
D/TC:0 0 mobj_mapped_shm_init:702 Shared memory address range: 2c300000, 2e300000
E/TC:0 0 plat_rng_init:354 Warning: seeding RNG with zeroes
D/TC:0 0 imx_wdog_base:125 path: /soc/aips-bus@2000000/wdog@20bc000
I/TC: Initialized
D/TC:0 0 init_primary_helper:928 Primary CPU switching to normal world boot
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.0-00618-gbad5e39a548d (shyam@debian) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.08
[    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5787d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Engicam i.CoreM6 Quad/Dual Starter Kit
[    0.000000] earlycon: ec_imx21 at MMIO 0x021f0000 (options '')
[    0.000000] bootconsole [ec_imx21] enabled
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] OF: fdt: Reserved memory: unsupported node format, ignoring
[    0.000000] cma: Reserved 64 MiB at 0x2a000000
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.0 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] random: get_random_bytes called from start_kernel+0x90/0x490 with crng_init=0
[    0.000000] percpu: Embedded 18 pages/cpu @(ptrval) s41832 r8192 d23704 u73728
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 122428
[    0.000000] Kernel command line: console=ttymxc3,115200 root=/dev/mmcblk0p1 rootwait rw earlycon
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 398056K/493568K available (11264K kernel code, 843K rwdata, 3620K rodata, 1024K init, 7650K bss, 2)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xde800000 - 0xff800000   ( 528 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xde200000   ( 482 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (12256 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 844 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   (7651 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] Running RCU self tests
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU lockdep checking is enabled.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] Switching to timer-based delay loop, resolution 333ns
[    0.000011] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
[    0.008185] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
[    0.019725] Console: colour dummy device 80x30
[    0.022275] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.030092] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.034102] ... MAX_LOCK_DEPTH:          48
[    0.038333] ... MAX_LOCKDEP_KEYS:        8191
[    0.042626] ... CLASSHASH_SIZE:          4096
[    0.047031] ... MAX_LOCKDEP_ENTRIES:     32768
[    0.051413] ... MAX_LOCKDEP_CHAINS:      65536
[    0.055849] ... CHAINHASH_SIZE:          32768
[    0.060339]  memory used by lock dependency info: 4655 kB
[    0.065681]  per task-struct memory footprint: 1536 bytes
[    0.071201] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
[    0.081322] pid_max: default: 32768 minimum: 301
[    0.086485] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.092499] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.102108] CPU: Testing write buffer coherency: ok
[    0.104402] CPU0: Spectre v2: using BPIALL workaround
[    0.111206] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.118881] Setting up static identity map for 0x10100000 - 0x10100078
[    0.123446] rcu: Hierarchical SRCU implementation.
[    0.131187] smp: Bringing up secondary CPUs ...
D/TC:1   init_secondary_helper:952 Secondary CPU Switching to normal world boot
[    0.144211] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.144228] CPU1: Spectre v2: using BPIALL workaround
D/TC:2   init_secondary_helper:952 Secondary CPU Switching to normal world boot
[    0.163626] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[    0.163643] CPU2: Spectre v2: using BPIALL workaround
D/TC:3   init_secondary_helper:952 Secondary CPU Switching to normal world boot
[    0.182665] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[    0.182681] CPU3: Spectre v2: using BPIALL workaround
[    0.191109] smp: Brought up 1 node, 4 CPUs
[    0.194645] SMP: Total of 4 processors activated (24.00 BogoMIPS).
[    0.200955] CPU: All CPU(s) started in SVC mode.
[    0.208895] devtmpfs: initialized
[    0.245968] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.254653] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.261801] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    0.275909] pinctrl core: initialized pinctrl subsystem
[    0.283581] NET: Registered protocol family 16
[    0.324561] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.333324] cpuidle: using governor menu
[    0.334723] CPU identified as i.MX6Q, silicon rev 1.2
[    0.369464] vdd1p1: supplied by regulator-dummy
[    0.373484] vdd3p0: supplied by regulator-dummy
[    0.377850] vdd2p5: supplied by regulator-dummy
[    0.382263] vddarm: supplied by regulator-dummy
[    0.387025] vddpu: supplied by regulator-dummy
[    0.391253] vddsoc: supplied by regulator-dummy
[    0.430569] No ATAGs?
[    0.431334] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.438942] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.449625] imx6q-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
[    0.554662] mxs-dma 110000.dma-apbh: initialized
[    0.567720] vgaarb: loaded
[    0.569248] SCSI subsystem initialized
[    0.573328] usbcore: registered new interface driver usbfs
[    0.577241] usbcore: registered new interface driver hub
[    0.582610] usbcore: registered new device driver usb
[    0.592020] i2c i2c-0: IMX I2C adapter registered
[    0.593940] i2c i2c-0: can't use DMA, using PIO instead.
[    0.601363] i2c i2c-1: IMX I2C adapter registered
[    0.603938] i2c i2c-1: can't use DMA, using PIO instead.
[    0.611480] i2c i2c-2: IMX I2C adapter registered
[    0.613947] i2c i2c-2: can't use DMA, using PIO instead.
[    0.619840] media: Linux media interface: v0.10
[    0.623896] videodev: Linux video capture interface: v2.00
[    0.629952] pps_core: LinuxPPS API ver. 1 registered
[    0.634180] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.643487] PTP clock support registered
[    0.648561] Advanced Linux Sound Architecture Driver Initialized.
[    0.657828] Bluetooth: Core ver 2.22
[    0.658737] NET: Registered protocol family 31
[    0.663014] Bluetooth: HCI device and connection manager initialized
[    0.669584] Bluetooth: HCI socket layer initialized
[    0.674265] Bluetooth: L2CAP socket layer initialized
[    0.679632] Bluetooth: SCO socket layer initialized
[    0.686984] clocksource: Switched to clocksource mxc_timer1
[    1.007680] VFS: Disk quotas dquot_6.6.0
[    1.008990] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    1.065012] NET: Registered protocol family 2
[    1.069590] tcp_listen_portaddr_hash hash table entries: 256 (order: 1, 10240 bytes)
[    1.074595] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    1.081854] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)
[    1.088819] TCP: Hash tables configured (established 4096 bind 4096)
[    1.095103] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    1.100581] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    1.107496] NET: Registered protocol family 1
[    1.114039] RPC: Registered named UNIX socket transport module.
[    1.117515] RPC: Registered udp transport module.
[    1.121858] RPC: Registered tcp transport module.
[    1.126552] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    1.137939] hw perfevents: no interrupt-affinity property for /pmu, guessing.
[    1.143341] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
[    1.157589] Initialise system trusted keyrings
[    1.160156] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    1.189590] NFS: Registering the id_resolver key type
[    1.191961] Key type id_resolver registered
[    1.196010] Key type id_legacy registered
[    1.200422] jffs2: version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.
[    1.208473] fuse init (API version 7.27)
[    1.229873] Key type asymmetric registered
[    1.231255] Asymmetric key parser 'x509' registered
[    1.236152] io scheduler noop registered
[    1.240096] io scheduler deadline registered
[    1.244648] io scheduler cfq registered (default)
[    1.249289] io scheduler mq-deadline registered
[    1.253419] io scheduler kyber registered
[    1.266813] pwm-backlight backlight-lvds: backlight-lvds supply power not found, using dummy regulator
[    1.273907] pwm-backlight backlight-lvds: Linked as a consumer to regulator.0
[    1.302767] imx-pgc-pd imx-pgc-power-domain.0: DMA mask not set
[    1.306320] imx-pgc-pd imx-pgc-power-domain.0: Linked as a consumer to 20dc000.gpc
[    1.314443] imx-sdma 20ec000.sdma: Direct firmware load for imx/sdma/sdma-imx6q.bin failed with error -2
[    1.317333] imx-pgc-pd imx-pgc-power-domain.1: DMA mask not set
[    1.323256] imx-sdma 20ec000.sdma: external firmware not found, using ROM firmware
[    1.329589] imx-pgc-pd imx-pgc-power-domain.1: Linked as a consumer to regulator.5
[    1.344696] imx-pgc-pd imx-pgc-power-domain.1: Linked as a consumer to 20dc000.gpc
[    1.357129] 21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 67, base_baud = 5000000) is a IMX
[    1.366121] console [ttymxc3] enabled
[    1.366121] console [ttymxc3] enabled
[    1.370780] bootconsole [ec_imx21] disabled
[    1.370780] bootconsole [ec_imx21] disabled
[    1.406060] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops)
[    1.412928] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops)
[    1.419649] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops)
[    1.425375] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108
[    1.440028] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007
[    1.455711] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215
[    1.461980] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0
[    1.471976] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0
[    1.485558] imx-ipuv3 2400000.ipu: IPUv3H probed
[    1.494746] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.501599] [drm] No driver support for vblank timestamp query.
[    1.509473] imx-drm display-subsystem: bound imx-ipuv3-crtc.2 (ops ipu_crtc_ops)
[    1.517537] imx-drm display-subsystem: bound imx-ipuv3-crtc.3 (ops ipu_crtc_ops)
[    1.525513] imx-drm display-subsystem: bound imx-ipuv3-crtc.6 (ops ipu_crtc_ops)
[    1.533513] imx-drm display-subsystem: bound imx-ipuv3-crtc.7 (ops ipu_crtc_ops)
[    1.542682] imx-drm display-subsystem: bound ldb (ops imx_ldb_ops)
[    1.599213] Console: switching to colour frame buffer device 100x30
[    1.618067] imx-drm display-subsystem: fb0: DRM emulated frame buffer device
[    1.628930] [drm] Initialized imx-drm 1.0.0 20120507 for display-subsystem on minor 1
[    1.637142] imx-ipuv3 2800000.ipu: IPUv3H probed
[    1.699351] brd: module loaded
[    1.742994] loop: module loaded
[    1.757165] etnaviv-gpu 130000.gpu: timed out waiting for idle: idle=0x7ffffffe
[    2.797481] gpmi-nand 112000.gpmi-nand: DMA timeout, last DMA
[    2.803281] gpmi-nand 112000.gpmi-nand: Show GPMI registers :
[    2.809201] gpmi-nand 112000.gpmi-nand: offset 0x000 : 0x20830001
[    2.815342] gpmi-nand 112000.gpmi-nand: offset 0x010 : 0x00000000
[    2.821575] gpmi-nand 112000.gpmi-nand: offset 0x020 : 0x00000000
[    2.827825] gpmi-nand 112000.gpmi-nand: offset 0x030 : 0x00000000
[    2.833962] gpmi-nand 112000.gpmi-nand: offset 0x040 : 0x00000000
[    2.840203] gpmi-nand 112000.gpmi-nand: offset 0x050 : 0x00000000
[    2.846338] gpmi-nand 112000.gpmi-nand: offset 0x060 : 0x0104000c
[    2.852576] gpmi-nand 112000.gpmi-nand: offset 0x070 : 0x00020101
[    2.858818] gpmi-nand 112000.gpmi-nand: offset 0x080 : 0x60000000
[    2.864954] gpmi-nand 112000.gpmi-nand: offset 0x090 : 0x03023336
[    2.871182] gpmi-nand 112000.gpmi-nand: offset 0x0a0 : 0x00000000
[    2.877428] gpmi-nand 112000.gpmi-nand: offset 0x0b0 : 0xff000005
[    2.883567] gpmi-nand 112000.gpmi-nand: offset 0x0c0 : 0x00000001
[    2.889803] gpmi-nand 112000.gpmi-nand: offset 0x0d0 : 0x05010000
[    2.895937] gpmi-nand 112000.gpmi-nand: Show BCH registers :
[    2.901740] gpmi-nand 112000.gpmi-nand: offset 0x000 : 0x00000000
[    2.907988] gpmi-nand 112000.gpmi-nand: offset 0x010 : 0x00000010
[    2.914125] gpmi-nand 112000.gpmi-nand: offset 0x020 : 0x00000000
[    2.920365] gpmi-nand 112000.gpmi-nand: offset 0x030 : 0x00000000
[    2.926501] gpmi-nand 112000.gpmi-nand: offset 0x040 : 0x00000000
[    2.932738] gpmi-nand 112000.gpmi-nand: offset 0x050 : 0x00000000
[    2.938982] gpmi-nand 112000.gpmi-nand: offset 0x060 : 0x00000000
[    2.945119] gpmi-nand 112000.gpmi-nand: offset 0x070 : 0xe4e4e4e4
[    2.951356] gpmi-nand 112000.gpmi-nand: offset 0x080 : 0x070a4080
[    2.957598] gpmi-nand 112000.gpmi-nand: offset 0x090 : 0x10da4080
[    2.963732] gpmi-nand 112000.gpmi-nand: offset 0x0a0 : 0x070a4080
[    2.969970] gpmi-nand 112000.gpmi-nand: offset 0x0b0 : 0x10da4080
[    2.976106] gpmi-nand 112000.gpmi-nand: offset 0x0c0 : 0x070a4080
[    2.982346] gpmi-nand 112000.gpmi-nand: offset 0x0d0 : 0x10da4080
[    2.988587] gpmi-nand 112000.gpmi-nand: offset 0x0e0 : 0x070a4080
[    2.994721] gpmi-nand 112000.gpmi-nand: offset 0x0f0 : 0x10da4080
[    3.000956] gpmi-nand 112000.gpmi-nand: offset 0x100 : 0x00000000
[    3.007198] gpmi-nand 112000.gpmi-nand: offset 0x110 : 0x00000000
[    3.013332] gpmi-nand 112000.gpmi-nand: offset 0x120 : 0x00000000
[    3.019563] gpmi-nand 112000.gpmi-nand: offset 0x130 : 0x00000000
[    3.025698] gpmi-nand 112000.gpmi-nand: offset 0x140 : 0x00000000
[    3.031935] gpmi-nand 112000.gpmi-nand: offset 0x150 : 0x20484342
[    3.038179] gpmi-nand 112000.gpmi-nand: offset 0x160 : 0x01000000
[    3.044317] gpmi-nand 112000.gpmi-nand: offset 0x170 : 0x00000000
[    3.050563] gpmi-nand 112000.gpmi-nand: BCH Geometry :
[    3.050563] GF length              : 0
[    3.050563] ECC Strength           : 0
[    3.050563] Page Size in Bytes     : 0
[    3.050563] Metadata Size in Bytes : 0
[    3.050563] ECC Chunk Size in Bytes: 0
[    3.050563] ECC Chunk Count        : 0
[    3.050563] Payload Size in Bytes  : 1024
[    3.050563] Auxiliary Size in Bytes: 128
[    3.050563] Auxiliary Status Offset: 0
[    3.050563] Block Mark Byte Offset : 0
[    3.050563] Block Mark Bit Offset  : 0
[    3.097412] gpmi-nand 112000.gpmi-nand: Chip: 0, Error -110
[    3.103152] gpmi-nand 112000.gpmi-nand: Chip: 0, Error -22
[    3.108790] gpmi-nand 112000.gpmi-nand: Chip: 0, Error -22
[    3.114336] gpmi-nand 112000.gpmi-nand: Chip: 0, Error -22
[    3.119984] gpmi-nand 112000.gpmi-nand: Chip: 0, Error -22
[    3.125513] nand: No NAND device found
[    3.135679] libphy: Fixed MDIO Bus: probed
[    3.141950] CAN device driver interface
[    3.146829] flexcan 2090000.flexcan: Linked as a consumer to regulator.9
[    3.156121] flexcan 2090000.flexcan: device registered (reg_base=(ptrval), irq=30)
[    3.164707] flexcan 2094000.flexcan: Linked as a consumer to regulator.9
[    3.173509] flexcan 2094000.flexcan: device registered (reg_base=(ptrval), irq=31)
[    3.184791] fec 2188000.ethernet: 2188000.ethernet supply phy not found, using dummy regulator
[    3.193977] fec 2188000.ethernet: Linked as a consumer to regulator.0
[    3.205632] pps pps0: new PPS source ptp0
[    3.211043] fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
[    3.221146] fec 2188000.ethernet (unnamed net_device) (uninitialized): Using random MAC address: ce:1b:e6:93:20:79
[    3.247287] libphy: fec_enet_mii_bus: probed
[    3.253253] fec 2188000.ethernet eth0: registered PHC device 0
[    3.261854] usbcore: registered new interface driver asix
[    3.267612] usbcore: registered new interface driver ax88179_178a
[    3.273930] usbcore: registered new interface driver cdc_ether
[    3.280076] usbcore: registered new interface driver net1080
[    3.285924] usbcore: registered new interface driver cdc_subset
[    3.292131] usbcore: registered new interface driver zaurus
[    3.298063] usbcore: registered new interface driver cdc_ncm
[    3.303767] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    3.310418] ehci-pci: EHCI PCI platform driver
[    3.315093] ehci-mxc: Freescale On-Chip EHCI Host driver
[    3.321857] usbcore: registered new interface driver usb-storage
[    3.333990] imx_usb 2184000.usb: Linked as a consumer to regulator.11
[    3.348852] ci_hdrc ci_hdrc.0: EHCI Host Controller
[    3.354112] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[    3.387136] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[    3.398319] hub 1-0:1.0: USB hub found
[    3.402581] hub 1-0:1.0: 1 port detected
[    3.411864] imx_usb 2184200.usb: Linked as a consumer to regulator.10
[    3.423107] ci_hdrc ci_hdrc.1: EHCI Host Controller
[    3.428281] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2
[    3.467105] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
[    3.475714] hub 2-0:1.0: USB hub found
[    3.479909] hub 2-0:1.0: 1 port detected
[    3.499496] input: max11801_ts as /devices/soc0/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-0048/input/input0
[    3.522605] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-rtc-lp as rtc0
[    3.532625] i2c /dev entries driver
[    3.532983] random: fast init done
[    3.550859] imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
[    3.558128] Bluetooth: HCI UART driver ver 2.3
[    3.562626] Bluetooth: HCI UART protocol H4 registered
[    3.568221] Bluetooth: HCI UART protocol LL registered
[    3.576009] sdhci: Secure Digital Host Controller Interface driver
[    3.582350] sdhci: Copyright(c) Pierre Ossman
[    3.586751] sdhci-pltfm: SDHCI platform and OF driver helper
[    3.595298] sdhci-esdhc-imx 2190000.usdhc: Got CD GPIO
[    3.638809] mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
[    3.649600] usbcore: registered new interface driver usbhid
[    3.655220] usbhid: USB HID core driver
[    3.668105] imx-media: subdev ipu1_vdic bound
[    3.672957] imx-media: subdev ipu2_vdic bound
[    3.678189] imx-media: subdev ipu1_ic_prp bound
[    3.684548] ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video0
[    3.687903] mmc0: host does not support reading read-only switch, assuming write-enable
[    3.692118] imx-media: subdev ipu1_ic_prpenc bound
[    3.705758] ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video1
[    3.710982] mmc0: new high speed SDHC card at address aaaa
[    3.712867] imx-media: subdev ipu1_ic_prpvf bound
[    3.721588] mmcblk0: mmc0:aaaa SS08G 7.40 GiB
[    3.723288] imx-media: subdev ipu2_ic_prp bound
[    3.733384] ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video2
[    3.739278]  mmcblk0: p1
[    3.740674] imx-media: subdev ipu2_ic_prpenc bound
[    3.749087] ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video3
[    3.756097] imx-media: subdev ipu2_ic_prpvf bound
[    3.763099] ipu1_csi0: Registered ipu1_csi0 capture as /dev/video4
[    3.769481] imx-media: subdev ipu1_csi0 bound
[    3.775007] ipu1_csi1: Registered ipu1_csi1 capture as /dev/video5
[    3.781391] imx-media: subdev ipu1_csi1 bound
[    3.787052] ipu2_csi0: Registered ipu2_csi0 capture as /dev/video6
[    3.793294] imx-media: subdev ipu2_csi0 bound
[    3.798999] ipu2_csi1: Registered ipu2_csi1 capture as /dev/video7
[    3.805239] imx-media: subdev ipu2_csi1 bound
[    3.815756] optee: probing for conduit method from DT.
I/TC: Dynamic shared memory is enabled
[    3.821057] optee: revision 3.3 (ee595e95)
[    3.826361] optee: initialized driver
[    3.842348] sgtl5000 2-000a: Linked as a consumer to regulator.7
[    3.847166] usb 2-1: new high-speed USB device number 2 using ci_hdrc
[    3.849043] sgtl5000 2-000a: Dropping the link to regulator.7
[    3.862448] sgtl5000 2-000a: Linked as a consumer to regulator.8
[    3.869046] sgtl5000 2-000a: Linked as a consumer to regulator.9
[    3.875526] sgtl5000 2-000a: Linked as a consumer to regulator.7
[    3.884344] sgtl5000 2-000a: Error reading chip id -6
[    3.889919] sgtl5000 2-000a: Dropping the link to regulator.8
[    3.896069] sgtl5000 2-000a: Dropping the link to regulator.9
[    3.903215] sgtl5000 2-000a: Dropping the link to regulator.7
[    3.918960] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    3.936809] NET: Registered protocol family 10
[    3.946827] Segment Routing with IPv6
[    3.951015] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    3.959870] NET: Registered protocol family 17
[    3.964416] can: controller area network core (rev 20170425 abi 9)
[    3.971178] NET: Registered protocol family 29
[    3.975728] can: raw protocol (rev 20170425)
[    3.980320] can: broadcast manager protocol (rev 20170425 t)
[    3.986073] can: netlink gateway (rev 20170425) max_hops=1
[    3.992631] Key type dns_resolver registered
[    4.000036] cpu cpu0: Linked as a consumer to regulator.4
[    4.005829] cpu cpu0: Linked as a consumer to regulator.5
[    4.011739] cpu cpu0: Linked as a consumer to regulator.6
[    4.023404] Registering SWP/SWPB emulation handler
[    4.031655] Loading compiled-in X.509 certificates
[    4.051831] hub 2-1:1.0: USB hub found
[    4.056247] hub 2-1:1.0: 4 ports detected
[    4.150497] imx-media: subdev ipu1_csi0_mux bound
[    4.156761] imx-media: subdev ipu2_csi1_mux bound
[    4.161952] imx-media: ipu2_csi1:1 -> ipu2_ic_prp:0
[    4.167058] imx-media: ipu2_csi1:1 -> ipu2_vdic:0
[    4.171853] imx-media: ipu2_csi1_mux:2 -> ipu2_csi1:0
[    4.177095] imx-media: ipu2_csi0:1 -> ipu2_ic_prp:0
[    4.182030] imx-media: ipu2_csi0:1 -> ipu2_vdic:0
[    4.186816] imx-media: ipu1_csi1:1 -> ipu1_ic_prp:0
[    4.191879] imx-media: ipu1_csi1:1 -> ipu1_vdic:0
[    4.196677] imx-media: ipu1_csi0:1 -> ipu1_ic_prp:0
[    4.201729] imx-media: ipu1_csi0:1 -> ipu1_vdic:0
[    4.206555] imx-media: ipu1_csi0_mux:2 -> ipu1_csi0:0
[    4.211775] imx-media: ipu2_ic_prp:1 -> ipu2_ic_prpenc:0
[    4.217262] imx-media: ipu2_ic_prp:2 -> ipu2_ic_prpvf:0
[    4.222548] imx-media: ipu1_ic_prp:1 -> ipu1_ic_prpenc:0
[    4.228014] imx-media: ipu1_ic_prp:2 -> ipu1_ic_prpvf:0
[    4.233295] imx-media: ipu2_vdic:2 -> ipu2_ic_prp:0
[    4.238324] imx-media: ipu1_vdic:2 -> ipu1_ic_prp:0
[    4.261225] imx_thermal tempmon: Industrial CPU temperature grade - max:105C critical:100C passive:95C
[    4.279775] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:00 UTC (0)
[    4.289558] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    4.305308] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    4.313379] ALSA device list:
[    4.316481]   No soundcards found.
[    4.321343] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    4.330340] cfg80211: failed to load regulatory.db
[    4.379989] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[    4.388566] VFS: Mounted root (ext4 filesystem) on device 179:1.
[    4.402367] devtmpfs: mounted
[    4.408244] Freeing unused kernel memory: 1024K
[    4.429082] Run /sbin/init as init process
[    4.596182] EXT4-fs (mmcblk0p1): re-mounted. Opts: (null)
Starting logging: OK
Initializing random number generator... [    4.937381] random: dd: uninitialized urandom read (512 bytes read)
done.
Starting network: OK

Welcome to Engicam i.CoreM6 Quad/Dual/DualLite/Solo
buildroot login:
Welcome to Engicam i.CoreM6 Quad/Dual/DualLite/Solo
buildroot login: root
# uname -a
Linux buildroot 4.19.0-00618-gbad5e39a548d #16 SMP Wed Oct 24 18:00:15 IST 2018 armv7l GNU/Linux
Optee Demo Applications

First we clone the repo

git clone https://github.com/linaro-swg/optee_examples.git


cd optee_examples

Set cross compile and optee specific environment variables

cat > optee_test_env.sh

export PATH=/home/shyam/buildroot/output/host/opt/ext-toolchain/bin:$PATH
export TA_DEV_KIT_DIR=/home/shyam/optee_os/out/arm-plat-imx/export-ta_arm32
export OPTEE_CLIENT_EXPORT=/home/shyam/optee_client/out/export
export CROSS_COMPILE=arm-linux-gnueabihf-
export TEEC_EXPORT=/home/shyam/optee_client/out/export
export HOST_CROSS_COMPILE=arm-linux-gnueabihf-
export TA_CROSS_COMPILE=arm-linux-gnueabihf-

source optee_test_env.sh

Build examples

ARCH=arm make

Now, copy optee client side application in sd card

cp -vrf out/ca/* /path to sd card mount directory/

Now, copy Optee Trusted Application in sdcard rootfs /lib/optee_armz

cp -vrf out/ta/* /path to sdcard mount directory/lib/optee_armtz/

Insert the sd card and boot linux with optee

Run tee-supplicant

tee-supplicant &

Run optee client side applications starting with prefix optee_example_*

/optee_example_hello_world
D/TA:  TA_CreateEntryPoint:39 has been called
D/TA:  TA_OpenSessionEntryPoint:68 has been called
I/TA: Hello World!
Invoking TA to increment 42
D/TA:  inc_value:105 has been called
I/TA: Got value: 42 from NW
I/TA: Increase value to: 43
TA incremented value to 43
I/TA: Goodbye!
D/TA:  TA_DestroyEntryPoint:50 has been called
OP-Tee Test suite
optee client

Note

Before building optee test suite, make sure you have already built the optee os

Optee client runs on linux side which provides tee-supplicant clone optee client repo

git clone https://github.com/OP-TEE/optee_client.git

cd optee_client

Setenv cross compile environment

export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=/home/shyam/buildroot/output/host/opt/ext-toolchain/bin:$PATH

make

Copy all files from out/export/ to sdcard rootfs

cp -vrf out/export/* /path to sd card mount directory/
Optee Test suite

Optee test suite provides benchmark and regression test suite.

Clone optee_test repo

git clone https://github.com/OP-TEE/optee_test.git

cd optee_test

Set cross compile and optee specific environment variables

export TA_DEV_KIT_DIR=/path to /optee_os/out/arm-plat-imx/export-ta_arm32
export OPTEE_CLIENT_EXPORT=/path to /optee_client/out/export
export CROSS_COMPILE_HOST=arm-linux-gnueabihf-
export CROSS_COMPILE_TA=arm-linux-gnueabihf-
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=/path to toolchain/bin:$PATH

Now we execute make command with COMPILE_NS_USER flag. For imx6qdl its 32

ARCH=arm make COMPILE_NS_USER=32

Copy all .ta *.elf in out/ to sd card rootfs /lib/optee_armtz/

cp -vrf `find out/ -name *.ta` /path to sdcard mount directory/lib/optee_armtz/
cp -vrf `find out/ -name *.elf` /path to sdcard mount directory/lib/optee_armtz/
cp -vf out/xtest/xtest /path to sdcard mount directory/bin/

Now, insert the sd card and boot linux with optee.

First run tee-supplicant

tee-supplicant &

First we run benchmark test with level 0, means minimal tests

xtest -t benchmark
Test Results:
benchmark_1001 TEE Trusted Storage Performance Test (WRITE)
-----------------+---------------+----------------
Data Size (B)    | Time (s)      | Speed (kB/s)
-----------------+---------------+----------------
256              |    0.040      |    6.250
512              |    0.055      |    9.091
1024             |    0.055      |   18.182
2048             |    0.100      |   20.000
4096             |    0.243      |   16.461
16384            |    1.086      |   14.733
524288           |   46.275       |   11.064
1048576          |   95.700      |   10.700
-----------------+---------------+----------------
benchmark_1001 OK

* benchmark_1002 TEE Trusted Storage Performance Test (READ)
-----------------+---------------+----------------
Data Size (B)    | Time (s)      | Speed (kB/s)
-----------------+---------------+----------------
256              |    0.001      |  250.000
512              |    0.001      |  500.000
1024             |    0.001      | 1000.000
2048             |    0.003      |  666.667
4096             |    0.008      |  500.000
16384            |    0.033      |  484.848
524288           |    1.027       |  498.539
1048576          |    2.035      |  503.194
-----------------+---------------+----------------
benchmark_1002 OK

* benchmark_1003 TEE Trusted Storage Performance Test (REWRITE)
-----------------+---------------+----------------
Data Size (B)    | Time (s)      | Speed (kB/s)
-----------------+---------------+----------------
256              |    0.042      |    5.952
512              |    0.042      |   11.905
1024             |    0.043      |   23.256
2048             |    0.286      |    6.993
4096             |    0.212      |   18.868
16384            |    0.991      |   16.145
524288           |   49.030      |   10.443
1048576          |  102.586      |    9.982
-----------------+---------------+----------------
benchmark_1003 OK

* benchmark_2001 TEE SHA Performance test (TA_SHA_SHA1)
min=262us max=588.333us mean=274.617us stddev=29.5489us (cv 10.76%) (3.55608MiB/s)
benchmark_2001 OK

* benchmark_2002 TEE SHA Performance test (TA_SHA_SHA226)
min=411.333us max=763.667us mean=430.237us stddev=36.6874us (cv 8.52726%) (9.07931MiB/s)
benchmark_2002 OK

* benchmark_2011 TEE AES Performance test (TA_AES_ECB)
min=319us max=638.334us mean=332.388us stddev=30.8239us (cv 9.27346%) (2.93802MiB/s)
benchmark_2011 OK

* benchmark_2012 TEE AES Performance test (TA_AES_CBC)
min=357us max=758us mean=373.566us stddev=34.0887us (cv 9.12523%) (2.61417MiB/s)
benchmark_2012 OK


Result of testsuite benchmark:
benchmark_1001 OK
benchmark_1002 OK
benchmark_1003 OK
benchmark_2001 OK
benchmark_2002 OK
benchmark_2011 OK
benchmark_2012 OK

24 subtests of which 0 failed
7 test cases of which 0 failed
0 test case was skipped
TEE test application done!

Now, we run benchmark test with level 15, means all the tests

xtest -t benchmark -l 15
-----------------+---------------+----------------
 Data Size (B)   | Time (s)      | Speed (kB/s)
-----------------+---------------+----------------
      256        |    0.052      |    4.808
      512        |    0.052      |    9.615
     1024        |    0.036      |   27.778
     2048        |    0.098      |   20.408
     4096        |    0.709      |    5.642
    16384        |    0.968      |   16.529
   524288        I/TA: command id: 0, test data size: 256, chunk size: 1024
|   46.708       |   10.962
  1048576        |   97.244      |   10.530
-----------------+---------------+----------------
  benchmark_1001 OK

* benchmark_1002 TEE Trusted Storage Performance Test (READ)
I/TA: start: 3318.376(s), stop: 3318.377(s), delta: 1(ms)
I/TA: command id: 0, test data size: 512, chunk size: 1024
I/TA: start: 3318.637(s), stop: 3318.639(s), delta: 2(ms)
I/TA: command id: 0, test data size: 1024, chunk size: 1024
I/TA: start: 3318.915(s), stop: 3318.917(s), delta: 2(ms)
I/TA: command id: 0, test data size: 2048, chunk size: 1024
I/TA: start: 3319.255(s), stop: 3319.258(s), delta: 3(ms)
I/TA: command id: 0, test data size: 4096, chunk size: 1024
I/TA: start: 3319.733(s), stop: 3319.741(s), delta: 8(ms)
I/TA: command id: 0, test data size: 16384, chunk size: 1024
I/TA: start: 3320.893(s), stop: 3320.925(s), delta: 32(ms)
I/TA: command id: 0, test data size: 524288, chunk size: 1024
I/TA: start: 3367.678(s), stop: 3368.727(s), delta: 1049(ms)
I/TA: command id: 0, test data size: 1048576, chunk size: 1024
I/TA: start: 3469.15(s), stop: 3471.55(s), delta: 2040(ms)
-----------------+---------------+----------------
 Data Size (B)   | Time (s)      | Speed (kB/s)
-----------------+---------------+----------------
      256        |    0.001      |  250.000
      512        |    0.002      |  250.000
     1024        |    0.002      |  500.000
     2048        |    0.003      |  666.667
     4096        |    0.008      |  500.000
    16384        |    0.032      |  500.000
   524288        I/TA: command id: 2, test data size: 256, chunk size: 1024
|    1.049       |  488.084
  1048576        |    2.040      |  501.961
-----------------+---------------+----------------
  benchmark_1002 OK

* benchmark_1003 TEE Trusted Storage Performance Test (REWRITE)
I/TA: start: 3471.361(s), stop: 3471.411(s), delta: 50(ms)
I/TA: command id: 2, test data size: 512, chunk size: 1024
I/TA: start: 3471.705(s), stop: 3471.747(s), delta: 42(ms)
I/TA: command id: 2, test data size: 1024, chunk size: 1024
I/TA: start: 3472.14(s), stop: 3472.55(s), delta: 41(ms)
I/TA: command id: 2, test data size: 2048, chunk size: 1024
I/TA: start: 3472.351(s), stop: 3472.450(s), delta: 99(ms)
I/TA: command id: 2, test data size: 4096, chunk size: 1024
I/TA: start: 3472.863(s), stop: 3473.97(s), delta: 234(ms)
I/TA: command id: 2, test data size: 16384, chunk size: 1024
I/TA: start: 3474.634(s), stop: 3475.460(s), delta: 826(ms)
I/TA: command id: 2, test data size: 524288, chunk size: 1024
I/TA: start: 3521.591(s), stop: 3569.728(s), delta: 48137(ms)
I/TA: command id: 2, test data size: 1048576, chunk size: 1024
I/TA: start: 3671.322(s), stop: 3772.377(s), delta: 101055(ms)
-----------------+---------------+----------------
 Data Size (B)   | Time (s)      | Speed (kB/s)
-----------------+---------------+----------------
      256        |    0.050      |    5.000
      512        |    0.042      |   11.905
     1024        |    0.041      |   24.390
     2048        |    0.099      |   20.202
     4096        |    0.234      |   17.094
    16384        |    0.826      |   19.370
   524288        |   48.137      |   10.636
  1048576        |  101.055      |   10.133
-----------------+---------------+----------------
  benchmark_1003 OK

* benchmark_2001 TEE SHA Performance test (TA_SHA_SHA1)
min=271us max=629.667us mean=283.53us stddev=28.9001us (cv 10.193%) (3.4443MiB/s)
  benchmark_2001 OK

* benchmark_2002 TEE SHA Performance test (TA_SHA_SHA226)
min=415.333us max=783.334us mean=435.947us stddev=38.411us (cv 8.81094%) (8.96038MiB/s)
  benchmark_2002 OK

* benchmark_2011 TEE AES Performance test (TA_AES_ECB)
min=329.667us max=676us mean=346.326us stddev=32.3748us (cv 9.34808%) (2.81978MiB/s)
  benchmark_2011 OK

* benchmark_2012 TEE AES Performance test (TA_AES_CBC)
min=359.667us max=792us mean=376.213us stddev=32.3281us (cv 8.59304%) (2.59577MiB/s)
  benchmark_2012 OK
+-----------------------------------------------------
Result of testsuite benchmark:
benchmark_1001 OK
benchmark_1002 OK
benchmark_1003 OK
benchmark_2001 OK
benchmark_2002 OK
benchmark_2011 OK
benchmark_2012 OK
+-----------------------------------------------------
24 subtests of which 0 failed
7 test cases of which 0 failed
0 test case was skipped
TEE test application done!

Now, we run the regression tests with level[0-15] 15

xtest -t regression -l 15
+-----------------------------------------------------
Result of testsuite regression:
regression_1001 OK
regression_1002 OK
regression_1003 OK
regression_1004 OK
regression_1005 OK
regression_1006 OK
regression_1007 OK
regression_1008 OK
regression_1009 OK
regression_1010 OK
regression_1011 OK
regression_1012 OK
regression_1013 OK
regression_1015 OK
regression_1016 OK
regression_1017 OK
regression_1018 OK
regression_1019 OK
regression_2001 OK
regression_2002 OK
regression_2003 OK
regression_2004 OK
regression_4001 OK
regression_4002 OK
regression_4003 OK
regression_4004 OK
regression_4005 OK
regression_4006 OK
regression_4007 OK
regression_4008 OK
regression_4009 OK
regression_4010 OK
regression_4011 OK
regression_4012 OK
regression_5006 OK
regression_6001 OK
regression_6002 OK
regression_6003 OK
regression_6004 OK
regression_6005 OK
regression_6006 OK
regression_6007 OK
regression_6008 OK
regression_6009 OK
regression_6010 OK
regression_6012 OK
regression_6013 OK
regression_6014 OK
regression_6015 OK
regression_6016 OK
regression_6017 OK
regression_6018 OK
regression_6019 OK
regression_6020 OK
regression_7001 OK
regression_7002 OK
regression_7003 OK
regression_7004 OK
regression_7005 OK
regression_7006 OK
regression_7007 OK
regression_7008 OK
regression_7009 OK
regression_7010 OK
regression_7013 OK
regression_7016 OK
regression_7017 OK
regression_7018 OK
regression_7019 OK
regression_8001 OK
regression_8002 OK
regression_8101 OK
regression_8102 OK
regression_8103 OK
+-----------------------------------------------------
16081 subtests of which 0 failed
74 test cases of which 0 failed
0 test case was skipped
TEE test application done!

SHA performance testing tool

xtest --aes-perf -v

Starting test: ECB, encrypt, keysize=128 bits, size=1024 bytes, random=no, in place=no, inner loops=1, loops=5000, warm-up=2 s
min=302.333us max=694us mean=316.77us stddev=30.7425us (cv 9.70496%) (3.08287MiB/s)
2-sigma interval: 255.286..378.255us (2.58175..3.82537MiB/s)

AES performance testing tool

xtest --sha-perf -v

Starting test: SHA1, size=1024 bytes, random=no, unaligned=no, inner loops=1, loops=5000, warm-up=2 s
min=261.667us max=588.333us mean=273.777us stddev=27.9708us (cv 10.2167%) (3.567MiB/s)
2-sigma interval: 217.835..329.718us (2.96181..4.48304MiB/s)

Linux DRM Subsystem

Linux Media Subsystem

MIPI-CSI2 OV5640 Camera

Build

Use buildroot rootfs with below Linux

git clone https://github.com/amarula/linux-amarula
cd linux-amarula
git checkout -b imx6-ov5640 origin/imx6-ov5640
ARCH=arm make imx_v6_v7_defconfig
ARCH=arm make LOADADDR=0x10008000 uImage dtbs -j 16
Capture

Once Linux boot, prepare media control chart for finding pipeline setups

On target

media-ctl --print-dot > mipi-ov5640.dot

On host

dot -T png -o mipi-ov5640.png mipi-ov5640.dot
_images/imx6-csi.png

Configure the pipeline with default format AYUV32/640x480,this can be alter with any other relevant format to testing with.

Setup MC links

media-ctl --links "'ov5640 2-003c':0->'imx6-mipi-csi2':0[1]"
media-ctl --links "'imx6-mipi-csi2':1->'ipu1_csi0_mux':0[1]"
media-ctl --links "'ipu1_csi0_mux':2->'ipu1_csi0':0[1]"
media-ctl --links "'ipu1_csi0':2->'ipu1_csi0 capture':0[1]"

Configure pads

media-ctl --set-v4l2 "'ov5640 2-003c':0[fmt:UYVY2X8/640x480 field:none]"
media-ctl --set-v4l2 "'imx6-mipi-csi2':1[fmt:UYVY2X8/640x480 field:none]"
media-ctl --set-v4l2 "'ipu1_csi0_mux':2[fmt:UYVY2X8/640x480 field:none]"
media-ctl --set-v4l2 "'ipu1_csi0':2[fmt:AYUV32/640x480 field:none]"

Launch the camera with ipu1_csi0 capture

gst-launch-1.0 -v v4l2src device=/dev/video4 ! autovideosink

Zephyr

Zephyr Setup

Follow steps 1, 2, 3, 4, and 5 from the zephyr project. This will install all the tools required to build zephyr, and download the zephyr sources.

ESP32

ESP32 Zephyr setup

This tutorial shows you have to set up the ESP32 Wrover development board for use with zephyr on Linux.

First time board configuration

The first time the board is used you should set the correct jumper configuration for using JTAG. This only needs to be done once per board. See the figure for the correct jumper settings.

_images/wrover.jpg
ESP32 Tools

Follow steps 1, 2 and 3 from espressif to install the required tools, download the sdk, and install the ESP32 toolchain.

Zephyr Tools

Follow these steps to download and set up zephyr and its build tools.

Environment

In order to build zephyr for ESP32 the following environment variables should be set. The value for ESPRESSIF_TOOLCHAIN_PATH depends on where you installed it during the tool instalation step. The value for ESP_IDF_PATH depends on where you downloaded it during the tool instalation step.

export ZEPHYR_TOOLCHAIN_VARIANT="espressif"
export ESPRESSIF_TOOLCHAIN_PATH="${HOME}/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/"
export ESP_IDF_PATH="${HOME}/esp/esp-idf"

Put these commands in a script somewhere and source it at the start of your development session.

Build and run

In order to build and run zephyr on the board use the following commands:

cd ~/zephyrproject
west build -b esp32 -s zephyr/samples/hello_world/
west flash

Texas Instruments

CC3220SF LaunchXL Zephyr Setup

This tutorial shows you how to set up the CC3220SF LaunchXL board for use with Zephyr on Linux.

First time board configuration

Before the board can be used with Zephyr for the first time it must be flashed with a service pack. This only has to be done once for each board.

  1. Download and install the SDK and UniFlash.

  2. Set the SOP jumper to 010 as shown in the picture.

    _images/jumper1.jpg
  3. Update the service pack and set the device to developer mode using Uniflash.

    1. Start UniFlash with the board connected by USB. UniFlash should automatically detect the board as shown in the figure below. Click Start.

      _images/uf1.png
    2. Click New Project

      _images/uf2.png
    3. Give the project a name. Make sure the device type is set correctly and Device Mode is set to Develop. Click Create Project.

      _images/uf3.png
    4. Click on Connect and select the service pack for this device. On a default instalation this file should be in ti/simplelink_cc32xx_sdk_4_10_00_07/tools/cc32xx_tools/servicepack-cc3x20/sp_3.15.0.1_2.0.0.0_2.2.0.7.bin.

      _images/uf4.png
    5. On the right side the device information should now be listed. Double check that the mode is set to Development. Click Burn in the bottom right.

      _images/uf5.png
    6. Click Program Image and wait for it to complete.

      _images/uf6.png
  4. Update XDS-110.

    1. Download and install the xds-110 software here.

    2. Switch to the instalation directory of the XDS110 software:

      cd ~/ti/ccs_base/common/uscif/xds110/
      
    3. Check that the device is correctly detected using the following command:

      ./xdsdfu -e
      

      The output should look like this:

      USB Device Firmware Upgrade Utility
      Copyright (c) 2008-2019 Texas Instruments Incorporated.  All rights reserved.
      
      Scanning USB buses for supported XDS110 devices...
      
      
      <<<< Device 0 >>>>
      
      VID: 0x0451    PID: 0xbef3
      Device Name:   XDS110 Embed with CMSIS-DAP
      Version:       2.3.0.16
      Manufacturer:  Texas Instruments
      Serial Num:    E0071009
      Mode:          Runtime
      Configuration: Standard
      
      Found 1 device.
      
    4. Put the XDS110 in DFU mode:

      ./xdsdfu -m
      
    5. Update the XDS110 firmware:

      ./xdsdfu -f firmware_3.0.0.11.bin -r
      
  5. Set the SOP jumper to 001 as shown in the picture.

    _images/jumper2.jpg
Zephyr Tools

Follow these steps to download and set up zephyr and its build tools.

Environment

Follow step 6 to set up the zephyr toolchain and the two environment variables ZEPHYR_TOOLCHAIN_VARIANT and ZEPHYR_SDK_INSTALL_DIR. Create a script that sets those and source it before starting a development session.

Build and run

In order to build and run zephyr on the board use the following commands:

cd ~/zephyrproject
west build -b cc3220sf_launchxl -s zephyr/samples/hello_world/
west flash

ChatGPT meets Gerrit

Motivation

Gerrit is a web-based code review and project management tool for Git repositories. It facilitates collaborative coding by allowing developers to submit their changes to a central server, where others can review, discuss, and ultimately approve the changes before they are merged into the project. This process enables multiple eyes to scrutinize every piece of code.

At Amarula, we extensively utilize Gerrit for our development processes, leveraging its robust code review and collaboration features. In light of its features, we concluded that the pairing of Gerrit and ChatGPT was a match already in the making. In our relentless quest for enhanced code quality and improved project management efficiency, we believe that incorporating ChatGPT into Gerrit can refine the review process and introduce an extra dimension of AI-powered intelligence.

As a Virtual Gerrit User, ChatGPT should be empowered to

  • Offer Insights and Suggestions
  • Provide Automated Code Analysis
  • Respond to Queries from Developers

Control is the Key

Talking about tools, the thin line that separates a dream from a nightmare is Control.

Bearing this key principle in mind, it is essential that Gerrit administrators have the capability to selectively enable the ChatGPT review function for particular projects, users, groups, and topics.

The reins of control are tightly held by the developers, as shown in the following workflow:

  • A Gerrit Patch Set that has the ChatGPT review function enabled is submitted to the Gerrit Server.
  • ChatGPT delivers an initial insight on the Patch Set, and this insight is displayed within the Gerrit UI.
  • Developers have the option to either disregard or act on the insight.
  • Developers can also decide to continue the dialogue with ChatGPT within the Gerrit UI to gain additional insights.

Alternatively, the process can also begin when developers use the Gerrit UI to start any conversation with ChatGPT on their own, whether it’s a general discussion or based on a specific section of a Patch Set code.

The so-designed Gerrit plugin is available as Open Source project at https://github.com/amarula/chatgpt-code-review-gerrit-plugin/.

Quickstart

Before diving into the specifics of the ChatGPT plugin, it’s essential to have a Gerrit server up and running.

System Requirements
  • Java SE Runtime Environment version 11 and up.
  • Maven 3.0 or higher.
Installing Gerrit Server

Below is an extract from the Quickstart for Installing Gerrit on Linux. To install a Gerrit production environment, the Standalone Daemon Installation Guide should be followed instead.

1. Download Gerrit from the official Gerrit Releases page. The command below downloads Gerrit 3.9.1:

wget https://gerrit-releases.storage.googleapis.com/gerrit-3.9.1.war
  1. Initialize Gerrit
export GERRIT_SITE=~/gerrit_testsite
java -jar gerrit*.war init --batch --dev -d $GERRIT_SITE
  1. Start Gerrit
$GERRIT_SITE/bin/gerrit.sh start
Installing Gerrit ChatGPT plugin

The following is an extract from the Getting Started section, intended for demonstration purposes. For production installation, please refer to the full guide at https://github.com/amarula/chatgpt-code-review-gerrit-plugin/.

  1. Download the plugin code
git clone https://github.com/amarula/chatgpt-code-review-gerrit-plugin.git
  1. Build the plugin
cd chatgpt-code-review-gerrit-plugin
mvn -U clean package
  1. Install the plugin

    Upload/copy the compiled jar file from the ./target directory to $GERRIT_SITE/plugins.

  2. Configure the plugin

    First, create a ChatGPT user in Gerrit. Then, set up the basic parameters in $GERRIT_SITE/etc/gerrit.config file, under the section

    [plugin "chatgpt-code-review-gerrit-plugin"]:

  • gptToken: OpenAI GPT token.

  • gerritAuthBaseUrl: The URL of Gerrit instance, similar to https://gerrit.local.team.

    NOTE: Do not append “/a” authentication sub-path to the URL.

  • gerritUserName: Gerrit username of ChatGPT user.

  • gerritPassword: Gerrit password of ChatGPT user.

  • globalEnable: Default value is false. The plugin will only review specified repositories. If set to true, the plugin will by default review all pull requests.

  1. Restart Gerrit
$GERRIT_SITE/bin/gerrit.sh restart

Going to Production

We are convinced that this initiative is not just a mere experiment. It’s a full-fledged implementation being rigorously tested in the crucible of real-world, production environments. This real-time testing scenario provides us with a golden opportunity to refine the integration, informed by practical feedback and demands for functionality enhancements.

We realized that it was the right time to move to production. Let’s take a look at the outcome.

Patch Set Review

ChatGPT, acting as a vigilant overseer, reviews Patch Sets of selected Gerrit projects as they arrive. This feature ensures that each submission undergoes a preliminary AI-driven analysis, setting a high standard of quality and coherence right from the start.

_images/chatgpt_patchset_review.png

ChatGPT’s insight on a patched code segment in Kotlin

Behind the scenes, the path towards enhancing the quality of ChatGPT’s responses was achieved through meticulous prompt engineering. This significant progression involved more than just fine-tuning algorithms; it focused on understanding the delicate dynamics of developer interactions and tailoring the responses to align with these nuances.

An additional feature allows for examining the congruence of the commit messages with the Patch Sets’ changes, ensuring that the narrative of the commit aligns with the actual modifications made.

_images/chatgpt_patchset_review_commit_message.png

ChatGPT’s insight on a Patch Set commit message

Interactive Assistance

ChatGPT goes beyond being just a tool, acting more like a virtual colleague. It’s ready to respond to user inquiries, offering suggestions, and clarifying any doubts. This function is akin to having an additional team member, one that’s always available to provide insights and clarifications, much like a knowledgeable human peer.

The ability to start conversations with ChatGPT directly from an inline comment adds a layer of dynamism to the interaction. Users can request reviews on specific parts of the code, extending even beyond the current Patch Set, or ask for improvement suggestions. This feature essentially brings an on-demand code review assistant into the workflow, available at the click of a button.

In the following example, a further inquiry about how to implement a change recommended by ChatGPT is showcased.

_images/chatgpt_interactive_assistance_cropped.png

ChatGPT’s interaction on a patched code segment in Java

In the example showcased next, ChatGPT is queried about a different implementation approach on a code segment that isn’t directly related to the changes in the Patch Set.

_images/chatgpt_query_min.png

ChatGPT interaction in response to an inquiry about a code line from a Python project

Adjusting Verbosity Level

The verbosity level can be further increased by specifically requesting multiple alternatives and code examples.

_images/chatgpt_query_max.png

ChatGPT interaction in response to an inquiry about a code line from a Python project

It is also possible to submit broader inquiries about the entire Patch Set.

_images/chatgpt_query_entire_patchset_bounds.png

ChatGPT answer to a broad query related to a Kotlin project

Security and Privacy

Last but certainly not least, we give utmost importance to security and privacy.

Recognizing scenarios where code confidentiality is paramount, we’ve introduced a new configuration option (gptFullFileReview) which, when set to false, restricts the code reviewed by ChatGPT to only the changes made, without including the entire file. This feature ensures that sensitive information remains within the confines of the organization, thus safeguarding intellectual property and adhering to privacy standards.

Conclusion

Our exploration of the integration of ChatGPT into Gerrit has highlighted several key points:

  • Virtual Gerrit Collaborator: We’ve discussed the groundbreaking integration of ChatGPT into a Gerrit plugin, showcasing how it acts not just as a tool but as a Virtual Collaborator in the development process.
  • Control and Customization: We emphasized the importance of control, allowing Gerrit administrators to selectively activate ChatGPT for specific projects, users, groups, and topics, and enabling developers to maintain a firm grip on the reins of control. This ensures that ChatGPT’s insights are relevant and aligned with the developers’ needs.
  • Interactive and Responsive Nature: The feature that allows developers to continue conversations based on initial insights or start new ones independently showcases the interactive and responsive nature of the plugin.
  • Security and Privacy: We shared best practices for maintaining security and privacy when using ChatGPT within Gerrit.

By integrating ChatGPT into Gerrit, we aim to enhance code quality, streamline project management, and introduce AI-driven intelligence into the software development lifecycle. This integration is a step towards a more efficient, collaborative, and intelligent coding environment, highlighting our commitment to innovation and excellence in software development.

Security topics

React Native and vulnerabilities

Introduction

Resolving vulnerabilities in React Native applications is crucial to ensure the security and stability of the codebase. We will explore the tools and techniques that can aid in resolving vulnerabilities efficiently. We will highlight the importance of utilizing Yarn Resolutions in package.json, which allows you to enforce specific versions of dependencies, overriding the versions specified in the yarn.lock file. Additionally, we will discuss the benefits of using Patch-package, a tool that enables you to make modifications to dependencies without directly modifying the source code in cooperation with postinstall. However patch-package should be considered as a last resort in the fixing crashes/issues or vulnerability resolution process, when other methods such as enforcing specific versions through Yarn Resolutions or managing dependency are not sufficient to address the vulnerabilities. The first step should be to search library repositories and look for vulnerability fixes.

Challenges

When it comes to resolving vulnerabilities, there are several challenges that developers may encounter. These challenges include compatibility issues, dependency management complexity, ensuring dependency compatibility, resolving transitive dependencies, handling version conflicts, and the need for testing and continuous monitoring. Let’s explore each of these challenges in detail and discuss strategies to overcome them effectively.

Compatibility Issues

Upgrading libraries to their maximum versions might lead to compatibility issues, as the highest versions may not be compatible with each other. To tackle this challenge, it is recommended to carefully test library upgrades in a controlled environment. Incrementally upgrade libraries one by one, ensuring compatibility as you progress. If compatibility issues arise, consider using older versions that are known to work well together or seek alternatives that offer similar functionality.

Dependency Management

Managing dependencies in a React Native project can be complex, especially when different libraries have conflicting or overlapping dependencies. To overcome this challenge, it is essential to have a thorough understanding of your project’s dependencies and their interdependencies. Utilize tools like yarn.lock to analyze and resolve dependency conflicts. Consider using dependency management tools like Yarn resolutions to enforce specific versions and resolve conflicts effectively.

Dependency Compatibility

One challenge you may face is ensuring compatibility between different dependencies when using yarn resolutions. Sometimes, upgrading one library to resolve a vulnerability can introduce compatibility issues with other dependencies.

To overcome this challenge, it’s important to carefully review the documentation and release notes of each dependency. Look for any breaking changes or compatibility issues that may arise when upgrading a specific library. Additionally, you can test your application thoroughly after making version changes to identify and address any compatibility issues early on.

Example: Let’s say you have a vulnerability in the react-navigation library. Upgrading it to the latest version (^6.0.0) causes compatibility issues with the react-native-gesture-handler library, which requires a lower version (^2.0.0).

To address this, you can specify a compatible version in the resolutions field of your package.json:

"resolutions": {
  "react-navigation": "^5.0.0"
}
Resolving Transitive Dependencies

Another challenge is resolving vulnerabilities in transitive dependencies, which are dependencies of your project’s direct dependencies. Simply upgrading the versions of direct dependencies may not solve vulnerabilities in their transitive dependencies.

To address this challenge, you can use yarn resolutions to enforce specific versions for the transitive dependencies as well. Analyze the vulnerability reports from tools like mend.io. There are another options which are reading from open streams, so it not may be trustful as mend.io, but for quick check can be just fine to run npm audit or yarn audit to identify the affected transitive dependencies and include them in the resolutions field of your package.json file.

Example: Let’s say you have a vulnerability in the axios library, and it has a transitive dependency on lodash which also has a vulnerability, but axios haven’t treat the vulnerability on lodash yet.

To resolve this, include the transitive dependency in the resolutions field of your package.json:

"dependencies": {
     "axios": "^0.21.1"
}
"resolutions": {
     "lodash": "^4.17.21"
}

Example2: Resolving vulnerabilities in transitive dependencies can become complex when multiple direct dependencies are involved, causing a chain of transitive dependencies. Let’s consider an example to illustrate this scenario:

Suppose your project has two direct dependencies, “libraryA” and “libraryB.” “LibraryA” has a vulnerability that requires an upgrade (and has security fix), and it has a transitive dependency on “libraryC.” However, “libraryC” also has a vulnerability that needs to be addressed, and it has a transitive dependency on “libraryD.”. If maintainers “libraryA” or “libraryB.” would ignore vulnerabilities in the libraryC and libraryC would also ignore vulnerability on libraryD then you should use yarn resolution. The big problem could be if there is no fix at all, then you can use patch package and fix it by yourself (may be help to other users to make pull request in their gits).

To tackle this complex situation, you can utilize yarn resolutions to enforce specific versions for all the transitive dependencies. In our example, you would include the resolutions for both “libraryC” and “libraryD” in your package.json. Direct dependency “libraryA”, you would include change in the dependencies block directly (without need of resolution):

"dependencies":{
    "libraryA":  "^1.5.7",
    "libraryB":  "^2.0.0",
}
"resolutions":  {
   "libraryC":  "^3.1.0",
   "libraryD":  "^4.1.0",
}

By explicitly specifying the versions in the resolutions field, you ensure that the vulnerable transitive dependencies are resolved, providing a more secure and stable environment for your project.

Version Conflicts

Resolving vulnerabilities using yarn resolutions can sometimes lead to version conflicts between different dependencies. This occurs when multiple dependencies have conflicting requirements for the same package.

To handle version conflicts, you may need to manually adjust the versions specified in the resolutions field of your package.json. Experiment with different versions or consult the documentation of the conflicting dependencies to find a compatible resolution.

Example: Let’s say you have a vulnerability in the react-native-image-picker library, and resolving it requires upgrading the react-native library to a higher version. However, another library, such as react-native-maps, has a specific version requirement that conflicts with the upgraded react-native version.

In this case, you may need to experiment with different versions or consult the documentation of the conflicting libraries to find a compatible resolution. For example:

"dependencies": {
     "react-native": "^0.65.0"
}
"resolutions": {
     "react-native-maps": "^0.28.0"
}
Testing and Validation

After resolving vulnerabilities, it is crucial to thoroughly test and validate your application. Ensure that the fixes and upgrades do not introduce new bugs or regressions. Perform comprehensive testing, including functional, integration, and security testing, to validate the effectiveness of the vulnerability resolutions.

Continuous Monitoring

Resolving vulnerabilities is an ongoing process, as new vulnerabilities may be discovered in dependencies over time. It’s essential to stay vigilant and keep your dependencies up to date.

Regularly monitor the vulnerability reports from tools like mend and continuously schedule the scan via jenkins tool for instance or npm audit or yarn audit. Stay informed about security advisories and updates related to your dependencies. Update your resolutions and dependencies accordingly to address newly discovered vulnerabilities.

Resolving Vulnerabilities tools

When it comes to resolving vulnerabilities, it is crucial to follow a proper procedure and prioritize the tools accordingly. Yarn is particularly valuable in this regard because it allows for upgrading direct dependencies and, as a result, their transitive dependencies. However, it is important to note that the first step should be to search library repositories and look for vulnerability fixes.

Utilizing Yarn Resolutions

Yarn provides a feature known as resolutions, which proved to be a valuable tool in resolving vulnerabilities efficiently. By configuring the resolutions field in the package.json file, specific versions of dependencies can be enforced, overriding the versions specified in the yarn.lock file. This approach ensures that the required versions are used, mitigating potential vulnerabilities.

To utilize yarn resolutions, follow these steps:

  1. Install Yarn globally if it doesn’t already installed by running the following command:
npm install -g yarn
  1. Navigate to the root directory of your project.
  2. Open the package.json file and add a resolutions field if it doesn’t already exist. For example:
"resolutions": {
     "**/xmldom": "latest"
}

In the example above, the xmldom library is forced to use the latest version.

4. Run the following command to install the dependencies with the enforced resolutions:

yarn install
Using Patch-package

Patch-package is a helpful tool that allows for making changes to the dependencies directly. It provides a mechanism to apply patches to libraries without modifying the original source code. By utilizing patch-package, you can address vulnerabilities or make necessary adjustments specific to your project, while still being able to easily update the library in the future.

  1. Navigate to the root directory of your project.

  2. Install patch-package by running the following command:
    yarn add patch-package
  3. Make the necessary changes to the dependencies in your project. For example change react-native index.js file.

  4. Run the following command to generate patch files for the modified dependencies:
    yarn patch-package  <package-name>\
    Replace <package-name> with the name of the package you made changes to.
  5. Commit the generated patch files and include them in your version control system.

  6. Install postinstall and follow steps below.

  7. Whenever you run yarn install, patch-package will automatically apply the patches, ensuring your modifications persist even after package updates. Beware that patches are on the specific version of the package, so whenever package’s version is changed, new patch file is required.

Postinstall Scripts

Postinstall scripts can be used to automate tasks after the installation of dependencies. By leveraging this feature, you can perform additional checks or actions to ensure the security and stability of the project. For example, running vulnerability scans or applying necessary patches can be automated using postinstall scripts.

  1. Navigate to the root directory of your project.

  2. Install patch-package by running the following command:
    yarn add postinstall-postinstall
  3. Open the package.json file in your project.

  4. Add a postinstall into block with script that includes the necessary commands. For example:
    "scripts":  {  "postinstall":  "patch-package"  }
  5. Save the changes to package.json.

  6. Run yarn install and the postinstall script will execute automatically.

Clearing Cache

Clearing the yarn cache and native part caches can help in recovering from potential issues related to cached dependencies and can also resolve certain problems that arise due to conflicting or outdated cache entries.

Important notice. You should be vigilant and make it a habit to regularly clean the cache of your project to avoid potential issues, bugs, crashes and ensure optimal performance.

Mend

Whitesource contains configuration file which set the behavior of the Unified Agent scan.

Here you can find the complete option documentation, but I highlighted most common config options:

npm.resolveLockFile - Whether the Unified Agent will rely on the manifest (package.json) and lock file (package-lock.json) for the resolution and not rely on NPM commands. If the lock file is missing, the detection will be based on the node_modules folder.

resolveAllDependencies -

Whether to enable or disable by default all dependency resolvers for a scan. Default value is True.

For example, when the following parameters are set, only npm dependencies will be resolved in this case:
resolveAllDependencies=false
npm.resolveDependencies=true
#maven.resolveDependencies***=*false

Maven would be normally True (thats default value), but it will be overwritten with the False value of resolveAllDependencies.

forceCheckAllDependencies - Force checks all policies for all dependencies introduced to the Mend projects.

excludes - Whether to exclude specific files from the scan. If a directory is specified to be excluded, no manifest files located in the directory will be picked up by the different resolvers.

fileSystemScan - Performs a file system scan for source files and binaries, in addition to the package manager based dependencies resolution. The files to be scanned can be controlled by the includes and excludes parameters and the resolver-specific ignoreSourceFiles parameters.

maven.resolveDependencies - Whether to resolve Maven dependencies, requires “pom.xml”.

gradle.resolveDependencies - Whether to resolve Gradle dependencies. Requires build.gradle or build.gradle.kts.

gradle.includedConfigurations -

Enables you to determine which dependency configurations to include in the scan.

The format is according to the following:

  • Exact configuration names to include.
Values should be space-delimited.
For example:

gradle.includedConfigurations= compileOnly testCompileOnly

Includes configurations named “compileOnly” and “testCompileOnly”.

  • Configurations can include regular expressions.

For example:

gradle.includedConfigurations=.Only.

Includes all configuration names that contain the string “Only”

npm.resolveDependencies - Whether to resolves NPM/yarn/pnpm dependencies.

npm.includeDevDependencies - Whether to include dev dependencies.

cocoapods.resolveDependencies - Whether to resolve CocoaPods dependencies (using CocoaPods).

cocoapods.ignoreSourceFiles - When using the dependency resolver, it will only include package dependencies, not source files.

docker.scanImages -

Runs scans on all or specified images.

When set to True, only Docker image scan will occur. This will include the detection of Linux packages, and a general scan of the image file system for package managers’ based resolution and identification of source files/binaries.

docker.scanTarFiles - Used when the user supplies the .tar file of a Docker image.

docker.scanContainers -

Scan all or specified containers.
When set to True, only Docker container scan will occur. This will include the detection of Linux packages, and a general scan of the container file system for package managers’ based resolution and identification of source files/binaries.

Before starting a container scan, run the command “docker ps -a” to check for listed containers.

scanPackageManager -

Scans Linux packages by their file name and version. Supported package types are Debian, RPM, Alpine, Arch Linux, and DNF.

Depending on the package type, one of the following commands will be run:

  • Debian: dpkg -l
  • RPM: rpm -qa
  • Alpine: apk -vv info
  • Arch Linux: pacman -Q
  • DNF/ centOS:8 - no command, image should contain at least journal.log file (installation log) and rpm.dnf.log file (in case of system packages update was executed).

Linux Foundations

Host

Git Bisect Tutorial

When we we are not sure which commit in our git repository broke something, we need some tool to find that bad/buggy commit. This situation becomes complex when there are large number of commits and we have no clue. In this situation git bisect is our saviour. Suppose we found bug in u-boot v2017.07 version and we know that v2017.05 version is working fine. But the number of commits between v2017.07 version and v2017.05 version are huge. In this situation checking each of the commits would take enormous time and it wouldn’t a wise thing to do.

In such scenarios git bisect plays a very vital role and saves our efforts and time in finding buggy or bad commit. We will see how to find buggy commit using git bisect. Lets starts! To start, we would need git commit ids of v2017.07(say 2f4c1d83f4e8) and v2017.05 (say a63d800196eb)

Steps:

step1: In our git repository we run,

git bisect start

git bisect good a63d800196eb

git bisect bad  2f4c1d83f4e8
_images/step1.png

Git bisect looked at all of the commits between a63d800196eb and 2f4c1d83f4e8, picked the middle one i.e be62fbf37626, and switched the current checkout to that instead. Now, we need to check whether commit be62fbf37626 is buggy/bad or not. We build at this commit and check whether it has that bug or not.

step2: Build repo at checkout commit in our case it is be62fbf37626

step3: Run either git bisect bad or git bisect good based on above build.

If commit id is buggy(say it is) then we run git bisect bad else we would run git bisect good

_images/step.png

Step4 …. N: keep repeating above step 2 and step3

_images/step3.png _images/4.png

Now that we are commit aab203eb2e0d, we build repo at this commit and check again whether this repos is buggy or not. Lets say it is not buggy, then execute git bisect good and after this will the first first bad commit , i.e, the first time when the bug was introduced in the repo.

_images/5.png

Now we know that d1e204b56681 is buggy commit. We can check changes this commit introduced that caused bug.

After a bisect session, to clean up the bisection state and return to the original HEAD (i.e., to quit bisecting), issue the following command:

$ git bisect reset

Thats all!!

Common Setup and Tools

Host

These are host ready tools installation for Ubuntu 18.04 LTS on 64 bit

$ apt-get update
$ apt-get install flex bison libsdl2-dev libssl-dev u-boot-tools git
$ apt-get install dtc python python-dev ia32-libs lib32ncurses5 lib32z1 swig xz
$ apt-get install gcc-arm-none-eabi
Crosstool
ARM
bash> cd /to/path
bash> wget https://releases.linaro.org/components/toolchain/binaries/6.3-2017.02/arm-linux-gnueabi/gcc-linaro-6.3.1-2017.02-i686_arm-linux-gnueabi.tar.xz
bash> tar xvf gcc-linaro-6.3.1-2017.02-i686_arm-linux-gnueabi.tar.xz
bash> export PATH=/to/path/gcc-linaro-6.3.1-2017.02-i686_arm-linux-gnueabi/bin:$PATH
bash> export CROSS_COMPILE=arm-linux-gnueabi-
ARM64
bash> cd /to/path
bash> wget https://releases.linaro.org/components/toolchain/binaries/6.3-2017.02/aarch64-linux-gnu/gcc-linaro-6.3.1-2017.02-i686_aarch64-linux-gnu.tar.xz
bash> tar xvf gcc-linaro-6.3.1-2017.02-i686_aarch64-linux-gnu.tar.xz
bash> export PATH=/to/path/gcc-linaro-6.3.1-2017.02-i686_aarch64-linux-gnu/bin:$PATH
bash> export CROSS_COMPILE=aarch64-linux-gnu-
Rockchip

rkdeveloptool

sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf
git clone https://github.com/rockchip-linux/rkdeveloptool
cd rkdeveloptool
sudo autoreconf -i
sudo make
sudo make install

If you encounter compile error like below:

./configure: line 4269: syntax error near unexpected token `LIBUSB1,libusb-1.0'
./configure: line 4269: `PKG_CHECK_MODULES(LIBUSB1,libusb-1.0)'

then:

sudo apt-get install pkg-config libusb-1.0
sudo autoreconf -i
sudo make
sudo make install
SD Setup
Single partition
$ fdisk /dev/mmcblk0


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 for help): n

To create more partitions, first replace a primary with an extended partition.


Command (m for help): p

Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 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: 0x00000000


Device         Boot Start      End  Sectors  Size Id Type

/dev/mmcblk0p1       2048 31116287 31114240 14.9G 83 Linux


Command (m for help): d

Selected partition 1

Partition 1 has been deleted.


Command (m for help): p

Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 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: 0x00000000


Command (m for help): n

Partition type

   p   primary (0 primary, 0 extended, 4 free)

   e   extended (container for logical partitions)

Select (default p):


Using default response p.

Partition number (1-4, default 1):

First sector (2048-31116287, default 2048):

Last sector, +sectors or +size{K,M,G,T,P} (2048-31116287, default 31116287):


Created a new partition 1 of type 'Linux' and of size 14.9 GiB.


Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.


$ mkfs.ext4 -L rootfs /dev/mmcblk0p1
Falcon partition
$ fdisk /dev/mmcblk0


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 for help): p

Disk /dev/mmcblk0: 14.4 GiB, 15489564672 bytes, 30253056 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: 0x00000000


Command (m for help): q


$ sfdisk /dev/mmcblk0


Welcome to sfdisk (util-linux 2.27.1).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.


Checking that no-one is using this disk right now ... OK


Disk /dev/mmcblk0: 14.4 GiB, 15489564672 bytes, 30253056 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: 0x00000000


Old situation:


Type 'help' to get more information.


>>> 30M,

Created a new DOS disklabel with disk identifier 0x13e85f5a.

Created a new partition 1 of type 'Linux' and of size 14.4 GiB.

/dev/mmcblk0p1 :        20480     30253055 (14.4G) Linux

/dev/mmcblk0p2: write


New situation:


Device         Boot Start      End  Sectors  Size Id Type

/dev/mmcblk0p1      20480 30253055 30232576 14.4G 83 Linux


The partition table has been altered.


Calling ioctl() to re-read partition table.

$ mkfs.ext4 -L rootfs /dev/mmcblk0p1
Dual partition
$ fdisk /dev/mmcblk0


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 for help): p

Disk /dev/mmcblk0: 14.4 GiB, 15489564672 bytes, 30253056 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: 0x00000000


Command (m for help): n

Partition type

   p   primary (0 primary, 0 extended, 4 free)

   e   extended (container for logical partitions)

Select (default p):


Using default response p.

Partition number (1-4, default 1):

First sector (2048-30253055, default 2048):

Last sector, +sectors or +size{K,M,G,T,P} (2048-30253055, default 30253055): +64M


Created a new partition 1 of type 'Linux' and of size 64 MiB.


Command (m for help): n

Partition type

   p   primary (1 primary, 0 extended, 3 free)

   e   extended (container for logical partitions)

Select (default p):


Using default response p.

Partition number (2-4, default 2):

First sector (133120-30253055, default 133120):

Last sector, +sectors or +size{K,M,G,T,P} (133120-30253055, default 30253055):


Created a new partition 2 of type 'Linux' and of size 14.4 GiB.


Command (m for help): p

Disk /dev/mmcblk0: 14.4 GiB, 15489564672 bytes, 30253056 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: 0x00000000


Device         Boot  Start      End  Sectors  Size Id Type

/dev/mmcblk0p1        2048   133119   131072   64M 83 Linux

/dev/mmcblk0p2      133120 30253055 30119936 14.4G 83 Linux


Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.

$ mkfs.vfat -n BOOT /dev/mmcblk0p1

$ mkfs.ext4 -L rootfs /dev/mmcblk0p2
Console Setting

We use minicom to get serial console.

SUNXI
sunxi-fel
$ git clone https://github.com/openedev/sunxi-tools
$ cd sunxi-tools
$ git checkout -b working origin/working
$ make
boot32-fel.scr
$ boot32-fel.cmd
setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait
bootz $kernel_addr_r - $fdt_addr_r
# ./tools/mkimage -C none -A arm -T script -d boot32-fel.cmd boot.scr
Image Name:
Created:      Fri Nov 24 14:29:56 2017
Image Type:   ARM Linux Script (uncompressed)
Data Size:    121 Bytes = 0.12 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 113 Bytes = 0.11 KiB = 0.00 MiB
boot64-fel.scr
$ boot64-fel.cmd
setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait
booti $kernel_addr_r - $fdt_addr_r
# ./tools/mkimage -C none -A arm -T script -d boot64-fel.cmd boot.scr
Image Name:
Created:      Fri Nov 24 14:29:56 2017
Image Type:   ARM Linux Script (uncompressed)
Data Size:    121 Bytes = 0.12 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 113 Bytes = 0.11 KiB = 0.00 MiB
Virtual disk
# dd if=/dev/zero of=zero.bin bs=1024 count=1024
1024+0 records in
1024+0 records out
# du -hs zero.bin
1.0M    zero.bin
# losetup /dev/loop0 zero.bin
# losetup -a
/dev/loop0: 0 zero.bin
# mke2fs -F -m0 /dev/loop0
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
128 inodes, 1024 blocks
0 blocks (0%) reserved for the super user
First data block=1
Maximum filesystem blocks=262144
1 block groups
8192 blocks per group, 8192 fragments per group
128 inodes per group
# mount -t ext4 /dev/loop0 /mnt/
[  293.048823] EXT4-fs (loop0): mounted filesystem without journal. Opts: (null)
# ls /mnt/
lost+found
# mount
/dev/loop0 on /mnt type ext4 (rw,relatime,block_validity,delalloc,barrier,user_xattr,acl)
# cd /mnt/
# ls
lost+found
# cp /etc/wpa_supplicant.conf .
# ls
lost+found           wpa_supplicant.conf
# cd -
/root
# sync
# umount  /mnt/
# losetup -d /dev/loop0
Network
TFTP

Install package

$ sudo apt-get install xinetd tftpd tftp

Create /etc/xinetd.d/tftp and put this entry

service tftp
{
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no
}

Create a folder /tftpboot this should match whatever you gave in server_args

$ sudo mkdir /tftpboot
$ sudo chmod -R 777 /tftpboot
$ sudo chown -R nobody /tftpboot

Build images from here and copy on /tftpboot, example rk3288-vyasa board

$ cp /path/to/linux-next/arch/arm/boot/uImage /tftpboot
$ cp /path/to/linux-next/arch/arm/boot/dts/rk3288-vyasa.dtb /tftpboot

Setup Host IP address, remember this is compatible with target serverip

$ ifconfig eth0 10.39.66.9 netmask 255.255.255.0 up

Restart the xinetd service

$ sudo service xinetd restart

Testing

OS Test automation

We in Amarula are working on various kinds of projects. But most of them comprise Android OS development. The development usually goes hand in hand with testing and test automation. There are tons of articles about android app test automation available on the internet, but only a few dealing with Android OS test automation. We are mainly using three types of frameworks that are sometimes integrated one to another. We always pay attention to careful identification of automatable scenarios. So we simplify our lives and not to make them harder blindly automating everything. In the following statement we will unveil the way to use them for OS Test Automation. Please note this article doesn’t mention Android Compatibility Test Suite that will be covered in a different article.

Bash/Batch scripting

Shell scripting is probably one of the most widely used technique among Linux/Android OS test developers. It is fast to program and run. It can be simply used for automation of manual steps done by using connection over USB debug bridge. Everytime you use the terminal (linux or android) for performing manual steps you can think of possible automation. But shell scripting has one big disadvantage, it gets complicated if you want to create test suites and do some advanced stuff around. You have to prepare everything by yourself.

We use shell scripting mostly for one time verification. When new build is ready, there is a shell script directly on the building server that verifies the content of update packages and signatures. Secondly we use shell scripts for load testing.

UiAutomator

UiAutomator is testing framework developed by Google. It is used for cross-app functional testing. People are usually more familiar with Espresso, but that one is only for a single app testing and requires test developer to have sources of the tested application. With UiAutomator it is possible to switch between applications and interact even with settings application without having any sources for the app. The main advantage of this framework is definitely the possibility to automate the ui interaction, but the disadvantage results from its purpose. When you try to automate the UI interaction you have to count with some delays and also some elements may not be loaded properly. This framework anyway should not replace the real user interaction with the device, it is just rather ment like a tool to automate some basic UI flow.

To start writing test cases in UiAutomator you will certainly use tool included in the SDK, called uiautomatorviewer. It helps to recognize UI elements present on the screen, that can be referenced in the code. It looks as shown on the following image.

_images/ScreenShotUiautomator3.png

The framework is based on Java and is well-suited for writing black box-style automated tests. The usage is really simple and the code should mimic manual steps like touch the button, swipe right and enter some text.

Device.getInstance(getInstrumentation());
UiObject2 obj = mDevice.findObject(By.text(label));
obj.clickAndWaitForNewWindow();

After building the project there are two apk files generated - framework and application containing tests. You have to install them both on the device and run tests by executing following commands.

instrumentation=$(adb -s "<device-ID>" shell pm list instrumentation \
 | grep "<package>" \
 | cut -d":" -f2 \
 | cut -d" " -f1)


adb -s "<device-ID>" shell am instrument -w -e "<extra-key>" "<extra-value>" -e class "<package.test-class>" "$instrumentation"
jUnit

JUnit is unit testing framework for testing of java based applications. The base for testing of OS with this framework is again connection with device over USB debug bridge. Compared to bash scripts, jUnit allows developers to create test suites with common classes and use java library functions. It means you can directly start defining test cases and run them one after another, in suites or like parameterized. The jUnit automated tests help us integrate some tests written in bash and in uiautomator into one test stack.

We have developed additional classes build on jUnit, that help us the manipulation of the device, collecting the results and logs when the test scenario finishes with failed result. The following test setup allows us to test on multiple devices in parallel on linux host.

_images/diag_general_arch.png

JUnit framework is complex tool to ease the test development. It uses predefined annotations @Test, @Before, @After etc. The construct is simple as shown in the following code snippet. Instead of testing java code we are basically comparing the results from Android shell commands or logcat output from running test applications with expected results. For example we can verify that the number of users in the OS are equal to three. Each test has to be annotated with @Test. @Before annotates method that is executed before each test present in the class.

public class Tests {
 @Before
 public void initialize() {
   //SETUP
 }

 @Test
 public void testScenario() {
   assertTrue(getUserCount(), 3, "The number of users in the OS is supposed to be 3");
 }

 @After
 Public void tearDown() {
   //TEAR DOWN
 }
}

This framework also has construct called parameterized tests. Thanks to that you can run the same test with different parameters, without necessity of the code repetition. You define set of tests and it evaluates each iteration as a separate execution with its own test result. The usage is following.

RunWith(Parameterized.class)
public class ParameterizedTest{

 @Before
 public void initialSetup() {
   //DO SETUP
 }

 static final Object[][] TEST_SCENARIOS = new Object[][]{
     {"First parameter 1", "Second parameter 1"},
     {"First parameter 2", "Second parameter 2"}
 };

 private final String param1;
 private final String param2;

 public ParameterizedTest(String param1, String param2) {
   this.param1 = param1;
   this.param2 = param2;
 }

 @Parameters
 public static Collection<Object[]> configs() {
   return Arrays.asList(TEST_SCENARIOS);
 }

 @Test
 public void test() {
   System.out.println("Testing with param1(" + param1
     + ") & param2(" + param2 + ")"
   //TEST WITH ASSERTION
 }
}
Android applications

The last approach we use are Android applications. The main advantage is the access to the device. You can run other applications, launch intents and initiate connection with instant application response. You don’t have to parse the output from the logcat but just get the response for the action directly. The biggest disadvantage of this approach is the fact your tests are located on the tested device. It can be a bit tricky to base your tests on the device you are testing. If there is any bug in the device your tests might not work as you expect. The device may reboot unexpectedly and you will get to the undefined state. Also execution and report gathering gets a bit more complicated that way.

We usually use this approach to create semi-automated tests. That means we create simple applications that have to be executed from outside and someone has to evaluate the output. The executions and evaluation can easily be done by jUnit tests or shell scripts. In that case you will get the best of both worlds. Or they can be simply incorporated to the manual tests to simplify their execution.

Conclusion

Android OS test automation is specific field of automation. It differs from automation of web or mobile application. We are mostly concerned about system security for which we use the test automation the most. Verifications that it is possible to send intents between specific domains, the files have correct labels, etc. For such purpose the automation is probably the only way.

Each of presented approaches has it’s advantages and disadvantages. But the best way to handle the automation is to take the best of all options.

Board Support Packages

Setup

Rockchip

RK3399 eMMC Boot

Few of high ended RK3399 SBC’s like Firefly and Orangepi vendor boards by default boot from eMMC and there is no way to boot from SD by means of any hardware jumpers or etc.

So, this document hack the boot mode programmatically erasing eMMC so-that the Rockchip BootROM will look for proper boot image in SD, assuming the SD card has valid boot image.

By default, the rockchip BootROM looking for IDB loader in eMMC at offsets {0, 512, 1024, 1536, 2048}KB + 32KB which are sectors 64, 1088, 2112, 3136, 4160

So zero to one byte on each above sector can by pass the ROM to look for another boot source.

So, boot the default board, which automatically boot from eMMC.

Better preserve existing eMMC data into disk, so it can help for future recovery.

$ dd if=/dev/block/mmcxxx of=orangepi-rk3399-emmc-default.img
$ dd if=/dev/zero of=/dev/block/mmcxxx bs=1b seek=64 count=1
$ dd if=/dev/zero of=/dev/block/mmcxxx bs=1b seek=1088 count=1
$ dd if=/dev/zero of=/dev/block/mmcxxx bs=1b seek=2112 count=1
$ dd if=/dev/zero of=/dev/block/mmcxxx bs=1b seek=3136 count=1
$ dd if=/dev/zero of=/dev/block/mmcxxx bs=1b seek=4160 count=1
Create U-Boot handle sdram timings dtsi from rkbin on RK3399

These steps are derived from the instructions supported by Liviu Dudau <liviu@dudau.co.uk> and posted here for public usage as per communication.

Example sdram rkbin:
rk3399_ddr_933MHz_v1.15.bin
  1. The binary contains multiple frequency settings, so you will have to choose the one you are interested in

  2. Convert the RAM frequency into Hz and use the hexadecimal value to search in the bin file. Here 933MHz is 933000000, or 0x379c7340. Depending on what you use to view the binary, you might have to convert to the little endian format (that’s the case for hexdump, so search for 40 73 9c 37). To validate that you’re not looking at some random data, you can check that you only get 2 matches in the bin file (one for single rank and one for dual rank). I haven’t checked for all combinations, but I think there are only 2 versions. Also look for the data around the match, some of the values form a fixed pattern (you can diff the attached files to find out which ones don’t change, but 0x80181219 for example is a good value to look for).

  3. Figure out where the start of the data is. The pattern is 02 0a 03 02, so from your frequency match walk backwards and choose the second instance (pattern repeats once)

  4. Figure out where the end of the data is. Usually, for the first block that matches, it will end before the single/dual rank block starts, as they are consecutive. For the v1.15 binary, it looks like it is 6044 bytes. The end pattern is 0x01010000 0x00000000. There might be another 32bit zero value between the blocks.

  5. Extract the DDR timings. For this file, I’ve used the following commands:

    $ dd if=rk3399_ddr_933MHz_v1.15.bin of=ddr_single_933mhz.bin bs=1 skip=51800 count=6044

    $ dd if=rk3399_ddr_933MHz_v1.15.bin of=ddr_dual_933mhz.bin bs=1 skip=57848 count=6044

  6. Converted the binaries to text with:

    $ hexdump -v –format ‘1/4 “%08x “’ ddr_single_933mhz.bin > rk3399-sdram-ddr3-single-1866.dtsi

    $ hexdump -v –format ‘1/4 “%08x “’ ddr_dual_933mhz.bin > rk3399-sdram-ddr3-dual-1866.dtsi

  7. Insert the start of the DT fragment into each .dtsi file, edit the initial values (don’t forget that they are in little endian form) to match what the SPL code expects, convert the frequency value from the binary back into MHz (line 38 in the attached dtsi files for reference)

Allwinner

Allwinner A13

Title
Subtitle
Sections
Subsection
subsubsections
Olimex A13-Olinuxino

Allwinner A20

A20-OLinuXino-LIME2

This tutorial will show the details of Olimex A20-OLinuXino-LIME2 board mainline support and other details like hardware, documentation, schematics are available at hardware and linux-sunxi

Hardware Access

Power supply: External 5V Jack USB OTG Cable, USB to TTL for debug

_images/lime2.jpg
BSP Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make A20-OLinuXino-Lime2_defconfig && make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm sunxi_defconfig
ARCH=arm make -j 4 zImage dtbs
Booting
SD Boot
FEL/USB Boot
U-Boot
USB Mass Storage gadget

We can use the board as a USB Mass Storage device: You will be able to access all the partitions of any block device that is on the board or connected to it, from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC, and you’ll be able to mount them, and have full read/write access to them. We can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc. This is especially useful for updating the internal eMMC. To do this you need to connect a USB cable between the OTG/Client port of the board and a regular USB Host port on your PC, and use U-Boot’s ums command.

U-Boot SPL 2017.11-00464-g2fac022-dirty (Dec 06 2017 - 11:21:03)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Trying to boot from MMC1
U-Boot 2017.11-00464-g2fac022-dirty (Dec 06 2017 - 11:21:03 +0530) Allwinner Technology
CPU: Allwinner A20 (SUN7I)
Model: Olimex A20-OLinuXino-LIME2
I2C: ready
DRAM: 1 GiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment
To exit the ums command and disconnect the USB device press ctrl+c.
In: serial
Out: serial
Err: serial
musb_usb_probe
sunxi_musb_init():
1 sunxi_musb_init():
2 sunxi_musb_init():
2.per sunxi_musb_init():
3 sunxi_musb_init():
sunxi_musb_disable():
musb-hdrc:ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx,
SoftConn)
musb-hdrc: MHDRC RTL version 0.0
musb-hdrc: setup fifo_mode 2
musb-hdrc: 7/11 max ep, 2624/8192 memory
USB Peripheral mode controller at 01c13000 using PIO, IRQ 0
Allwinner mUSB OTG (Peripheral)
SCSI: SATA link 0 timeout.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst
Net: eth0: ethernet@01c50000
Warning: usb_ether using MAC address from ROM
, eth1: usb_ether
starting USB...
USB0: USB EHCI 1.00
USB1: USB OHCI 1.0
USB2: USB EHCI 1.00
USB3: USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 2 0
=> ums 0 mmc 0
UMS: LUN 0, dev 0, hwpart 0, sector 0x0, count 0xe94000
sunxi_musb_enable():
|/musb-hdrc: peripheral reset irq lost!
-\|/-\/-\|/-\/-\|/-\/-\|/-\/-\|/-\/-\|/
#include <linux/uinput.h>

void emit(int fd, int type, int code, int val)
{
   struct input_event ie;

   ie.type = type;
   ie.code = code;
   ie.value = val;
   /* timestamp values below are ignored */
   ie.time.tv_sec = 0;
   ie.time.tv_usec = 0;

   write(fd, &ie, sizeof(ie));
}

int main(void)
{
   struct uinput_setup usetup;

   int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);


   /*
    * The ioctls below will enable the device that is about to be
    * created, to pass key events, in this case the space key.
    */
   ioctl(fd, UI_SET_EVBIT, EV_KEY);
   ioctl(fd, UI_SET_KEYBIT, KEY_SPACE);

   memset(&usetup, 0, sizeof(usetup));
   usetup.id.bustype = BUS_USB;
   usetup.id.vendor = 0x1234; /* sample vendor */
   usetup.id.product = 0x5678; /* sample product */
   strcpy(usetup.name, "Example device");

   ioctl(fd, UI_DEV_SETUP, &usetup);
   ioctl(fd, UI_DEV_CREATE);

   /*
    * On UI_DEV_CREATE the kernel will create the device node for this
    * device. We are inserting a pause here so that userspace has time
    * to detect, initialize the new device, and can start listening to
    * the event, otherwise it will not notice the event we are about
    * to send. This pause is only needed in our example code!
    */
   sleep(1);

}
Bananapi M1

This tutorial will show the details of Bananapi M1 board mainline support and other needed details, for more information about hardware and linux-sunxi

BSP Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make make Bananapi_defconfig
make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm sunxi_defconfig
ARCH=arm make -j 4 zImage dtbs
SD Boot
FEL/USB Boot

More information here and build the fel tools from here

Insert SD card from and Press K3 located between the HDMI and USB host connectors and Power-on

Enter FEL

# sunxi-fel version
ERROR: Allwinner USB FEL device not found!
# sunxi-fel version
AWUSBFEX soc=00001651(A20) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000
Boot Linux

From Host, get the boot.scr from here

# sunxi-fel -v uboot /path/to/u-boot-sunxi-with-spl.bin \
> write 0x42000000 /path/to/linux-next/arch/arm/boot/zImage \
> write 0x43000000 /path/to/linux-next/arch/arm/boot/dts/sun7i-a20-bananapi.dtb \
> write 0x43000000 boot.scr
Stack pointers: sp_irq=0x00002000, sp=0x00005E08
Reading the MMU translation table from 0x00020000
Disabling I-cache, MMU and branch prediction... done.
=> Executing the SPL... done.
Setting write-combine mapping for DRAM.
Setting cached mapping for BROM.
Writing back the MMU translation table.
Enabling I-cache, MMU and branch prediction... done.
Writing image "U-Boot 2017.11-00063-gfb344e3 fo", 376540 bytes @ 0x4A000000.
Passing boot info via sunxi SPL: script address = 0x43000000, uEnv length = 0
Starting U-Boot (0x4A000000).

From Target UART

U-Boot SPL 2017.11-00063-gfb344e3 (Nov 24 2017 - 12:40:59)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Trying to boot from FEL
U-Boot 2017.11-00063-gfb344e3 (Nov 24 2017 - 12:40:59 +0530) Allwinner Technology
CPU:   Allwinner A20 (SUN7I)
Model: LeMaker Banana Pi
I2C:   ready
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

Setting up a 720x576i composite-pal console (overscan 32x20)
In:    serial
Out:   vga
Err:   vga
SCSI:  SATA link 0 timeout.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst
Net:   eth0: ethernet@01c50000
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
USB2:   USB EHCI 1.00
USB3:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
(FEL boot)
## Executing script at 43100000
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
   Loading Device Tree to 49ff6000, end 49fff8ed ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.0-next-20171121 (root@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #1 SMP Fri Nov 24 01:26:00 IST 2017
[    0.000000] CPU: ARMv7 Processor [410fc074] revision 4 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: LeMaker Banana Pi
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] percpu: Embedded 16 pages/cpu @ef7c6000 s33740 r8192 d23604 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 260202
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait
Buildroot
ML
Bananapi M1 Plus

This tutorial will show the details of Bananapi M1 board mainline support and other needed details, for more information about hardware and linux-sunxi

BSP Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make make Bananapi_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

$ cd linux-next
$ make mrproper
$ ARCH=arm sunxi_defconfig
$ ARCH=arm make -j 4 zImage dtbs
SD Boot
FEL/USB Boot

More information here and build the fel tools from here

Insert SD card from and Press K3 located between the HDMI and USB host connectors and Power-on

Enter FEL
# sunxi-fel version
ERROR: Allwinner USB FEL device not found!
# sunxi-fel version
AWUSBFEX soc=00001651(A20) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000
Boot Linux

From Host, get the boot.scr from here

# sunxi-fel -v uboot /path/to/u-boot-sunxi-with-spl.bin \
> write 0x42000000 /path/to/linux-next/arch/arm/boot/zImage \
> write 0x43000000 /path/to/linux-next/arch/arm/boot/dts/sun7i-a20-bananapi.dtb \
> write 0x43000000 boot.scr
Stack pointers: sp_irq=0x00002000, sp=0x00005E08
Reading the MMU translation table from 0x00020000
Disabling I-cache, MMU and branch prediction... done.
=> Executing the SPL... done.
Setting write-combine mapping for DRAM.
Setting cached mapping for BROM.
Writing back the MMU translation table.
Enabling I-cache, MMU and branch prediction... done.
Writing image "U-Boot 2017.11-00063-gfb344e3 fo", 376540 bytes @ 0x4A000000.
Passing boot info via sunxi SPL: script address = 0x43000000, uEnv length = 0
Starting U-Boot (0x4A000000).

From Target UART

U-Boot SPL 2017.11-00063-gfb344e3 (Nov 24 2017 - 12:40:59)

DRAM: 1024 MiB

CPU: 912000000Hz, AXI/AHB/APB: 3/2/2

Trying to boot from FEL

U-Boot 2017.11-00063-gfb344e3 (Nov 24 2017 - 12:40:59 +0530) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)

Model: LeMaker Banana Pi

I2C:   ready

DRAM:  1 GiB

MMC:   SUNXI SD/MMC: 0

*** Warning - bad CRC, using default environment


Setting up a 720x576i composite-pal console (overscan 32x20)

In:    serial

Out:   vga

Err:   vga

SCSI:  SATA link 0 timeout.

AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode

flags: ncq stag pm led clo only pmp pio slum part ccc apst

Net:   eth0: ethernet@01c50000

starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
USB2:   USB EHCI 1.0
USB3:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
(FEL boot)
## Executing script at 43100000
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
   Loading Device Tree to 49ff6000, end 49fff8ed ... OK

Starting kernel ...


[    0.000000] Booting Linux on physical CPU 0x0

[    0.000000] Linux version 4.14.0-next-20171121 (root@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #1 SMP Fri Nov 24 01:26:00 IST 2017

[    0.000000] CPU: ARMv7 Processor [410fc074] revision 4 (ARMv7), cr=10c5387d

[    0.000000] CPU: div instructions available: patching division code

[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

[    0.000000] OF: fdt: Machine model: LeMaker Banana Pi

[    0.000000] Memory policy: Data cache writealloc

[    0.000000] psci: probing for conduit method from DT.

[    0.000000] psci: Using PSCI v0.1 Function IDs from DT

[    0.000000] percpu: Embedded 16 pages/cpu @ef7c6000 s33740 r8192 d23604 u65536

[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 260202

[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait

Allwinner A33

Olimex A33 OlinuXino

This tutorial will show the details of Olimex A33-OLinuXino board mainline support and other details like hardware, documentation, schematics are available at hardware and linux-sunxi

Hardware Access

Power supply: External 5V Jack USB OTG Cable, USB to TTL for debug

BSP Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make A33-OLinuXino_defconfig && make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm sunxi_defconfig
ARCH=arm make -j 4 zImage dtbs
Booting
SD Boot

Write Boot image

dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=8k seek=1

Now insert the card into A33-OlinuXino board, power on.

Allwinner A64

Amarual A64-Relic

This tutorial will show the details of Amarula A64-Relic mainline support and other needed details

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here for Host and Crosstool

ATF
git clone https://github.com/apritzel/arm-trusted-firmware.git
cd arm-trusted-firmware
make PLAT=sun50iw1p1 bl31
export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make amarula_a64_relic_defconfig
make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm64 make defconfig
ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported bananapi-m64 already. See read this readme.txt for more info.

git clone git://git.busybox.net/buildroot
cd buildroot
make amarula_a64_relic_defconfig
make
Boot

Since the target doesn’t support SD card, we need to boot the U-Boot from FEL and update the firmware images

FEL boot

Set FEL mode pins and power-on the board

git clone https://github.com/amarula/bsp-a64-relic
cd bsp-a64-relic/prebuilt
bash run-u-boot.sh

Interrupt u-boot by pressing enter

Write eMMC

on target, create GPT partitions and trigger fastboot

=> mmc dev 1
=> gpt write mmc 1 $partitions
=> fastboot 0

on host, write images from host onto eMMC using fastboot

buildroot/output/images
fastboot -i 0x1f3a flash loader1 sunxi-spl.bin
fastboot -i 0x1f3a flash loader2 u-boot.itb
fastboot -i 0x1f3a flash esp boot.vfat
fastboot -i 0x1f3a flash system rootfs.ext4
Wifi

System will automatically detect wifi if buildroot images were used, once done follow below steps

# wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
 (type password and enter)
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
# udhcpc -i wlan0
# ping google.com
GUI Interface

For Display, Touchscreen, Camera, Sensor see below buildroot from respective github sources

git clone https://github.com/amarula/buildroot-amarula
cd buildroot-amarula
git checkout -b a64-relic origin/a64-relic
make amarula_a64_relic_updated_defconfig
make

follow flash instruction from board/amarula/a64-relic/readme.txt

Oceanic 5205-5inMFD
Hardware Access
BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for SoPine board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make oceanic_5205_5inmfd_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

Read readme.txt from board/oceanic/5205-5inmfd/readme.tx for more info.

$ git clone https://github.com/amarula/buildroot-amarula
$ cd buildroot
$ git checkout -b 5inmfd origin/5inmfd
$ make oceanic_5205_5inmfd_defconfig
$ make
Bananapi M64

This tutorial will show the details of Bananapi M64 board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access

Serial debug and Power connections

_images/bpi-m64.jpeg
BSP Build
Manual Build

For manual building refer here for all necessary information.

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Banana Pi BPI-M64 board.

ATF
git clone https://github.com/apritzel/arm-trusted-firmware.git
cd arm-trusted-firmware
make PLAT=sun50iw1p1 bl31
export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make bananapi_m64_defconfig
make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm64 make defconfig
ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported bananapi-m64 already. See read this readme.txt for more info.

git clone git://git.busybox.net/buildroot
cd buildroot
make bananapi_m64_defconfig
make
Booting
SD Boot

Partition the SD card in host with Single Falcon partition

Prepare SD

Write boot image

cd /to/u-boot
cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=8k seek=1

Write rootfs, update boot/extlinux/extlinux.conf

git clone https://github.com/openedev/rootfs-sun64
cp -rf rootfs-sun64/* /media/jagan/rootfs/
cp /to/linux-next/arch/arm64/boot/Image /media/jagan/rootfs/boot
cp /to/linux-next/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dtb /media/jagan/rootfs/boot
sync && umount /dev/mmcblk0*

Insert the SD card and power-on the board. See the Linux boot start from SPL - unplug SD Card during U-Boot proper boot

USB Boot

Prepare SD card with from SD Boot and prepare USB mass storage with single partition by copying rootfs and update boot/extlinux/extlinux.conf

Insert the SD card, USB Mass storage and power-on the board. See the Linux boot start from SPL

U-Boot SPL 2017.11-00063-gfb344e3-dirty (Nov 27 2017 - 12:38:05)
DRAM: 2048 MiB
Trying to boot from MMC1
NOTICE:  BL3-1: Running on A64/H64 (1689) in SRAM A2 (@0x44000)
NOTICE:  Configuring SPC Controller
NOTICE:  BL3-1: v1.0(debug):aa75c8d
NOTICE:  BL3-1: Built : 23:14:48, Nov  4 2017
NOTICE:  Configuring AXP PMIC
NOTICE:  PMIC: setup successful
INFO:    BL3-1: Initializing runtime services
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address: 0x4a000000, SPSR: 0x3c9


U-Boot 2017.11-00063-gfb344e3-dirty (Nov 27 2017 - 12:38:05 +0530) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: BananaPi-M64
DRAM:  2 GiB
MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0
Card did not respond to voltage select!
mmc_init: -95, time 22
switch to partitions #0, OK
mmc1(part 0) is current device
** No partition table - mmc 1 **

Device 0: Vendor: Sony     Rev: 0100 Prod: Storage Media
            Type: Removable Hard Disk
            Capacity: 30040.8 MB = 29.3 GB (61523712 x 512)
... is now current device
Scanning usb 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
151 bytes read in 157 ms (0 Bytes/s)
1:      linux-next
Retrieving file: /boot/Image
16908800 bytes read in 21856 ms (754.9 KiB/s)
append: console=ttyS0,115200 earlyprintk root=/dev/sda1 rootwait
Retrieving file: /boot/sun50i-a64-bananapi-m64.dtb
12817 bytes read in 142 ms (87.9 KiB/s)
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
   Loading Device Tree to 0000000049ff9000, end 0000000049fff210 ... OK

Starting kernel ...

[�r��������Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 4.14.0-next-20171123-00001-gae19a8e (root@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) 7
[    0.000000] Machine model: BananaPi-M64
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 16 MiB at 0x00000000bf000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000000000-0x00000000bfffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xbefe3000-0xbefe4aff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x00000000bfffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x00000000bfffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x00000000bfffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv0.2 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] random: get_random_bytes called from start_kernel+0xa4/0x408 with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @ffff80007ef80000 s55832 r8192 d30184 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: enabling workaround for ARM erratum 845719
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 516096
[    0.000000] Policy zone: DMA
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/sda1 rootwait
U-Boot
USB Mass Storage gadget

We can use the board as a USB Mass Storage device:

You will be able to access all the partitions of any block device that is on the board or connected to it,

from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC,

and you’ll be able to mount them, and have full read/write access to them.

We can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc.

This is especially useful for updating the internal eMMC.

To do this you need to connect a USB cable between the OTG/Client port of the board and a regular USB Host port on your PC,

and use U-Boot’s ums command.

Linux
USB OTG

Here, we can take mass storage as gadget function and will show how it can work with ‘host’ and ‘peripheral’ modes

Build otg mass storage as statically linked module with

CONFIG_USB_MASS_STORAGE=y

Append bootargs with ‘g_mass_storage.removable=1 g_mass_storage.luns=1’

Peripheral

Plug USB otg cable A-type to host pc and B-type to bananapi

[    1.952386] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.952954] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.952965] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 5
[    1.957274] hub 5-0:1.0: USB hub found
[    1.957303] hub 5-0:1.0: 1 port detected
[    1.961702] Mass Storage Function, version: 2009/09/11
[    1.961708] LUN: removable file: (no medium)
[    1.961761] LUN: removable file: (no medium)
[    1.961764] Number of LUNs=1
[    1.972523] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[    1.972527] g_mass_storage gadget: userspace failed to provide iSerialNumber
[    1.972530] g_mass_storage gadget: g_mass_storage ready
# cat /proc/cmdline
console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait g_mass_storage.removable=1 g_mass_storage.luns=1
# fdisk -l
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors
486192 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    320,0,1     815,3,16         20480   31116287   31095808 14.8G 83 Linux
# echo /dev/mmcblk0 > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/gadget/lun0/file

Access the disk at host pc and write and umount

Host

Plug USB host cable where A-type connect with USB stick and B-type connect to bananapi and

See USB stick detection on bananapi

# cat /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/mode
b_peripheral
# echo host > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/mode
[   19.231613] phy phy-1c19400.phy.0: Changing dr_mode to 1
# [  451.961240] usb 1-1: new high-speed USB device number 2 using ehci-platform
[  452.133893] usb-storage 1-1:1.0: USB Mass Storage device detected
[  452.140884] scsi host0: usb-storage 1-1:1.0
[  453.151349] scsi 0:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 4
[  453.161156] sd 0:0:0:0: [sda] 15728640 512-byte logical blocks: (8.05 GB/7.50 GiB)
[  453.169900] sd 0:0:0:0: [sda] Write Protect is off
[  453.175770] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  453.191292]  sda: sda1
[  453.197283] sd 0:0:0:0: [sda] Attached SCSI removable disk
FriendlyARM Nanopi A64

This tutorial will show the details of Nanopi A64 board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access

Hardware Access Serial debug: 4Pin, 2.54mm pitch pin-header

Power cable: DC 5V/2A USB

_images/nanopi_a64.jpeg
BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Nanopi A64 board.

ATF
git clone https://github.com/apritzel/arm-trusted-firmware.git
cd arm-trusted-firmware
make PLAT=sun50iw1p1 bl31
export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make nanopi_a64_defconfig
make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm64 make defconfig
ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported nanopi-a64 already. See read this readme.txt for more info.

git clone git://git.busybox.net/buildroot
cd buildroot
make friendlyarm_nanopi_a64_defconfig
make
Booting
SD Boot

Partition the SD card in host with Single Falcon partitionc

git clone https://github.com/openedev/rootfs-sun64
cp -rf rootfs-sun64/* /media/jagan/rootfs/
cp /to/linux-next/arch/arm64/boot/Image /media/jagan/rootfs/boot
cp /to/linux-next/arch/arm64/boot/dts/allwinner/sun50i-a64-nanopi-a64.dtb /media/jagan/rootfs/boot
[Update boot/extlinux/extlinux.conf]
cd /to/u-boot
cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=8k seek=1;
sync

Insert the SD card and power-on the board. See the Linux boot start from SPL

Linux
RTL8189ES Wifi
EMAC
Olimex A64-Olinuxino

This tutorial will show the details of Olimex A64-Olinuxino board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access

Serial debug and Power connections

_images/a64-olin.jpeg
BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Olimex A64-Olinuxino board.

ATF
git clone https://github.com/apritzel/arm-trusted-firmware.git
cd arm-trusted-firmware
make PLAT=sun50iw1p1 bl31
export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
git clone git://git.denx.de/u-boot.git
cd u-boot
make a64-olinuxino_defconfig
make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm64 make defconfig
ARCH=arm64 make -j 4 Image dtbs
ARCH=arm64 make modules && ARCH=arm64 make modules_install
Buildroot

It’s easy to build entire system using buildroot and mainline supported a64-olinuxino already. See read this readme.txt for more info.

git clone git://git.busybox.net/buildroot
cd buildroot
make olimex_a64_olinuxino_defconfig
make
Booting
SD Boot

Prepare SD

Linux
USB OTG

Here, we can take mass storage as gadget function and will show how it can work with ‘host’ and ‘peripheral’ modes

Build otg mass storage as statically linked module with

CONFIG_USB_MASS_STORAGE=yi

Append bootargs with ‘g_mass_storage.removable=1 g_mass_storage.luns=1’

Peripheral

Plug USB otg cable A-type to host pc and B-type to bananapi

[    1.952386] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.952954] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.952965] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 5
[    1.957274] hub 5-0:1.0: USB hub found
[    1.957303] hub 5-0:1.0: 1 port detected
[    1.961702] Mass Storage Function, version: 2009/09/11
[    1.961708] LUN: removable file: (no medium)
[    1.961761] LUN: removable file: (no medium)
[    1.961764] Number of LUNs=1
[    1.972523] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[    1.972527] g_mass_storage gadget: userspace failed to provide iSerialNumber
[    1.972530] g_mass_storage gadget: g_mass_storage ready
# cat /proc/cmdline
console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait g_mass_storage.removable=1 g_mass_storage.luns=1
# fdisk -l
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors
486192 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    320,0,1     815,3,16         20480   31116287   31095808 14.8G 83 Linux
# echo /dev/mmcblk0 > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/gadget/lun0/file

Access the disk at host pc and write and umount

Host

Plug USB host cable where A-type connect with USB stick and B-type connect to bananapi and

See USB stick detection on bananapi

# cat /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/mode
b_peripheral
# echo host > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/mode
[   19.231613] phy phy-1c19400.phy.0: Changing dr_mode to 1
# [  451.961240] usb 1-1: new high-speed USB device number 2 using ehci-platform
[  452.133893] usb-storage 1-1:1.0: USB Mass Storage device detected
[  452.140884] scsi host0: usb-storage 1-1:1.0
[  453.151349] scsi 0:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 4
[  453.161156] sd 0:0:0:0: [sda] 15728640 512-byte logical blocks: (8.05 GB/7.50 GiB)
[  453.169900] sd 0:0:0:0: [sda] Write Protect is off
[  453.175770] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  453.191292]  sda: sda1
[  453.197283] sd 0:0:0:0: [sda] Attached SCSI removable disk
RTL8723BS Wifi

Enable custom configuration and build buildroot

Build the Linux with CONFIG_RTL8723BS=m

Prepare SD card from SD Boot

Clone linux-firmware and copy rtlwifi into rootfs lib/firmware

Insert SD card and power-on

# modprobe -a r8723bs
[    9.105532] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    9.146445] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    9.154195] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    9.162867] cfg80211: failed to load regulatory.db
[   11.397622] r8723bs: module is from the staging directory, the quality is unknown, you have been warned.
[   11.419119] RTL8723BS: module init start
[   11.423079] RTL8723BS: rtl8723bs v4.3.5.5_12290.20140916_BTCOEX20140507-4E40
[   11.430140] RTL8723BS: rtl8723bs BT-Coex version = BTCOEX20140507-4E40
[   11.437219] pnetdev = ffff80003d222000
[   11.489920] RTL8723BS: rtw_ndev_init(wlan0)
[   11.495399] RTL8723BS: module init ret =0

# ifconfig -a
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr CC:D2:9B:78:F4:52
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# ifconfig wlan0 up
[   28.884993] rtl8723bs: acquire FW from file:rtlwifi/rtl8723bs_nic.bin
[   29.080937] random: crng init done
[   30.219787] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

# wpa_passphrase Ji-Fi >> /etc/wpa_supplicant.conf
(type password and enter)

# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
Successfully initialized wpa_supplicant
# [   48.465226] RTL8723BS: rtw_set_802_11_connect(wlan0)  fw_state = 0x00000008
[   48.681824] RTL8723BS: start auth
[   48.686931] RTL8723BS: auth success, start assoc
[   48.697104] RTL8723BS: rtw_cfg80211_indicate_connect(wlan0) BSS not found !!
[   48.704164] RTL8723BS: assoc success
[   48.711402] RTL8723BS: send eapol packet
[   48.739960] RTL8723BS: send eapol packet
[   48.744078] RTL8723BS: set pairwise key camid:4, addr:48:00:33:98:95:1f, kid:0, type:AES
[   48.744495] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   48.759105] RTL8723BS: set group key camid:5, addr:48:00:33:98:95:1f, kid:1, type:AES

# udhcpc -i wlan0
udhcpc: started, v1.27.2
udhcpc: sending discover
udhcpc: sending select for 192.168.0.25
udhcpc: lease of 192.168.0.25 obtained, lease time 604800
deleting routers
adding dns 202.88.174.6
adding dns 202.88.174.8
# ping google.com
PING google.com (172.217.26.174): 56 data bytes
64 bytes from 172.217.26.174: seq=0 ttl=55 time=24.710 ms
64 bytes from 172.217.26.174: seq=1 ttl=55 time=24.677 ms
Orangepi Win

This tutorial will show the details of Orangepi Win/Win+ board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access

Serial debug and Power connections

_images/opi_win.jpeg
BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Orangepi Win/Win+ board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_win_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported orangepi-win already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make orangepi_win_defconfig
$ make
SD Boot

Partition the SD card in host with Single Falcon partition

$ git clone https://github.com/openedev/rootfs-sun64
$ cp -rf rootfs-sun64/* /media/jagan/rootfs/
$ cp /to/linux-next/arch/arm64/boot/Image /media/jagan/rootfs/boot
$ cp /to/linux-next/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dtb /media/jagan/rootfs/boot
$ cd /to/u-boot
$ cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
$ dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=8k seek=1
$ sync && umount /dev/mmcblk0*

Insert the SD card and power-on the board. See the Linux boot start from SPL

U-Boot SPL 2017.11-00061-g6130b1f (Nov 23 2017 - 22:22:00)
DRAM: 1024 MiB
Trying to boot from MMC1
NOTICE:  BL3-1: Running on A64/H64 (1689) in SRAM A2 (@0x44000)
NOTICE:  Configuring SPC Controller
NOTICE:  BL3-1: v1.0(debug):aa75c8d
NOTICE:  BL3-1: Built : 23:14:48, Nov  4 2017
NOTICE:  Configuring AXP PMIC
NOTICE:  PMIC: Output power control 2 is an unexpected 0x0
ERROR:   PMIC: setup failed: -3
INFO:    BL3-1: Initializing runtime services
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address: 0x4a000000, SPSR: 0x3c9

U-Boot 2017.11-00061-g6130b1f (Nov 23 2017 - 22:22:00 +0530) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: OrangePi Win/Win Plus
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

Warning: HDMI PHY init timeout!
Warning: HDMI PHY init timeout!
In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
156 bytes read in 261 ms (0 Bytes/s)
1:      linux-next
Retrieving file: /boot/Image
16908800 bytes read in 1073 ms (15 MiB/s)
append: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait
Retrieving file: /boot/sun50i-a64-orangepi-win.dtb
11879 bytes read in 240 ms (47.9 KiB/s)
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
   Loading Device Tree to 0000000049ffa000, end 0000000049fffe66 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 4.14.0-next-20171123-00001-gae19a8e (root@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #2 SMP PREEMPT Thu Nov 23 22:557
[    0.000000] Machine model: OrangePi Win/Win Plus
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 16 MiB at 0x000000007f000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x7efe4180-0x7efe5c7f]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv0.2 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] random: get_random_bytes called from start_kernel+0xa4/0x408 with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @ffff80003ef81000 s55832 r8192 d30184 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: enabling workaround for ARM erratum 845719
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 258048
[    0.000000] Policy zone: DMA
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait
FEL/USB Boot

More information here and build the fel tools from

Enter FEL

Prepare SD card from and Power-on board without SD

# sunxi-fel version
ERROR: Allwinner USB FEL device not found!
# sunxi-fel version
AWUSBFEX soc=00001689(A64) 00000001 ver=0001 44 08 scratchpad=00017e00 00000000 00000000
Build U-Boot

Mainline U-Boot not supporting FEL for H5/A64 due to 64-Bit mode in SPL so we need to build 32-bit SPL and 64-bit U-Boot proper

Export arm toolchain from here

$ git clone https://github.com/openedev/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b sun64-fel32 origin/sun64-fel32
$ make sun50i_spl32_defconfig && make
Boot Linux

From Host, get the boot.scr from here

# sunxi-fel -v -p spl /path/to/u-boot-amarula/sunxi-spl.bin \
> write 0x44000 /path/to/arm-trusted-firmware/build/sun50iw1p1/debug/bl31.bin \
> write 0x4a000000 /path/to/u-boot/u-boot.bin \
> write 0x40080000 /root/JSpace/code/linux-next-sunxi64/arch/arm64/boot/Image \
> write 0x4FA00000 /root/JSpace/code/linux-next-sunxi64/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dtb \
> write 0x4FB00000 boot.scr \
> reset64 0x44000
Stack pointers: sp_irq=0x00012000, sp=0x00015E08
MMU is not enabled by BROM
=> Executing the SPL... done.
100% [================================================]    33 kB,  447.0 kB/s
100% [================================================]   450 kB,  467.2 kB/s
100% [================================================] 16909 kB,  467.9 kB/s
100% [================================================]    12 kB,  476.0 kB/s
100% [================================================]     0 kB,  130.0 kB/s
Passing boot info via sunxi SPL: script address = 0x4FB00000, uEnv length = 0
Store entry point 0x00044000 to RVBAR 0x017000A0, and request warm reset with RMR mode 3... done.

From Target UART

U-Boot SPL 2017.09-g5f1fe13 (Nov 24 2017 - 15:25:44)
DRAM: 1024 MiB
Trying to boot from FEL
NOTICE:  BL3-1: Running on A64/H64 (1689) in SRAM A2 (@0x44000)
NOTICE:  Configuring SPC Controller
NOTICE:  BL3-1: v1.0(debug):aa75c8d
NOTICE:  BL3-1: Built : 23:14:48, Nov  4 2017
NOTICE:  Configuring AXP PMIC
NOTICE:  PMIC: setup successful
INFO:    BL3-1: Initializing runtime services
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address: 0x4a000000, SPSR: 0x3c9

U-Boot 2017.11-00063-gfb344e3 (Nov 24 2017 - 17:23:04 +0530) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: OrangePi Win/Win Plus
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
(FEL boot)
## Executing script at 4fb00000
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
   Loading Device Tree to 0000000049ffa000, end 0000000049fffe66 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 4.14.0-next-20171123-00002-gd14e643-dirty (root@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #3 SMP PREEMPT Fri Nov 247
[    0.000000] Machine model: OrangePi Win/Win Plus
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 16 MiB at 0x000000007f000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x7efe4180-0x7efe5c7f]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv0.2 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] random: get_random_bytes called from start_kernel+0xa4/0x408 with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @ffff80003ef81000 s55832 r8192 d30184 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: enabling workaround for ARM erratum 845719
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 258048
[    0.000000] Policy zone: DMA
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait
Pine A64

This tutorial will show the details of Pine64 board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access

Serial debug: 4Pin, 2.54mm pitch pin-header Power cable: DC 5V @ 2A USB

_images/pine64.jpeg
BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Pine64 board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make pine64_plus_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported pine64 already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make pine64_defconfig
$ make
Booting
SD Write

Create Dual partition and Insert the SD on host

$ cp /to/linux-next/arch/arm64/boot/Image /media/jagan/BOOT
$ cp /to/linux-next/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dtb /media/jagan/BOOT
$ git clone https://github.com/openedev/rootfs-sun64
$ cp -rf rootfs-sun64/* /media/jagan/rootfs/
$ cd /to/u-boot
$ cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
$ dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=8k seek=1
$ sync

Insert the SD card and power-on the board. Once U-Boot booted set these and boot Linux

# setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait
# fatload mmc 0 $kernel_addr_r Image
# fatload mmc 0 $fdt_addr_r sun50i-a64-pine64.dtb
# booti $kernel_addr_r - $fdt_addr_r
Buildroot
SoPine A64

This tutorial will show the details of SoPine board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access

Serial debug: 4Pin, 2.54mm pitch pin-header

Power cable: DC 5V @ 2A JACK

_images/sopine.jpeg
BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for SoPine board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make sopine_baseboard_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported sopine already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make pine64_sopine_defconfig
$ make
SD Write

Create Dual partition and Insert the SD on host

$ cp /to/linux-next/arch/arm64/boot/Image /media/jagan/BOOT
$ cp /to/linux-next/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dtb /media/jagan/BOOT
$ git clone https://github.com/openedev/rootfs-sun64
$ cp -rf rootfs-sun64/* /media/jagan/rootfs/
$ cd /to/u-boot
$ cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
$ dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=8k seek=1
$ sync

Insert the SD card and power-on the board. Once U-Boot booted set these and boot Linux

# setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait
# fatload mmc 0 $kernel_addr_r Image
# fatload mmc 0 $fdt_addr_r sun50i-a64-sopine-baseboard.dtb
# booti $kernel_addr_r - $fdt_addr_r
Buildroot

Allwinner H3

Orangepi PC

This tutorial will show the details of Olimex A20-OLinuXino-LIME2 board mainline support and other details like

hardware, documentation, schematics are available at hardware and linux-sunxi

Hardware Access
_images/orange_pi_pc.jpg
BSP Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_pc_defconfig && make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm sunxi_defconfig && $ ARCH=arm make -j 4 zImage dtbs
Booting
SD Boot
FEL/USB Boot
U-Boot
USB Mass Storage gadget

We can use the board as a USB Mass Storage device:

You will be able to access all the partitions of any block device that is on the board or connected to it,

from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC,

and you’ll be able to mount them, and have full read/write access to them.

We can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc.

This is especially useful for updating the internal eMMC.

To do this you need to connect a USB cable between the OTG/Client port of the board and a regular USB Host port on your PC,

and use U-Boot’s ums command.

Linux
USB Mass Storage gadget

Build otg mass storage as statically linked module with

CONFIG_USB_GADGET_LEGACY=y

CONFIG_USB_MASS_STORAGE=y

Append bootargs with g_mass_storage.removable=1 g_mass_storage.luns=1

[    1.676222] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.687279] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.693023] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 9
[    1.701483] hub 9-0:1.0: USB hub found
[    1.705290] hub 9-0:1.0: 1 port detected
[    1.709841] Mass Storage Function, version: 2009/09/11
[    1.715010] LUN: removable file: (no medium)
[    1.719330] LUN: removable file: (no medium)
[    1.723613] Number of LUNs=1
[    1.726619] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[    1.733592] g_mass_storage gadget: userspace failed to provide iSerialNumber
[    1.740629] g_mass_storage gadget: g_mass_storage ready
# cat /proc/cmdline
console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait g_mass_storage.removable=1 g_mass_storage.luns=1
# fdisk -l
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors
486192 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    320,0,1     815,3,16         20480   31116287   31095808 14.8G 83 Linux
# echo /dev/mmcblk0 > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/gadget/lun0/file

Access the disk and write and umount

FriendlyARM Nanopi M1 Plus
Hardware
_images/friendlyarm_nanopi_m1_plus.jpg
Buildroot

It’s easy to build entire system using buildroot and mainline supported FriendlyARM Nanopi M1 Plus. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make nanopi_m1_plus_defconfig
$ make
FriendlyARM Nanopi M1
Hardware
_images/nanopi_m1.jpg
Buildroot

It’s easy to build entire system using buildroot and mainline supported FriendlyARM Nanopi M1 Plus. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make nanopi_m1_defconfig
$ make
Orangepi Plus

This tutorial will show the details of Olimex A20-OLinuXino-LIME2 board mainline support and other details like hardware, documentation, schematics are available at hardware and linux-sunxi

Hardware Access
_images/orange_pi_plus.jpg
BSP Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_pc_defconfig && make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm sunxi_defconfig && $ ARCH=arm make -j 4 zImage dtbs
Booting
SD Boot
FEL/USB Boot
U-Boot
USB Mass Storage gadget

We can use the board as a USB Mass Storage device: You will be able to access all the partitions of any block device that is on the board or connected to it, from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC, and you’ll be able to mount them, and have full read/write access to them. We can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc. This is especially useful for updating the internal eMMC. To do this you need to connect a USB cable between the OTG/Client port of the board and a regular USB Host port on your PC, and use U-Boot’s ums command.

Linux
USB Mass Storage gadget

Build otg mass storage as statically linked module with

CONFIG_USB_GADGET_LEGACY=y

CONFIG_USB_MASS_STORAGE=y

Append bootargs with g_mass_storage.removable=1 g_mass_storage.luns=1

[    1.676222] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.687279] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.693023] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 9
[    1.701483] hub 9-0:1.0: USB hub found
[    1.705290] hub 9-0:1.0: 1 port detected
[    1.709841] Mass Storage Function, version: 2009/09/11
[    1.715010] LUN: removable file: (no medium)
[    1.719330] LUN: removable file: (no medium)
[    1.723613] Number of LUNs=1
[    1.726619] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[    1.733592] g_mass_storage gadget: userspace failed to provide iSerialNumber
[    1.740629] g_mass_storage gadget: g_mass_storage ready
# cat /proc/cmdline
console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait g_mass_storage.removable=1 g_mass_storage.luns=1
# fdisk -l
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors
486192 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    320,0,1     815,3,16         20480   31116287   31095808 14.8G 83 Linux
# echo /dev/mmcblk0 > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/gadget/lun0/file

Access the disk and write and umount

Allwinner H5

FriendlyARM-NanoPi-NEO2

This tutorial will show the details of Nanopi NEO2 board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access
_images/nanopi_neo2.jpeg

Serial debug and Power connections

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Nanopi NE02 board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make nanopi_neo2_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported nanopi-neo2 already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make friendlyarm_nanopi_neo2_defconfig
$ make
Booting
SD Boot
U-Boot
USB Mass Storage gadget

We can use the board as a USB Mass Storage device:

You will be able to access all the partitions of any block device that is on the board or connected to it,

from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC,

and you’ll be able to mount them, and have full read/write access to them.

We can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc.

This is especially useful for updating the internal eMMC.

To do this you need to connect a USB cable between the OTG/Client port of the board and a regular USB Host port on your PC,

and use U-Boot’s ums command.

Linux
USB Mass Storage gadget

Build otg mass storage as statically linked module with

CONFIG_USB_GADGET_LEGACY=y

CONFIG_USB_MASS_STORAGE=y

Append bootargs with ‘g_mass_storage.removable=1 g_mass_storage.luns=1’

[    1.676222] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.687279] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.693023] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 9
[    1.701483] hub 9-0:1.0: USB hub found
[    1.705290] hub 9-0:1.0: 1 port detected
[    1.709841] Mass Storage Function, version: 2009/09/11
[    1.715010] LUN: removable file: (no medium)
[    1.719330] LUN: removable file: (no medium)
[    1.723613] Number of LUNs=1
[    1.726619] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[    1.733592] g_mass_storage gadget: userspace failed to provide iSerialNumber
[    1.740629] g_mass_storage gadget: g_mass_storage ready
# cat /proc/cmdline
console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rootwait g_mass_storage.removable=1 g_mass_storage.luns=1
# fdisk -l
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors
486192 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    320,0,1     815,3,16         20480   31116287   31095808 14.8G 83 Linux
# echo /dev/mmcblk0 > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/gadget/lun0/file

Access the disk and write and umount

Orangepi PC2

This tutorial will show the details of OrangepiPC2 board mainline support and other details like documentation, hardware schismatic

and other needful information is available at hardware and linux-sunxi

Hardware Access
_images/opi_pc2.jpg

Serial debug and Power connections

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 DEBUG=1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_pc2_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported orangepi pc2 already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make orangepi_pc2_defconfig
$ make
Booting
SD Boot
FEL/USB Boot
Buildroot
Orangepi Prime

This tutorial will show the details of Orangepi Prime board mainline support and other needed details, for more information about hardware

Hardware Access
_images/opi_prime.jpeg

Serial debug and Power connections

BSP Build
Manual Build

For manual building refer here for all necessary information.

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Orangepi Prime board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_prime_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported orangepi prime already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make orangepi_prime_defconfig
$ make
Booting
SD Boot
Buildroot
Orangepi Zero Plus2

This tutorial will show the details of Orangepi Zero Plus2 board mainline support and other needed details, for more information about hardware and linux-sunxi

Hardware Access
_images/opi_zero_plus2.jpeg

Serial debug and Power connections

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Orangepi Zero Plus2 board.

ATF
$ git clone https://github.com/apritzel/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make PLAT=sun50iw1p1 DEBUG=1 bl31
$ export BL31=/path/to/arm-trusted-firmware/build/sun50iw1p1/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_zero_plus2_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported orangepi zero plus2 already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make orangepi_zero_plus2_defconfig
$ make
Booting

Allwinner H6

Orangepi Lite2

This tutorial will show the details of Orangepi One Plus board mainline support and other details like documentation, hardware schismatic and other needful information is available at hardware and linux-sunxi

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

ATF
$ git clone https://github.com/ARM-software/arm-trusted-firmware
$ cd arm-trusted-firmware
$ sudo CROSS_COMPILE=/to/path/aarch64-linux-gnu- make PLAT=sun50i_h6
$ export BL31=/path/to/arm-trusted-firmware/build/sun50i_h6/release/bl31.bin
U-Boot
$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b h6-v1.0a h6-v1.0a
$ make orangepi_lite_defconfig
$ make
Linux
$ git clone https://github.com/amarula/linux-amarula
$ cd linux-amarula
$ git checkout -b h6-v1.0b h6-v1.0b
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported orangepi one plus already. See read this readme.txt for more info.

$ git clone https://github.com/amarula/buildroot-amarula
$ cd buildroot-amarula
$ git checkout -b WIP-H6 origin/WIP-H6
$ make orangepi_lite2_defconfig
$ make
Orangepi One Plus

This tutorial will show the details of Orangepi One Plus board mainline support and other details like documentation, hardware schismatic and other needful information is available at hardware and linux-sunxi

Hardware Access
_images/opi-one-plus.jpg

Serial debug and Power connections

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

ATF
$ git clone https://github.com/ARM-software/arm-trusted-firmware
$ cd arm-trusted-firmware
$ sudo CROSS_COMPILE=/to/path/aarch64-linux-gnu- make PLAT=sun50i_h6
$ export BL31=/path/to/arm-trusted-firmware/build/sun50i_h6/release/bl31.bin
U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make orangepi_one_plus_defconfig; $ make
Linux
$ git clone https://github.com/amarula/linux-amarula
$ cd linux-amarula
$ git checkout -b wip-sun-h6 origin/wip-sun-h6
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make -j 4 Image dtbs
Buildroot

It’s easy to build entire system using buildroot and mainline supported orangepi one plus already. See read this readme.txt for more info.

$ git clone https://github.com/amarula/buildroot-amarula
$ cd buildroot-amarula
$ git checkout -b wip-sun-h6 origin/wip-sun-h6
$ make orangepi_one_plus_defconfig
$ make

I.MX

IMX6 QDL

i.CoreM6 1.5

This tutorial will show the details of Engicam i.CoreM6 1.5 SOM Mainline software support and other needed details.

This SOM is compatible with EDIMM STARTER KIT i.Core 1.5 MIPI Evaluation board Support Boot from SD/MMC card and eMMC.

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here for Host and Crosstool

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make imx6qdl_icore_mipi_defconfig && make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm make imx_v6_v7_defconfig
$ ARCH=arm make LOADADDR=0x10008000 uImage dtbs
Buildroot
$ git clone https://github.com/amarula/buildroot-amarula
$ cd buildroot-amarula
$ git checkout -b imx6-media origin/imx6-media
$ make engicam_imx6qdl_icore_qt5_gst1_media_defconfig && make
Boot
Write SD

For manual build images will write by partitioning SD card

$ cd /path/to/u-boot
$ dd if=SPL of=/dev/mmcblk0 bs=1k seek=1
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
$ cd /path/to/linux-next
$ cp arch/arm/boot/uImage /media/jagan/rootfs
$ cp arch/arm/boot/dts/imx6q-icore-mipi.dtb /media/jagan/rootfs
$ cp arm_ramdisk.image.gz /media/jagan/rootfs
$ sync && umount /dev/mmcblk0p1

For buildroot, we can write single image sdcard.img directly

$ cd /path/to/buildroot
$ dd if=output/images/sdcard.img of=/dev/mmcblk0
$ sync
Boot SD
  • Insert the SD card in the SD slot of the board;
  • Connect 3-wire RS232 serial port J28 on board, and connect with other
  • Serial end or USB cable(if serial-to-usb converter used) using a terminal emulator at 115200 bps, 8n1;
  • Close JM3 for sd boot.
  • Power on the board.
Boot eMMC
  • Boot from SD and write images on eMMC in Linux prompt
  • Open JM3 for eMMC boot
USB SDP

More info at, u-boot/doc/README.sdp

  1. Clone imx_usb_loader
$ git clone git://github.com/boundarydevices/imx_usb_loader.git
$ cd imx_usb_loader
$ make
  1. Build the BSP and copy SPL, u-boot-dtb.img in imx_usb_loader directory
  2. Put the board in “Serial Download Mode” ( Using jumpers circled in below image)
_images/engicam_imx_serialdownload_jumpers.jpeg
  1. Plug-in USB-to-Serial and USB OTG cables to Host and Turn-on board
  2. Identify VID/PID using lsusb

Bus 001 Device 010: ID 15a2:0061 Freescale Semiconductor, Inc. i.MX 6Solo/6DualLite SystemOnChip in RecoveryMode

  1. Update the conf files

    imx_usb.conf

    0x15a2:0x0054, mx6_usb_rom.conf, 0x0525:0xb4a4, mx6_usb_sdp_spl.conf
    

mx6_usb_rom.conf

mx6_usb
hid,1024,0x910000,0x10000000,512M,0x00900000,0x40000
SPL:jump header

mx6_usb_sdp_spl.conf

mx6_spl_sdp
hid,uboot_header,1024,0x910000,0x10000000,512M,0x00900000,0x40000
u-boot-dtb.img:jump header
  1. Launch the loader

    ./imx_usb
    
  2. Identify board booting on serial

MIPI-CSI2 OV5640 Camera
Build

Since Mainline Linux has some regression issue with 0v5640 So build linux-next till working commit.

$ git clone https://github.com/amarula/linux-amarula
$ cd linux-amarula
$ git checkout -b imx6-ov5640 origin/imx6-ov5640
$ ARCH=arm make imx_v6_v7_defconfig
$ ARCH=arm make LOADADDR=0x10008000 uImage dtbs -j 16

Use rootfs.ext4 from buildroot built

Capture

Once Linux boot, prepare media control chart for finding pipeline setups

On target
# media-ctl --print-dot > mipi-ov5640.dot

On host
$ dot -T png -o mipi-ov5640.png mipi-ov5640.dot
_images/mipi-ov5640.png

configure the pipeline with default format AYUV32/640x480,this can be alter with any other relevant format to testing with.

/* setup MC links */

# media-ctl --links "'ov5640 2-003c':0->'imx6-mipi-csi2':0[1]"
# media-ctl --links "'imx6-mipi-csi2':1->'ipu1_csi0_mux':0[1]"
# media-ctl --links "'ipu1_csi0_mux':2->'ipu1_csi0':0[1]"
# media-ctl --links "'ipu1_csi0':2->'ipu1_csi0 capture':0[1]"

/* configure pads */

# media-ctl --set-v4l2 "'ov5640 2-003c':0[fmt:UYVY2X8/640x480 field:none]"
# media-ctl --set-v4l2 "'imx6-mipi-csi2':1[fmt:UYVY2X8/640x480 field:none]"
# media-ctl --set-v4l2 "'ipu1_csi0_mux':2[fmt:UYVY2X8/640x480 field:none]"
# media-ctl --set-v4l2 "'ipu1_csi0':2[fmt:AYUV32/640x480 field:none]"
Launch the camera with ipu1_csi0 capture

# gst-launch-1.0 -v v4l2src device=/dev/video4 ! autovideosink
BTicino i.MX6DL

This tutorial will show the detail usage of BTicino i.MX6DL Mamoj board with respective mainline projects.

Hardware Access
BSP Building

Image building need host to ready with all necessary tools ready, refer here

U-Boot
$ git clone https://github.com/openedev/u-boot-amarula.git
$ cd u-boot
$ git checkout bticino origin/bticino
$ make imx6dl_mamoj_defconfig && make
Linux
$ git clone https://github.com/openedev/linux-openedev
$ cd linux-openedev
$ git checkout bticino origin/bticino
$ ARCH=arm make imx_v6_v7_defconfig
$ ARCH=arm make LOADADDR=0x10008000 uImage dtbs
Buildroot
Boot
USB SDP

More info at, u-boot/doc/README.sdp

  1. Clone imx_usb_loader
$ git clone git://github.com/boundarydevices/imx_usb_loader.git
$ cd imx_usb_loader
$ make
  1. Build the BSP and copy SPL, u-boot-dtb.img in imx_usb_loader directory
  2. Put the board in “Serial Download Mode”
  3. Plug-in USB-to-Serial and USB OTG cables to Host and Turn-on board
  4. Identify VID/PID using lsusb

Bus 001 Device 010: ID 15a2:0061 Freescale Semiconductor, Inc. i.MX 6Solo/6DualLite SystemOnChip in RecoveryMode

  1. Update the conf files

    imx_usb.conf

    0x15a2:0x0061, mx6_usb_rom.conf, 0x0525:0xb4a4, mx6_usb_sdp_spl.conf
    

mx6_usb_rom.conf

mx6_usb
hid,1024,0x910000,0x10000000,512M,0x00900000,0x40000
SPL:jump header2

mx6_usb_sdp_spl.conf

mx6_spl_sdp
hid,uboot_header,1024,0x910000,0x10000000,512M,0x00900000,0x40000
u-boot-dtb.img:jump header2
  1. Launch the loader
$ ./imx_usb
  1. Identify board booting on serial
U-Boot SPL 2018.03-rc3-00114-gcd9c6d25c1-dirty (Mar 08 2018 - 00:26:48 +0530)
Trying to boot from USB SDP
SDP: initialize...
SDP: handle requests...
Downloading file of size 344342 to 0x177fffc0... done
Jumping to header at 0x177fffc0
Header Tag is not an IMX image

U-Boot 2018.03-rc3-00114-gcd9c6d25c1-dirty (Mar 08 2018 - 00:26:48 +0530)
CPU:   Freescale i.MX6DL rev1.3 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 49C
Reset cause: POR
Model: BTicino Mamoj board
DRAM:  512 MiB
MMC:   FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@02188000
Hit any key to stop autoboot:  0
eMMC
Normal Mode
Falcon Mode
Secure Boot
U-Boot Accessing Peripherals
eMMC
FEC

Build the BSP and Setup host tftp server from here

=> setenv ethaddr 00:01:02:03:04:05
=> setenv serverip 10.39.66.9
=> setenv ipaddr 10.39.66.10
ping 10.39.66.9
Using ethernet@02188000 device
host 10.39.66.9 is alive
# tftpboot $loadaddr uImage
Using ethernet@02188000 device
TFTP from server 10.39.66.9; our IP address is 10.39.66.10
Filename 'uImage'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ####################################################
         969.7 KiB/s
done
Bytes transferred = 7437704 (717d88 hex)
# tftpboot $fdtaddr imx6dl-mamoj.dtb
Using ethernet@02188000 device
TFTP from server 10.39.66.9; our IP address is 10.39.66.10
Filename 'imx6dl-mamoj.dtb'.
Load address: 0x18000000
Loading: ###
         5.9 KiB/s
done
Bytes transferred = 32233 (7de9 hex)
# setenv bootargs 'console=ttymxc2,115200n8 rw root=/dev/mmcblk1p3'
# bootm $loadaddr - $fdtaddr
## Booting kernel from Legacy Image at 12000000 ...
   Image Name:   Linux-4.16.0-rc2-next-20180221-0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    7437640 Bytes = 7.1 MiB
   Load Address: 10008000
   Entry Point:  10008000
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Loading Kernel Image ... OK
   Loading Device Tree to 2ef6c000, end 2ef76de8 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.16.0-rc2-next-20180221-00004-gd4b3e85ef7dc (root@localhost.localdomain) (gcc versi
on 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #2 SMP Thu Mar 8 00:35:51 IST 2018
I2C
=> i2c bus
Bus 2:  i2c@021a8000
Bus 3:  i2c@021f8000
=> i2c dev 2
Setting bus to 2
=> i2c speed 400000
Setting bus speed to 400000 Hz
=> i2c probe
Valid chip addresses: 20 51 53
=> i2c md 53 0xff
00ff: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
=> i2c md 51 0xff
00ff: a8 08 40 50 09 43 46 52 42 18 80 8e ae a9 d0 53    ..@P.CFRB......S
=> i2c dev 3
Setting bus to 3
=> i2c speed 100000
Setting bus speed to 100000 Hz
=> i2c probe
Valid chip addresses: 08 40 48 4B
=> i2c md 08 0xff
00ff: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
PFUSE100
=> pmic list
| Name                            | Parent name         | Parent uclass @ seq
| pfuze100@08                     | i2c@021f8000        | i2c @ 3
=> pmic dev pfuze100@08
dev: 0 @ pfuze100@08
=> pmic dump
Dump pmic: pfuze100@08 registers

0x00: 10 00 00 21 00 01 3f 01 00 7f 00 00 00 00 00 81
0x10: 00 00 3f 00 00 00 00 00 00 00 00 10 00 00 00 00
0x20: 2b 2b 2b 08 c4 00 00 00 00 00 00 00 00 00 2b 2b
0x30: 2b 08 c4 00 00 72 72 72 08 d4 00 00 2c 2c 2c 08
0x40: e4 00 00 2c 2c 2c 08 e4 00 00 6f 6f 6f 08 f4 00
0x50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x60: 00 00 00 00 00 00 48 00 00 00 10 06 1e 1e 17 10
0x70: 1a 1f 00 00 00 00 00 00 00 00 00 00 00 00 00
USB
Linux Accessing Peripherals
eMMC
FEC
I2C
USB

Rockchip

PX30

ENGICAM-PX30-EDIMM2.2

This is the tutorial for ENGICAM PX30-EDIMM2.2 carrier board with PX30.Core SOM.

Hardware details and wiki EDIMM2.2 Starter Kit

Hardware Access
_images/engicam-px30-edimm2-2.jpeg
Program SD

Assume the SD card detected in host via /dev/sda

Flashing:

git clone https://github.com/amarula/bsp-rockchip.git
cd bsp-rockchip
sudo xzcat px30-core-edimm2.2-buildroot.img.xz | sudo dd of=/dev/sda
sync

Insert the Micro SD card on the board microSD slot(J17)

Connect UART port on the board(J26).

Launch minicom at host wih 1152008N1

Power on the kit.

Check the board booting. and enter root at login prompt.

U-Boot TPL board init
DDR4, 333MHz
BW=32 Col=10 Bk=4 BG=2 CS0 Row=16 CS=1 Die BW=16 Size=2048MB
out

U-Boot SPL 2020.10 (Oct 30 2020 - 02:55:08 +0530)
Trying to boot from MMC2
Card did not respond to voltage select!
spl: mmc init failed with error: -95
Trying to boot from MMC1
NOTICE:  BL31: v2.3(release):
NOTICE:  BL31: Built : 18:11:03, Oct 29 2020


U-Boot 2020.10 (Oct 30 2020 - 02:55:08 +0530)

Model: Engicam PX30.Core EDIMM2.2 Starter Kit
DRAM:  2 GiB
PMIC:  RK8090 (on=0x40, off=0x00)
MMC:   dwmmc@ff370000: 1, dwmmc@ff390000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff160000
Out:   serial@ff160000
Err:   serial@ff160000
Model: Engicam PX30.Core EDIMM2.2 Starter Kit
Net:   eth0: ethernet@ff360000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:3...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
197 bytes read in 4 ms (47.9 KiB/s)
1:      PX30.Core-EDIMM2.2 linux
Retrieving file: /Image
31070720 bytes read in 1303 ms (22.7 MiB/s)
append: earlycon=uart8250,mmio32,0xff160000 root=PARTUUID=e605584d-2513-4fd1-ab25-90cccc9f8ed8 rw rootwait
Retrieving file: /px30-px30-core-edimm2.2.dtb
40987 bytes read in 5 ms (7.8 MiB/s)
Moving Image from 0x280000 to 0x400000, end=2230000
## Flattened Device Tree blob at 08300000
Booting using the fdt blob at 0x8300000
Loading Device Tree to 000000007df28000, end 000000007df3501a ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd042]
[    0.000000] Linux version 5.10.0-rc1-next-20201028 (ub@ub-XPS-13-9350) (aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2020.08-844-g60a98501db) 9.3.0, GNU ld (GNU Binutils) 2
.34) #1 SMP PREEMPT Thu Oct 29 20:46:48 IST 2020
[    0.000000] Machine model: Engicam PX30.Core EDIMM2.2 Starter Kit

Starting network: OK

Welcome to PX30.Core EDIMM2.2
px30-core-edimm2 login: root
#
Program eMMC

Connect USB otg cable A-type to host pc, Micro USB end to board.

Close Jumper JM5.

Boot the Kit with SD boot.

Program eMMC in U-Boot.

At Target:

mmc dev 0
gpt write mmc 0 $partitions
fastboot 0

Copy boot images from /boot of rootfs partition of buildroot img.

At host:

lsusb | grep 2207
sudo fastboot -i 0x2207 flash loader1 idbloader.img
sudo fastboot -i 0x2207 flash loader2 u-boot.itb
WIFI/BT

Testing WiFi on the target.

# ifconfig -a | grep wlan0
wlan0     Link encap:Ethernet  HWaddr 00:25:CA:2D:2E:91
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# ifconfig wlan0 up
# iw dev wlan0 scan | grep SSID
        SSID: TP-Link_6DA4
        SSID: SiriVista501
        SSID: dlink-A430

# wpa_passphrase "SSID name" "SSID Password" >> /etc/wpa_supplicant.conf

# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
# [  580.535821] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

# udhcpc -i wlan0
udhcpc: started, v1.32.0
udhcpc: sending discover
udhcpc: sending select for 192.168.1.5
udhcpc: lease of 192.168.1.5 obtained, lease time 86400
deleting routers
adding dns 192.168.1.1

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=119 time=29.269 ms
64 bytes from 8.8.8.8: seq=1 ttl=119 time=26.163 ms
64 bytes from 8.8.8.8: seq=2 ttl=119 time=23.070 ms

Testing Bluetooth on the target.

# hciconfig -a
[  605.701708] Bluetooth: Core ver 2.22
[  605.709923] NET: Registered protocol family 31
[  605.718930] Bluetooth: HCI device and connection manager initialized
[  605.729967] Bluetooth: HCI socket layer initialized
[  605.739499] Bluetooth: L2CAP socket layer initialized
[  605.749121] Bluetooth: SCO socket layer initialized

# hciattach /dev/ttyUSB0 bcm43xx 921600
bcm43xx_init
Set Controller UART speed to 921600 bit/s
Flash firmware /lib/firmware/brcm/BCM43430A1.hcd
Set Controller UART speed to 921600 bit/s
[  627.490432] Bluetooth: HCI UART driver ver 2.3
[  627.499424] Bluetooth: HCI UART protocol H4 registered
[  627.509078] Bluetooth: HCI UART protocol LL registered
[  627.519087] Bluetooth: HCI UART protocol Broadcom registered
[  627.529106] Bluetooth: HCI UART protocol QCA registered
Device setup complete

# hciconfig hci0 up piscan
# hciconfig -a
hci0:   Type: Primary  Bus: UART
        BD Address: 00:25:CA:2D:2E:92  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN ISCAN
        RX bytes:1377 acl:0 sco:0 events:73 errors:0
        TX bytes:867 acl:0 sco:0 commands:73 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: 'BCM4343WA1 37.4MHz Laird Linux BT4.2-0119'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous,
        HCI Version: 4.2 (0x8)  Revision: 0x1d8
        LMP Version: 4.2 (0x8)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)

# hcitool scan
Scanning ...
        BC:9F:EF:F2:2F:CB       Arya_iPhone

# /usr/libexec/bluetooth/bluetoothd &
# [  764.238352] NET: Registered protocol family 38

# bt-adapter -d
Searching...
[11:9F:23:F2:F5:AH]
Name: Arya_iPhone
Alias: Arya_iPhone
Address: 11:9F:23:F2:F5:AH
Icon: phone
Class: 0x7a020c
LegacyPairing: 0
Paired: 0
RSSI: -37

# bt-device -c 11:9F:23:F2:F5:AH
Connecting to: 11:9F:23:F2:F5:AH
Device: Arya_iPhone (11:9F:23:F2:F5:AH)
Confirm passkey: 567321 (yes/no)? yes
connected
Linux USB OTG

Connect USB otg cable A-type to host pc, Micro USB end to board.

Close Jumper JM5.

At Target:

# fdisk -l
Disk /dev/mmcblk0: 3796 MB, 3980394496 bytes, 7774208 sectors
121472 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1 *  2,10,9      6,30,24          32768      98303      65536 32.0M  c Win95 FAT32 (LBA)
/dev/mmcblk0p2    0,0,2       0,0,34               1         33         33 16896 ee EFI GPT

Partition table entries are not in disk order
Disk /dev/mmcblk2: 7456 MB, 7818182656 bytes, 15269888 sectors
238592 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Disk /dev/mmcblk2 doesn't contain a valid partition table

# echo /dev/mmcblk2 > /sys/devices/platform/ff300000.usb/gadget/lun0/file

# [   55.912084] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.030006] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.042477] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)
[   56.055034] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.174016] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.186105] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)
[   56.199436] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.318007] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.329719] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)
[   56.341557] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.458056] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.469340] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)

At Host:

$ sudo fdisk -l

Disk /dev/sdb: 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

On host /dev/mmcblk2 will be detected as a storage device.

ENGICAM-PX30-CTOUCH2.0

This is the tutorial for ENGICAM PX30-CTOUCH2.0 carrier board with PX30.Core SOM.

Hardware details and wiki CTOUCH2.0 Starter Kit

Hardware Access
_images/engicam-px30-ctouch2-0.jpeg
Program SD

Assume the SD card detected in host via /dev/sda

Flashing:

git clone https://github.com/amarula/bsp-rockchip.git
cd bsp-rockchip
sudo xzcat px30-core-ctouch2-of10-buildroot.img.xz | sudo dd of=/dev/sda
sync

Insert the Micro SD card on the board microSD slot(J17)

Connect UART port on the board(J26).

Launch minicom at host wih 1152008N1

Power on the kit.

Check the board booting. and enter root at login prompt.

U-Boot TPL board init
DDR4, 333MHz
BW=32 Col=10 Bk=4 BG=2 CS0 Row=16 CS=1 Die BW=16 Size=2048MB
out

U-Boot SPL 2020.10 (Oct 30 2020 - 02:55:08 +0530)
Trying to boot from MMC2
Card did not respond to voltage select!
spl: mmc init failed with error: -95
Trying to boot from MMC1
NOTICE:  BL31: v2.3(release):
NOTICE:  BL31: Built : 18:11:03, Oct 29 2020


U-Boot 2020.10 (Oct 30 2020 - 02:55:08 +0530)

Model: Engicam PX30.Core C.TOUCH 2.0 10.1" Open Frame
DRAM:  2 GiB
PMIC:  RK8090 (on=0x40, off=0x00)
MMC:   dwmmc@ff370000: 1, dwmmc@ff390000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff160000
Out:   serial@ff160000
Err:   serial@ff160000
Model: Engicam PX30.Core C.TOUCH 2.0 10.1" Open Frame
Net:   eth0: ethernet@ff360000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:3...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
197 bytes read in 4 ms (47.9 KiB/s)
1:      PX30.Core-EDIMM2.2 linux
Retrieving file: /Image
31070720 bytes read in 1303 ms (22.7 MiB/s)
append: earlycon=uart8250,mmio32,0xff160000 root=PARTUUID=e605584d-2513-4fd1-ab25-90cccc9f8ed8 rw rootwait
Retrieving file: /px30-px30-core-ctouch2-of10.dtb
40987 bytes read in 5 ms (7.8 MiB/s)
Moving Image from 0x280000 to 0x400000, end=2230000
## Flattened Device Tree blob at 08300000
Booting using the fdt blob at 0x8300000
Loading Device Tree to 000000007df28000, end 000000007df3501a ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd042]
[    0.000000] Linux version 5.10.0-rc1-next-20201028 (ub@ub-XPS-13-9350) (aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2020.08-844-g60a98501db) 9.3.0, GNU ld (GNU Binutils) 2
.34) #1 SMP PREEMPT Thu Oct 29 20:46:48 IST 2020
[    0.000000] Machine model: Engicam PX30.Core C.TOUCH 2.0 10.1" Open Frame

Starting network: OK

Welcome to PX30.Core C.TOUCH2 10.1" OF
px30-core-ctouch-of10 login: root
#
Program eMMC

Connect USB otg cable A-type to host pc, Micro USB end to board.

Boot the Kit with SD boot.

Program eMMC in U-Boot.

At Target:

mmc dev 0
gpt write mmc 0 $partitions
fastboot 0

Copy boot images from /boot of rootfs partition of buildroot img.

At host:

lsusb | grep 2207
sudo fastboot -i 0x2207 flash loader1 idbloader.img
sudo fastboot -i 0x2207 flash loader2 u-boot.itb
WIFI/BT

Testing WiFi on the target.

# ifconfig -a | grep wlan0
wlan0     Link encap:Ethernet  HWaddr 00:25:CA:2D:2E:91
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# ifconfig wlan0 up
# iw dev wlan0 scan | grep SSID
        SSID: TP-Link_6DA4
        SSID: SiriVista501
        SSID: dlink-A430

# wpa_passphrase "SSID name" "SSID Password" >> /etc/wpa_supplicant.conf

# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
# [  580.535821] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

# udhcpc -i wlan0
udhcpc: started, v1.32.0
udhcpc: sending discover
udhcpc: sending select for 192.168.1.5
udhcpc: lease of 192.168.1.5 obtained, lease time 86400
deleting routers
adding dns 192.168.1.1

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=119 time=29.269 ms
64 bytes from 8.8.8.8: seq=1 ttl=119 time=26.163 ms
64 bytes from 8.8.8.8: seq=2 ttl=119 time=23.070 ms

Testing Bluetooth on the target.

# hciconfig -a
[  605.701708] Bluetooth: Core ver 2.22
[  605.709923] NET: Registered protocol family 31
[  605.718930] Bluetooth: HCI device and connection manager initialized
[  605.729967] Bluetooth: HCI socket layer initialized
[  605.739499] Bluetooth: L2CAP socket layer initialized
[  605.749121] Bluetooth: SCO socket layer initialized

# hciattach /dev/ttyUSB0 bcm43xx 921600
bcm43xx_init
Set Controller UART speed to 921600 bit/s
Flash firmware /lib/firmware/brcm/BCM43430A1.hcd
Set Controller UART speed to 921600 bit/s
[  627.490432] Bluetooth: HCI UART driver ver 2.3
[  627.499424] Bluetooth: HCI UART protocol H4 registered
[  627.509078] Bluetooth: HCI UART protocol LL registered
[  627.519087] Bluetooth: HCI UART protocol Broadcom registered
[  627.529106] Bluetooth: HCI UART protocol QCA registered
Device setup complete

# hciconfig hci0 up piscan
# hciconfig -a
hci0:   Type: Primary  Bus: UART
        BD Address: 00:25:CA:2D:2E:92  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN ISCAN
        RX bytes:1377 acl:0 sco:0 events:73 errors:0
        TX bytes:867 acl:0 sco:0 commands:73 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: 'BCM4343WA1 37.4MHz Laird Linux BT4.2-0119'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous,
        HCI Version: 4.2 (0x8)  Revision: 0x1d8
        LMP Version: 4.2 (0x8)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)

# hcitool scan
Scanning ...
        BC:9F:EF:F2:2F:CB       Arya_iPhone

# /usr/libexec/bluetooth/bluetoothd &
# [  764.238352] NET: Registered protocol family 38

# bt-adapter -d
Searching...
[11:9F:23:F2:F5:AH]
Name: Arya_iPhone
Alias: Arya_iPhone
Address: 11:9F:23:F2:F5:AH
Icon: phone
Class: 0x7a020c
LegacyPairing: 0
Paired: 0
RSSI: -37

# bt-device -c 11:9F:23:F2:F5:AH
Connecting to: 11:9F:23:F2:F5:AH
Device: Arya_iPhone (11:9F:23:F2:F5:AH)
Confirm passkey: 567321 (yes/no)? yes
connected
Linux USB OTG

Connect USB otg cable A-type to host pc, Micro USB end to board.

At Target:

# fdisk -l
Disk /dev/mmcblk0: 3796 MB, 3980394496 bytes, 7774208 sectors
121472 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1 *  2,10,9      6,30,24          32768      98303      65536 32.0M  c Win95 FAT32 (LBA)
/dev/mmcblk0p2    0,0,2       0,0,34               1         33         33 16896 ee EFI GPT

Partition table entries are not in disk order
Disk /dev/mmcblk2: 7456 MB, 7818182656 bytes, 15269888 sectors
238592 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Disk /dev/mmcblk2 doesn't contain a valid partition table

# echo /dev/mmcblk2 > /sys/devices/platform/ff300000.usb/gadget/lun0/file

# [   55.912084] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.030006] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.042477] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)
[   56.055034] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.174016] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.186105] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)
[   56.199436] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.318007] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.329719] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)
[   56.341557] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.458056] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 1)
[   56.469340] dwc2 ff300000.usb: dwc2_hsotg_ep_sethalt(ep 0000000006ae2021 ep1in, 0)

At Host:

$ sudo fdisk -l

Disk /dev/sdb: 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

On host /dev/mmcblk2 will be detected as a storage device.

RK3288

ROCKPI-N8

This tutorial will show the details of Radxa ROCKPI-N8 board with VMARC RK3288 SOM.

Hardware details and wiki ROCKPI-N8

Hardware Access
_images/rock-pi-n8.jpg
BSP Building

Host require few tools/packages to build BSP, install them from host

U-Boot

$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b rock-pi origin/rock-pi
$ make rock-pi-n8-rk3288_defconfig
$ make

Linux

$ git clone https://github.com/amarula/linux-amarula.git
$ cd linux-amarula
$ git checkout -b rockpi origin/rockpi
$ make mrproper
$ ARCH=arm make multi_v7_defconfig
$ ARCH=arm make LOADADDR=0x02000000 uImage dtbs -j 4

Buildroot

$ git clone git://git.buildroot.net/buildroot
$ cd buildroot
$ make rock_pi_n8_defconfig
$ make

SD Boot

In the output/images directory, flash sdcard.img on to micro sd

$ sudo dd if=output/images/sdcard.img of=/dev/sdX status=progress (X - find it from fdisk -l)
$ sync

VMARC RK3288 SOM used on this board looks for images on EMMC and then SD(EMMC is the first in boot order). If EMMC has a valid image then it boots from EMMC. To make SD boot, follow the below link to erase EMMC. It is also valid for RK3288.

EMMC erase notes RK3288 EMMC

Put the micro-SD card onto your board in the slot and power the board. You should see something like:

U-Boot TPL 2020.07-rc4 (Jul 06 2020 - 18:50:52)
Trying to boot from BOOTROM
Returning to boot ROM...
Trying to boot from MMC1


U-Boot 2020.07-rc4 (Jul 06 2020 - 18:50:52 +0530)

SoC: Rockchip rk3288
Reset cause: RST
Model: Radxa ROCK Pi N8
DRAM:  4 GiB
PMIC:  RK808
MMC:   dwmmc@ff0c0000: 1, dwmmc@ff0f0000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff690000
Out:   serial@ff690000
Err:   serial@ff690000
Model: Radxa ROCK Pi N8
Net:   No ethernet found.

Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc1(part 1) is current device
Scanning mmc 1:3...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
146 bytes read in 5 ms (30.4 KiB/s)
1:     RK3399_ROCKPI_N8
Retrieving file: /uImage
9396800 bytes read in 616 ms (14.5 MiB/s)
append: console=ttyS2,115200n8 root=/dev/mmcblk0p4 rw rootwait
Retrieving file: /rk3288-rock-pi-n8.dtb
39356 bytes read in 18 ms (2.1 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
Loading Device Tree to 0fff3000, end 0ffff9bb ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x500
[    0.000000] Linux version 5.7.0-rc1 (suniel@suniel-P5WE0) (gcc version 9.3.0 (Buildroot 2020.08-git-00494-g07339c7-dirty), GNU ld (GNU Binutils) 2.0
[    0.000000] CPU: ARMv7 Processor [410fc0d1] revision 1 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Radxa ROCK Pi N8
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 64 MiB at 0xfa000000
[    0.000000] percpu: Embedded 20 pages/cpu s49356 r8192 d24372 u81920
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 1038848
[    0.000000] Kernel command line: console=ttyS2,115200n8 rw rootwait root=/dev/mmcblk0p4 rootfstype=ext4
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 4038496K/4161536K available (13312K kernel code, 1792K rwdata, 5452K rodata, 2048K init, 403K bss, 57504K reserved, 65536K cma-)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=4.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] random: get_random_bytes called from start_kernel+0x300/0x4a4 with crng_init=0
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000006] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000022] Switching to timer-based delay loop, resolution 41ns
[    0.005949] Console: colour dummy device 80x30
[    0.005997] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.006014] pid_max: default: 32768 minimum: 301
[    0.006180] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.006199] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.006915] CPU: Testing write buffer coherency: ok
[    0.006950] CPU0: Spectre v2: using BPIALL workaround
[    0.007167] CPU0: thread -1, cpu 0, socket 5, mpidr 80000500
[    0.007920] Setting up static identity map for 0x300000 - 0x3000ac
[    0.009927] rcu: Hierarchical SRCU implementation.
[    0.014334] EFI services will not be available.
[    0.014553] smp: Bringing up secondary CPUs ...
[    0.016215] CPU1: thread -1, cpu 1, socket 5, mpidr 80000501
[    0.016223] CPU1: Spectre v2: using BPIALL workaround
[    0.018003] CPU2: thread -1, cpu 2, socket 5, mpidr 80000502
[    0.018011] CPU2: Spectre v2: using BPIALL workaround
[    0.019761] CPU3: thread -1, cpu 3, socket 5, mpidr 80000503
[    0.019770] CPU3: Spectre v2: using BPIALL workaround
[    0.019910] smp: Brought up 1 node, 4 CPUs
[    0.019923] SMP: Total of 4 processors activated (192.00 BogoMIPS).
[    0.019931] CPU: All CPU(s) started in SVC mode.
[    0.020624] devtmpfs: initialized
[    0.029817] VFP support v0.3: implementor 41 architecture 3 part 30 variant d rev 0
[    0.030125] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.030146] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.032048] pinctrl core: initialized pinctrl subsystem
[    0.034138] thermal_sys: Registered thermal governor 'step_wise'
[    0.034814] DMI not present or invalid.
[    0.035247] NET: Registered protocol family 16
[    0.037639] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.040375] cpuidle: using governor menu
[    0.041044] No ATAGs?
[    0.041180] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.041194] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.044438] Serial: AMBA PL011 UART driver
[    0.107102] AT91: Could not find identification node
[    0.107815] vcc5v0_sys: supplied by vcc12v_dcin
[    0.108269] vbus_host: supplied by vcc5v0_sys
[    0.108709] vbus_typec: supplied by vcc5v0_sys
[    0.112010] iommu: Default domain type: Translated
[    0.113458] vgaarb: loaded
[    0.114414] SCSI subsystem initialized
[    0.114875] usbcore: registered new interface driver usbfs
[    0.114929] usbcore: registered new interface driver hub
[    0.114998] usbcore: registered new device driver usb
[    0.116660] pps_core: LinuxPPS API ver. 1 registered
[    0.116671] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.116694] PTP clock support registered
[    0.116905] EDAC MC: Ver: 3.0.0
[    0.120011] clocksource: Switched to clocksource arch_sys_counter
[    1.361978] NET: Registered protocol family 2
[    1.362638] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    1.362677] TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    1.362759] TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    1.362950] TCP: Hash tables configured (established 8192 bind 8192)
[    1.363059] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[    1.363112] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[    1.363313] NET: Registered protocol family 1
[    1.363779] RPC: Registered named UNIX socket transport module.
[    1.363791] RPC: Registered udp transport module.
[    1.363799] RPC: Registered tcp transport module.
[    1.363806] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    1.363818] PCI: CLS 0 bytes, default 64
[    1.364888] hw perfevents: enabled with armv7_cortex_a12 PMU driver, 7 counters available
[    1.366309] Initialise system trusted keyrings
[    1.366489] workingset: timestamp_bits=30 max_order=20 bucket_order=0
[    1.374312] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    1.375102] NFS: Registering the id_resolver key type
[    1.375130] Key type id_resolver registered
[    1.375139] Key type id_legacy registered
[    1.375157] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    1.375192] ntfs: driver 2.1.32 [Flags: R/O].
[    1.375649] Key type asymmetric registered
[    1.375661] Asymmetric key parser 'x509' registered
[    1.375719] bounce: pool size: 64 pages
[    1.375761] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 247)
[    1.375771] io scheduler mq-deadline registered
[    1.375779] io scheduler kyber registered
[    1.410568] dma-pl330 ff250000.dma-controller: Loaded driver for PL330 DMAC-241330
[    1.410588] dma-pl330 ff250000.dma-controller:       DBUFF-128x8bytes Num_Chans-8 Num_Peri-20 Num_Events-16
[    1.411318] dma-pl330 ffb20000.dma-controller: Loaded driver for PL330 DMAC-241330
[    1.411336] dma-pl330 ffb20000.dma-controller:       DBUFF-64x8bytes Num_Chans-5 Num_Peri-6 Num_Events-10
[    1.476400] Serial: 8250/16550 driver, 5 ports, IRQ sharing enabled
[    1.479637] ff180000.serial: ttyS0 at MMIO 0xff180000 (irq = 34, base_baud = 1500000) is a 16550A
[    1.480908] ff690000.serial: ttyS2 at MMIO 0xff690000 (irq = 35, base_baud = 1500000) is a 16550A
[    2.243259] printk: console [ttyS2] enabled
[    2.250329] SuperH (H)SCI(F) driver initialized
[    2.256667] msm_serial: driver initialized
[    2.261506] STMicroelectronics ASC driver initialized
[    2.268898] STM32 USART driver initialized
[    2.291052] brd: module loaded
[    2.303028] loop: module loaded
[    2.319631] libphy: Fixed MDIO Bus: probed
[    2.325424] CAN device driver interface
[    2.330915] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded
[    2.338665] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[    2.345225] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    2.351925] igb: Intel(R) Gigabit Ethernet Network Driver - version 5.6.0-k
[    2.359706] igb: Copyright (c) 2007-2014 Intel Corporation.
[    2.369300] clk: failed to reparent mac_clk to clkin_gmac: -22
[    2.375909] rk_gmac-dwmac ff290000.ethernet: IRQ eth_lpi not found
[    2.382960] rk_gmac-dwmac ff290000.ethernet: PTP uses main clock
[    2.389706] rk_gmac-dwmac ff290000.ethernet: phy regulator is not available yet, deferred probing
[    2.402427] pegasus: v0.9.3 (2013/04/25), Pegasus/Pegasus II USB Ethernet driver
[    2.410763] usbcore: registered new interface driver pegasus
[    2.417131] usbcore: registered new interface driver asix
[    2.423226] usbcore: registered new interface driver ax88179_178a
[    2.430100] usbcore: registered new interface driver cdc_ether
[    2.436665] usbcore: registered new interface driver smsc75xx
[    2.443159] usbcore: registered new interface driver smsc95xx
[    2.449616] usbcore: registered new interface driver net1080
[    2.455998] usbcore: registered new interface driver cdc_subset
[    2.462673] usbcore: registered new interface driver zaurus
[    2.468953] usbcore: registered new interface driver cdc_ncm
[    2.477943] dwc2 ff540000.usb: supply vusb_d not found, using dummy regulator
[    2.486027] dwc2 ff540000.usb: supply vusb_a not found, using dummy regulator
[    2.560245] dwc2 ff540000.usb: DWC OTG Controller
[    2.565532] dwc2 ff540000.usb: new USB bus registered, assigned bus number 1
[    2.573477] dwc2 ff540000.usb: irq 40, io mem 0xff540000
[    2.580259] hub 1-0:1.0: USB hub found
[    2.584495] hub 1-0:1.0: 1 port detected
[    2.589512] dwc2 ff580000.usb: supply vusb_d not found, using dummy regulator
[    2.597607] dwc2 ff580000.usb: supply vusb_a not found, using dummy regulator
[    2.740075] dwc2 ff580000.usb: EPs: 10, dedicated fifos, 972 entries in SPRAM
[    2.748493] dwc2 ff580000.usb: DWC OTG Controller
[    2.753810] dwc2 ff580000.usb: new USB bus registered, assigned bus number 2
[    2.761741] dwc2 ff580000.usb: irq 41, io mem 0xff580000
[    2.768445] hub 2-0:1.0: USB hub found
[    2.772706] hub 2-0:1.0: 1 port detected
[    2.778361] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    2.785686] ehci-pci: EHCI PCI platform driver
[    2.790723] ehci-platform: EHCI generic platform driver
[    2.796796] ehci-platform ff500000.usb: EHCI Host Controller
[    2.803172] ehci-platform ff500000.usb: new USB bus registered, assigned bus number 3
[    2.812123] ehci-platform ff500000.usb: irq 38, io mem 0xff500000
[    2.840039] ehci-platform ff500000.usb: USB 2.0 started, EHCI 1.00
[    2.847692] hub 3-0:1.0: USB hub found
[    2.851953] hub 3-0:1.0: 1 port detected
[    2.856922] ehci-orion: EHCI orion driver
[    2.861647] SPEAr-ehci: EHCI SPEAr driver
[    2.866306] ehci-st: EHCI STMicroelectronics driver
[    2.871956] ehci-exynos: EHCI Exynos driver
[    2.876803] ehci-atmel: EHCI Atmel driver
[    2.881485] tegra-ehci: Tegra EHCI driver
[    2.886165] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    2.893109] ohci-pci: OHCI PCI platform driver
[    2.898126] ohci-platform: OHCI generic platform driver
[    2.904228] ohci-platform ff520000.usb: Generic Platform OHCI controller
[    2.911768] ohci-platform ff520000.usb: new USB bus registered, assigned bus number 4
[    2.920775] ohci-platform ff520000.usb: irq 39, io mem 0xff520000
[    2.994823] hub 4-0:1.0: USB hub found
[    2.999060] hub 4-0:1.0: 1 port detected
[    3.004063] SPEAr-ohci: OHCI SPEAr driver
[    3.008740] ohci-st: OHCI STMicroelectronics driver
[    3.014403] ohci-atmel: OHCI Atmel driver
[    3.019874] usbcore: registered new interface driver usb-storage
[    3.033736] i2c /dev entries driver
[    3.041510] rtc-hym8563 1-0051: no valid clock/calendar values available
[    3.049179] rtc-hym8563 1-0051: registered as rtc0
[    3.054877] rtc-hym8563 1-0051: no valid clock/calendar values available
[    3.062400] rtc-hym8563 1-0051: hctosys: unable to read the hardware clock
[    3.073046] rk808 0-001b: chip id: 0x0
[    3.081112] rk808-regulator rk808-regulator: there is no dvs0 gpio
[    3.088053] rk808-regulator rk808-regulator: there is no dvs1 gpio
[    3.095061] DCDC_REG1: supplied by vcc5v0_sys
[    3.100702] DCDC_REG2: supplied by vcc5v0_sys
[    3.106147] DCDC_REG3: supplied by vcc5v0_sys
[    3.111304] DCDC_REG4: supplied by vcc5v0_sys
[    3.116788] LDO_REG1: supplied by vcc5v0_sys
[    3.122842] LDO_REG2: supplied by vcc5v0_sys
[    3.127809] vcca_codec: Bringing 1800000uV into 3300000-3300000uV
[    3.135696] LDO_REG3: supplied by vcc5v0_sys
[    3.141635] LDO_REG4: supplied by vcc_io
[    3.146994] LDO_REG5: supplied by vcc_io
[    3.152555] LDO_REG6: supplied by vcc5v0_sys
[    3.158297] LDO_REG7: supplied by vcc5v0_sys
[    3.164258] LDO_REG8: supplied by vcc5v0_sys
[    3.170045] SWITCH_REG1: supplied by vcc_io
[    3.175010] SWITCH_REG2: supplied by vcc_io
[    3.184612] vccio_flash: supplied by vcc_io
[    3.202185] cpufreq: cpufreq_online: CPU0: Running at unlisted freq: 500000 KHz
[    3.210703] cpufreq: cpufreq_online: CPU0: Unlisted initial frequency changed to: 600000 KHz
[    3.222909] sdhci: Secure Digital Host Controller Interface driver
[    3.229815] sdhci: Copyright(c) Pierre Ossman
[    3.236600] Synopsys Designware Multimedia Card Interface Driver
[    3.244558] dwmmc_rockchip ff0c0000.mmc: IDMAC supports 32-bit address mode.
[    3.252480] dwmmc_rockchip ff0c0000.mmc: Using internal DMA controller.
[    3.259869] dwmmc_rockchip ff0c0000.mmc: Version ID is 270a
[    3.266124] dwmmc_rockchip ff0c0000.mmc: DW MMC controller at irq 30,32 bit host data width,256 deep fifo
[    3.289946] mmc_host mmc0: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[    3.314279] dwmmc_rockchip ff0f0000.mmc: IDMAC supports 32-bit address mode.
[    3.322230] dwmmc_rockchip ff0f0000.mmc: Using internal DMA controller.
[    3.329626] dwmmc_rockchip ff0f0000.mmc: Version ID is 270a
[    3.335891] dwmmc_rockchip ff0f0000.mmc: DW MMC controller at irq 31,32 bit host data width,256 deep fifo
[    3.346703] mmc_host mmc1: card is non-removable.
[    3.360313] mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 50000000Hz, actual 50000000HZ div = 0)
[    3.364588] mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[    3.371238] mmc0: new high speed SD card at address 0002
[    3.387742] mmcblk0: mmc0:0002 00000 1.87 GiB
[    3.394650] sdhci-pltfm: SDHCI platform and OF driver helper
[    3.402353] ledtrig-cpu: registered to indicate activity on CPUs
[    3.409628] usbcore: registered new interface driver usbhid
[    3.415868] usbhid: USB HID core driver
[    3.422432] drop_monitor: Initializing network drop monitor service
[    3.423601] GPT:Primary header thinks Alt. header is not at the end of the disk.
[    3.429751] NET: Registered protocol family 10
[    3.437705] GPT:524320 != 3911679
[    3.437706] GPT:Alternate GPT header not at the end of the disk.
[    3.437708] GPT:524320 != 3911679
[    3.437709] GPT: Use GNU Parted to correct GPT errors.
[    3.437727]  mmcblk0: p1 p2 p3 p4
[    3.442984] Segment Routing with IPv6
[    3.470324] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    3.477160] NET: Registered protocol family 17
[    3.482131] can: controller area network core (rev 20170425 abi 9)
[    3.484792] random: fast init done
[    3.489056] NET: Registered protocol family 29
[    3.497786] can: raw protocol (rev 20170425)
[    3.502554] can: broadcast manager protocol (rev 20170425 t)
[    3.506339] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
[    3.508873] can: netlink gateway (rev 20190810) max_hops=1
[    3.521025] mmc1: new high speed MMC card at address 0001
[    3.526067] Key type dns_resolver registered
[    3.532240] mmcblk1: mmc1:0001 SLD32G 28.9 GiB
[    3.536763] ThumbEE CPU extension supported.
[    3.541953] mmcblk1boot0: mmc1:0001 SLD32G partition 1 4.00 MiB
[    3.546508] Registering SWP/SWPB emulation handler
[    3.553368] mmcblk1boot1: mmc1:0001 SLD32G partition 2 4.00 MiB
[    3.558599] Loading compiled-in X.509 certificates
[    3.565141] mmcblk1rpmb: mmc1:0001 SLD32G partition 3 4.00 MiB, chardev (235:0)
[    3.580223] clk: failed to reparent mac_clk to clkin_gmac: -22
[    3.582322]  mmcblk1: p1 p2 p3 p4 p5
[    3.586767] rk_gmac-dwmac ff290000.ethernet: IRQ eth_lpi not found
[    3.597702] rk_gmac-dwmac ff290000.ethernet: PTP uses main clock
[    3.604474] rk_gmac-dwmac ff290000.ethernet: clock input or output? (input).
[    3.612356] rk_gmac-dwmac ff290000.ethernet: TX delay(0x28).
[    3.618675] rk_gmac-dwmac ff290000.ethernet: RX delay(0x11).
[    3.625001] rk_gmac-dwmac ff290000.ethernet: integrated PHY? (no).
[    3.631924] rk_gmac-dwmac ff290000.ethernet: cannot get clock clk_mac_speed
[    3.639698] rk_gmac-dwmac ff290000.ethernet: clock input from PHY
[    3.651511] rk_gmac-dwmac ff290000.ethernet: init for RGMII
[    3.657839] rk_gmac-dwmac ff290000.ethernet: User ID: 0x10, Synopsys ID: 0x35
[    3.665826] rk_gmac-dwmac ff290000.ethernet:         DWMAC1000
[    3.671668] rk_gmac-dwmac ff290000.ethernet: DMA HW capability register supported
[    3.680031] rk_gmac-dwmac ff290000.ethernet: RX Checksum Offload Engine supported
[    3.688389] rk_gmac-dwmac ff290000.ethernet: COE Type 2
[    3.694226] rk_gmac-dwmac ff290000.ethernet: TX Checksum insertion supported
[    3.702101] rk_gmac-dwmac ff290000.ethernet: Wake-Up On Lan supported
[    3.709305] rk_gmac-dwmac ff290000.ethernet: Normal descriptors
[    3.715919] rk_gmac-dwmac ff290000.ethernet: Ring mode enabled
[    3.722435] rk_gmac-dwmac ff290000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    3.731383] rk_gmac-dwmac ff290000.ethernet: device MAC address 76:ec:85:f3:b0:94
[    3.843959] libphy: stmmac: probed
[    3.847845] RTL8211E Gigabit Ethernet stmmac-0:00: attached PHY driver [RTL8211E Gigabit Ethernet] (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[    3.861869] RTL8211E Gigabit Ethernet stmmac-0:01: attached PHY driver [RTL8211E Gigabit Ethernet] (mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[    3.877357] dw-apb-uart ff690000.serial: forbid DMA for kernel console
[    3.904177] EXT4-fs (mmcblk0p4): mounted filesystem with ordered data mode. Opts: (null)
[    3.913251] VFS: Mounted root (ext4 filesystem) on device 179:4.
[    3.922533] devtmpfs: mounted
[    3.927824] Freeing unused kernel memory: 2048K
[    3.971529] Run /sbin/init as init process
[    4.134971] EXT4-fs (mmcblk0p4): re-mounted. Opts: (null)
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: [    5.214934] random: dd: uninitialized urandom read (512 bytes read)
OK
Starting system message bus: [    5.269464] random: dbus-uuidgen: uninitialized urandom read (12 bytes read)
[    5.277635] random: dbus-uuidgen: uninitialized urandom read (8 bytes read)
dbus-daemon[177]: Failed to start message bus: Could not get UID and GID for username "dbus"
done
Starting network: OK

Welcome to ROCKPI-N8..!!
rockpi-n8 login:

use root for login.

Tinker RK3288

This tutorial will show the details of Tinker board mainline support and other needed details, for more information about hardware

Hardware Access
_images/tinker.jpg

Serial debug and Power connections

BSP Build
Manual Build

Image building need host to ready with all necessary tools ready, refer here

Below are the details of Image build for Tinker RK3288 board. Manual Build

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make tinker-rk3288_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm make multi_v7_defconfig
$ ARCH=arm make -j 4 LOADADDR=0x02000000 uImage dtbs
$ ARCH=arm make modules -j 4
$ ARCH=arm make modules_install -j 4
Buildroot

It’s easy to build entire system using buildroot and mainline supported Tinker board already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make asus_tinker_rk3288_defconfig && make
SD Boot

Create Single partition and Insert the SD on host

$ git clone https://github.com/openedev/rfs-rk3288
$ cp rfs-rk3288/* /media/jagan/rootfs
$ cd /path/to/u-boot
$ ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out
$ dd if=out of=/dev/mmcblk0 seek=64
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=16384
$ cp /path/to/linux-next/arch/arm/boot/uImage /media/jagan/rootfs/boot
$ cp /path/to/linux-next/arch/arm/boot/dts/rk3288-tinker.dtb /media/jagan/rootfs/boot
$ sync && $ umount /dev/mmcblk0
Falcon Boot

Build U-Boot, Linux manually from above steps, and create falcon mode partition from, here

Once the partitioning done, copy all images like SD Boot. Configure falcon

U-Boot TPL 2017.11-rc4-00029-gb142d38-dirty (Nov 10 2017 - 17:04:00)
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2018.03-rc2-00018-g339b842-dirty (Feb 18 2018 - 19:57:13 +0530)
Trying to boot from MMC1
Expected Linux image is not found. Trying to start U-boot

U-Boot 2018.03-rc2-00018-g339b842-dirty (Feb 18 2018 - 19:57:13 +0530)

Model: Tinker-RK3288
DRAM:  2 GiB
MMC:   dwmmc@ff0c0000: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment


Failed (-5)
In:    serial
Out:   serial
Err:   serial
Model: Tinker-RK3288
Net:   failed to enable clock 0
No ethernet found.
Hit any key to stop autoboot:  0
Vyasa RK3288

This tutorial will show the details of Vyasa RK3288 Linux BSP Guide. Most of the software supported by Vyasa is mainlined already. You can check hardware details here

Hardware Access

Serial: NULL Modem cable, Serial-to-USB converter

Power: DC-in 12V ~ 24V socket supply

Sometimes junk characters show on serial console so better to plug-in USB OTG cable

_images/vyasa.jpg
Prebuilt Image

Insert the SD card on to host and write the image.

$ git clone https://github.com/openedev/rootfs-rk32
$ cd rootfs-rk32/boot
$ xzcat sdcard-vyasa.img.xz | dd of=/dev/mmcblk0
$ sync
$ umount /dev/mmcblk0*

Turn-on the board

BSP Building
Manual Build

Image building need host to ready with all necessary tools ready, refer here

U-Boot
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make vyasa-rk3288_defconfig
$ make
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm make multi_v7_defconfig
$ ARCH=arm make menuconfig
[select CONFIG_DWMAC_ROCKCHIP=m]
$ ARCH=arm make -j 4 LOADADDR=0x02000000 uImage dtbs
$ ARCH=arm make modules -j 4

#modules would installed in lib/ directory of kernel source
$ ARCH=arm make modules_install -j 4 INSTALL_MOD_PATH=./

#for linux-next kernel repo
$ find . -name *`cat localversion-next`
Rootfs
Buildroot

It’s easy to build entire system using buildroot and mainline supported Vyasa board already. See read this readme.txt for more info.

$ git clone git://git.busybox.net/buildroot
$ cd buildroot
$ make amarula_vyasa_rk3288_defconfig && make

Prepare your SDCard:

Buildroot generates a ready-to-use SD card image that you can flash directly to the card. The image will be in output/images/sdcard.img. You can write this image directly to an SD card device (i.e. /dev/xxx)

$ sudo dd if=output/images/sdcard.img of=/dev/xxx
$ sudo sync

Finally, you can insert the SD card to the Vyasa RK3288 board, close J4 and boot it.

Ubuntu 16.04
U-Boot/Linux

Build U-Boot. Linux from BSP Build and Build Mali

Ubuntu RFS ubuntu-xenial

$ cd /path/to
$ wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-armhf.tar.gz
$ mkdir /path/to/ubuntu
$ cd ubuntu
$ tar xvf ../ubuntu-base-16.04-core-armhf.tar.gz

copy qemu

$ apt-get install qemu-user-static
$ cp /usr/bin/qemu-arm-static usr/bin/

copy host’s dns

$ cp -b /etc/resolv.conf  etc/resolv.conf

add the following repository to etc/apt/sources.list(for compiling xserver)

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial main  restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted

## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial universe
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates universe

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted

deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
#deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
#deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
#deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse
#deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse

deb http://ports.ubuntu.com/ubuntu-ports/ xenial-proposed main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-proposed main restricted

chroot to RFS

Download ch-mount.sh

$ cd ../
$ ch-mount.sh -m ubuntu/

Install desktop

$ apt-get update
$ apt-get install lightdm vim git
$ apt-get build-dep xserver-xorg-core

Build xserver

$ cd /opt
$ git clone git://anongit.freedesktop.org/xorg/lib/libXfont
$ cd libXfont
$ ./autogen.sh --prefix=/usr
$ make check
$ make && make install
$ cd ..
$ apt install libxcb-xkb-dev
$ git clone https://github.com/rockchip-linux/xserver.git
$ cd xserver
[ delete these line on configure.ac ]
AC_CHECK_DECL(GBM_BO_USE_LINEAR,
                        [AC_DEFINE(GLAMOR_HAS_GBM_LINEAR, 1, [Have GBM_BO_USE_LINEAR])], []
$ ./autogen.sh --prefix=/usr --enable-aiglx --enable-composite --enable-record --enable-xv --enable-xvmc \
--enable-dga --enable-screensaver \--enable-xdmcp --enable-xdm-auth-1 --enable-glx --enable-dri --enable-dri2 \
 --enable-glamor --enable-dri3 --enable-libdrm --enable-present --enable-xinerama --enable-xf86vidmode \
--enable-xace --enable-xselinux --enable-xfree86-utils --enable-systemd-logind --with-systemd-daemon \
--enable-suid-wrapper --enable-dmx --enable-xvfb --enable-xnest --enable-kdrive --enable-xephyr --enable-xmir \
--with-sha1=libgcrypt --enable-xcsecurity --with-log-dir=/var/log
$ make && make install

set password

$ useradd -s '/bin/bash' -m -G adm,sudo rk
$ echo "Set password for rk:"
$ passwd rk
$ echo "Set password for root:"
$ passwd root

exit chroot

$ exit
$ ch-mount.sh -u ubuntu/

libmali

Copy libmali here to ubuntu/opt

Prepare SD Create Single partition and Insert the SD on host.

$ cp ubuntu/* /media/jagan/rootfs
$ cp path/to/arch/arm/boot/uImage /media/jagan/rootfs/boot
$ cp /path/to/rockchip_forwardports/midgard_r13p0/mali_kbase.ko /media/jagan/root
$ cp path/to/arch/arm/boot/dts/rk3288-vyasa.dtb /media/jagan/rootfs/boot
$ mkdir /media/jagan/rootfs/boot/extlinux/
$ vi /media/jagan/rootfs/boot/extlinux/extlinux.conf
label Vyasa linux-next
  kernel /boot/uImage
  devicetree /boot/rk3288-vyasa.dtb
  append console=ttyS2,115200n8 root=/dev/mmcblk0p1 rootwait
$ cd /path/to/u-boot
$ ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out
$ dd if=out of=/dev/mmcblk0 seek=64
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=16384
$ sync && sudo umount /media/jagan/rootfs
Boot Ubuntu

Insert the SD card put SD Bootmode and power-on the board

We need insert mali drivers and libs

root@localhost:/opt/libmali# cat /sys/devices/platform/*gpu/gpuinfo
Mali-T76x MP4 r0p0 0x0750
root@localhost:/opt/libmali# mount -n -oremount,rw /
root@lalhost:/opt/libmali# dpkg -i libmali-rk-midgard-t76x-r14p0-r0p0_1.5-6_arm
Selecting previously unselected package libmali-rk-midgard-t76x-r14p0-r0p0:armhf.
(Reading database ... 62913 files and directories currently installed.)
Preparing to unpack libmali-rk-midgard-t76x-r14p0-r0p0_1.5-6_armhf.deb ...
Unpacking libmali-rk-midgard-t76x-r14p0-r0p0:armhf (1.5-6) ...
Replacing files in old package libgbm1:armhf (17.2.4-0ubuntu1~16.04.2) ...
Setting up libmali-rk-midgard-t76x-r14p0-r0p0:armhf (1.5-6) ...
root@localhost:/opt/libmali# dpkg -i libmali-rk-dev_1.5-6_armhf.deb
Selecting previously unselected package libmali-rk-dev:armhf.
(Reading database ... 62927 files and directories currently installed.)
Preparing to unpack libmali-rk-dev_1.5-6_armhf.deb ...
Unpacking libmali-rk-dev:armhf (1.5-6) ...
Replacing files in old package libegl1-mesa-dev:armhf (17.2.4-0ubuntu1~16.04.2) ...
Replacing files in old package libgbm-dev:armhf (17.2.4-0ubuntu1~16.04.2) ...
Setting up libmali-rk-dev:armhf (1.5-6) ...
root@localhost:~# modprobe -a governor_simpleondemand
root@localhost:~# insmod /root/mali_kbase.ko

Switch to Graphical mode

root@localhost:~# systemctl start graphical.target
Booting
SDMMC Boot
Write SD

Create Single partition and Insert the SD on host.

$ git clone https://github.com/openedev/rootfs-rk32
$ cp rootfs-rk32/* /media/jagan/rootfs/
$ cp arch/arm/boot/uImage /media/jagan/rootfs/boot
$ cp arch/arm/boot/dts/rk3288-vyasa.dtb /media/jagan/rootfs/boot
$ cd /path/to/u-boot
$ ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out
$ dd if=out of=/dev/mmcblk0 seek=64
$ dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=16384
$ sync && sudo umount /media/jagan/rootfs

Turn-on Board * Plug the SD card to Vyasa, * Open minicom with detected /dev/ttyUSBX device (where X is detected device number) * Baudrate 115200n8 * close JP4 for SD boot * Plug-in USB OTG cable * Turn-on the power supply

eMMC Boot

U-Boot Accessing Peripherals SDMMC

=> mmc list
dwmmc@ff0c0000: 1 (SD)
=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device
=> mmcinfo
Device: dwmmc@ff0c0000
Manufacturer ID: 12
OEM: 3456
Name: MS
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
=> ext4ls  mmc 1:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 proc
<DIR>       4096 etc
<DIR>       4096 lib
<DIR>       4096 media
<DIR>       4096 tmp
<DIR>       4096 dev
<SYM>          3 lib32
<DIR>       4096 var
<DIR>       4096 usr
<DIR>       4096 run
<DIR>       4096 sbin
<DIR>       4096 root
<DIR>       4096 bin
<DIR>       4096 opt
<DIR>       4096 mnt
<DIR>       4096 boot
<SYM>         11 linuxrc
<DIR>       4096 sys
=> ext4load mmc 1:1 $kernel_addr_r /boot/uImage
7975488 bytes read in 374 ms (20.3 MiB/s)
=> iminfo $kernel_addr_r

## Checking Image at 02000000 ...
   Legacy image found
   Image Name:   Linux-4.14.0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    7975424 Bytes = 7.6 MiB
   Load Address: 02000000
   Entry Point:  02000000
   Verifying Checksum ... OK

eMMC GMAC Setup host tftp server from here once U-Boot booted from SD

=> setenv serverip 10.39.66.9
=> setenv ipaddr 10.39.66.10
=> ping 10.39.66.9
Speed: 100, full duplex
Using ethernet@ff290000 device
host 10.39.66.9 is alive
=> tftpboot $kernel_addr_r uImage
Speed: 100, full duplex
Using ethernet@ff290000 device
TFTP from server 10.39.66.9; our IP address is 10.39.66.10
Filename 'uImage'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #######################################
         3.8 MiB/s
done
Bytes transferred = 8184392 (7ce248 hex)
=> tftpboot $fdt_addr_r rk3288-vyasa.dtb
Speed: 100, full duplex
Using ethernet@ff290000 device
TFTP from server 10.39.66.9; our IP address is 10.39.66.10
Filename 'rk3288-vyasa.dtb'.
Load address: 0x1f00000
Loading: ########
         1.8 MiB/s
done
Bytes transferred = 38215 (9547 hex)
=> setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p1 rootwait'
=> bootm ${kernel_addr_r} - ${fdt_addr_r}
## Booting kernel from Legacy Image at 02000000 ...
   Image Name:   Linux-4.14.0-rc4-next-20171013-0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8184328 Bytes = 7.8 MiB
   Load Address: 02000000
   Entry Point:  02000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Kernel Image ... OK
   Loading Device Tree to 0fff3000, end 0ffff546 ... OK

Starting kernel ...

USB HDMI Linux Accessing Peripherals SDMMC

Welcome to VYASA RK3288!
vyasa-rk3288 login: root
# dmesg | grep mmcblk0
[    0.000000] Kernel command line: console=ttyS2,115200n8 root=/dev/mmcblk0p1 rootwait
[    2.472712] Waiting for root device /dev/mmcblk0p1...
[    2.530084] mmcblk0: mmc0:59b4 MS    3.67 GiB
[    2.535640]  mmcblk0: p1
[    2.564302] EXT4-fs (mmcblk0p1): couldn't mount as ext3 due to feature incompatibilities
[    2.574054] EXT4-fs (mmcblk0p1): couldn't mount as ext2 due to feature incompatibilities
[    2.592747] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[    2.857154] EXT4-fs (mmcblk0p1): re-mounted. Opts: data=ordered
# fdisk -l
Disk /dev/mmcblk0: 3763 MB, 3945791488 bytes, 7706624 sectors
22666 cylinders, 85 heads, 4 sectors/track
Units: cylinders of 340 * 512 = 174080 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    1,15,1      66,84,4          17010    1065585    1048576  512M 83 Linux
# mount /dev/mmcblk0p1 /mnt/
# ls /mnt/
bin         lib         media       root        tmp
boot        lib32       mnt         run         usr
dev         linuxrc     opt         sbin        var
etc         lost+found  proc        sys
# umount  /mnt/

eMMC GMAC Wifi/BT USB Vyasa has two host port connectors and below shows the details of accessing devices on these ports

High Speed device

# [  446.332807] usb 3-1.3: new high-speed USB device number 4 using ehci-platform
[  446.493489] usb-storage 3-1.3:1.0: USB Mass Storage device detected
[  446.502271] scsi host0: usb-storage 3-1.3:1.0
[  447.515719] scsi 0:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 4
[  447.528895] sd 0:0:0:0: [sda] 15728640 512-byte logical blocks: (8.05 GB/7.50 GiB)
[  447.538389] sd 0:0:0:0: [sda] Write Protect is off
[  447.544764] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  447.560649]  sda: sda1
[  447.566779] sd 0:0:0:0: [sda] Attached SCSI removable disk
# fdisk -l /dev/sda1
Disk /dev/sda1: 7679 MB, 8052015104 bytes, 15726592 sectors
1022 cylinders, 248 heads, 62 sectors/track
Units: cylinders of 15376 * 512 = 7872512 bytes

Full Speed device - Wireless mouse, testing with left and right click

# [  100.947712] usb 3-1.3: USB disconnect, device number 4
[  109.942893] usb 3-1.3: new full-speed USB device number 5 using ehci-platform
[  110.104052] input: Compx 2.4G Receiver as /devices/platform/ff500000.usb/usb3/3-1/3-1.3/3-1.3:1.0/0003:1D57:FA60.0001/input/input0
[  110.184781] hid-generic 0003:1D57:FA60.0001: input: USB HID v1.00 Keyboard [Compx 2.4G Receiver] on usb-ff500000.usb-1.3/input0
[  110.199732] input: Compx 2.4G Receiver as /devices/platform/ff500000.usb/usb3/3-1/3-1.3/3-1.3:1.1/0003:1D57:FA60.0002/input/input1
[  110.212938] hid-generic 0003:1D57:FA60.0002: input: USB HID v1.00 Mouse [Compx 2.4G Receiver] on usb-ff500000.usb-1.3/input1
[  110.230060] input: Compx 2.4G Receiver as /devices/platform/ff500000.usb/usb3/3-1/3-1.3/3-1.3:1.2/0003:1D57:FA60.0003/input/input2
[  110.312793] hid-generic 0003:1D57:FA60.0003: input: USB HID v1.00 Device [Compx 2.4G Receiver] on usb-ff500000.usb-1.3/input2
# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Compx 2.4G Receiver
/dev/input/event1:      Compx 2.4G Receiver
/dev/input/event2:      Compx 2.4G Receiver
Select the device event number [0-2]: 1
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x1d57 product 0xfa60 version 0x100
Input device name: "Compx 2.4G Receiver"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 272 (BTN_LEFT)
    Event code 273 (BTN_RIGHT)
    Event code 274 (BTN_MIDDLE)
    Event code 275 (BTN_SIDE)
    Event code 276 (BTN_EXTRA)
  Event type 2 (EV_REL)
    Event code 0 (REL_X)
    Event code 1 (REL_Y)
    Event code 6 (REL_HWHEEL)
    Event code 8 (REL_WHEEL)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 153.949644, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 153.949644, type 1 (EV_KEY), code 272 (BTN_LEFT), value 1
Event: time 153.949644, type 2 (EV_REL), code 0 (REL_X), value 1163
Event: time 153.949644, type 2 (EV_REL), code 1 (REL_Y), value -108
Event: time 153.949644, -------------- SYN_REPORT ------------
Event: time 154.145610, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 154.145610, type 1 (EV_KEY), code 272 (BTN_LEFT), value 0
Event: time 154.145610, -------------- SYN_REPORT ------------
Event: time 164.089632, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 164.089632, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1
Event: time 164.089632, -------------- SYN_REPORT ------------
Event: time 164.229603, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 164.229603, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 0
Event: time 164.229603, -------------- SYN_REPORT ------------

Thermal Management RK3288 supports three thermal zones for CPU, GPU and reserved. We can control and read these zone temperature and polices through /proc

# cat /sys/class/thermal/
cooling_device0/  thermal_zone0/    thermal_zone1/    thermal_zone2/
# cat /sys/class/thermal/thermal_zone0/type
reserve_thermal
# cat /sys/class/thermal/thermal_zone0/temp
cat: read error: Invalid argument
# cat /sys/class/thermal/thermal_zone1/type
cpu_thermal
# cat /sys/class/thermal/thermal_zone1/temp
47727
# cat /sys/class/thermal/thermal_zone1/policy
step_wise
# cat /sys/class/thermal/thermal_zone2/type
gpu_thermal
# cat /sys/class/thermal/thermal_zone2/temp
45454
# cat /sys/class/thermal/thermal_zone2/policy
step_wise

VGA HDMI Connect HDMI cable between external monitor with vyasa hdmi port

# modprobe -a rockchipdrm
[   29.856111] rockchip-drm display-subsystem: bound ff930000.vop (ops vop_component_ops [rockchipdrm])
[   29.866742] rockchip-drm display-subsystem: bound ff940000.vop (ops vop_component_ops [rockchipdrm])
[   29.877119] dwhdmi-rockchip ff980000.hdmi: Detected HDMI TX controller v2.00a with HDCP (DWC MHL PHY)
[   29.888348] rockchip-drm display-subsystem: bound ff980000.hdmi (ops dw_hdmi_rockchip_ops [rockchipdrm])
[   29.898973] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[   29.906374] [drm] No driver support for vblank timestamp query.
[   29.950736] Console: switching to colour frame buffer device 128x48
[   30.010803] rockchip-drm display-subsystem: fb0:  frame buffer device
[   30.053757] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0
LVDS
eDP
Mali t760
Mali t760 tested well with Qt5 and OpenGL ES, see steps to verify here

VCODEC
vcodec tested well with Gsteamer, see steps to verify here

Audio
Mainline Efforts
See this page for Mainline status and WIP

Jtag debugging needs a jtag-breakout program to be flashed to eMMC while connecting jtag probe through sd-card pins. This can be done by using a sd-card sniffer(i.e. Sparkfun microSD Sniffer). Follow this repository to make it work: https://github.com/giuliobenetti/rk-jtag-breakout

Lauterbach Trace32 script for debugging Linux

; --------------------------------------------------------------------------------
; @Title: RK3288-Vyasa Linux debugging Rockchip RK3288
; @Description:
;   The example is generated for Rockchip RK3288
; @Keywords: linux, Rockchip, rk3288*, RK3288*
; @Author: Giulio Benetti <giulio.benetti@benettiengineering.com>
; @Board: RK3288-Vyasa*
; @Chip: RK3288*
; --------------------------------------------------------------------------------
; $Id: linux.cmm

LOCAL &uboot_path
LOCAL &linux_path
LOCAL &dtb_path
LOCAL &dtbo_path
LOCAL &ka_path
LOCAL &awareness

&uboot_path="/home/user/git/amarula/debian/u-boot"
&linux_path="/home/user/git/amarula/debian/kernel"
&dtb_path="/home/user/git/amarula/debian/kernel/arch/arm/boot/dts"

; Debugger Reset
WinPAGE.RESet
AREA.RESet
WinPOS 0. 25. 75. 9. 0. 0. W000
AREA.view

PRINT "resetting..."

RESet
SYStem.CPU RK3288

SYSTEM.RESETOUT ; hard reset
SYStem.JTAGCLOCK 20MHz

SYStem.Option DACR ON          ; give Debugger global write permissions
TrOnchip.Set DABORT OFF        ; used by Linux for page miss!
TrOnchip.Set PABORT OFF        ; used by Linux for page miss!
TrOnchip.Set UNDEF OFF         ; my be used by Linux for FPU detection
SYStem.Option MMUSPACES OFF    ; disable space to allow loading and running u-boot
SETUP.IMASKASM ON          ; lock interrupts while single stepping
SETUP.IMASKHLL ON          ; lock interrupts while single stepping

SYStem.Up

;load tpl in sram
data.load.binary &uboot_path/tpl/u-boot-tpl.bin 0xff704000
data.load.elf &uboot_path/tpl/u-boot-tpl /nocode
Register.Init
r.s pc 0xff704000

; start and wait for tpl to pass sdram_init
go.direct back_to_bootrom
WAIT !run()
break

;load spl in sdram
data.load.binary &uboot_path/spl/u-boot-spl-dtb.bin 0x0
data.load.elf &uboot_path/spl/u-boot-spl /nocode
Register.Init
r.s pc 0x00000020

; start and wait for spl to hang
go.direct hang
WAIT !run()

data.load.binary &uboot_path/u-boot-dtb.bin 0x00200000
data.load.elf &uboot_path/u-boot /nocode; uncomment this to debug before relocation
;data.load.elf &uboot_path/u-boot 0x14F70000 /nocode /noreg /noclear
Register.Init
r.s pc 0x00200000

go
wait 3s
break

PRINT "loading Linux image..."
; Loading Linux image and DTB via ICD
Data.LOAD.Binary &linux_path/arch/arm/boot/zImage 0x02008000
; Load the Linux kernel symbols into the debugger
PRINT "loading Linux kernel symbols..."
Data.LOAD.Elf &linux_path/vmlinux /gnu /NoCODE
; Load DTB
PRINT "loading DTB..."
Data.LOAD.Binary &dtb_path/rk3288-vyasa.dtb 0x08300000 /NoClear

; Open serial terminal window on ttyUSB0
DO ~~/demo/etc/terminal/serial/term.cmm /dev/ttyUSB0 115200.

; Starting the kernel
Go
PRINT "Starting Linux..."
; Wait for uboot to be ready to receive characters on serial
;wait 3s
; Stop autoboot of U-Boot
TERM.Out 0x03 ; Ctrl-C
WAIT 0.1s
; Set boot arguments
TERM.Out "setenv bootargs console=ttyS2,115200 earlyprintk root=/dev/mmcblk0p1 rootwait rw panic=10" 0x0a
WAIT 0.1s

TERM.Out "bootz 0x02008000 - 0x08300000" 0x0a
WAIT 0.1s
break

Go.direct start_kernel /Onchip
WAIT !run()

; enable MMU option since u-boot has already setup MMU
SYStem.Option MMUSPACES ON

; Map the virtual kernel symbols to physical addresses
; to give the debugger access to it before CPU MMU is
; initialized
PRINT "initializing debugger MMU..."
SYStem.Option MMUSPACES ON
MMU.FORMAT LINUX swapper_pg_dir 0xc0000000--0xffffffff 0x00000000
TRANSlation.COMMON 0xc0000000--0xffffffff     ; common area for kernel and processes
TRANSlation.TableWalk ON   ; debugger uses a table walk to decode virtual addresses
TRANSlation.ON

; Initialize Linux Awareness
&ka_path="~~/demo/arm/kernel/linux/awareness"
&awareness="linux.t32"

PRINT "initializing RTOS support..."
TASK.CONFIG &ka_path/&awareness      ; loads Linux awareness
MENU.ReProgram &ka_path/linux        ; loads Linux menu
; Group kernel area to be displayed with red bar
GROUP.Create "kernel" 0xc0000000--0xffffffff /RED

List.Hll

break.config.method.program Onchip

enddo

Lauterbach Trace32 script for debugging U-Boot

; --------------------------------------------------------------------------------
; @Title: RK3288-Vyasa U-Boot debugging Rockchip RK3288
; @Description:
;   The example is generated for Rockchip RK3288
; @Keywords: uboot, Rockchip, rk3288*, RK3288*
; @Author: Giulio Benetti <giulio.benetti@benettiengineering.com>
; @Board: RK3288-Vyasa*
; @Chip: RK3288*
; --------------------------------------------------------------------------------
; $Id: uboot.cmm

LOCAL &uboot_path

&uboot_path="/home/user/git/amarula/debian/u-boot"

; Debugger Reset
WinPAGE.RESet
AREA.RESet
WinPOS 0. 25. 75. 9. 0. 0. W000
AREA.view

PRINT "resetting..."

RESet
SYStem.CPU RK3288

SYSTEM.RESETOUT ; hard reset
SYStem.JTAGCLOCK 20MHz

SYStem.Up

SETUP.IMASKASM ON          ; lock interrupts while single stepping

;load tpl in sram
data.load.binary &uboot_path/tpl/u-boot-tpl.bin 0xff704000
data.load.elf &uboot_path/tpl/u-boot-tpl /nocode
Register.Init
r.s pc 0xff704000

; start and wait for tpl to pass sdram_init
go.direct back_to_bootrom
WAIT !run()
break

;load spl in sdram
data.load.binary &uboot_path/spl/u-boot-spl-dtb.bin 0x0
data.load.elf &uboot_path/spl/u-boot-spl /nocode
Register.Init
r.s pc 0x00000020

; start and wait for spl to hang
go.direct hang
WAIT !run()

data.load.binary &uboot_path/u-boot-dtb.bin 0x00200000
data.load.elf &uboot_path/u-boot /nocode; uncomment this to debug before relocation
;data.load.elf &uboot_path/u-boot 0x14F70000 /nocode /noreg /noclear
Register.Init
r.s pc 0x00200000

go.direct board_init_f
WAIT !run()

list.auto

enddo

RK3399

NanoPC T4

This tutorial will show the details of NanoPC T4 board mainline support.

Hardware details and wiki NanoPC T4

Hardware Access

_images/npc-t4.jpg

BSP Build

ATF

$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
$ cd /path/to/arm-trusted-firmware
$ make realclean
$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
$ cp /path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf /path/to/u-boot

U-Boot

$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b rockdev origin/rockdev
$ make nanopc-t4-rk3399_defconfig
$ make
$ make u-boot.itb

Linux

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4

Buildroot

SD Boot

Create Single partition and Insert the SD on host

$ cd /path/to/u-boot
$ ./tools/mkimage  -n rk3399 -T rksd -d ./spl/u-boot-spl-dtb.bn out
$ sudo dd if=out of=/dev/sdc seek=64
$ sudo dd if=u-boot.itb of=/dev/sdc seek=16384
$ sync

Put this SD (or micro-SD) card into your board and reset it. You should see something like:

U-Boot SPL board init
Trying to boot from MMC1


U-Boot 2019.04-rc4 (Apr 25 2019 - 16:58:42 +0530)

Model: FriendlyElec NanoPC-T4
DRAM:  3.9 GiB
MMC:   dwmmc@fe310000: 2, dwmmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff1a0000
Out:   serial@ff1a0000
Err:   serial@ff1a0000
Model: FriendlyElec NanoPC-T4
Net:
Error: ethernet@fe300000 address not set.
eth-1: ethernet@fe300000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
151 bytes read in 3 ms (48.8 KiB/s)
1:      NanoPc T4
Retrieving file: /boot/Image
21027328 bytes read in 948 ms (21.2 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p1 rootwait
Retrieving file: /boot/rk3399-nanopc-t4.dtb
57825 bytes read in 5 ms (11 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 00000000f5f17000, end 00000000f5f281e0 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.1.0-rc1-dirty (jagan@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #13 SMP PREEMPT Tue Apr 30 1
6:43:34 IST 2019
[    0.000000] Machine model: FriendlyElec NanoPC-T4
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x00000000f6000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xf57db840-0xf57dcfff]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.1
[    0.000000] random: get_random_bytes called from start_kernel+0xac/0x46c with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @(____ptrval____) s56984 r8192 d29032 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] Speculative Store Bypass Disable mitigation not required
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 999432
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p1 rootwait
NanoPI NEO4

This tutorial will show the details of NanoPI NEO4 board mainline support.

Hardware details and wiki NanoPI NEO4

Hardware Access
_images/neo4.jpg
BSP Build
Manual Build
ATF
::
$ git clone https://github.com/ARM-software/arm-trusted-firmware.git $ cd /path/to/arm-trusted-firmware $ make realclean $ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31 $ cp /path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf /path/to/u-boot
U-Boot
::
$ git clone https://github.com/amarula/u-boot-amarula $ cd u-boot-amarula $ git checkout -b rockdev origin/rockdev $ make nanopi-neo4-rk3399_defconfig $ make $ make u-boot.itb
Rockchip miniloader
$ git clone https://github.com/rockchip-linux/rkbin.git
$ cd /path/to/rkbin
$ ./tools/trust_merger RKTRUST/RK3399TRUST.ini
$ ./tools/loaderimage --pack --uboot /path/to/u-boot/u-boot-dtb.bin uboot.img
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4
Buildroot
SD Boot

Create Single partition and Insert the SD on host

$ cd /path/to/u-boot
$ ./tools/mkimage  -n rk3399 -T rksd -d /path/to/rkbin/bin/rk33/rk3399_ddr_800MHz_v1.20.bin idbloader.img
$ cat /path/to/rkbin/bin/rk33/rk3399_miniloader_v1.19.bin >> idbloader.img

$ sudo dd if=idbloader.img of=/dev/sdc seek=64
$ sudo dd if=trust.img of=/dev/sdc seek=24576
$ sudo dd if=uboot.img of=/dev/sdc seek=16384
$ sync

Put this SD (or micro-SD) card into your board and reset it. You should see something like:

DDR Version 1.20 20190314
In
Channel 0: DDR3, 933MHz
Bus Width=32 Col=10 Bank=8 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
no stride
ch 0 ddrconfig = 0x101, ddrsize = 0x20
pmugrf_os_reg[2] = 0x10006281, stride = 0x17
OUT
Boot1: 2019-03-14, version: 1.19
CPUId = 0x0
ChipType = 0x10, 239
mmc: ERROR: SDHCI ERR:cmd:0x102,stat:0x18000
mmc: ERROR: Card did not respond to voltage select!
emmc reinit
mmc: ERROR: SDHCI ERR:cmd:0x102,stat:0x18000
mmc: ERROR: Card did not respond to voltage select!
emmc reinit
mmc: ERROR: SDHCI ERR:cmd:0x102,stat:0x18000
mmc: ERROR: Card did not respond to voltage select!
SdmmcInit=2 1
mmc0:cmd5,20
SdmmcInit=0 0
BootCapSize=0
UserCapSize=60543MB
FwPartOffset=2000 , 0
StorageInit ok = 45266
SecureMode = 0
SecureInit read PBA: 0x4
SecureInit read PBA: 0x404
SecureInit read PBA: 0x804
SecureInit read PBA: 0xc04
SecureInit read PBA: 0x1004
SecureInit read PBA: 0x1404
SecureInit read PBA: 0x1804
SecureInit read PBA: 0x1c04
SecureInit ret = 0, SecureMode = 0
atags_set_bootdev: ret:(0)
GPT 0x3380ec0 signature is wrong
recovery gpt...
GPT 0x3380ec0 signature is wrong
recovery gpt fail!
LoadTrust Addr:0x4000
No find bl30.bin
Load uboot, ReadLba = 2000
hdr 0000000003380880 + 0x0:0x88,0x41,0x3e,0x97,0xe6,0x61,0x54,0x23,0xe9,0x5a,0xd1,0x2b,0xdc,0x2f,0xf9,0x35,

Load OK, addr=0x200000, size=0x9c9c0
RunBL31 0x10000
NOTICE:  BL31: v1.3(debug):370ab80
NOTICE:  BL31: Built : 09:23:41, Mar  4 2019
NOTICE:  BL31: Rockchip release version: v1.1
INFO:    GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 0
INFO:    plat_rockchip_pmu_init(1181): pd status 3e
INFO:    BL31: Initializing runtime services
INFO:    BL31: Initializing BL32
INF [0x0] TEE-CORE:init_primary_helper:337: Initializing (1.1.0-195-g8f090d20 #6 Fri Dec  7 06:11:20 UTC 2018 aarch64)

INF [0x0] TEE-CORE:init_primary_helper:338: Release version: 1.2

INF [0x0] TEE-CORE:init_teecore:83: teecore inits done
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2019.04-rc4-00136-gfd121f9641-dirty (Apr 16 2019 - 14:02:47 +0530)

Model: FriendlyARM NanoPi NEO4
DRAM:  1022 MiB
MMC:   dwmmc@fe310000: 2, dwmmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff1a0000
Out:   serial@ff1a0000
Err:   serial@ff1a0000
Model: FriendlyARM NanoPi NEO4
Net:   eth0: ethernet@fe300000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
160 bytes read in 5 ms (31.3 KiB/s)
1:      linux-4.17.0-rc3
Retrieving file: /boot/Image
20361728 bytes read in 1308 ms (14.8 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk0p1 rootwait
Retrieving file: /boot/rk3399-nanopi-neo4.dtb
54786 bytes read in 11 ms (4.7 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000003df1c000, end 000000003df2c601 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.1.0-rc1 (jagan@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #1 SMP PREEMPT Mon Apr 15 22:40:42
 IST 2019
[    0.000000] Machine model: FriendlyARM NanoPi NEO4
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x000000003e000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x000000003fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x3dda2840-0x3dda3fff]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000000200000-0x000000003fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x000000003fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x000000003fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.0 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] random: get_random_bytes called from start_kernel+0xac/0x46c with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @(____ptrval____) s56664 r8192 d29352 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 257544
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk0p1 rootwait
NanoPI M4
About this

This tutorial will show the details of NanoPI M4 board mainline support.

Hardware Access
_images/nanopi_m4.jpg
BSP building

ATF

git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
cd /path/to/trusted-firmware-a
make distcleanclean
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf

U-Boot

git clone https://github.com/amarula/u-boot-amarula
cd u-boot-amarula
git checkout -b rockchip origin/rockchip
make nanopi-m4-rk3399_defconfig
make

Linux

git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=arm64 make defconfig
ARCH=arm64 make Image dtbs -j 16
Booting from

SD:

cd /path/to/u-boot
sudo dd if=u-boot-rockchip.bin of=/dev/mmcblk0 seek=64
sync

Put this SD (or micro-SD) card into your board and reset it. You should see something like on minicom(1500000 8N1):

Boot log
U-Boot TPL 2020.01-00648-gd87aa5008a-dirty (Jan 23 2020 - 17:22:13)
Channel 0: LPDDR3, 933MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR3, 933MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
256B stride
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.01-00648-gd87aa5008a-dirty (Jan 23 2020 - 17:22:13 +0530)
Trying to boot from MMC1


U-Boot 2020.01-00648-gd87aa5008a-dirty (Jan 23 2020 - 17:22:13 +0530)

SoC: Rockchip rk3399
Reset cause: RST
Model: FriendlyElec NanoPC-T4
DRAM:  3.9 GiB
PMIC:  RK808
MMC:   dwmmc@fe310000: 2, dwmmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial
Out:   vidconsole
Err:   vidconsole
Model: FriendlyElec NanoPC-T4
rockchip_dnl_key_pressed: adc_channel_single_shot fail!
Net:
Error: ethernet@fe300000 address not set.
No ethernet found.

Hit any key to stop autoboot:  0
Invalid bus 0 (err=-19)
Failed to initialize SPI flash at 0:0 (error -19)
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
158 bytes read in 6 ms (25.4 KiB/s)
1:      linux-4.17.0-rc3
Retrieving file: /boot/Image
27736576 bytes read in 1185 ms (22.3 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk0p1 rootwait rw
Retrieving file: /boot/rk3399-nanopc-t4.dtb
55886 bytes read in 8 ms (6.7 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 00000000f4f19000, end 00000000f4f29a4d ... OK

Starting kernel ...
Orangepi RK3399

This tutorial will show the details of OrangePI RK3399 board mainline support.

Hardware details and wiki OrangePI RK3399

Hardware Access
_images/opi_rk3399.jpg
BSP Build
Manual Build
ATF
::
$ git clone https://github.com/ARM-software/arm-trusted-firmware.git $ cd /path/to/arm-trusted-firmware $ make realclean $ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31 $ cp /path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf /path/to/u-boot
U-Boot
::
$ git clone https://github.com/amarula/u-boot-amarula $ cd u-boot-amarula $ git checkout -b rockdev origin/rockdev $ make orangepi-rk3399_defconfig $ make $ make u-boot.itb
Linux
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4
Buildroot
::
$ git clone https://github.com/amarula/buildroot-amarula $ cd buildroot-amarula $ git checkout -b rockdev origin/rockdev $ make orangepi_rk3399_defconfig
SD Boot

Create Single partition and Insert the SD on host or use sdcard.img from buildroot.

$ cd /path/to/u-boot
$ ./tools/mkimage  -n rk3399 -T rksd -d spl/u-boot-spl-dtb.bin out
$ sudo dd if=out of=/dev/sdc seek=64
$ sudo dd if=u-boot.itb of=/dev/sdc seek=16384
$ sync

If board is always boot from eMMC, refer to RK3399 SD Boot Setup

Put this SD (or micro-SD) card into your board and reset it. You should see something like:

U-Boot SPL board init
Trying to boot from MMC1

U-Boot 2019.04-rc4 (Apr 22 2019 - 13:38:40 +0530)

Model: Orange Pi RK3399 Board
DRAM:  2 GiB
MMC:   dwmmc@fe310000: 2, dwmmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff1a0000
Out:   serial@ff1a0000
Err:   serial@ff1a0000
Model: Orange Pi RK3399 Board
Net:   eth0: ethernet@fe300000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
157 bytes read in 2 ms (76.2 KiB/s)
1:      OrangePi RK3399
Retrieving file: /boot/Image
20886016 bytes read in 943 ms (21.1 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p1 rootwait
Retrieving file: /boot/rk3399-orangepi.dtb
55460 bytes read in 5 ms (10.6 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000007df18000, end 000000007df288a3 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.1.0-rc1 (shyam@debian) (gcc version 7.4.0 (Buildroot 2019.05-git-00362-gcd58f3609b-dirty)) #2 SMP PREEMPT Mon Apr 22 13:39
:32 IST 2019
[    0.000000] Machine model: Orange Pi RK3399 Board
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x000000007e000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x000000007fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x7dba0840-0x7dba1fff]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000000200000-0x000000007fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x000000007fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x000000007fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.1
[    0.000000] random: get_random_bytes called from start_kernel+0xa8/0x46c with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @(____ptrval____) s56664 r8192 d29352 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] Speculative Store Bypass Disable mitigation not required
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 515592
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p1 rootwait
Rockpro64

This tutorial will show the details of NanoPC T4 board mainline support.

Hardware details and wiki NanoPC T4

Hardware Access

_images/rockpro64.jpg

BSP Build

ATF

$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
$ cd /path/to/arm-trusted-firmware
$ make realclean
$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
$ cp /path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf /path/to/u-boot

U-Boot

$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b rockdev origin/rockdev
$ make rockpro64-rk3399_defconfig
$ make
$ make u-boot.itb

Linux

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4

Buildroot

SD Boot

Create Single partition and Insert the SD on host

$ cd /path/to/u-boot
$ ./tools/mkimage -n rk3399 -T rksd -d ./tpl/u-boot-tpl-dtb.bin out
$ cat ./spl/u-boot-spl-dtb.bin >> out;
$ sudo dd if=out of=/dev/sda seek=64;
$ sudo dd if=u-boot.itb  of=/dev/sda seek=16384
$ sync

Put this SD (or micro-SD) card into your board and reset it. You should see something like:

U-Boot 2019.04-rc4 (Apr 25 2019 - 16:58:42 +0530)

Model: Pine64 RockPro64
DRAM:  3.9 GiB
MMC:   dwmmc@fe310000: 2, dwmmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff1a0000
Out:   serial@ff1a0000
Err:   serial@ff1a0000
Model: Pine64 RockPro64
Net:
Error: ethernet@fe300000 address not set.
eth-1: ethernet@fe300000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
151 bytes read in 3 ms (48.8 KiB/s)
1:      NanoPc T4
Retrieving file: /boot/Image
21027328 bytes read in 948 ms (21.2 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p1 rootwait
Retrieving file: /boot/rk3399-rockpro64.dtb
57825 bytes read in 5 ms (11 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 00000000f5f17000, end 00000000f5f281e0 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.1.0-rc1-dirty (jagan@jagan-XPS-13-9350) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #13 SMP PREEMPT Tue Apr 30 1
6:43:34 IST 2019
[    0.000000] Machine model: Pine64 RockPro64
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x00000000f6000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xf57db840-0xf57dcfff]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.1
[    0.000000] random: get_random_bytes called from start_kernel+0xac/0x46c with crng_init=0
[    0.000000] percpu: Embedded 23 pages/cpu @(____ptrval____) s56984 r8192 d29032 u94208
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] Speculative Store Bypass Disable mitigation not required
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 999432
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p1 rootwait
ROC-RK3399-PC
About this

This tutorial will show the details of ROC-RK3399-PC board mainline support.

Hardware Access
_images/roc-rk3399-pc.jpg
BSP Building

Host require few tools to build BSP, those are host and rockchip

ATF

$ git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
$ cd /path/to/trusted-firmware-a
$ make distcleanclean
$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31

U-Boot

$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b rockchip origin/rockchip
$ export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf
$ make roc-pc-rk3399_defconfig #sd
(or)
$ make roc-pc-rk3399-spi_defconfig #spi
$ make

Linux

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4
Booting from

SPI Flash:

load mmc 1:1 $kernel_addr_r idbloader.img
sf probe
sf erase 0 +$filesize
sf write $kernel_addr_r 0 ${filesize}
load mmc 1:1 ${kernel_addr_r} u-boot.itb
sf erase 0x40000 +$filesize
sf write $kernel_addr_r 0x40000 ${filesize}

SD:

cd u-boot-amarula
sudo dd if=u-boot-rockchip.bin of=/dev/mmcblk0 seek=64
sudo sync

eMMC:

connect USB-OTG cable.

(target side)
# mmc dev 0
# gpt write mmc 0 $partitions
# fastboot 0

(host side)
cd u-boot-amarula
sudo fastboot -i 0x2207 flash loader1 idbloader.img
sudo fastboot -i 0x2207 flash loader2 u-boot.itb
Distroot

There are several ways to build and flash the distributions to external storage devices like SD, eMMC, USB, SATA.

Since the ROC-RK3399-PC has in built SPI Flash, we use this flash to boot with initramfs and program the distributions on supported external storage devices on board using distroot.

All images are available at:

git clone https://github.com/amarula/bsp-rockchip

Prerequisites:

Power off the board.
Remove any bootable storage media like SD, eMMC module.
(Or plug it and make sure it doesn't have bootable images)
Plug the USB Type-C cable to Type-C 1 port on ROC-RK3399-PC.
Plug the Debug port with board
Open minicom with 1500000 8N1
Power on the board.

Mask ROM mode:

lsusb command on host pc should show
Bus 001 Device 020: ID 2207:330c Fuzhou Rockchip Electronics Company RK3399 in Mask ROM mode

If mask rom mode doesn’t appear, then:

Check Prerequisites steps or
Close SPI CLK and GND pins of J16.

Program SPI Flash:

cd bsp-rockchip
unxz roc-rk3399-pc-spinor.img.xz
sha256sum roc-rk3399-pc-spinor.img
(check the sha256 values with roc-rk3399-pc-spinor.img.xz.sha256sum)

rkdeveloptool ld
rkdeveloptool db rk3399_loader_spinor_v1.15.114.bin
rkdeveloptool wl 0 roc-rk3399-pc-spinor.img
rkdeveloptool rd

Program SD card/eMMC/USB/SSD:

Once SPI booted with initramfs, then install the distroot on selected
flash device.

login with root
# wget --no-check-certificate \
  > https://raw.githubusercontent.com/amarula/bsp-rockchip/master/distroot.sh
# sh ./distroot.sh

[distroot] try to program the flash...

1 SD card
2 eMMC
3 USB disk

Choose the flash [1-3]: 2

Power off or reboot, the board will pickup the distro based
on u-boot distboot order.
Buildroot

Assume the disk connected via /dev/mmcblk0 in host:

cd bsp-rockchip
unxz roc-rk3399-pc-sdcard.img.xz
sha256sum roc-rk3399-pc-sdcard.img
(check the sha256 values with roc-rk3399-pc-sdcard.img.xz.sha256sum)
sudo dd if=roc-rk3399-pc-sdcard.img of=/dev/mmcblk0
sudo sync
ROCKPI-4

This is the tutorial for the Radxa ROCK-PI-4 target.

Hardware details and wiki ROCKPI-4C

If incase the board is not displayed on there website, here are the quick specs:

Single HDMI 2.0 port is replaced with a micro HDMI port and a mini DisplayPort, meaning two external displays can be connected. 4GB RAM and a WiFi/Bluetooth module. Rest of the specs are same as its predecessor ROCKPI-4B.

Radxa ROCK-PI-4 series has three board models: Model A Model B Model C

Hardware Access
_images/rockpi_4.jpg
BSP Building

Host require few tools/packages to build BSP, install them from host

ATF

$ git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
$ cd /path/to/trusted-firmware-a
$ make distclean
$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31

U-Boot

$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b rock-pi origin/rock-pi
$ export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf
$ make rock-pi-4-rk3399_defconfig
$ make

Linux

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4

Buildroot

$ git clone git://git.buildroot.net/buildroot
$ cd buildroot
$ make rockpi_4_defconfig
$ make

SD Boot

In the output/images directory, flash sdcard.img on to micro sd

$ sudo dd if=output/images/sdcard.img of=/dev/sdX status=progress (X - find it from fdisk -l)
$ sync

Put this micro-SD card onto your board in the slot and power the board. You should see something like:

U-Boot TPL 2020.07-rc4 (Jun 16 2020 - 22:29:04)
Channel 0: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
256B stride
lpddr4_set_rate: change freq to 400000000 mhz 0, 1
lpddr4_set_rate: change freq to 800000000 mhz 1, 0
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.07-rc4 (Jun 16 2020 - 22:29:04 +0530)
Trying to boot from MMC1


U-Boot 2020.07-rc4 (Jun 16 2020 - 22:29:04 +0530)

SoC: Rockchip rk3399
Reset cause: POR
Model: Radxa ROCK Pi 4
DRAM:  3.9 GiB
PMIC:  RK808
MMC:   mmc@fe310000: 2, mmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment

In:    serial
Out:   serial
Err:   serial
Model: Radxa ROCK Pi 4
Net:   eth0: ethernet@fe300000
Hit any key to stop autoboot:  0
Card did not respond to voltage select!
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:3...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
156 bytes read in 5 ms (30.3 KiB/s)
1:      RK3399_ROCKPI4 linux
Retrieving file: /Image
26288640 bytes read in 1122 ms (22.3 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p4 rw rootwait
Retrieving file: /rk3399-rock-pi-4.dtb
54196 bytes read in 7 ms (7.4 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 00000000f2503000, end 00000000f25133b3 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.10.0-rc5 (suniel@suniel-P5WE0) (gcc version 8.4.0 (Buildroot 2020.08-git-00273-g8f70124)) #1 SMP PREEMPT Tue Oct 10 22:32:16 IST 2020
[    0.000000] Machine model: Radxa ROCK Pi 4
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x00000000f6000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xf57ef800-0xf57f0fff]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] percpu: Embedded 22 pages/cpu s52952 r8192 d28968 u90112
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 999432
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p4 rw rootwait
[    0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    1.182515] Segment Routing with IPv6
OK

Welcome to ROCKPI4..!!
rockpi4 login:

use root for login.

DisplayPort

Since DisplayPort is still in Mainling list. Please use below patch to support dual display support on ROCK-Pi 4C.

ROCK-Pi 4C DisplayPort patch Virtual PD

RK3399pro

ROCKPI-N10

This tutorial will show the details of Radxa ROCKPI-N10 board with VMARC RK3399pro SOM mainline support.

Hardware details and wiki ROCKPI-N10

Hardware Access
_images/rk3399pro-rock-pi-n10.jpg
BSP Building

Host require few tools/packages to build BSP, install them from host

ATF

$ git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
$ cd /path/to/trusted-firmware-a
$ make distclean
$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31

U-Boot

$ git clone https://github.com/amarula/u-boot-amarula
$ cd u-boot-amarula
$ git checkout -b rock-pi origin/rock-pi
$ export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf
$ make rock-pi-n10-rk3399pro_defconfig
$ make

Linux

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ cd linux-next
$ make mrproper
$ ARCH=arm64 make defconfig
$ ARCH=arm64 make Image dtbs -j 4

Buildroot

$ git clone git://git.buildroot.net/buildroot
$ cd buildroot
$ make rockpi_n10_defconfig
$ make

SD Boot

In the output/images directory, flash sdcard.img on to micro sd

$ sudo dd if=output/images/sdcard.img of=/dev/sdX status=progress (X - find it from fdisk -l)
$ sync

Put this micro-SD card onto your board in the slot and power the board. You should see something like:

U-Boot TPL 2020.07-rc4 (Jun 16 2020 - 19:29:04)
Channel 0: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
256B stride
lpddr4_set_rate: change freq to 400000000 mhz 0, 1
lpddr4_set_rate: change freq to 800000000 mhz 1, 0
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.07-rc4 (Jun 16 2020 - 19:29:04 +0530)
Trying to boot from MMC1


U-Boot 2020.07-rc4 (Jun 16 2020 - 19:29:04 +0530)

SoC: Rockchip rk3399
Reset cause: POR
Model: Radxa ROCK Pi N10
DRAM:  3.9 GiB
PMIC:  RK808
MMC:   mmc@fe310000: 2, mmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment

In:    serial
Out:   serial
Err:   serial
Model: Radxa ROCK Pi N10
Net:   eth0: ethernet@fe300000
Hit any key to stop autoboot:  0
Card did not respond to voltage select!
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:3...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
156 bytes read in 5 ms (30.3 KiB/s)
1:      RK3399_ROCKPI_N10 linux
Retrieving file: /Image
26288640 bytes read in 1122 ms (22.3 MiB/s)
append: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p4 rw rootwait
Retrieving file: /rk3399pro-rock-pi-n10.dtb
54196 bytes read in 7 ms (7.4 MiB/s)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 00000000f2503000, end 00000000f25133b3 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.7.2 (suniel@suniel-P5WE0) (gcc version 8.4.0 (Buildroot 2020.08-git-00273-g8f70124)) #1 SMP PREEMPT Tue Jun 16 19:32:16 IST 2020
[    0.000000] Machine model: Radxa ROCK Pi N10
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 32 MiB at 0x00000000f6000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] NUMA: NODE_DATA [mem 0xf57ef800-0xf57f0fff]
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] percpu: Embedded 22 pages/cpu s52952 r8192 d28968 u90112
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: ARM erratum 845719
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 999432
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 root=/dev/mmcblk1p4 rw rootwait
[    0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 3921744K/4061184K available (12220K kernel code, 1864K rwdata, 6448K rodata, 5056K init, 450K bss, 106672K reserved, 32768K cma-reserved)

use root for login.

RISC-V

QEMU RISC-V

Testing RISC V under qemu
Build and Install

Building the full system emulator and the user mode emulator on Linux:

git clone --recursive https://github.com/riscv/riscv-qemu.git
cd riscv-qemu
./configure \
    --target-list=riscv64-softmmu,riscv32-softmmu,riscv64-linux-user,riscv32-linux-user
make -j$(nproc)
# last operation require root right, so possible that you need sudo make install
make install

# it will be installed under /usr/local/bin so you need to add your path if it's in the default one

Use a working buildroot environment

Download buildroot project for risc-v
git clone https://github.com/riscv/riscv-buildroot.git
git checkout origin/riscv-start
Build buildroot enviroment
cd riscv-buildroot
make qemu_riscv64_virt_defconfig
make

This configuration let you work on version downloaded in the configuration

Use mainline kernel
# create local.mk file inside your buildroot directory

echo "LINUX_OVERRIDE_SRCDIR=linux-mainline" > local.mk

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-mainline

# checkout the mainline commit id or tag you need for example
cd linux-mainline
git checkout v4.20-rc7 -b devel-riscv

# if you system is already build
make linux-dirclean
make

# otherwise follow the instruction on previous section
make qemu_riscv64_virt_defconfig
make


# configure the kernel
make linux-menuconfig
Run your built image

Your output image are in output/images. In order to execute just run:

qemu-system-riscv64 -M virt -kernel output/images/bbl -append "root=/dev/vda ro console=ttyS0" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic

SiFive

HiFive Unleashed A00

This tutorial will show the details of SiFive HiFive Unleashed A00 board mainline support.

More information about SoC manual and schematics are at FU540 C000 and Schematics

Hardware Access
_images/hifive-unleashed.jpg
Prebuilt

Prebuilt images for Booting from MMC, SPI with Mainline Linux are available in below link. The necessary steps available at REAME file.

git clone https://github.com/amarula/bsp-sifive
cd bsp-sifive
Building
OpenSBI
git clone https://github.com/riscv/opensbi
cd opensbi
CROSS_COMPILE=/path/to/riscv64-linux-gnu- make PLATFORM=sifive/fu540 FW_DYNAMIC=y
U-Boot
git clone https://github.com/amarula/u-boot-amarula
cd u-boot-amarula
make sifive_fu540_defconfig
make
Linux
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
cd linux-next
make mrproper
ARCH=riscv make defconfig
ARCH=arm64 make Image dtbs
Buildroot
git clone https://github.com/amarula/buildroot-amarula
cd buildroot-amarula
make hifive_unleashed_defconfig
Booting
  1. Parttion table SiFive ZSBL (BROM) would look for partition GUID for next boot stages like
5B193300-FC78-40CD-8002-E86C45580B47 - FSBL
2E54B353-1271-4842-806F-E436D6AF6985 - Bootloader

So, use buildroot sdcard.img and write into SD card since it has default
partition table.
  1. Bootmodes Bootmodes are configured in SiFive Unleased via MSEL3-MSEL0.
MSEL = 1111, default bootmode. load FSBL from QSPI
MSEL = 1011, load FSB from SD card

Make sure the MSEL will be in default.
  1. Serial ports

    Board as USB port which used USB-to-Serial, host will trigger

/dev/ttyUSB1 - for debug
/dev/ttyUSB0 - for JTAG
OpenSBI with Linux as payload

Take the empty unpartitioned SD card

Build the Buildroot like

git clone https://github.com/amarula/buildroot-amarula
cd buildroot-amarula
make hifive_unleashed_defconfig
sudo dd if=output/images/sdcard.img of=/dev/mmcblk0

Set MSEL[3:0] to 1111, default bootmode. load FSBL from QSPI

Turn On the board and open minicom with /dev/ttyUSB1 with 115200 baudrate.

SiFive FSBL:       2018-03-20
HiFive-U serial #: 000001e0

OpenSBI v0.4 (Sep 18 2019 22:56:42)
     ____                    _____ ____ _____
    / __ \                  / ____|  _ \_   _|
   | |  | |_ __   ___ _ __ | (___ | |_) || |
   | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
   | |__| | |_) |  __/ | | |____) | |_) || |_
    \____/| .__/ \___|_| |_|_____/|____/_____|
          | |
          |_|

Platform Name          : SiFive Freedom U540
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs     : 5
Current Hart           : 2
Firmware Base          : 0x80000000
Firmware Size          : 92 KB
Runtime SBI Version    : 0.1

PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0x0000007fffffffff (A,R,W,X)
[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Linux version 5.1.0 (jagan@jagan-XPS-13-9350) (gcc version 8.3.0 (Buildroot 2019.11-git-00334-g2b5e835dcd)) #1 SMP Wed Sep 18 22:51:28 IST 9
[    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
OpenSBI with U-Boot as payload

Use same SD card partition as of above method.

Attach u-boot payload from U-Boot <https://wiki.amarulasolutions.com/bsp/riscv/hifive-unleashed.html#u-boot>_

cd /path/to/opensbi
make distclean
make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=/path/to/u-boot/u-boot-dtb.bin
sudo dd if=./build/platform/sifive/fu540/firmware/fw_payload.bin of=/dev/mmcblk0p1 bs=1024

Set MSEL[3:0] to 1111, default bootmode. load FSBL from QSPI

Turn On the board and open minicom with /dev/ttyUSB1 with 115200 baudrate.

SiFive FSBL:       2018-03-20
HiFive-U serial #: 000001e0

OpenSBI v0.4 (Sep 18 2019 22:56:42)
     ____                    _____ ____ _____
    / __ \                  / ____|  _ \_   _|
   | |  | |_ __   ___ _ __ | (___ | |_) || |
   | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
   | |__| | |_) |  __/ | | |____) | |_) || |_
    \____/| .__/ \___|_| |_|_____/|____/_____|
          | |
          |_|

Platform Name          : SiFive Freedom U540
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs     : 5
Current Hart           : 2
Firmware Base          : 0x80000000
Firmware Size          : 92 KB
Runtime SBI Version    : 0.1

PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0x0000007fffffffff (A,R,W,X)


U-Boot 2020.01-rc1-00217-g10aa74cb53-dirty (Nov 09 2019 - 17:12:46 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
MMC:   spi@10050000:mmc@0: 0
In:    serial@10010000
Out:   serial@10010000
Err:   serial@10010000
Net:   eth0: ethernet@10090000
Hit any key to stop autoboot:  0
=>
OpenSBI FW_DYNAMIC
  1. Booting from MMC

1.1) Take the empty unpartitioned SD card

1.2) Build the buildroot

git clone https://github.com/amarula/buildroot-amarula
cd buildroot-amarula
git checkout -b sifive origin/sifive
make hifive_unleashed_defconfig
make

1.3) Program the SD card

cd /path/to/buildroot
sudo dd if=output/images/sdcard.img of=/dev/mmcblk0
sudo sync

1.4) Set MSEL jumper to MSEL[3:0] to 1011 like

_images/hifive-unleashed-sdboot.jpg

1.5) Turn On the board and open minicom with /dev/ttyUSB1 with 115200 baudrate.

U-Boot SPL 2020.04-rc4 (Apr 08 2020 - 23:26:19 +0530)
Trying to boot from MMC1


U-Boot 2020.04-rc4 (Apr 08 2020 - 23:26:19 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
MMC:   spi@10050000:mmc@0: 0
In:    serial@10010000
Out:   serial@10010000
Err:   serial@10010000
Net:   eth0: ethernet@10090000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:3...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
151 bytes read in 3 ms (48.8 KiB/s)
1:      HiFive-Unleashed linux
Retrieving file: /boot/Image
9734224 bytes read in 4735 ms (2 MiB/s)
append: console=ttySIF0 root=/dev/mmcblk0p3 rootwait rw
Retrieving file: /boot/hifive-unleashed-a00.dtb
6987 bytes read in 7 ms (974.6 KiB/s)
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Using Device Tree in place at 0000000088000000, end 0000000088004b4a

Starting kernel ...

[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Linux version 5.6.0 (jagan@jagan-XPS-13-9350) (gcc version 8.4.0 (Buildroot 2020.05-git-00624-g689b9c1a7c-dirty)) #1 SMP Wed Apr 8
22:35:27 IST 2020
[    0.000000] initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000000027fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000027fffffff]
[    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
[    0.000000] CPU with hartid=0 is not available
[    0.000000] CPU with hartid=0 is not available
[    0.000000] elf_hwcap is 0x112d
[    0.000000] percpu: Embedded 17 pages/cpu s31848 r8192 d29592 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
[    0.000000] Kernel command line: console=ttySIF0 root=/dev/mmcblk0p3 rootwait rw
  1. Booting from SPI

2.1) Boot the board from MMC as described in section 1)

2.2) On Linux, create GPT over SPI flash

# sgdisk --clear \
> --set-alignment=2 \
> --new=1:40:2087 --change-name=1:loader1 --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \
> --new=2:2088:10279 --change-name=2:loader2 --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
> --new=3:10536:65494 --change-name=3:rootfs --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \
> /dev/mtdblock0

2.3) Power off and power on the board and stop at U-Boot prompt

2.4) Build the SPI defconfig

git clone https://github.com/amarula/buildroot-amarula
cd buildroot-amarula
git checkout -b sifive origin/sifive
make hifive_unleashed_spi_defconfig O=../spi
cd ../spi
make

2.5) Setup tftp and copy spi images at /tftpboot area

cp ./images/spi/* /tftpboot

2.6) Program the SPI flash

# tftpboot $fdt_add_r upgrade_sf.scr
# source $fdt_add_r

2.7) Power off the board

2.8) Set MSEL jumper to MSEL[3:0] to 0110 like

_images/hifive-unleashed-spiboot.jpg

2.9) Turn On the board and open minicom with /dev/ttyUSB1 with 115200 baudrate.

# sgdisk --clear \
> --set-alignment=2 \
> --new=1:40:2087 --change-name=1:loader1 --typecode=1:5B193300-FC78-40CD-8002-E
86C45580B47 \
> --new=2:2088:10279 --change-name=2:loader2 --typecode=2:2E54B353-1271-4842-806
F-E436D6AF6985 \
> --new=3:10536:65494 --change-name=3:rootfs --typecode=3:0FC63DAF-8483-4772-8E7
9-3D69D8477DE4 \
> /dev/mtdblock0
Creating new GPT entries in memory.
Setting name!
partNum is 0
Setting name!
partNum is 1
Setting name!
partNum is 2
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
#
U-Boot SPL 2020.04-rc4 (Apr 29 2020 - 13:48:59 +0530)
Trying to boot from MMC1


U-Boot 2020.04-rc4 (Apr 29 2020 - 13:48:59 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
MMC:   spi@10050000:mmc@0: 0
Loading Environment from SPI Flash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 3
2 MiB
*** Warning - bad CRC, using default environment

In:    serial@10010000
Out:   serial@10010000
Err:   serial@10010000
Net:   eth0: ethernet@10090000
Hit any key to stop autoboot:  0
=>
=> setenv serverip 192.168.1.10
=> setenv ipaddr 192.168.1.11
=> tftpboot $fdt_add_r upgrade_sf.scr
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using ethernet@10090000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.11
Filename 'upgrade_sf.scr'.
Load address: 0x80200000
Loading: #
         44.9 KiB/s
done
Bytes transferred = 920 (398 hex)
=> source $fdt_add_r
## Executing script at 80200000
Probe flash
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
Program loader1
SF: 1048576 bytes @ 0x5000 Erased: OK
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using ethernet@10090000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.11
Filename 'u-boot-spl.bin'.
Load address: 0x84000000
Loading: ##############
         5.9 KiB/s
done
Bytes transferred = 66623 (1043f hex)
device 0 offset 0x5000, size 0x1043f
SF: 66623 bytes @ 0x5000 Written: OK
Program loader2
SF: 1048576 bytes @ 0x105000 Erased: OK
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using ethernet@10090000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.11
Filename 'u-boot.itb'.
Load address: 0x84000000
Loading: #################################################################
         #######################################
         674.8 KiB/s
done
Bytes transferred = 532404 (81fb4 hex)
device 0 offset 0x105000, size 0x81fb4
SF: 532404 bytes @ 0x105000 Written: OK
Program uImage.itb
SF: 14680064 bytes @ 0x525000 Erased: OK
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using ethernet@10090000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.11
Filename 'uImage.itb'.
Load address: 0x84000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###########################
         283.2 KiB/s
done
Bytes transferred = 5126451 (4e3933 hex)
device 0 offset 0x525000, size 0x4e3933
SF: 5126451 bytes @ 0x525000 Written: OK
Program boot_initramfs.scr
SF: 4096 bytes @ 0x1fff000 Erased: OK
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using ethernet@10090000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.11
Filename 'boot_initramfs.scr'.
Load address: 0x84000000
Loading: #
         26.4 KiB/s
done
Bytes transferred = 193 (c1 hex)
device 0 offset 0x1fff000, size 0xc1
SF: 193 bytes @ 0x1fff000 Written: OK
Done!
=>

U-Boot SPL 2020.04-rc4 (Apr 29 2020 - 13:46:59 +0530)
Trying to boot from SPI


U-Boot 2020.04-rc4 (Apr 29 2020 - 13:46:59 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
MMC:   spi@10050000:mmc@0: 0
Loading Environment from SPI Flash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 3
2 MiB
*** Warning - bad CRC, using default environment

In:    serial@10010000
Out:   serial@10010000
Err:   serial@10010000
Net:   eth0: ethernet@10090000
Hit any key to stop autoboot:  0
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
device 0 offset 0x1fff000, size 0x1000
SF: 4096 bytes @ 0x1fff000 Read: OK
## Executing script at 88100000
device 0 offset 0x525000, size 0xe00000
SF: 14680064 bytes @ 0x525000 Read: OK
## Loading kernel from FIT Image at 84000000 ...
   Using 'conf@0' configuration
   Trying 'kernel@0' kernel subimage
     Description:  RISC-V Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x840000e4
     Data Size:    5117737 Bytes = 4.9 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0xa4000000
     Entry Point:  0xa4000000
   Verifying Hash Integrity ... OK
## Loading fdt from FIT Image at 84000000 ...
   Using 'conf@0' configuration
   Trying 'fdt@0' fdt subimage
     Description:  HiFive Unleashed A00 blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x844e18c4
     Data Size:    6987 Bytes = 6.8 KiB
     Architecture: RISC-V
   Verifying Hash Integrity ... OK
   Booting using the fdt blob at 0x844e18c4
   Uncompressing Kernel Image
   Using Device Tree in place at 00000000844e18c4, end 00000000844e640e

Starting kernel ...

Amarula Hardware

Giotto Tune

Giotto tune-box and board-amarula

_images/giotto-tune-box-and-board-amarula.jpg

WE PRESENT YOU GIOTTO TUNE

Giotto Tune is born from a passion to make great sound quality available and affordable to everyone. Named after the painter who stayed true to nature’s purest form, it allows you to listen to music clear and cleaner as you’ve never heard before.

WHAT IS GIOTTO TUNE?

Giotto Tune plays music files encoded in PCM of different formats and at different bitrates, ranging from 44.100Khz to 192.000Khz up to 32bit and files in DSD64 format and DSD128 format. It allows you to enjoy and control your music with the Open Source Audiophile Music player Volumio 2, Kodi, UPnP and all mpd compatible players.

Plus, it is highly compatible. Not only does it fit perfectly on the well known Raspberry PI, but we are making the Giotto Tune also compatible with the Asus Tinker board.

DOWNLOAD SOURCE CODE FOR GIOTTO AND COMPILE

git clone https://github.com/panicking/linux-giotto


export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
make bcm2709_defconfig
make zImage modules dtbs
mount sdcard partitions
cp arch/arm/boot/zImage /media/user/boot/kernel7.img
cp arch/arm/boot/dts/*.dtb /media/user/boot/
cp arch/arm/boot/dts/overlays/*.dtb* /media/user/boot/overlays/

Change or add in /media/user/config.txt dtoverlay=giotto-dac

sudo make -j4 ARCH=arm INSTALL_MOD_PATH=/media/user/rootfs/ modules_install

umount the sdcard partitions

# Now your device is ready. Volume should be controlled by sysfs but this will be in another update

Vyasa RK3288