i.MX 8M Mini Cortex-M4 Hello World

In addition to supporting imx8mm 4 Cortex-A53 with a further nuclear Cortex-M4, Cortex-M4 herein require bare metal cores running program or system.

Run Official bin file

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

Cortex-M4 serial printer:

hello world.

Download NXP official SDK

SDK_2.5.0_EVK-MIMX8MM

Install cross compiler chain

NXP official compilation chain: 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) 

Set the environment variable: 

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

Compiler demo

Enter the directory: SDK_2.5.0_EVK-MIMX8MM / boards / evkmimx8mm / demo_apps / hello_world / armgcc

Modify gcc: Modify arm-none-eabi as aarch64-linux-gnu

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

Otherwise it will report the following error: 

  Tip the following errors:

Need comments following parameters:

Or will compile a compendium .s thumb instruction file temporarily abandon the use of this compilation chain.

Replace the compilation chain

Compile chain: 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

 

Guess you like

Origin blog.csdn.net/TSZ0000/article/details/90267724