前言
在工业4.0与边缘计算深度融合的今天,STM32MP257F作为意法半导体第二代工业级64位微处理器的旗舰产品,凭借异构计算架构、1.35 TOPS边缘AI算力和军工级安全特性,已成为工业自动化、机器视觉和新能源控制等领域的标杆方案。
-
性能跃迁的异构架构
搭载双核Cortex-A35(1.5GHz)与Cortex-M33(400MHz)的异构计算引擎,完美平衡高性能运算与硬实时控制需求:
-
边缘AI的落地实践
内置VeriSilicon GC8000UL NPU的1.35 TOPS算力,配合TensorFlow Lite/ONNX框架支持,可部署机器视觉质检、预测性维护等AI模型:
该处理器已成功应用于国产PLC控制系统(支持EtherCAT总线与32轴同步控制)、储能EMS系统(通过CAN FD实现毫秒级BMS通信)、以及智能充电桩(集成LVDS触控与支付模块)等场景。本文将以Yocto定制开发为主线,开启STM32MP257F开发之旅。
文章目录
材料准备
开发环境:Ubuntu22.04.5
开发版本选择
官方提供三个版本的开发包,选择建议参考:
功能维度 | Starter Package (入门包) | Developer Package (开发者包) | Distribution Package (发行包) |
---|---|---|---|
定位 | 开箱即用,快速验证功能 | 深度定制化开发 | 企业级产品化开发 |
核心特点 | - 预编译镜像 - 无需编译环境 - 功能受限 | - 全源码开放 - 支持驱动/内核修改 - 提供交叉编译工具 | - 基于Yocto定制系统 - AI/RT扩展包 - 安全启动/OTA |
适用场景 | 开发板初体验;原型展示;硬件快速验证 | 二次开发(传感器驱动等);内核优化;多核通信 | 工业产品(HMI/AI网关);团队私有仓库;安全认证项目 |
技术门槛 | 低(零基础可用) | 中(需嵌入式开发经验) | 高(需系统架构经验) |
源码/工具支持 | 仅二进制镜像 | 开源代码+SDK | 开源代码+扩展包+企业级工具链 |
典型用户 | 学生/方案演示者 | 开发者/小型团队 | 企业研发团队 |
硬件扩展性 | 仅支持官方配置 | 可适配同系列芯片 | 支持多平台移植 |
或者参考官方说明。
本文以Distribution Package (发行包)
为例
实操过程
安装开发环境
开发环境可以直接安装物理机也可以安装虚拟机,也可以使用虚拟机安装,考虑到性能问题,本文选择直接安装物理机。注意版本一定要选择Ubuntu22.04.5
进入Ubuntu22系统,首先需要配置一些基础环境,参考官方推荐。
关于网络问题可以借鉴这个
安装STM32CubeProgramer
,后续要用来烧录镜像,参考官方教程
获取仓库源码
新建一个本地工作目录,推荐使用~/STMicroelectronics/Distribution-Package
bash
mkdir ~/STMicroelectronics/Distribution-Package
cd ~/STMicroelectronics/Distribution-Package
通过repo
来拉取远程仓库到本地(注:repo
是和git
类似的版本管理工具,适合操作较大的仓库)
bash
repo init -u https://github.com/STMicroelectronics/oe-manifest -b refs/tags/openstlinux-6.6-yocto-scarthgap-mpu-v24.12.05
repo sync
编译镜像
首先source
一下开发环境
bash
DISTRO=openstlinux-weston MACHINE=stm32mp25-eval source layers/meta-st/scripts/envsetup.sh
执行下面的命令,使用yocto编译st-image-weston
镜像
bash
bitbake st-image-weston
如果看到如下界面,说明可以成功开始编译

