i.MX 8M Mini Cortex-M4 Hello World

news/2024/11/23 16:57:53/

        imx8mm除了支持4个Cortex-A53还带1个Cortex-M4核,运行频率高达400MHz,本文需要在Cortex-M4核运行裸机程序或者系统。

运行官方bin文件

	u-boot=> tftp 0x7e0000 imx8mm_m4_TCM_hello_world.bin    Using ethernet@30be0000 deviceTFTP from server 192.168.1.99; our IP address is 192.168.1.55Filename 'imx8mm_m4_TCM_hello_world.bin'.Load address: 0x7e0000Loading: #617.2 KiB/sdoneBytes transferred = 6320 (18b0 hex)u-boot=> u-boot=> bootaux 0x7e0000## Starting auxiliary core at 0x007E0000 ...

Cortex-M4串口打印:

hello world.

下载NXP官方SDK

SDK_2.5.0_EVK-MIMX8MM

安装交叉编译链

NXP官方编译链:gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu

aarch64-linux-gnu-gcc -v
gcc version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (Linaro GCC 7.4-2019.02) 

设置环境变量: 

export ARMGCC_DIR="/home/logread/imx8m-mini/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu"

export PATH=$PATH:/home/logread/imx8m-mini/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin

编译demo

进入目录:SDK_2.5.0_EVK-MIMX8MM/boards/evkmimx8mm/demo_apps/hello_world/armgcc

修改gcc:修改arm-none-eabi为aarch64-linux-gnu

SDK_2.5.0_EVK-MIMX8MM/tools/cmake_toolchain_files/armgcc.cmake +24

否则会报下面错误: 

  提示下面错误:

需要注释下面的参数:

还是会编译.s汇编文件的thumb指令问题,暂时放弃使用这个编译链。

更换编译链

编译链:gcc-arm-none-eabi-7-2017-q4-major-linux.bz2

/home/logread/imx8m-mini/gcc-arm-none-eabi-7-2017-q4-major

export ARMGCC_DIR="/home/logread/imx8m-mini/gcc-arm-none-eabi-7-2017-q4-major"

export PATH=$PATH:/home/logread/imx8m-mini/gcc-arm-none-eabi-7-2017-q4-major/bin

logread@logread:~/imx8m-mini/gcc-arm-none-eabi-7-2017-q4-major$ arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/home/logread/imx8m-mini/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/lto-wrapper
Target: arm-none-eabi
Configured with: /tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/src/gcc/configure --target=arm-none-eabi --prefix=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native --libexecdir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/lib --infodir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/arm-none-eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-gmp=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-mpfr=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-mpc=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-isl=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-libelf=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for Arm Embedded Processors 7-2017-q4-major' --with-multilib-list=rmprofile
Thread model: single
gcc version 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 

编译链改会arm-none-eabi,编译成功:

加载运行

拷贝debug/hello_world.bin,通过tftp加载,运行成功

u-boot=> tftp  0x7e0000  hello_world.bin
Using ethernet@30be0000 device
TFTP from server 192.168.1.99; our IP address is 192.168.1.55
Filename 'hello_world.bin'.
Load address: 0x7e0000
Loading: ##980.5 KiB/s
done
Bytes transferred = 15072 (3ae0 hex)
u-boot=> bootaux 0x7e0000
## Starting auxiliary core at 0x007E0000 ...Cortex-M4 serial:
hello world.
hello 2-che.

编译除的bin和elf文件差别,elf文件怎么跑的呢?

logread@logread:~/imx8m-mini/SDK_2.5.0_EVK-MIMX8MM/boards/evkmimx8mm/demo_apps/hello_world/armgcc$ file debug/hello_world.bin 
debug/hello_world.bin: data
logread@logread:~/imx8m-mini/SDK_2.5.0_EVK-MIMX8MM/boards/evkmimx8mm/demo_apps/hello_world/armgcc$ file debug/hello_world.elf 
debug/hello_world.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

elf文件需要使用J-LINK+gdb来运行在M4核:

$ arm-none-eabi-gdb hello_world.elf


http://www.ppmy.cn/news/231478.html

相关文章

爱普生EPSON ME 1+打印机清零程序及其使用说明

爱普生EPSON ME 1打印机清零程序下载 EPSON ME1打印机废墨记数器清零使用说明 注意:运行维修程序前要确保打印已开机并且已连接好打印线,运行完成后关闭打印机,数秒钟后再开机,打印机即可恢复正常。

爱普生Epson L120 打印机驱动

爱普生Epson L120 打印机驱动是官方提供的一款打印机驱动,本站收集提供高速下载,用于解决打印机与电脑连接不了,无法正常使用的问题,本动适用于:Windows XP / Windows 7 / Windows 8 / Windows 10 32/64位操作系统。有…

l360清零软件无响应_爱普生L360清零软件

爱普生L360清零软件是为同名打印机打造的一款专业的清零软件,打印机在使用一段时间之后废墨盒计数器就会满,这时就需要进行清零操作,以促使打印机可以正常工作。小编还带来了具体的清零教程,需要的朋友可以参考! 爱普生L360清零教程 第一步,双击打开清零软件双击AdjProg.…

华为 MatePad 系列:绝版精美壁纸一套

高清原图,请等待加载完毕 绝对悦目 关注逆锋起笔 获取更多精彩内容 点击【阅读原文】 获取主题壁纸 喜欢这篇文章 快点点【在看】

银河麒麟V10——Ubantu--银河麒麟系统安装

目录 一、系统安装 一、系统安装 ##银河麒麟镜像下载地址: https://eco.kylinos.cn/partners/mirror.html##优麒麟镜像下载地址: https://www.ubuntukylin.com/downloads/##本次采用银河麒麟镜像: 银河麒麟高级服务器操作系统(A…

天玑oracle一体机,天玑720处理器相当于哪款麒麟处理器?

大家都知道,天玑720处理器是一款性能非常高的中端手机的处理器,那么天玑720处理器相当于麒麟多少呢?相信很多小伙伴㐊非常了解,下面就让小编为大家详细的介绍天玑720处理器,感兴趣的朋友不要错过了。 天玑720处理器采用…

天玑720支持鸿蒙系统吗,天玑720和麒麟820哪个好_天玑720和麒麟820对比评测

天玑720和麒麟820这两款手机处理器都是定位的中高端处理器,目前很多手机都是使用的这两款手机处理器,那你知道这两款处理器,哪个更好用吗?小编接下来给大家简单介绍一下吧~ 一、性能 天玑720 5G芯片采用了7纳米工艺制程&#xff0…

【壁纸】 Kali Linux 2019.13 原版壁纸

从Kali Linux 2019.3 系统提取到的原版壁纸,请自行食用!