官方wiki教程:https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157C-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-A7/Install_the_SDK
这部分指导安装开发Arm® Cortex®-A7端的STM32MP1 开发包。
STM32MP1 开发包包含Arm® Cortex®-A7端的软件开发工具包(SDK),该工具包允许您交叉编译自己的应用程序或重建Linux®内核。
有个注意事项:需要在PC上运行一个Ubuntu 16.04的系统。
安装Ubuntu软件注意事项:如果是在中国,先将Ubuntu的下载站点改为国内的一些镜像网站,不然执行apt-get很慢,修改方法如下:https://www.cnblogs.com/tademeng/p/7451125.html
先安装一些额外的Ubuntu包,打开终端,依次执行以下命令:
PC $> sudo apt-get update
PC $> sudo apt-get install sed wget curl cvs subversion git-core coreutils unzip texi2html texinfo docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ desktop-file-utils chrpath libxml2-utils xmlto docbook bsdmainutils iputils-ping cpio python-wand python-pycryptopp python-crypto
PC $> sudo apt-get install libsdl1.2-dev xterm corkscrew nfs-common nfs-kernel-server device-tree-compiler mercurial u-boot-tools libarchive-zip-perl
PC $> sudo apt-get install ncurses-dev bc linux-headers-generic gcc-multilib libncurses5-dev libncursesw5-dev lrzsz dos2unix lib32ncurses5 repo libssl-dev
PC $> sudo apt-get install default-jre
有些执行过程比较长,有的会花费几分钟,甚至几十分钟。
执行第二个指令时出现如下提示:
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
出现这个问题可能是有另外一个程序正在运行,导致资源被锁不可用。而导致资源被锁的原因可能是上次运行安装或更新时没有正常完成,才导致这个问题发生。
解决方法:
删掉之前遗留下来的进程
sudo rm /var/lib/dpkg/lock-frontend
然后再重新执行第二个命令。
上述命令执行完成后,需要添加配置,执行如下命令:
PC $> echo 'options mmc_block perdev_minors=16' > /tmp/mmc_block.conf
PC $> sudo mv /tmp/mmc_block.conf /etc/modprobe.d/mmc_block.conf
如果在HOME下没有$HOME/STM32MPU_workspace/tmp,则先创建STM32MPU_workspace/tmp目录(可右键鼠标New Folder),打开FireFox 浏览器,访问:https://www.st.com/content/st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-mpu-openstlinux-distribution/stm32mp1dev.html网址,下载Yocto_SDK,将下载好的压缩包移动到$HOME/STM32MPU_workspace/tmp目录下,下载SDK需要登录ST的账户,如果没有的话,可以先注册。
然后解压SDK压缩包,执行如下命令:
PC $> cd $HOME/STM32MPU_workspace/tmp
PC $> tar xvf en.SDK-x86_64-stm32mp1-openstlinux-4.19-thud-mp1-19-02-20.tar.xz
创建存放 STM32MP15 Developer Package SDK的文件夹,执行如下命令:
PC $> mkdir $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0
PC $> mkdir $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package
PC $> mkdir $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK
PC $> chmod +x $HOME/STM32MPU_workspace/tmp/stm32mp1-openstlinux-4.19-thud-mp1-19-02-20/sdk/st-image-weston-openstlinux-weston-stm32mp1-x86_64-toolchain-2.6-openstlinux-4.19-thud-mp1-19-02-20.sh
PC $> $HOME/STM32MPU_workspace/tmp/stm32mp1-openstlinux-4.19-thud-mp1-19-02-20/sdk/st-image-weston-openstlinux-weston-stm32mp1-x86_64-toolchain-2.6-openstlinux-4.19-thud-mp1-19-02-20.sh -d $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK
注意官方Wiki文章的第二条指令有误,Developer-Package写成了Developer-Packager。
如果安装成功,会出现如下日志:
ST OpenSTLinux - Weston - (A Yocto Project Based Distro) SDK installer version 2.6-openstlinux-4.19-thud-mp1-19-02-20
=====================================================================================================================
You are about to install the SDK to "/local/home/frq08927/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK". Proceed[Y/n]? Y
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.
$ . //STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi
运行SDK环境启动脚本,并且每次在一个新的终端命令执行交叉编译时都需要运行一次此脚本,执行如下命令:
PC $> cd $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package
PC $> source SDK/environment-setup-cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi
检测SDK是否正确启动,执行如下命令:
检测目标架构
PC $> echo $ARCH
arm
检测目标工具的工具链二进制前缀
PC $> echo $CROSS_COMPILE
arm-openstlinux_weston-linux-gnueabi-
检测编译器的版本
PC $> $CC --version
arm-openstlinux_weston-linux-gnueabi-gcc (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
检测SDK的版本
PC $> echo $OECORE_SDK_VERSION
2.6-openstlinux-4.19-thud-mp1-19-02-20
如果这些指令失败了或者没有返回期望的结果,请尝试重新安装SDK。
火柴棍科技工作室:www.huochaigun.top
技术交流群
STM32MP1:861926625
ESP8266:476685983