- As mentioned in the above accepted answer, we can use the
mcuxpresso_sdk
to build bin/elf for the Coral Dev CM4.
- Additionally I'd to capture details to use the
multicore_example
,rtos_example
from the Coral repo.
- Also I'd like to add points on rpmsg/remoteproc support for imx8mq in linux kernel v4.14, the required patches adn dts support for imx8mq.
FreeRTOS SDK example - Boot CM4 from u-boot
- SDK source for Coral Dev
hello_world_tflite
example works without any changes.
- Why? in
main.c
the BOARD_InitPins
function is called which configures the UART pins for the CM4 console (in pin_mux.c
)
- This configuration is not applied for other examples. Therefore, I copied files
board.h, board.c, clock_config.c, clock_config.h, pin_mux.c, pin_mux.h
from hello_world_tflite to other example projects.
- And
BOARD_InitPins()
must be called
- Example for
rtos_examples/freertos_hello
$ cd mcuxpresso_sdk/boards/evkmimx8mq/rtos_examples/freertos_hello/
// copy board files from hello_word_tflite example
$ cp -rf ../../demo_apps/hello_world_tflite/[pin_mux.* board.* clock_config.*] ./
// freertos_hello.c -> main -> BOARD_InitBootPins() -> BOARD_InitPins()
// Update pin_mux.c, BOARD_InitBootPins() call BOARD_InitPins()
void BOARD_InitBootPins(void)
{
+ BOARD_InitPins();
}
$ cd armgcc
//compile your project
// copy release/freertos_hello.bin to your SDcard/emmc/tftpboot location
// I use tftp
u-boot=> tftp 0x7e0000 192.168.0.33:/tftpboot/coral/boot/freertos_hello.bin
u-boot=> bootaux 0x7e0000
// Open other emulated console and verify output
Load CM4 elf from Linux Remoteproc
Linux kernel support
- The CM4 can be loaded from linux side using remoteproc support
- I did not find remoteproc support for imx8mq in https://coral.googlesource.com/linux-imx/
- But there were set of patches available for imx8mq remoteproc support here
- And basically we cannot enable
IMX_REMOTEPROC
because of the same reason
- For my experimental support and learning I applied only the [08/10] remoteproc: imx_rproc: support i.MX8MQ/M patch
- And added Kconfig support for
IMX_REMOTEPROC
by adding HAVE_IMX8_SOC
, which let's me enable remoteproc for IMX8MQ
Linux DTS support
- This is my current dts smip from
arch/arm64/boot/dts/freescale/fsl-imx8mq-phanbell.dts
. (Add at the top of dts file)
/ {
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
m4_reserved: m4@0x80000000 {
no-map;
reg = <0 0x80000000 0 0x1000000>;
};
};
imx8mq-cm4 {
compatible = "fsl,imx8mq-cm4";
memory-region = <&m4_reserved>;
syscon = <&src>;
clocks = <&clk IMX8MQ_CLK_M4_ROOT>;
};
};
&rpmsg{
/*
* 64K for one rpmsg instance:
* --0xb8000000~0xb800ffff: pingpong
*/
vdev-nums = <1>;
reg = <0x0 0xb8000000 0x0 0x10000>;
status = "okay";
};
&uart2{
status="disabled";
};
&uart3{
status="disabled";
};
Linux RPMsg support
- I enabled the imx rpmsg module examples
IMX_RPMSG_TTY and IMX_RPMSG_PINGPONG
- Also enabled
RPMSG_CHAR
- Also CM4 application side rpmsg readme can be found here
- With above listed changes to linux kernel and CM4 sdk application examples, we can use the remoteproc to laod elf to CM4 and use
pmsg_lite_str_echo_rtos
example to communicate between APU and M4
Example CM4 elf load using remoteproc
- Load ddr build
hello_world.elf
using remoteproc. The elf file is expected to be in /lib/firmware
of your coral rootfs. Copy to respective location.
$ cd /path/to/mcuxpresso_sdk/...../hello_world/armgcc
$ ./build_ddr_release.sh
$ sudo cp ddr_release/hello_world.elf (sdcard/emmc/nfs rootfs)/lib/firmware/
// load firmware using remoteproc
root@coraldev:~# echo hello_world_tflite.elf > /sys/class/remoteproc/remoteproc0/firmware
root@coraldev:~# echo start > /sys/class/remoteproc/remoteproc0/state
[ 109.365150] remoteproc remoteproc0: powering up imx-rproc
[ 109.372949] remoteproc remoteproc0: Booting fw image hello_world_tflite.elf, size 295228
[ 109.381399] remoteproc remoteproc0: filesz 0x240 memsz 0x240
[ 109.387196] remoteproc remoteproc0: da 0x80000000 mem 0x240
[ 109.392959] remoteproc remoteproc0: filesz 0x1ee78 memsz 0x1ee78
[ 109.399094] remoteproc remoteproc0: da 0x80000240 mem 0x1ee78
[ 109.405366] remoteproc remoteproc0: filesz 0x6f4 memsz 0x6f4
[ 109.411181] remoteproc remoteproc0: da 0x8001f0b8 mem 0x6f4
[ 109.416945] remoteproc remoteproc0: filesz 0x0 memsz 0x3ba8
[ 109.422638] remoteproc remoteproc0: da 0x8001f7c0 mem 0x3ba8
[ 109.428501] remoteproc remoteproc0: remote processor imx-rproc is now up
- But sometimes I'm not able to view M4 UART console
- Loading any other example than
hello_world*
I get bad phdr da 0x80000000 mem 0x240
. This I'm not sure how to resolve
- Maybe dts mem reg should be updated
- Maybe wait for official support for imx8mq remoteproc
- But basic learning and experiment works
Linux side rpmsg char driver example
- Compile
multicore_examples/rpmsg_lite_str_echo_rtos/armgcc
with update board init pins
- Load the bin from u-boot
- After linux boots, up insmod the
imx_rpmsg_tty.ko
(need to enabled in menuconfig)
// Load cm4
u-boot=> tftp 0x7e0000 192.168.0.33:/tftpboot/coral/boot/rpmsg_lite_str_echo_rtos_imxcm4.bin
u-boot=> bootaux 0x7e0000
// on linux side
root@coraldev:~# insmod /lib/modules/4.14.98+/kernel/drivers/rpmsg/imx_rpmsg_tty.ko
root@coraldev:~# ls -las /dev/ttyRPMSG30
0 crw-rw---- 1 root dialout 235, 0 Jan 1 04:52 /dev/ttyRPMSG30
root@coraldev:~# echo "hello from linux" > /dev/ttyRPMSG30
// on CM4 console, other emulated ttyUSB1
RPMSG String Echo FreeRTOS RTOS API Demo...
Nameservice sent, ready for incoming messages...
Get Message From Master Side : "hello world!" [len : 12]
Get Message From Master Side : "hello from linux" [len : 16]
Get New Line From Master Side
- I've tried to update here everything I tried about using CM4 in coral dev
- I'm still facing issues with remoteproc.
- I hope some of these information are helpful for anyone stumbling across this post