This document provides instructions for advanced users how Embedian offers patches and builds a customized version of FreeRTOS for Embedian's SMARC-iMX8MM product platform and how to install the images to bring the evaluation board up and running.
Our aim is to fully support our hardware through device drivers. We also provide unit tests so that testing a board is easy and custom development can start precisely. The recommended host environment is Ubuntu 16.04.
Before using this guide, we assume you understand how to setup a Yocto, Debian or Ubuntu working SD card. This guild apply to U-boot 2019.04 and Linux kernel 4.19.35 or higher. Here we are not mention Yocto/Debian/Ubuntu setup and compilation. There are well document available from Embedian.
There are several options in both processors, code can be located in one of the following:
Note that the TCM is the preferred option when possible since it offers the best performances since it is an internal memory dedicated to the Cortex-M4.
External memories, such as the DDR, offer more space but are also much slower to access.
In this article, it is assumed that every application runs from the TCM.
SMARC-iMX8MM from Embedian
EVK-STD-CARRIER-S20 (universal carrier board for all SMARC 2.0 modules) from Embedian
To build Embedian’s SMARC-iMX8MM FreeRTOS, you will need to install the following ARM GNU gcc compiler first:
For MCUXpresso 2.8.0 FreeRTOS, you need to use the following ARM GNU GCC coss compilier.
|
Test:
If this test fails, verify that you have the 32bit libraries installed on your development system.
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599] |
To download the source codes, you need to register at Embedian's git server first and put your ssh public key there.
We recommend you use SSH keys to establish a secure connection between your computer and Embedian Gitlab server. The steps below will walk you through generating an SSH key and then adding the public key to our Gitlab account.
First, we need to check for existing ssh keys on your computer. Open up Git Bash and run:
$ cd ~/.ssh $ ls # Lists the files in your .ssh directory |
Check the directory listing to see if you have a file named either id_rsa.pub
or id_dsa.pub
. If you don't have either of those files go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.
To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.
$ ssh-keygen -t rsa -C "your_email@example.com" # Creates a new ssh key, using the provided email as a label # Generating public/private rsa key pair. # Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter] $ ssh-add id_rsa |
Now you need to enter a passphrase.
Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again] |
Which should give you something like this:
Your identification has been saved in /c/Users/you/.ssh/id_rsa. Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com |
Copy the key to your clipboard.
$ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAABDAQABAAABAQDQUEnh8uGpfxaZVU6+uE4bsDrs/tEE5/BPW7jMAxak 6qgOh6nUrQGBWS+VxMM2un3KzwvLRJSj8G4TnTK2CSmlBvR+X8ZeXNTyAdaDxULs/StVhH+QRtFEGy4o iMIzvIlTyORY89jzhIsgZzwr01nqoSeWWASd+59JWtFjVy0nwVNVtbek7NfuIGGAPaijO5Wnshr2uChB Pk8ScGjQ3z4VqNXP6CWhCXTqIk7EQl7yX2GKd6FgEFrzae+5Jf63Xm8g6abbE3ytCrMT/jYy5OOj2XSg 6jlxSFnKcONAcfMTWkTXeG/OgeGeG5kZdtqryRtOlGmOeuQe1dd3I+Zz3JyT your_email@example.c om |
Go to Embedian Git Server. At Profile Setting --> SSH Keys --> Add SSH Key
Paste your public key and press "Add Key" and your are done.
For downloading the latest source code of FreeRTOS for SMARC-iMX8MM, we have to use MCUExpresso SDK generator online tool. Below is the link:
https://mcuxpresso.nxp.com/en/select
Embedian has customized it for SMARC-iMX8MM.
|
The file structures are as below.
|
Install cmake.
|
Change the directory to the application project directory, which has a path similar to the following:
|
This will compile and create binaries. The binaries will be available as <install_dir>freertos/boards/smarcimx8mm/multicore_examples/rpmsg_lite_str_echo_rtos/armgcc/release/rpmsg_lite_str_echo_rtos_imxcm4.bin
Same steps will be applied for other sample applications.
Once you finished compilation of rtos application, you can test it at U-Boot first. Prepare a working SD card.
|
Bootup the device and stop at U-Boot Command Prompt.
u-boot$ load mmc 1:1 0x48000000 rpmsg_lite_str_echo_rtos_imxcm4.bin
|
You will see messages from Cortex-M4 debug port at SER1.
"RPMSG String Echo FreeRTOS RTOS API Demo..."
u-boot$ load mmc 1:1 0x48000000 rpmsg_lite_str_echo_rtos_imxcm4.bin
2. If your u-boot version is v2020.04, the imx-atf patch should not be applied. This UART4 should be assigned to M4 domain in RDC. |
Assuming that you have a working Yocto/Debian/Ubuntu SD card.
The FreeRTOS examples uses SER1, I2C3 (I2C_GP, S48 and S49), SPI0, GPIO0 (P108) and PWM3 (GPIO5). It is therefore, we need to disable those pin for Cortex-A53 and reserve a dedicate memory area for Cortex-M4.
All available DTB files for Cortex-M4 are listed in the table below.
DTB File Name (for Cortex-M4) | Description |
---|---|
fsl-smarcimx8mm-m4.dtb | Device tree blob for SMARC-iMX8MM |
Replacing Kernel device tree file to adopt Cortex-M4
$ export DISK=/dev/sdb
|
The device tree name in your SD card has be to fsl-smarcimx8mm.dtb |
At uEnv.txt file, you need to add the following parameters.
$ sudo mount $ sudo vim /media/boot/uEnv.txt $ sudo umount /media/boot |
Add the following parameter below the line "image=Image"
m4_bin=m4_binary_name.bin |
Add the following parameters in the "uenvcmd" and before "run mmcboot".
uenvcmd=run loadimage; run loadfdt; run loadm4bin; run cpm4mem; run m4boot; run mmcboot |
Boot up the device and you will see "M4 is started" at dmesg.
In this section, we will show how to use the demo programs.
This demo application demonstrates the RPMsg remote peer stack. It works with Linux RPMsg master peer to transfer string content back and forth. The Linux driver creates a tty node to which you can write to. The MCU displays what is received, and echoes back the same message as an acknowledgement. The tty reader on ARM Cortex-A53 core can get the message, and start another transaction. The demo demonstrates RPMsg’s ability to send arbitrary content back and forth.
Copy rpmsg_lite_str_echo_rtos_imxcm4.bin to the first partition of your SD card and add m4_bin=rpmsg_lite_str_echo_rtos_imxcm4.bin at uEnv.txt file. Boot up the device. You will see SER1 print out the following Cortex-M4 messages.
RPMSG String Echo FreeRTOS RTOS API Demo...
Nameservice sent, ready for incoming messages...
At device side,
|
You will see SER1 print out the following messages.
Get Message From Master Side : "hello world!" [len : 12]
Get Message From Master Side : "this is a test" [len : 14]
Get New Line From Master Side
Same as previous demo, this one demonstrates the RPMsg communication. After the communication channels are created, Linux OS transfers the first integer to FreeRTOS OS. The receiving peer adds 1 to the integer and transfers it back, a hundred times and then stops.
Copy rpmsg_lite_pingpong_rtos_linux_remote.bin to the first partition of your SD card and add m4_bin=rpmsg_lite_pingpong_rtos_linux_remote.bin at uEnv.txt file. Boot up the device. You will see SER1 print out the following Cortex-M4 messages.
RPMSG Ping-Pong FreeRTOS RTOS API Demo...
RPMSG Share Base Addr is 0xb8000000
Link is up!
Namevice announce sent.
At device side,
|
You will see SER1 print out the following messages.
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
Sending pong...
Waiting for ping...
The Hello World project is a simple demonstration program that uses the BSP software. It prints the “Hello World” message to the ARM Cortex-M4 debug terminal SER1.
Copy hello_world.bin to the first partition of your SD card and add m4_bin=hello_world.bin at uEnv.txt file. Boot up the device. You will see SER1 print out the following Cortex-M4 messages.
hello world.
The GPIO demo code uses GPIO0 as an example to toggle this pin.
Copy igpio_led_output.bin to the first partition of your SD card and add m4_bin=igpio_led_output.bin at uEnv.txt file. Boot up the device. You will see SER1 print out the following Cortex-M4 messages.
GPIO Driver example
The LED is blinking.
Use scope to measure GPIO0, you will see a square wave that means this pin is toggled.
The PWM demo code uses GPIO5 (PWM3) as an example.
Copy ipwm.bin to the first partition of your SD card and add m4_bin=ipwm.bin at uEnv.txt file. Boot up the device. You will see SER1 print out the following Cortex-M4 messages.
PWM driver example.
Use scope to measure GPIO5, you will see PWM signals
For SMARC-iMX8MM, the SD card is always emulated as /dev/mmcblk1 and on-module eMMC is always emulated as /dev/mmcblk0. Setting up eMMC now is nothing but changing the device descriptor.
Follow exactly the same steps as that set up SD card. This time, the first partition of eMMC will be /dev/mmcblk0p1.