微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于NXP iMX7 ARM处理器部署FreeRTOS实时操作系统

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

时间:08-15 来源:互联网 点击:

ri 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 # s**eenv

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

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 # s**eenv

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

  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下执行下面命令

-----

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top