STM32MP257(MYC-LD257)开发环境配置详解与学习笔记

1. VMware Workstation安装

  可参考此链接VMware 17.6安装教程

2. Ubuntu20.04虚拟机安装

2.1 创建虚拟机

  此处可参考书籍《【正点原子】STM32MP1嵌入式Linux驱动开发指南V2.0》1.2小节。
  注意事项:可独立设置一个空盘留给Unbuntu系统。

2.2 安装Ubuntu

  此处可参考书籍《【正点原子】STM32MP1嵌入式Linux驱动开发指南V2.0》1.3小节。
  镜像文件可从清华大学镜像库下载:ubuntu 20.04清华源镜像下载
  注意事项:
  1. 首先设置“USB 控制器”选项,默认 USB 控制器的 USB 兼容性为 USB2.0,这样当你使用USB3.0 的设备的时候 Ubuntu 可能识别不出来,因此我们需要调整 USB 兼容性为 USB3.0。
  
  2. 部分电脑在直接安装Ubuntu时可能看不见部分按键,导致无法继续安装,此处可先点击试用Ubuntu,调整分辨率后再安装Ubuntu。
  
  3.部分在此界面无法使用键盘输入,多数情况可采用更新 VMware Tools解决。(VMware Tools 是一组增强虚拟机功能的驱动程序和实用程序。确保已安装并更新了最新版本的 VMware Tools。过时的 VMware Tools 可能会导致键盘和其他外围设备出现问题)。
   4.安装ubuntu之后,可能会出现突然发现Ubuntu连不上网络,右上角也没有网络图标;解决方法可参考链接第二种方法:Ubuntu连接不了网络的解决方法(第二种亲测可行)

2.3 配置 VMware 使用双网卡

  可参考书籍韦东山STM32MP157《嵌入式Linux应用开发完全手册V5.1_STM32MP157_Pro开发板》第三篇 环境搭建与开发板操作 第1章 配置 VMware 使用双网卡
   – NAT 网卡:Ubuntu 通过它上网,只要 Windows 能上网,Ubuntu 就能上网
   – 桥接网卡:Ubuntu 通过它跟开发板联通

3. 主机环境配置

3.1 更换清华源

  查询版本
  先查询自己系统的版本号:
  命令:lsb_release -a

sxl@sxl-ubuntu:/usr/bin$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

  可以看出我系统版本是 Ubuntu 20.04.6 LTS,注意这个开发代号Codename,Ubuntu每一个版本都有一个代号,这个一定要跟国内源对应,否则会出问题。

  更换办法
  1. 备份

sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

  2. 编辑
  打开vim编辑器,把sources.list文件中所有的deb文件全部注释掉或者删除掉,然后把上面给的国内镜像复制去就可以。

sudo vim /etc/apt/sources.list

  3. 更新

sudo apt update
sudo apt upgrade

  清华源

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

3.2 windows和ubuntu共享文件夹

  可参考VMware下Linux虚拟机挂载Windows共享文件夹

3.3 安装必要工具

  非常重要,请确保主机环境正确执行了以下操作,并且在完成如下操作后重启。

