玩轉STM32MP157-開發環境搭建


(一)STM32MP

1、什么是 STM32MPU
STM32MPU是 ST 推出的 Cortex-A7 + Cortex-M4 多核異構處理器

  • STM32MPU151 是單核 A7+M4,、STM32MPU153、STM32MPU157是雙核A7+M4。
  • A7核最高可以跑到650MHZ,M4核最高可以達到209MHZ,

2、開發資源(ST官方)
1.硬件
目前為止(20190618),能夠在官網找到的開發板有4款,分兩類:

2.軟件

  1. M4核方面,ST提供了Enhanced STM32Cube一整套開發工具,
  1. A核方面,有 Linux 跟 android:

(二)Linux 開發環境

1、安裝ubuntu

ST官方推薦使用ubuntu 64bit,可以直接安裝到PC里也可以是虛擬機(參考PC_prerequisites)。

安裝完系統后,還需要安裝一些依賴和軟件:

sudo apt-get update

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

sudo apt-get install libsdl1.2-dev xterm corkscrew nfs-common nfs-kernelserver device-tree-compiler mercurial u-boot-tools libarchive-zip-perl

sudo apt-get install ncurses-dev bc linux-headers-generic gcc-multilib
libncurses5-dev libncursesw5-dev lrzsz dos2unix lib32ncurses5 repo libssldev

sudo apt-get install default-jre
2、安裝編譯器

參考Install_the_SDK

下載:

wget https://www.st.com/content/ccc/resource/technical/software/sw_development_suite/group0/51/24/58/51/93/19/4f/3f/stm32mp1dev_yocto_sdk/files/SDK-x86_64-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz/jcr:content/translations/en.SDK-x86_64-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz

解壓:

tar xvf en.SDK-x86_64-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz

修改權限:

chmod +x stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sdk/st-image-weston-openstlinux-weston-stm32mp1-x86_64-toolchain-3.1-openstlinux-5.10-dunfell-mp1-21-03-31.sh

新建個目錄用做該編譯器的安裝目錄:

mkdir STM32MP
cd STM32MP
mkdir SDK

安裝:

$HOME/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sdk/st-image-weston-openstlinux-weston-stm32mp1-x86_64-toolchain-3.1-openstlinux-5.10-dunfell-mp1-21-03-31.sh -d $HOME/STM32MP/SDK
3、使用SDK

SDK的安裝目錄提供一個腳本文件用來設置環境變量,該腳本文件是:

$HOME/STM32MP/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi

看下該腳本文件中有什么內容:

該文件主要就是設置一些環境變量,比如,如果你要用arm-openstlinux_weston-linux-gnueabi-gcc的話,可以使用變量CC

首先使能環境變量

source $HOME/STM32MP/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi

查看下CC是什么內容:

hl@hl-ub:~$ echo $CC
arm-openstlinux_weston-linux-gnueabi-gcc -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/ub/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi

可以看到CC指定了編譯器,設置了編譯選項,還指定了sysroot路勁

創建一個簡單的C程序,保存為helloworld.c:

#include <stdio.h>

int main(int argc,char **argv)
{
	printf(“Hello STM32MP1\n”);
	return 0
}

編譯:

$CC -o helloworld helloworld.c

然后看下文件helloword信息:

編譯環境安裝完成

(三) 獲取、編譯uboot

  • 下載uboot

wget https://www.st.com/content/ccc/resource/technical/sw-updater/firmware2/group0/6c/b7/e5/68/0b/d5/49/13/stm32cube_Standard_A7_BSP_components_u-boot/files/SOURCES-u-boot-stm32mp1-openstlinux-4.19-thud-mp1-19-02-20.tar.xz/jcr:content/translations/en.SOURCES-u-boot-stm32mp1-openstlinux-4.19-thud-mp1-19-02-20.tar.xz

  • 然后解壓:

tar xvf en.SOURCES-u-boot-stm32mp1-openstlinux-4.19-thud-mp1-19-02-20.tar.xz

  • 進入u-boot所在目錄:

cd stm32mp1-openstlinux-4.19-thud-mp1-19-02-20/sources/arm-openstlinux_weston-linux-gnueabi/u-boot-stm32mp-2018.11-r0

該目錄所包含的文件如下:

里面有一些補丁文件(*.path),有個說明文件,還有uboot源碼:

解壓uboot源碼並打補丁:

tar xvf v2018.11.tar.gz
cd u-boot-2018.11
for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
  • 編譯

編譯之前需要設置下環境變量

(1):編譯STM32MP157C-DK2

basic boot:

make stm32mp15_basic_defconfig
make DEVICE_TREE=stm32mp157c-dk2 all

trusted boot:

make stm32mp15_basic_defconfig
make DEVICE_TREE=stm32mp157c-dk2 all

(2):編譯STM32MP157C-EV1

basic boot:

make stm32mp15_trusted_defconfig
make DEVICE_TREE=stm32mp157c-ev1 all

trusted boot:

make stm32mp15_trusted_defconfig
make DEVICE_TREE=stm32mp157c-ev1 all

參考

(四) 獲取、編譯內核

tar xvf en.SOURCES-kernel-stm32mp1-openstlinux-4.19-thud-mp1-19-02-20.tar.xz
  • 打補丁
for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

make multi_v7_defconfig fragment*.config
for f in `ls -1 ../fragment*.config`; do scripts/kconfig/merge_config.sh -m -r .config $f; done
yes '' | make oldconfig
  • 編譯內核
make uImage vmlinux dtbs LOADADDR=0xC2000040

參考


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM