toradex的个人空间 https://blog.eetop.cn/1539194 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

基于NXP iMX7 ARM处理器部署FreeRTOS实时操作系统

已有 1575 次阅读| 2016-8-11 17:18

5). M4核心上面运行Firmware

a). M4的固件程序在Colibri iMX7 A7核心Linux系统U-Boot中进行加载, 将编译好的 hello_world.bin程序放到SD卡根目录 (FAT32格式) ,并连接到开发板上.

------------------------

Colibri iMX7 # fatload mmc 0:1 0x7F8000 hello_world.bin

...

Colibri iMX7 # dcache flush

Colibri iMX7 # bootaux 0x7F8000

## Starting auxiliary core at 0x007F8000 ...

------------------------

 

b). FreeRTOS 默认使用 UARTB 作为其调试输出串口, 波特率设置115200 8N1。A7 Linux 默认device tree设置也会访问UARTB, 为了防止出现冲突, 推荐在device tree 中禁用 UARTB(设置status参数)。也可以在 U-Boot 中添加下面参数,临时禁用 UARTB。

------------------------

Colibri iMX7 # setenv fdt_fixup 'fdt addr ${fdt_addr_r} && fdt rm /soc/aips-bus@30800000/spba-bus@30800000/serial@30890000'

Colibri iMX7 # saveenv

------------------------

 

c). Linux会自动关闭不使用设备的时钟,但A7核心Linux无法知道哪些时钟在M4核心上面被使用,因此需要添加下面内核参数来保证M4相关时钟正常。

------------------------

Colibri iMX7 # setenv defargs clk_ignore_unused

------------------------

 

d). 通过另外一个窗口连接UARTB, 可以收到hello world程序运行后的打印输出

------------------------

$ sudo minicom -D /dev/ttyUSB1 -b 115200

 

Welcome to minicom 2.7

......

Port /dev/ttyUSB1, 11:52:46

Press CTRL-A Z for help on special keys

 

Hello World!

------------------------

 

e). 自动启动加载 M4 上运行的程序

// 运行下面命令将SD卡上面的程序文件复制到系统为M4程序单独提供的ubi分区空间

------------------------

Colibri iMX7 # ubi part ubi

...

Colibri iMX7 # fatload mmc 0:1 ${loadaddr} hello_world.bin

...

Colibri iMX7 # ubi write ${loadaddr} m4firmware ${filesize}

------------------------

// 设置启动变量,之后U-Boot会在开机启动Linux前先启动M4程序

------------------------

Colibri iMX7 # setenv m4boot 'ubi read 0x7F8000 m4firmware && dcache flush && bootaux 0x7F8000'

Colibri iMX7 # saveenv

------------------------

 

6). M4 程序示例

除了上面测试的hello world, 在examples目录中还有很多示例程序.

a). GPIO示例

// 例程位置: .../examples/imx7_colibri_m4/driver_examples/gpio_imx/

// 同上述方法编译后生成应用: gpio_imx_example.bin

// 例程中使用EXT_IO1作为按键输入, EXT_IO0作为输出控制LED; 在Colibri 评估板上面, 利用X21将对应Pin脚和组件相连:

------------------------

EXT_IO0 => X21-LED1

EXT_IO1 => X21-SW6

------------------------

 

// 在Uboot运行程序, 由于A7 Linux Device Tree也定义了这几个GPIO, 因此测试只在U-Boot环境下进行.

------------------------

====================== GPIO Example ========================

 

=================== GPIO Interrupt =====================

The (EXT_IO1) button is configured to trigger GPIO interrupt

Press the (EXT_IO1) button 3 times to continue.

 

Button pressed 1 time.

Button pressed 2 time.                                                         

Button pressed 3 time.                                                         

                                                                                

================= GPIO Functionality==================                         

The button state is now polled.                                                

Press the button to switch LED on or off                                        

                                                                               

Button pressed 1 times                                                         

Button pressed 2 times                  

...

------------------------

 

b). RPMsg示例 - M4和A7通讯

// 例程位置: .../examples/imx7_colibri_m4/demo_apps/rpmsg/str_echo_freertos/

// 同上述方法编译后生成应用: rpmsg_str_echo_freertos_example.bin

// A7 Linux kernel对应module 源文件: drivers/rpmsg/imx_rpmsg_tty.c

 

// U-Boot执行如下命令

------------------------

fatload mmc 0:1 0x7F8000 rpmsg_str_echo_freertos_example.bin    

reading rpmsg_str_echo_freertos_example.bin                                    

20860 bytes read in 21 ms (969.7 KiB/s)                                        

Colibri iMX7 # dcache flush                                                     

Colibri iMX7 # bootaux 0x7F8000                                                

## Starting auxiliary core at 0x007F8000 ...

Colibri iMX7 # run ubiboot

------------------------

 

// M4 串口输出

------------------------

RPMSG String Echo FreeRTOS RTOS API Demo...                                    

RPMSG Init as Remote

------------------------

 

// A7 Linux下执行下面命令

------------------------

$ modprobe imx_rpmsg_tty                                    

[  184.656763] imx_rpmsg_tty rpmsg0: new channel: 0x400 -> 0x0!                

[  184.663331] Install rpmsg tty driver!                                       

$ stty -F /dev/ttyRPMSG -echo                               

...

------------------------


// M4串口对应输出

------------------------

RPMSG String Echo FreeRTOS RTOS API Demo...                                    

RPMSG Init as Remote                                                           

Name service handshake is done, M4 has setup a rpmsg channel [0 ---> 1024]     

Get Message From Master Side : "Test" [len : 4]                                

Get New Line From Master Side

------------------------

 

// 如需将Linux kernel module 设置为开机自动加载

------------------------

$ echo imx_rpmsg_tty > /etc/modules-load.d/rpmsg_tty.conf

------------------------

 

// 另外关于RPMsg还有其他如pingpong demo, 可以自行测试.

 

7). 总结

本文对iMX7 异构双核架构进行了说明, 并基于Toradex Colibri iMX7 模块演示了在M4核心上面运行FreeRTOS例程以及A7和M4核心通过RPMsg通信例程, 相信对NXP iMX7架构以及应用有了一个初步的了解, 其非常适合用于同时有人机交互和实时控制的工业应用场景, 同时非常低的功耗也使得整个嵌入式系统的稳定可靠性有了很好的保证.

 

参考文档

http://developer.toradex.com/knowledge-base/freertos-on-the-cortex-m4-of-a-colibri-imx7


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 3

    粉丝
  • 0

    好友
  • 1

    获赞
  • 2

    评论
  • 13923

    访问数
关闭

站长推荐 上一条 /2 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-20 20:24 , Processed in 0.013955 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部