sudo apt-get update
sudo apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc u-boot-tools cpio sudo locales bc libncurses5-dev screen flex bison vim-tiny device-tree-compiler xvfb libgtk2.0-dev libssl-dev net-tools libyaml-dev rsync liblz4-tool zstd python3-pip git-lfs iputils-ping jq
sudo rm -rf /var/lib/apt/lists/*
sudo curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > /usr/bin/repo

  如出现:

bash: /usr/bin/repo: 权限不够

  可使用su root切换成root权限。

sudo chmod a+x /usr/bin/repo
sudo ln -s /usr/bin/python3 /usr/bin/python

  此处可能会出现报错说是/usr/bin/python已存在;可参考解决方案
  误删 /usr/bin/python解决方案

sudo sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
echo 'LANG="en_US.UTF-8"' | sudo tee /etc/default/locale > /dev/null
sudo dpkg-reconfigure --frontend=noninteractive locales
sudo update-locale LANG=en_US.UTF-8
sudo pip3 install pyusb usb crypto ecdsa crcmod tqdm pycryptodome pycryptodomex pyelftools

3.4 安装系统交叉编译工具链

  此处使用米尔科技提供的工具链,位于:03-Tools/Compile Toolchain/:

工具链文件名 描述
myir-image-full-openstlinux-weston-myd-ld25x-x86_64-toolchain- 4.2.4-snapshot.sh 包含一个独立的交叉开发工具链还提供 qmake, 目标平台的 sysroot, Qt 应用开发所依赖的库和头文件等。用户可以直接使用这个 SDK来建立一个独立的开发环境

  安装步骤
  1. 将文件拷贝至Ubuntu虚拟机
   2. 执行安装脚本

$ ./myir-image-full-openstlinux-weston-myd-ld25x-x86_64-toolchain-4.2.4-snapshot.sh
ST OpenSTLinux - Weston - (A Yocto Project Based Distro) SDK installer versi
on 4.2.4-snapshot =====================================================
========================================
Enter target directory for SDK (default: /opt/st/myd-ld25x/4.2.4-snapshot): ./
You are about to install the SDK to "/home/myir/myd-ld25x-toolchain". Proce
ed [Y/n]? y
Extracting SD
K..................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................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 sour
ce the environment setup script e.g.

   3. 初始化环境变量:

source ~/MYIR-LD25x-ToolChain/environment-setup-cortexa35-ostl-linux

注:每个终端窗口想使用该工具链编译代码,得重新使用该命令初始化后才可使用
   4. 测试SDK

sxl@sxl-ubuntu:~$ source ~/myd-ld25x-toolchain/environment-setup-cortexa35-ostl-linux
sxl@sxl-ubuntu:~$ echo $ARCH
arm64
sxl@sxl-ubuntu:~$ echo $CROSS_COMPILE
aarch64-ostl-linux-
sxl@sxl-ubuntu:~$ $CC --version
aarch64-ostl-linux-gcc (GCC) 12.3.0
Copyright (C) 2022 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.

sxl@sxl-ubuntu:~$ echo $OECORE_SDK_VERSION
4.2.4-snapshot
sxl@sxl-ubuntu:~$ 

3.5 arm交叉编译工具链

  arm 交叉编译器各种gcc
  arm-none-linux-gnueabi-gcc:(ARM architecture, no vendor, creates binaries that run on the Linux operating system,and uses the GNU EABI)主要用于基于ARM架构的Linux系统,可用于编译 ARM 架构的 u-boot、Linux内核、linux应用等。arm-none-linux-gnueabi基于GCC,使用Glibc库,经过 Codesourcery 公司优化过推出的编译器。arm-none-linux-gnueabi-xxx 交叉编译工具的浮点运算非常优秀。一般ARM9、ARM11、Cortex-A 内核,带有 Linux 操作系统的会用到。
  arm-linux-gnueabi-gcc 和 arm-linux-gnueabihf-gcc:两个交叉编译器分别适用于 armel 和 armhf 两个不同的架构,armel 和 armhf 这两种架构在对待浮点运算采取了不同的策略(有 fpu 的 arm 才能支持这两种浮点运算策略)。
这两个交叉编译器是 gcc 的选项 -mfloat-abi 的默认值不同。gcc 的选项 -mfloat-abi 有三种值 soft、softfp、hard(其中后两者都要求 arm 里有 fpu 浮点运算单元,soft 与后两者是兼容的,但 softfp 和 hard 两种模式互不兼容):
soft: 不用fpu进行浮点计算,即使有fpu浮点运算单元也不用,而是使用软件模式。
softfp: armel架构(对应的编译器为 arm-linux-gnueabi-gcc )采用的默认值,用fpu计算,但是传参数用普通寄存器传,这样中断的时候,只需要保存普通寄存器,中断负荷小,但是参数需要转换成浮点的再计算。
hard: armhf架构(对应的编译器 arm-linux-gnueabihf-gcc )采用的默认值,用fpu计算,传参数也用fpu中的浮点寄存器传,省去了转换,性能最好,但是中断负荷高。
  相关解释可参考:arm 交叉编译器各种gcc 傻傻分不清楚:gnueabi,gnueabhf,none-eaib
  此处依次安装三种交叉编译工具链(可不安装,后续在MYC_LD257开发板上执行的代码使用第3.4节中的交叉编译工具链)

   1. arm-linux-gnueabi-gcc 和 arm-linux-gnueabihf-gcc:

sxl@sxl-ubuntu:~$ sudo apt install gcc-arm-linux-gnueabi

  安装完成后使用如下命令查看两者版本

sxl@sxl-ubuntu:~$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --without-target-system-zlib --enable-libpth-m2 --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
sxl@sxl-ubuntu:~$ arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/9/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --without-target-system-zlib --enable-libpth-m2 --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-specs='%{mfloat-abi=hard:-march=armv7-a -mcpu=generic-armv7-a -mfloat-abi=hard}' --with-arch=armv5t --with-float=soft --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2) 

  或者进入/usr目录查看是否有以下文件:

   2. arm-none-linux-gnueabi-gcc
  可参考书籍《【正点原子】STM32MP1嵌入式Linux驱动开发指南V2.0.pdf》4.3 Ubuntu 交叉编译工具链安装
  安装完成后使用如下命令验证是否成功

sxl@sxl-ubuntu:/usr$ arm-none-linux-gnueabihf-gcc -v
使用内建 specs。
COLLECT_GCC=arm-none-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/sxl/gcc-arm-linux/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../libexec/gcc/arm-none-linux-gnueabihf/10.3.1/lto-wrapper
目标:arm-none-linux-gnueabihf
配置为:/data/jenkins/workspace/GNU-toolchain/arm-10/src/gcc/configure --target=arm-none-linux-gnueabihf --prefix= --with-sysroot=/arm-none-linux-gnueabihf/libc --with-build-sysroot=/data/jenkins/workspace/GNU-toolchain/arm-10/build-arm-none-linux-gnueabihf/install//arm-none-linux-gnueabihf/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-10/build-arm-none-linux-gnueabihf/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-10/build-arm-none-linux-gnueabihf/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-10/build-arm-none-linux-gnueabihf/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-10/build-arm-none-linux-gnueabihf/host-tools --with-arch=armv7-a --with-fpu=neon --with-float=hard --with-mode=thumb --with-arch=armv7-a --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
线程模型:posix
Supported LTO compression algorithms: zlib
gcc 版本 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 

3.6 安装相关软件

  1. VMware虚拟机使用主机VPN设置教程可参考:VMware Ubuntu虚拟机 使用主机VPN 配置(简单、可行)
  2. VScode:可参考教程

sxl@sxl-ubuntu:~/下载$ ls
code_1.97.2-1739406807_amd64.deb
sxl@sxl-ubuntu:~/下载$ sudo dpkg -i code_1.97.2-1739406807_amd64.deb 
[sudo] password for sxl: 
Selecting previously unselected package code.
(Reading database ... 259240 files and directories currently installed.)
Preparing to unpack code_1.97.2-1739406807_amd64.deb ...
Unpacking code (1.97.2-1739406807) ...
Setting up code (1.97.2-1739406807) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for shared-mime-info (1.15-1) ...
sxl@sxl-ubuntu:~/下载$ 

  因个人使用GitHub账号同步VScode配置,故需挂载上述VPN。

  3. Mobaxterm
  要在Win11系统上安装和使用Mobaxterm进行Linux的远程连接,您可以按照以下步骤操作:
   – 前往Mobaxterm官方网站:https://mobaxterm.mobatek.net/;在下载页面选择适用于Windows的版本并下载安装程序。执行安装程序并按照安装向导完成安装过程。
   – 启动Mobaxterm:安装完成后,启动Mobaxterm应用程序。
   – 创建一个新的远程连接会话:在Mobaxterm主界面上,点击"Session"(会话)按钮,然后选择"SSH"选项;在"Remote Host"(远程主机)栏中输入您要连接的Linux服务器的IP地址或主机名。输入端口号(通常为22)。在“Specify username”(指定用户名)中输入您在Linux服务器上的用户名。
   – 连接到Linux服务器:点击“OK”按钮,Mobaxterm 将尝试连接到您指定的Linux服务器。如果是首次连接,Mobaxterm 会提示您接受服务器的SSH密钥。选择接受并保存密钥。
   – 输入密码进行认证:输入您在Linux服务器上的密码进行认证。
   – 远程连接成功:如果一切正常,您将成功连接到Linux服务器,并且可以在Mobaxterm中执行Linux命令和操作。

3.7 调试串口

   1. 安装CH340驱动(CH341SER.EXE)并将开发板UART2通过TTL转USB(CH340G模块USB转TTL)连接至Windows。
   2. Mobexterm的Serial设置如下

  按下回车键登录如下:

myd-ld25x login: weston
myd-ld25x:~$ ls
wayland-1  wayland-1.lock  weston.log  weston-previous.log
myd-ld25x:~$

4. 开发板系统基础配置

4.1 更新软件源

  执行以下命令更新软件源:

root@myd-ld25x:~# apt update

The software package is provided AS IS, and by downloading it, you agree to be bound to the terms of
the software license agreement (SLA).
The detailed content licenses can be found at https://wiki.st.com/stm32mpu/wiki/OpenSTLinux_licenses.

Get:1 http://packages.openstlinux.st.com/5.1 mickledore InRelease [5,723 B]
Reading package lists... Done
E: Release file for http://packages.openstlinux.st.com/5.1/dists/mickledore/InRelease is not valid yet (invalid for another 699d 22h 26min 28s). Updates for this repository will not be applied.

  更新源需要 MYD-LD25X 连接互联网,请确保网络通畅。执行上述命令时,可能会出现以下问题导致更新错误:

E: Release file for http://packages.openstlinux.st.com/5.1/dists/mickledore/InRelease is not valid yet (invalid for another 1383d 8h 14min 14s). Updates for this repository will not be applied. 
E: Release file for http://extra.packages.openstlinux.st.com/AI/5.1/dists/mickledore/InRelease is not valid yet (invalid for another 1381d 8h 10min 47s). Updates for this repository will not be applied.

  出现上述问题的原因是当前开发板时间没有和网络时间成功同步,执行以下操作同步网络时间,首先修改 timesyncd.conf 配置文件,新增 FallbackNTP 授时中心网站,按如下所示修改:

# vi /etc/systemd/timesyncd.conf
... 
[Time]
#NTP=
FallbackNTP=ntp.ntsc.ac.cn cn.ntp.org.cn
...

  然后输入如下命令重启同步时间服务:

# systemctl restart systemd-timesyncd

  再次输入 date 查看时间是否成功更新,根据网络情况不同部分情况可能需要一定时间同步:

root@myd-ld25x:/etc/systemd# date
2025年 03月 09日 星期日 12:55:19 CST
root@myd-ld25x:/etc/systemd# date
2025年 03月 09日 星期日 12:55:22 CST

  再次更新软件:

root@myd-ld25x:/etc/systemd# apt update

The software package is provided AS IS, and by downloading it, you agree to be bound to the terms of
the software license agreement (SLA).
The detailed content licenses can be found at https://wiki.st.com/stm32mpu/wiki/OpenSTLinux_licenses.

Get:1 http://packages.openstlinux.st.com/5.1 mickledore InRelease [5,723 B]
Get:2 http://packages.openstlinux.st.com/5.1 mickledore/main arm64 Packages [725 kB]
Get:3 http://packages.openstlinux.st.com/5.1 mickledore/updates arm64 Packages [38.5 kB]
Get:4 http://packages.openstlinux.st.com/5.1 mickledore/untested arm64 Packages [1,338 kB]
Fetched 2,107 kB in 33s (63.9 kB/s)
Reading package lists... Done
Building dependency tree... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
root@myd-ld25x:/etc/systemd# apt upgrade
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libssh4
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 183 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://packages.openstlinux.st.com/5.1 mickledore/untested arm64 libssh4 arm64 0.10.5-r0 [183 kB]
Fetched 183 kB in 4s (49.0 kB/s)

The software package is provided AS IS, and by downloading it, you agree to be bound to the terms of
the software license agreement (SLA).
The detailed content licenses can be found at https://wiki.st.com/stm32mpu/wiki/OpenSTLinux_licenses.

(Reading database ... 20339 files and directories currently installed.)
Preparing to unpack .../libssh4_0.10.5-r0_arm64.deb ...
Unpacking libssh4 (0.10.5-r0) over (0.9.5-r0~tttech1) ...
Setting up libssh4 (0.10.5-r0) ...

4.2 vim修改

  配置修改Vim编辑器中TAB键的缩进长度
  有时候在使用vim编辑器进行编辑时发现,tab键的缩进长度太大,造成代码阅读编辑不方便,可以按照以下步骤配置修改vim编辑器的tab键缩进。

  1)使用vim打开配置文件~/.vimrc。(如果该文件不存在可以自己新建一个)
  2)在文件的末尾添加新行,内容如下:

set tabstop=4
set shiftwidth=4
set expandtab

  这里是设置制表符宽度和缩进宽度均为4,并将制表符转换为空格。
  3)保存后退出。
  4)使用source ~/.vimrc命令使得修改生效。

4.3 Ubuntu和开发板之间的文件互传

  此处通过桥接网络实现虚拟机Ubuntu20.04与MYC-LD257之间的文件传输和SSH调试。
  1. 通过ssh root@192.168.5.9命令进行连接。SSH 首次连接到该主机时,会提示你确认目标主机的身份,以防出现中间人攻击。此时显示了该主机的 RSA 密钥指纹(fingerprint),你可以通过核对开发板上的实际 RSA 密钥指纹来验证其真实性。
  输入了 yes,因此 SSH 将目标主机的密钥永久存储到你的 ~/.ssh/known_hosts 文件中,并继续尝试连接。

sxl@sxl-ubuntu:~$ ssh root@192.168.5.9
The authenticity of host '192.168.5.9 (192.168.5.9)' can't be established.
RSA key fingerprint is SHA256:/++/HeyJpPsfPad3vn5lp/beP5UCFpecv8kS2TsKghY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.5.9' (RSA) to the list of known hosts.

  如果重新烧录了开发板的系统,需要删除旧的主机密钥后再次连接即可:

sxl@sxl-ubuntu:~$ ssh-keygen -f "/home/sxl/.ssh/known_hosts" -R "192.168.5.9"
# Host 192.168.5.9 found: line 1
/home/sxl/.ssh/known_hosts updated.
Original contents retained as /home/sxl/.ssh/known_hosts.old
sxl@sxl-ubuntu:~$ ssh root@192.168.5.9
The authenticity of host '192.168.5.9 (192.168.5.9)' can't be established.
RSA key fingerprint is SHA256:CYFpOVrQZ91+rU/zXlpmIuVuhrm+zpqfW7+AUurbBCY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.5.9' (RSA) to the list of known hosts.
root@myd-ld25x:~# ls

  2. shell终端会出现MYC-LD257调试终端。

root@myd-ld25x:~# ls
README-CHECK-GPU

  3. 虚拟机Ubuntu20.04与MYC-LD257之间的文件传输可通过scp指令实现。scp(secure copy)指令是一种在不同主机之间进行文件传输的安全手段,基于SSH协议。使用scp时,文件可以加密方式在本地和远程主机之间或者两台远程主机之间传输。具体可参考:使用 scp 指令互传(一种在不同主机之间进行文件传输的安全手段,基于SSH协议)
  本处测试将下述的hello_world文件传输至开发板并执行:

sxl@sxl-ubuntu:~/code/Hello_World_Test$ scp /home/sxl/code/Hello_World_Test/hello_world root@192.168.5.9:/home/user_code/hello_world_test
hello_world                                   100%   75KB   1.2MB/s   00:00

  传输完成下方会出现文件传输详情。

root@myd-ld25x:/home/user_code/hello_world_test# ls
root@myd-ld25x:/home/user_code/hello_world_test# ls
hello_world
root@myd-ld25x:/home/user_code/hello_world_test# chmod +x hello_world 
root@myd-ld25x:/home/user_code/hello_world_test# ./hello_world xiaolong
Hello, xiaolong!

  传输后可查看文件夹是否有hello_world文件。赋予文件可执行权限后便可在MYC-LD257执行该程序。

5. 系统镜像烧录

   米尔公司设计的 MYD-LD25X 系列开发板是基于 ST 公司 的 STM32MP257 系列微处理器,其启动方式多样,所以需要不同的更新工具与方法。用户可以根据需求选择不同的方式进行更新。更新方式主要有以下几种:
   – 通过 STM32CubeProgrammer:是一种 Windows 软件,可以通过 typeC 直接连接开发板进行烧录,无需其他存储介质。
   – 制作 TF 卡启动器:适用于研发调试,快速启动等场景,启动器并不能烧录镜像。
   – 制作 TF 卡烧录器:适用于批量生产烧写 emmc。
  此处只介绍如何使用Windows系统进行烧录系统镜像。

5.1 STM32CubeProgrammer 工具烧录

  1. STM32CubeProgrammer
   STM32CubeProgrammer 是 ST Microelectronics 提供的一款用于管理 STM32 微控制器的通用软件工具。它提供了多种功能,包括芯片烧录、擦除(擦除 flash)、读取和保护设置的功能,同时它的前身是 ST-LINK Utility。
   支持从 STM32 微控制器读取 Flash 和 RAM 内容,用于验证和备份程序和数据。允许设置 STM32 芯片的安全功能,包括读保护、写保护和加密功能,以确保程序和数据的安全性和完整性。
   下载路径:STM32CubeProgrammer软件下载
  2. 烧录系统镜像
   – 开发板连接 PC:首先将 TypeC USB 线连接开发板的 J3 USBOTG 接口和 PC 主机,并且将拨码调整为表 1-1 的 TypeC USB 下载模式(拨码开关0000),然后上电启动。
   – 配置 STM32CubeProgrammer下载模式并连接
  打开 STM32CubeProgrammer软件,点击下图位置并调整为 USB 连接。点击下图中的刷新按钮,如果上述操作无误,那么会在左边显示 USB1 的端口已识别成功,如果没有成功识别到端口,请检查上述准备操作是否有误,或者可以更换 typeC线。重新操作一遍。最后点击 Connect 连接即可。
   – 烧录镜像
  此处将以 myir-image-full 烧录到 eMMC 为例,仅供参考,烧录其他镜像时请根据实际情况修改部分配置:

  点击 Open file 并且选择 02-Images/8E2D/myir-image-full/flashlayout_myir-image-full/optee/FlashLayout_emmc_myb-stm32mp257x-2GB-optee.tsv,如果需要将 full 镜像烧录到 TF 卡中,首先是需要将 TF 卡接入开发板,然后这里选择 FlashLayout_sdcard_myb-stm32mp257x-2GB-optee.tsv 文件,这里以烧录 eMMC 为例,myir-image-core 同理。

  选择完成后会根据 tsv 自动加载需要烧录的文件和对应的偏移,然后修改下方的Binaries path 路径,路径为 02-Images/8E2D/myir-image-full/的绝对路径,点击右边的Browse 选择 myir-image-full 目录即可。
  选择完成后直接点击上方的 Download 开始下载即可,烧录完成后会弹窗提示完成,完成后点击 Disconnect 后完成镜像烧录。

5.2 Win32DiskImager 工具烧录

  1. Win32 DiskImager
  Win32 DiskImager 工具用于将.sdcard 后缀的镜像快速烧录到 TF 卡之中,并且需要将 TF 卡接入读卡器并连接到 PC Windows 下,后续章节会介绍关于工具的获取和使用。
  请确保 Windows 的文件资源管理器下文件扩展名已经被勾选,这能确保用户在烧录镜像时能够准确判断镜像的类型。
  Win32 DiskImager 工具是一种开源的工具,可以从网络中获取,如果想使用和本文中同版本的软件,可以从 MYD-LD25X 的发布资料中获取,工具压缩包的目录位置在 03-Tools/Win32 DiskImager,使用前需要先解压。

  能够使用 Win32 DiskImager 工具的镜像有如下选择,这些镜像都位于 02-Images中:

  其中 myir-image-full、myir-image-core 镜像,用于烧录到 TF 卡中,用来做开发板的启动、测试、软件调试,并不能将镜像烧录到 eMMC 中;myir-image-burn 镜像,用于烧录到 TF 卡中,然后将其中包含在内部的 full 镜像自动烧录到 eMMC 中,是便于量产的一种自动烧录镜像。
  2. 烧录系统镜像
   – 制作 TF 卡启动器
   点击下图中①的位置选择 TF 卡的设备分区,如果 TF 卡有多个分区,则选择第一个分区即可。然后在点击图中②的位置进入选择镜像文件的界面:

   选择好镜像后点击 Write,再点击 Yes 开始烧录:

   烧录完成,弹出成功窗口:

   当写入完成后,即可使用此 TF 进行启动,将 TF 插入开发板 TF 卡槽;并将拨码开关调至 TF 卡启动即可启动系统。
   – 制作 TF 卡烧录器
  为满足生产烧录的需要,米尔开发了适用于大批量生产的烧录方法。具体制作过程请按照下列步骤完成。
  Burn 镜像的制作:myir-image-burn 镜像需要通过 Yocto 制作完成,具体详细制作过程请查看《MYD-LD25X Linux 软件开发指南》5.3.3 章节内容。也可以直接通过发布资料中 02-Images 下分别获取适用于 Win32DiskImager 工具烧录的 myir-image-burn 镜像;
  将 burn 镜像烧写进 TF 卡:具体操作基本类似 3.3.1 章节的操作步骤,唯一区别就是需要将烧录的文件替换为 eMMC 的对应 myir-image-burn 镜像文件。
  烧录镜像到 eMMC:完成上述操作后,设置拨码开关为 TF 卡方式启动,将 TF 插入开发板的 TF 卡槽,插上电源。系统启动后开始自动烧写镜像至 eMMC。可以接上 J15 串口(贴近网口的 TTL串口)查看烧录状态。这里需要注明 burn 镜像的烧录过程中 User 灯的状态,方便在没有串口的情况下也能监控烧录进度。在开发板正常运行时 User 蓝灯处于心跳灯状态,也就是两闪一灭,当进入烧录状态是一亮一灭,当烧录完成后,User 灯会保持常亮,当烧录出现异常失败时,User 灯则会保持熄灭状态。
  当串口打印烧录成功或者 User 灯常亮后,需要拔掉 TF 卡然后调整拨码从 eMMC 重新启动:

6. 开发入门

6.1 hello-world

  此阶段介绍如何使用新安装的 SDK 创建、构建和执行简单的 C 代码应用程序。
   1. 创建一个将托管源代码的目录,后续代码全部存放在~/code路径下

sxl@sxl-ubuntu:~$ mkdir ~/code

   2. 为您的用户空间创建目录示例。

sxl@sxl-ubuntu:~$ mkdir ~/code/Hello_World_Test

  3. 为您的用户空间示例创建源代码文件:hello_world.c

#include <stdio.h>
/* 执行命令: ./hello weidongshan 
 2. argc = 2
 3. argv[0] = ./hello
 4. argv[1] = weidongshan
 */