添加模块
官方原版的系统为了最小化镜像大小,把很多不常用的模块都去除了,例如git
。如果需要用到这些模块,可以按照如下步骤进行添加:
编辑local.conf
文件
bash
nano conf/local.conf
在文件最后添加需要的模块,例如需要添加git
、nano
、tmux
等模块
bash
IMAGE_INSTALL:append = " \
git \
tmux \
nano \
"
编译过程如果提示ERROR: st-image-weston-1.0-r0 do_image_tar: The rootfs size 1277996(K) exceeds IMAGE_ROOTFS_MAXSIZE: 1000000(K)
,说明添加模块之后导致整个镜像大小超过了限制,可以在conf/local.conf
最后添加下面的命令,增加大小限制到1000000 kB
bash
IMAGE_ROOTFS_MAXSIZE = "1000000"
继续使用yocto重新编译st-image-weston
镜像
bash
bitbake st-image-weston -c cleanall
编译完成后的文件结构如下:
bash
acc@acc-server:~/STMicroelectronics/Distribution-Package/build-openstlinuxweston-stm32mp25-eval/tmp-glibc/deploy/images/stm32mp25-eval$ pwd
/home/acc/STMicroelectronics/Distribution-Package/build-openstlinuxweston-stm32mp25-eval/tmp-glibc/deploy/images/stm32mp25-eval
acc@acc-server:~/STMicroelectronics/Distribution-Package/build-openstlinuxweston-stm32mp25-eval/tmp-glibc/deploy/images/stm32mp25-eval$ tree -L 1
.
├── arm-trusted-firmware
├── arm-trusted-firmware-m
├── fip
├── flashlayout_st-image-weston
├── kernel
├── optee
├── scripts
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.ext4
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.manifest
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.spdx.tar.zst
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.tar.xz
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.testdata.json
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs.ext4 -> st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.ext4
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs.manifest -> st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.manifest
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs.spdx.tar.zst -> st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.spdx.tar.zst
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs.tar.xz -> st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.tar.xz
├── st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs.testdata.json -> st-image-bootfs-openstlinux-weston-stm32mp25-eval.bootfs-20250425080741.testdata.json
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.cpio.gz
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.manifest
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.spdx.tar.zst
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.testdata.json
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs.cpio.gz -> st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.cpio.gz
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs.manifest -> st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.manifest
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs.spdx.tar.zst -> st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.spdx.tar.zst
├── st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs.testdata.json -> st-image-resize-initrd-openstlinux-weston-stm32mp25-eval.rootfs-20250425080741.testdata.json
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.ext4
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.manifest
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.spdx.tar.zst
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.tar.xz
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.testdata.json
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs.ext4 -> st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.ext4
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs.manifest -> st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.manifest
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs.spdx.tar.zst -> st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.spdx.tar.zst
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs.tar.xz -> st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.tar.xz
├── st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs.testdata.json -> st-image-userfs-openstlinux-weston-stm32mp25-eval.userfs-20250425080741.testdata.json
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.ext4
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.manifest
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.spdx.tar.zst
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.tar.xz
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.testdata.json
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs.ext4 -> st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.ext4
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs.manifest -> st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.manifest
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs.spdx.tar.zst -> st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.spdx.tar.zst
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs.tar.xz -> st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.tar.xz
├── st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs.testdata.json -> st-image-vendorfs-openstlinux-weston-stm32mp25-eval.vendorfs-20250425080741.testdata.json
├── st-initrd-openstlinux-weston-stm32mp25-eval
└── u-boot
8 directories, 39 files
下载到板子
通过开发板的OTG
口连接到PC,同时通过USB_PWR
口进行供电。注意:供电口尽量使用type-C转type-C
的线,否则可能出现供电不足导致无法启动
使用如下命令将镜像下载到板子
bash
acc@acc-server:~/STMicroelectronics/Distribution-Package/build-openstlinuxweston-stm32mp25-eval/tmp-glibc/deploy/images/stm32mp25-eval$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/optee/FlashLayout_sdcard_stm32mp257f-ev1-optee.tsv
-------------------------------------------------------------------
STM32CubeProgrammer v2.18.0
-------------------------------------------------------------------
USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in HS Mode @Device ID /0x505, @Revision ID /0x2000
SN : 002D001D4136500B00373653
DFU protocol: 1.1
Board : --
Device ID : 0x0505
Device name : STM32MP23xx/25xx
Device type : MPU
Revision ID : --
Device CPU : Cortex-A35
Start Embedded Flashing service
Opening and parsing file: tf-a-stm32mp257f-ev1-optee-programmer-usb.stm32
Memory Programming ...
File : tf-a-stm32mp257f-ev1-optee-programmer-usb.stm32
Size : 198.95 KB
Partition ID : 0x01
Download in Progress:
^C================================= ] 68%
使用UART连接到开发板
将供电口同时也是ST-LINK
口连接到带有串口助手的PC,这里的串口命令行软件使用的是Putty
,打开对应串口,同时板子已经上电,就能在软件上看到系统启动信息,等待启动完成
开发板联网
为了让开发板连接到网络,这里连接上以太网,同时将PC的互联网连接共享到以太网口。
具体参考
开发板时间配置
如果直接使用apt update
,会提示如下错误
bash
root@stm32mp25-eval-e3-e0-f5:~# 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/6.0 scarthgap InRelease [5724 B]
Reading package lists... Done
E: Release file for http://packages.openstlinux.st.com/6.0/dists/scarthgap/InRelease is not valid yet (invalid for another 301d 18h 9min 33s). Updates for this repository will not be applied.
具体原因是本机系统时间和互联网时间没有对应,需要手动设置本机时间
bash
date -s "2025-04-25 16:04:00"
重新尝试apt update
即可
本文完!
参考
https://wiki.st.com/stm32mpu/index.php/STM32MPU_Distribution_Package
https://www.st.com/en/embedded-software/stm32mp2distrib.html#documentation