如何在Google Coral Dev中将bin加载到Cortex-M4 我尝试了什么?我观察到的东西问题 Linux内核支持 Linux DTS支持 Linux RPMsg支持使用remoteproc的CM4小精灵加载示例 Linux端rpmsg char驱动程序示例

问题描述

  • 当前,我正尝试从Google Coral开发中的u-boot将hello_world.bin加载到皮质m4

我尝试了什么?

  • 提出Coral开发目标
  • i.MX8MQ的
  • SDK
    • https://mcuxpresso.nxp.com/下载SDK
    • 对于处理器'MIMX8MQ6xxxJZ'(自动选择板-EVK-MIMX8MQ)
    • 为Cortex M4(基于TCM)构建hello_world.bin。在BOARD_InitBootPins
    • 中使用UART2
$ tar -xzf SDK_2.8.0_MIMX8MQ6xxxJZ.tar.gz
$ cd boards/evkmimx8mq/demo_apps/hello_world/armgcc
$ export ARMGCC_DIR=<path to>/gcc-arm-none-eabi-9-2020-q2-update/
$ export PATH=$PATH:<path to>/gcc-arm-none-eabi-9-2020-q2-update/bin
$ ./build_debug.sh 
$ ls debug/hello_world.bin 
  • 从u-boot加载hello_world.bin
    • 我已将垃圾箱放置在tftpboot位置。
Hit any key to stop autoboot:  0 
u-boot=> tftp 0x7e0000 192.168.0.33:/tftpboot/coral/boot/hello_world.bin
Using ethernet@30be0000 device
TFTP from server 192.168.0.33; our IP address is 192.168.0.133
Filename '/tftpboot/coral/boot/hello_world.bin'.
Load address: 0x7e0000
Loading: ####
         2.3 MiB/s
done
Bytes transferred = 16700 (413c hex)
u-boot=> bootaux 0x7e0000
## Starting auxiliary core at 0x007E0000 ...
  • 但是我在第二个终端ttyUSB1上看不到任何输出
  • 第二个终端上的预期输出应为Hello World

我观察到的东西

  • Coral-Dev-Board-baseboard-schematic.pdf
    • 根据底板框图,UART2/3通过转换器连接到MicroUSB
      • 但是UART1(ttymxc0)也可以在微型USB上使用
      • 内核引导后,微型USB上的UART3(ttymxc0)可用
    • 但是在内核启动后,我注意到UART3在第二个枚举端口上可用
    • 例如,
// On coral dev
root@wishful-zebra:~# ls -las /dev/ttymxc*
0 crw------- 1 mendel tty     207,16 Aug 20 03:45 /dev/ttymxc0
0 crw-rw---- 1 root   dialout 207,17 Aug 20 03:05 /dev/ttymxc1
0 crw-rw---- 1 root   dialout 207,18 Aug 20 03:40 /dev/ttymxc2

root@wishful-zebra:~# stty -echo raw speed 115200 < /dev/ttymxc2
115200
root@wishful-zebra:~# echo "test" > /dev/ttymxc2 

// prints 'test' on /dev/ttyUSB1 host side
Welcome to minicom 2.7.1

OPTIONS: I18n 
Compiled on Aug 13 2017,15:25:34.
Port /dev/ttyUSB1,23:55:15

Press CTRL-A Z for help on special keys

test

问题

  • 如何在Google Coral Dev上将固件加载到Cortex M4?
  • 要用于Google Coral Dev的哪个i.MX SDK端口?
  • 微型USB上有哪些UART?
  • Google Coral Dev中的Cortex M4使用哪个UART

解决方法

以下是启动imx8m M4并在其上运行TFLite Micro Hello World(输出正弦波)的说明: https://coral.googlesource.com/mcuxpresso_sdk/+/refs/heads/master/boards/evkmimx8mq/demo_apps/hello_world_tflite/

您需要同步项目存储库并重建linux-imx和uboot-imx。

通过USB连接串行端口时,枚举的第二个UART上将显示M4内核的输出。

,
  • 如上面接受的答案所述,我们可以使用mcuxpresso_sdk来为Coral Dev CM4构建bin / elf。
  • 此外,我想捕获细节以使用Coral存储库中的multicore_examplertos_example
  • 我还想在linux内核v4.14中对imx8mq的rpmsg / remoteproc支持上添加点,对imx8mq的必需补丁和dts支持。

FreeRTOS SDK示例-从u-boot引导CM4

    用于珊瑚开发的
  • SDK源
  • hello_world_tflite示例可以正常运行。
    • 为什么?在main.c中,调用BOARD_InitPins函数,该功能为CM4控制台(在pin_mux.c中)配置UART引脚
  • 此配置不适用于其他示例。因此,我将文件board.h,board.c,clock_config.c,clock_config.h,pin_mux.c,pin_mux.h从hello_world_tflite复制到其他示例项目。
  • 必须调用BOARD_InitPins()
  • 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

从Linux Remoteproc加载CM4小精灵

Linux内核支持

Linux DTS支持

  • 这是我目前从arch/arm64/boot/dts/freescale/fsl-imx8mq-phanbell.dts发来的tst smip。 (在dts文件顶部添加)
/ {
  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支持

  • 我启用了imx rpmsg模块示例IMX_RPMSG_TTY and IMX_RPMSG_PINGPONG
  • 还启用了RPMSG_CHAR
  • 还可以在here中找到CM4应用程序侧rpmsg自述文件

  • 通过上面列出的对Linux内核和CM4 sdk应用示例的更改,我们可以使用remoteproc将elf加载到CM4,并使用pmsg_lite_str_echo_rtos示例在APU和M4之间进行通信

使用remoteproc的CM4小精灵加载示例

  • 使用remoteproc加载ddr构建hello_world.elf。 elf文件应位于珊瑚rootfs的/lib/firmware中。复制到各自的位置。
$ 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

  • 但是有时候我无法查看M4 UART控制台
  • 加载hello_world*以外的其他示例,我得到bad phdr da 0x80000000 mem 0x240。这我不确定如何解决
    • 也许dts mem reg应该更新
    • 也许正在等待对imx8mq remoteproc的官方支持
  • 但是基础学习和实验有效

Linux端rpmsg char驱动程序示例

  • 使用更新板初始化引脚编译multicore_examples/rpmsg_lite_str_echo_rtos/armgcc
  • 从u-boot加载垃圾箱
  • 在Linux启动后,将insmod imx_rpmsg_tty.ko(需要在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

  • 我试图在这里更新我在珊瑚开发中使用CM4的所有尝试
  • 我仍然面临remoteproc的问题。
  • 我希望其中一些信息对在这篇文章中遇到绊脚石的人有所帮助

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...