int main(int argc, char **argv)
{
	if (argc >= 2)
		printf("Hello, %s!\n", argv[1]);
	else
		printf("Hello, world!\n");
	return 0;
}

  4. 测试X86_64 平台、Ubuntu 系统下的 HelloWorld
  Ubuntu 默认安装 GCC 编译工具链,写好程序后可以直接进行编译,请尝试执行以下命令:

sxl@sxl-ubuntu:~/code/Hello_World_Test$ gcc -o hello_world hello_world.c
sxl@sxl-ubuntu:~/code/Hello_World_Test$ ls
hello_world  hello_world.c
sxl@sxl-ubuntu:~/code/Hello_World_Test$ ./hello_world
Hello, world!

  执行 gcc 编译命令后看到目录下生成了一个可执行文件 hello,然后通过“./”符号加上程序的名字即可运行,此处的“.”表示当前目录,所以当我们想运行一个可执行程序的时候,输出它的路径名即可执行。hello 程序运行时代码中 printf 的内容直接输出到了终端。
  可以通过readelf -h hello_world命令查看输出可执行文件hello_world可以运行环境的系统架构: Advanced Micro Devices X86-64。

sxl@sxl-ubuntu:~/code/Hello_World_Test$ readelf -h hello_world
ELF 头:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  类别:                              ELF64
  数据:                              2 补码,小端序 (little endian)
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI 版本:                          0
  类型:                              DYN (共享目标文件)
  系统架构:                          Advanced Micro Devices X86-64
  版本:                              0x1
  入口点地址:               0x1080
  程序头起点:          64 (bytes into file)
  Start of section headers:          14760 (bytes into file)
  标志:             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         13
  Size of section headers:           64 (bytes)
  Number of section headers:         31
  Section header string table index: 30

   5. ARM 平台、Debian 系统下的 HelloWorld
   上述命令编译得到的可执行程序 hello 可以在 Ubuntu 中运行,但是如果把它放到 ARM 板子上去,它是无法执行的。因为它是使用 gcc 编译的,是给 PC 机编译的,里面的机器指令是 x86 的。我们要想给 ARM 板编译出 hello 程序,需要使用交叉编译工具链。

sxl@sxl-ubuntu:~/code/Hello_World_Test$ ls
hello_world  hello_world.c
sxl@sxl-ubuntu:~/code/Hello_World_Test$ $CC -o hello hello_world.c
sxl@sxl-ubuntu:~/code/Hello_World_Test$ ls
hello  hello_world  hello_world.c
sxl@sxl-ubuntu:~/code/Hello_World_Test$ readelf -h hello
ELF 头:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  类别:                              ELF64
  数据:                              2 补码,小端序 (little endian)
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI 版本:                          0
  类型:                              EXEC (可执行文件)
  系统架构:                          AArch64
  版本:                              0x1
  入口点地址:               0x400680
  程序头起点:          64 (bytes into file)
  Start of section headers:          74904 (bytes into file)
  标志:             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         11
  Size of section headers:           64 (bytes)
  Number of section headers:         37
  Section header string table index: 36

  此处检查文件夹中包含hello_world.c和X86-64架构下的可执行文件hello_world,使用arm-none-linux-gnueabihf-gcc工具链将hello_world.c编译成ARM架构下的可执行文件hello,并检查文件是否生成和系统架构是否为AArch64(可参考解释x86-64、amd64、arm、aarch64 都是些什么?)。

  6.上传到开发板并运行
  检查可执行文件的权限当中包含x,表示可执行,具体Linux系统下的文件权限可参考Linux文件权限详解:

