查看“MYZR-STM32-EK152编译参考手册”的源代码
←
MYZR-STM32-EK152编译参考手册
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
## 交叉编译工具 当我们想要编译源码或者编译自己修改的源码时,首先要做的第一步就是配置对应的交叉编译工具。对于本套源码,我们是以st官方SDK提供的交叉编译工具为基础来进行编译的。 #### 编译工具下载和安装 **下载:** 交叉编译工具的下载需到我们提供的网盘上来进行下载,其对应的网盘目录为 <!--网盘路径-->。下载到电脑后,需要通过Samba或其他方法将其复制到虚拟机上来。 我们可以创建一个stm32mp157a专属的目录来存放相关的源码,编译工具和以后用到的一些东西。如我的目录为:**/home/kuangwh/my-work/stm32mp1**,在此目录下我又创建了4个子目录: <pre> =====> Input: $ ls 01_image 02_sources 03_sdk 04_app </pre> 01目录可以用来放置我们编译好的镜像(以后用到会说明) 02目录则是用来放置源码 03目录则是放置我们刚才下载好的交叉编译工具 04目录我们可以用来放置自己的app(用户自己分配) 把工具放到03目录下后,接下来进行工具的安装。 **安装:** 在03目录下运行此工具链脚本,输入如下命令: <pre> =====> Input: $ ./st-image-weston-openstlinux-weston-stm32mp1-x86_64-toolchain-3.1-openstlinux-5.4-dunfell-mp1-20-06-24.sh </pre> 输入安装目录/home/kuangwh/my-work/stm32mp1/03_sdk/ <pre> ST OpenSTLinux - Weston - (A Yocto Project Based Distro) SDK installer version 3.1-openstlinux-5.4-dunfell-mp1-20-06-24 ======================================================================================================================= Enter target directory for SDK (default: /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24): /home/kuangwh/my-work/stm32mp1/03_sdk/ </pre> 输入y <pre> You are about to install the SDK to "/home/kuangwh/my-work/stm32mp1/03_sdk". Proceed [Y/n]? y </pre> 安装过程需要耐心等待,直达出现successfully安装成功 <pre> =====> Output: Extracting SDK...................................................................................................... done Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /home/kuangwh/my-work/stm32mp1/03_sdk/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi </pre> #### 交叉编译工具配置 安装成功后,在03目录下有一个environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi脚本,输入如下命令: <pre> =====> Input: $ source environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi </pre> source后检查交叉编译工具版本等信息 <pre> =====> Input: $ $CC -v =====> Output: Using built-in specs. COLLECT_GCC=arm-ostl-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/sdc1/kwh-work/stm32mp1/03_sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/../../libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/9.3.0/lto-wrapper Target: arm-ostl-linux-gnueabi Configured with: ../../../../../../work-shared/gcc-9.3.0-r0/gcc-9.3.0/configure --build=x86_64-linux --host=x86_64-ostl_sdk-linux --target=arm-ostl-linux-gnueabi --prefix=/opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/sysroots/x86_64-ostl_sdk-linux/usr --exec_prefix=/opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/sysroots/x86_64-ostl_sdk-linux/usr --bindir=/opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi --sbindir=/opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell- 。。。。。。 gcc version 9.3.0 (GCC) </pre> **Note: CC是设置的宏,$CC中的"$"不能去掉** 看到版本信息后,编译工具配置成功,接下来就可以进行源码的编译步骤。需要注意的是,在每次打开终端窗口后都需要进行一次source配置。 ## 编译TF-A #### 下载源码包 <!--到提供的网盘上下载源码包-->,并使用Samba或其他方法将源码包复制到虚拟机中的~/my-work/stm32mp1/02_sources目录下。 将源码包tf-a解压到当前目录下: <pre> =====> Input: ~/my-work/stm32mp1/02_sources$ tar xvf tf-a-stm32mp-2.2.tar.bz2 </pre> #### 编译 进入目录tf-a-stm32mp-2.2 <pre> =====> Input: $ cd tf-a-stm32mp-2.2/ $ ls Makefile.sdk tf-a-stm32mp-2.2.r1 </pre> 先配置交叉编译工具 <pre> =====> Input: $ source ~/my-work/stm32mp1/03_sdk/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi </pre> 进入tf-a-stm32mp-2.2.r1目录 <pre> =====> Input: $ cd tf-a-stm32mp-2.2.r1/ </pre> 编译前先clean <pre> =====> Input: $ make -f ../Makefile.sdk clean </pre> make编译 <pre> =====> Input: $ make -f ../Makefile.sdk all </pre> 几分钟后,编译成功,会在上级目录出现一个build/trusted目录,里面存放的就是编译出的镜像文件**tf-a-myzr-stm32mp15-256m-trusted.stm32**/**tf-a-myzr-stm32mp15-512m-trusted.stm32**。 ## 编译u-boot #### 下载uboot源码 <!--到提供的网盘上下载源码包-->,并使用Samba或其他方法将源码包复制到虚拟机中的~/my-work/stm32mp1/02_sources目录下。 将源码包u-boot-stm32mp-2020.01.tar.bz2解压 <pre> =====> Input: $ tar xvf u-boot-stm32mp-2020.01.tar.bz2 </pre> #### 编译 进入目录u-boot-stm32mp-2020.01 <pre> =====> Input: ~/my-work/stm32mp1/02_sources$ cd u-boot-stm32mp-2020.01/ </pre> 先配置交叉编译工具 <pre> =====> Input: $ source ~/my-work/stm32mp1/03_sdk/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi </pre> 生成.config文件 <pre> =====> Input: $ make myzrstm32mp15_defconfig =====> Output: # # configuration written to .config # </pre> make编译,512m内存的板子make DEVICE_TREE=myzr-stm32mp15-512m,256m的板子make DEVICE_TREE=myzr-stm32mp15-256m <pre> =====> Input: $ make DEVICE_TREE=myzr-stm32mp15-256m =====> or $ make DEVICE_TREE=myzr-stm32mp15-512m =====> Output: scripts/kconfig/conf --syncconfig Kconfig CHK include/config.h UPD include/config.h CFG u-boot.cfg 。。。 MKIMAGE u-boot.stm32 OBJCOPY u-boot.srec SYM u-boot.sym COPY u-boot.dtb CFGCHK u-boot.cfg </pre> **u-boot.stm32**即为编译出的目标文件 <pre> $ ls u-boot.stm32 u-boot.stm32 </pre> ## 编译kernel #### 下载kernel源码 <!--到提供的网盘上下载源码包-->,并使用Samba或其他方法将源码包复制到虚拟机中的~/my-work/stm32mp1/02_sources目录下。 将源码包linux-5.4.31.tar.bz2解压 <pre> =====> Input: $ tar xvf linux-5.4.31.tar.bz2 </pre> #### 安装库 第一次编译内核时,需要在虚拟机ubuntu下安装相应的库 <pre> $ sudo apt-get install libncurses5-dev libncursesw5-dev libyaml-dev $ sudo apt-get install u-boot-tools $ sudo apt-get install libyaml-dev </pre> #### 编译内核 进入目录linux-5.4.31 <pre> =====> Input: ~/my-work/stm32mp1/02_sources$ cd linux-5.4.31/ </pre> 先配置交叉编译工具 <pre> =====> Input: $ source ~/my-work/stm32mp1/03_sdk/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi </pre> 生成.config文件 <pre> =====> Input: $ make myzrstm32mp15_defconfig =====> Output: HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTLD scripts/kconfig/conf # # configuration written to .config # </pre> 编译内核目标文件 <pre> =====> Input: $ make uImage LOADADDR=0xC2000040 =====> Output: 。。。 UIMAGE arch/arm/boot/uImage Image Name: Linux-5.4.31 Created: Mon Oct 19 07:14:40 2020 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 7312904 Bytes = 7141.51 KiB = 6.97 MiB Load Address: c2000040 Entry Point: c2000040 Kernel: arch/arm/boot/uImage is ready </pre> 内核镜像编译的时间比较久,编译成功后**arch/arm/boot/uImage** 即内核目标文件。 #### 编译设备树 输入如下命令单独编译出设备树 <pre> =====> Input: $ make myzr-stm32mp15.dtb =====> Output: DTC arch/arm/boot/dts/myzr/myzr-stm32mp15.dtb </pre> 设备树dtb文件生成在**arch/arm/boot/dts/myzr/myzr-stm32mp15.dtb**。 编译使用hdmi显示的设备树: <pre> =====> Input: $ make myzr-stm32mp15-hdmi.dts =====> Output: DTC arch/arm/boot/dts/myzr/myzr-stm32mp15-hdmi.dtb </pre> #### 编内核模块包 执行编译 <pre> =====> Input: $ make modules =====> Output: 。。。 CC [M] sound/usb/snd-usb-audio.mod.o LD [M] sound/usb/snd-usb-audio.ko CC [M] sound/usb/snd-usbmidi-lib.mod.o LD [M] sound/usb/snd-usbmidi-lib.ko </pre> 安装内核模块到指定目录 <pre> =====> Input: $ make INSTALL_MOD_PATH="$PWD/install_artifact" modules_install =====> Output: INSTALL sound/soc/fsl/snd-soc-fsl-sai.ko INSTALL sound/soc/generic/snd-soc-simple-card.ko INSTALL sound/usb/snd-usb-audio.ko INSTALL sound/usb/snd-usbmidi-lib.ko DEPMOD 5.4.31 </pre> 删除source和build目录 <pre> =====> Input: $ rm install_artifact/lib/modules/5.4.31/source $ rm install_artifact/lib/modules/5.4.31/build </pre> strip内核模块 <pre> =====> Input: $ find install_artifact/ -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates </pre> ## 应用编程示例 <!--网盘下载应用程序代码-->,并使用Samba或其他方法将源码包复制到虚拟机中的~/my-work/stm32mp1/04_app目录下。 进入hello_world目录 <pre> =====> Input: $ cd hello_world/ </pre> 先配置交叉编译工具 <pre> =====> Input: $ source ~/my-work/stm32mp1/03_sdk/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi </pre> 编译gtk_hello_world.c <pre> =====> Input: $ make </pre> 将编译出的二进制文件gtk_hello_world移动到开发板(移动方法参考前面体验篇的文件传输),开发板需接上显示屏。 给以可执行权限并执行文件 <pre> =====> Input: $ chmod +x gtk_hello_world $ ./gtk_hello_world =====> Output: (gtk_hello_world:6370): dbind-WARNING **: 18:17:49.914: Error retrieving accessibility bus address: org.a11y.Bus.Error: Failed to execute chi) </pre> 成功运行后可在屏幕上显示出hello world窗口。
返回至
MYZR-STM32-EK152编译参考手册
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
[-_-]
NXP平台:
MYZR-IMX6-EK200
MYZR-IMX6-EK200(EN)
MYZR-IMX6-EK314
MYZR-IMX6-EK314(EN)
MYZR-IMX6-EK336
MYZR-IMX6-EK336(EN)
MYZR-IMX6-EK140
MYZR-IMX6-EK140(EN)
MYZR-IMX6-EK140P
MYZR-IMX6-EK140P(EN)
MYZR-IMX8M-EK300
MYZR-IMX8M-EK300(EN)
MYZR-IMX8M-EVK
MYZR-IMX8Mmini-EK240
MYZR-IMX8Mmini-EK240(EN)
MYZR-IMX28-EK142
MYZR-IMX28-EK142(EN)
MYZR-LS1012A-EK200
MYZR-LS1012A-EK200(EN)
Rockchip平台:
MYZR-RK3288-EK314
MYZR-RK3288-EK314(EN)
MYZR-RK3399-EK314
MYZR-RK3399-EK314(EN)
Allwinner平台:
MYZR-R16-EK166
MYZR-R16-EK166(EN)
Microchip平台:
MYZR-SAMA5-EK200
MYZR-SAMA5-EK200(EN)
网关产品:
GW200
GW300
GW310/GW311
ST平台:
MYZR-STM32-EK152
所有页面
工具
链入页面
相关更改
特殊页面
页面信息