root@myd-ld25x:/home/user_code/hello_world_test# ls -l hello_world
-rwxr-xr-x 1 root root 77272  3月  2 16:13 hello_world

  如不包含x可使用下述命令后再次检查:

root@myd-ld25x:/home/user_code/hello_world_test# sudo chmod +x hello_world
root@myd-ld25x:/home/user_code/hello_world_test# ls -l hello_world
-rwxr-xr-x 1 root root 77272  3月  2 16:13 hello_world

  最后执行代码:

root@myd-ld25x:/home/user_code/hello_world_test# ./hello_world root
Hello, root!

6.2 板级支持包的单独编译和更新

6.2.1 板级支持包介绍

  为了适配用户新的硬件平台,首先需要了解米尔的 MYD-LD25X 开发板提供了哪些资源,具体的信息可以查看《MYD-LD25X SDK 发布说明》。除此之外我们也对 BSP 各个部分中需要改动的一些文件列表整理出来,方便用户查找和修改,具体内容如下表所示:

6.2.2 板载 BootLoader 编译与更新

  U-boot 是一个功能非常丰富的开源启动引导程序,包括内核引导,下载更新等众多方面,在嵌入式领域应用十分广泛,可查看官网获取更多信息 http://www.denx.de/wiki/U-Boot/WebHome;
此部分在编译时,必须运行交叉编译工具链。

source ~/MYIR-LD25x-ToolChain/environment-setup-cortexa35-ostl-linux

   1.编译 Bootloader
  MYD-LD25X-Uboot-L2022.10-V1.0.0 的目录结构:

$ ls -la
build/ 编译生成的文件目录
build-uboot-en.sh 英文构建脚本
build-uboot-zh.sh 中文构建脚本
deploy/ 部署用的文件目录
FIP_artifacts/ FIP 相关文件
fiptool-stm32mp STM32MP FIP 工具
Makefile.sdk SDK 编译规则文件
myir-st-external-dt/ U-Boot 的外部设备树文件
myir-st-optee/ OP-TEE 文件目录
myir-st-u-boot/ U-Boot 源码目录
output/ fip 最终文件输出目录
README_en README 英文版本
README_zh README 中文版本

  运行一键编译脚本,将会自动编译。

sxl@sxl-ubuntu:~/myir/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Uboot-L2022.10-V1.1.0/Bootloader$ source ~/myd-ld25x-toolchain/environment-setup-cortexa35-ostl-linux
sxl@sxl-ubuntu:~/myir/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Uboot-L2022.10-V1.1.0/Bootloader$ ./build-uboot-zh.sh 
-----------------------------------------------------------------------------脚本开始运行---------------------------------------------------------------------------------
编译链正常
请选择需要构建的ddr大小配置(1/2):
1 - 1GB型号 适用于MYD-LD257-8E1D
2 - 2GB型号 适用于MYD-LD257-8E2D
请输入选择 (1 或 2): 2
正在运行 compile_2GB...
2GB 构建开始
**************
* 开始配置Uboot. *
**************
[██████████████████████████████████████████████████] 100%
**************
* 开始编译Uboot. *
**************
[██████████████████████████████████████████████████] 100%
**************
* 开始配置Optee. *
**************
[██████████████████████████████████████████████████] 100%
**************
* 开始构建Fip文件. *
**************
[██████████████████████████████████████████████████] 100%
**********************************************************************************************************************
* 编译完成,fip文件位于/home/sxl/myir/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Uboot-L2022.10-V1.1.0/Bootloader/output *
**********************************************************************************************************************

  最后编译完成的文件会保存在和脚本同级目录的 output 中,内容如下:

sxl@sxl-ubuntu:~/myir/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Uboot-L2022.10-V1.1.0/Bootloader$ ls output/ -l
总用量 5568
-rw-rw-r-- 1 sxl sxl 2848046 3月   5 14:30 fip-myb-stm32mp257x-2GB-optee-emmc.bin
-rw-rw-r-- 1 sxl sxl 2848046 3月   5 14:30 fip-myb-stm32mp257x-2GB-optee-sdcard.bin

   2. 更新 Bootloader
   此处先通过Ubuntu系统将fip-myb-stm32mp257x-2GB-optee-emmc.bin文件上传至开发板/home/root文件夹:

sxl@sxl-ubuntu:~/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Uboot-L2022.10-V1.1.0/Bootloader/output$ scp ~/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Uboot-L2022.10-V1.1.0/Bootloader/output/fip-myb-stm32mp257x-2GB-optee-emmc.bin root@192.168.5.9:/home/root
fip-myb-stm32mp257x-2GB-optee-emmc.bin        100% 2781KB   7.1MB/s   00:00

   再打开开发板的SSH连接查看是否上传成功

sxl@sxl-ubuntu:~$ ssh root@192.168.5.9
root@myd-ld25x:~# ls
fip-myb-stm32mp257x-2GB-optee-emmc.bin	README-CHECK-GPU

  在开发板串口调试串口执行即可完成Bootloader更新

root@myd-ld25x:~# dd if=fip-myb-stm32mp257x-2GB-optee-emmc.bin of=/dev/mmcblk1p3 bs=1M conv=fsync
2+1 records in
2+1 records out
2848046 bytes (2.8 MB, 2.7 MiB) copied, 0.011613 s, 245 MB/s
root@myd-ld25x:~# dd if=fip-myb-stm32mp257x-2GB-optee-emmc.bin of=/dev/mmcblk1p4 bs=1M conv=fsync
2+1 records in
2+1 records out
2848046 bytes (2.8 MB, 2.7 MiB) copied, 0.0122781 s, 232 MB/s

dd:用于在Unix和类Unix系统上复制和转换文件的命令行工具。
if=fip-myb-stm32mp257x-2GB-optee-emmc.bin:指定输入文件(if)。在这个例子中,它是一个名为 fip-myb-stm32mp257x-2GB-optee-emmc.bin 的二进制文件。
of=/dev/mmcblk1p3:指定输出文件(of)。在这里,它是一个设备,可能是eMMC存储芯片上的一个分区,由 /dev/mmcblk1p3 标识。
bs=1M:将块大小设置为1兆字节(bs)。这指定了dd一次读写的数据量,可以影响性能。
conv=fsync:这个选项确保输出文件在完成后被完全同步到磁盘。这意味着所有写入的数据在dd命令完成前被物理写入存储设备。

6.2.3 板载 Kernel 编译与更新

  Kernel 内核是操作系统的核心,负责管理硬件资源和系统服务。它处理进程管理、内存分配、设备驱动、文件系统等关键任务。内核在系统启动时加载,确保硬件和软件能够顺利配合。常见的开源内核如 Linux 内核,广泛应用于各种设备,从嵌入式系统到服务器。
   1. 编译Kernel
  MYD-LD25X-Linux-L6.1.82-V1.0.0 的目录结构:

sxl@sxl-ubuntu:~/myir/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Linux-L6.1.82-V1.1.0$ ls
build-linux-en.sh  linux 源码,其中包含了完整的 Linux 源码
build-linux-zh.sh  一键编译脚本,中文提示
myir-st-linux  一键编译脚本,英文提示
README_en  中文说明文档
README_zh  英文说明文档

  运行一键编译脚本,将会自动解压源码包并编译,此处使用./build-linux-zh -h查看参数。

sxl@sxl-ubuntu:~/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Linux-L6.1.82-V1.1.0$ ./build-linux-zh.sh -h
参数提示: ./build-linux-zh.sh [-h] [y/n] [y/n] [y/n]
选项:
  -h    打印帮助信息
  -c    Clean编译内容
参数:
  y/n   选择是否执行该任务 (y: 是, n: 否)
 第一个参数为编译内核
 第二个参数为编译设备树
 第三个参数为编译模块modules
 可自选执行,例如./build-linux-zh.sh n y n单独构建设备树
 不配置参数直接执行默认编译全部内容

   此处全部编译./build-linux-zh.sh y y y

sxl@sxl-Ubuntu:/media/sxl/HD1/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Linux-L6.1.82-V1.1.0$ ./build-linux-zh.sh y y y

请输入编译的线程个数:12
检测到myir-st-linux目录存在,跳过解压步骤
Toolchain OK
开始配置内核
开始编译内核
[██████████████████████████████] 100%
编译完成
开始构建设备树
[██████████████████████████████] 100%
编译完成
开始编译模块
[██████████████████████████████] 100%
编译完成
开始安装模块到modules目录
构建完成,输出目录为:/media/sxl/HD1/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Linux-L6.1.82-V1.1.0/output

最后编译完成的文件会保存在和脚本同级目录的 output 中,内容如下:

sxl@sxl-Ubuntu:/media/sxl/HD1/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Linux-L6.1.82-V1.1.0$ ls output/ -l
总用量 87184
-rw-rw-r-- 1 sxl sxl 27679232 3月  10 10:11 Image
-rw-rw-r-- 1 sxl sxl 11418831 3月  10 10:11 Image.gz
-rw-rw-r-- 1 sxl sxl 49827840 3月  10 10:12 modules.tar.gz
-rw-rw-r-- 1 sxl sxl   116331 3月  10 10:11 myb-stm32mp257x-1GB.dtb
-rw-rw-r-- 1 sxl sxl   116426 3月  10 10:11 myb-stm32mp257x-1GB-ethswitch.dtb
-rw-rw-r-- 1 sxl sxl   116319 3月  10 10:11 myb-stm32mp257x-2GB.dtb
-rw-rw-r-- 1 sxl sxl   116426 3月  10 10:11 myb-stm32mp257x-2GB-ethswitch.dtb

   2. 更新 Kernel
  本章节描述的文件单独烧录方式为开发板上使用命令烧录,也可以使用 STM32Cube Programmer 工具在 PC 通过 TypeC 直接连接开发板烧录,STM32CubeProgrammer 工具的烧录方法请查阅《MYD-LD25X 量产指导手册》。如下操作中 mmcblk1 为 eMMC 分区,mmcblk0 为 TF 卡分区。
   – 替换 Image.gz 到 eMMC 开发板或者 TF 卡
   将编译好的 Image.gz 拷贝到 eMMC 开发板,可以通过 scp 或者存储介质如 U 盘等传输到开发板,这里以 scp 为例,在开发板串口调试串口执行,替换前最好按照如下操作备份:

# cd /boot
# mv Image.gz bak-Image.gz
# scp beste@192.168.40.21:~/scpfile/Image.gz /boot
# ls /boot
# bak-Image.gz
# Image.gz
.......

   TF 卡启动的系统替换 Image 基本与上述一致
   – 替换设备树到 eMMC 开发板或者 TF 卡
   将编译好的 output 目录下的 dtb 文件拷贝到 eMMC 开发板,所有设备树文件拷贝方式和下文中的操作类似,这里以 myb-stm32mp257x-2GB.dtb 为参考。可以通过 scp 或者存储介质如 U 盘等传输到开发板,这里以 scp 为例,在开发板串口调试串口执行,替换前最好按照如下操作备份:

# cd /boot
# mv myb-stm32mp257x-2GB.dtb bak-myb-stm32mp257x-2GB.dtb
# scp beste@192.168.40.21:~/scpfile/myb-stm32mp257x-2GB.dtb /boot
# ls /boot
...... myb-stm32mp257x-2GB.dtb
bak-myb-stm32mp257x-2GB.dtb
......

   – 更新 Module 到开发板
  更新 modules 模块,首先将/lib/modules/6.1.82*备份到 linux-bak,然后将编译好的 modules.tar.gz 解压到根目录就可以完成更新。

# cp /lib/modules/6.1.82* ~/linux-bak -rf
# rm /lib/modules/6.1.82* -rf
# scp beste@192.168.40.21:/media/sxl/HD1/User_Code/MYD-LD25X-Distribution-L6.1.82-V1.1.0/MYD-LD25X-Linux-L6.1.82-V1.1.0/output/modules.tar.gz  /lib/modules
# tar xf modules.tar.gz -C / > /dev/null 2>&1

作者:会充电的皮卡丘

物联沃分享整理
物联沃-IOTWORD物联网 » STM32MP257(MYC-LD257)开发环境配置详解与学习笔记

发表回复