STM32MPU开发之旅:从零开始构建嵌入式Linux镜像

前言

在工业4.0与边缘计算深度融合的今天,STM32MP257F作为意法半导体第二代工业级64位微处理器的旗舰产品,凭借异构计算架构、1.35 TOPS边缘AI算力和军工级安全特性,已成为工业自动化、机器视觉和新能源控制等领域的标杆方案。

  1. 性能跃迁的异构架构
    搭载双核Cortex-A35(1.5GHz)与Cortex-M33(400MHz)的异构计算引擎,完美平衡高性能运算与硬实时控制需求:

  2. 边缘AI的落地实践
    内置VeriSilicon GC8000UL NPU的1.35 TOPS算力,配合TensorFlow Lite/ONNX框架支持,可部署机器视觉质检、预测性维护等AI模型:

该处理器已成功应用于国产PLC控制系统(支持EtherCAT总线与32轴同步控制)、储能EMS系统(通过CAN FD实现毫秒级BMS通信)、以及智能充电桩(集成LVDS触控与支付模块)等场景。本文将以Yocto定制开发为主线,开启STM32MP257F开发之旅。

文章目录

  • 前言
  • 材料准备
  • 开发版本选择
  • 实操过程
    • 安装开发环境
    • 获取仓库源码
    • 编译镜像
    • 添加模块
    • 下载到板子
    • 使用UART连接到开发板
    • 开发板联网
    • 开发板时间配置
  • 参考

材料准备

硬件:STM32MP257F-EV1
开发环境: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

mkdir ~/STMicroelectronics/Distribution-Package
cd ~/STMicroelectronics/Distribution-Package

通过repo来拉取远程仓库到本地(注:repo是和git类似的版本管理工具,适合操作较大的仓库)

repo init -u https://github.com/STMicroelectronics/oe-manifest -b refs/tags/openstlinux-6.6-yocto-scarthgap-mpu-v24.12.05
repo sync

编译镜像

首先source一下开发环境

DISTRO=openstlinux-weston MACHINE=stm32mp25-eval source layers/meta-st/scripts/envsetup.sh

执行下面的命令,使用yocto编译st-image-weston镜像

bitbake st-image-weston

如果看到如下界面,说明可以成功开始编译

在这里插入图片描述

添加模块

官方原版的系统为了最小化镜像大小,把很多不常用的模块都去除了,例如git。如果需要用到这些模块,可以按照如下步骤进行添加:

编辑local.conf文件

nano conf/local.conf

在文件最后添加需要的模块,例如需要添加gitnanotmux等模块

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

IMAGE_ROOTFS_MAXSIZE = "1000000"

继续使用yocto重新编译st-image-weston镜像

bitbake st-image-weston -c cleanall

编译完成后的文件结构如下:

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-evalacc@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-boot8 directories, 39 files

下载到板子

通过开发板的OTG口连接到PC,同时通过USB_PWR口进行供电。注意:供电口尽量使用type-C转type-C的线,否则可能出现供电不足导致无法启动

使用如下命令将镜像下载到板子

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-A35Start Embedded Flashing serviceOpening and parsing file: tf-a-stm32mp257f-ev1-optee-programmer-usb.stm32Memory Programming ...File          : tf-a-stm32mp257f-ev1-optee-programmer-usb.stm32Size          : 198.95 KB Partition ID  : 0x01 Download in Progress:
^C=================================                ]  68% 

使用UART连接到开发板

将供电口同时也是ST-LINK口连接到带有串口助手的PC,这里的串口命令行软件使用的是Putty,打开对应串口,同时板子已经上电,就能在软件上看到系统启动信息,等待启动完成

开发板联网

为了让开发板连接到网络,这里连接上以太网,同时将PC的互联网连接共享到以太网口。

具体参考

开发板时间配置

如果直接使用apt update,会提示如下错误

root@stm32mp25-eval-e3-e0-f5:~# apt updateThe 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.

具体原因是本机系统时间和互联网时间没有对应,需要手动设置本机时间

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
https://wiki.st.com/stm32mpu/index.php?title=Category:Yocto-based_OpenSTLinux_embedded_software&sfr=stm32mpu
https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/80452.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

大模型应用开发(PAFR)

Prompt问答 特征:利用大模型推理能力完成应用的核心功能 应用场景: 文本摘要分析 舆情分析 坐席检查 AI对话 AgentFunction Calling 特征:将应用端业务能力与AI大模型推理能力结合,简化复杂业务功能开发 应用场景: 旅行指南 数据…

SpringClound 微服务分布式Nacos学习笔记

一、基本概述 在实际项目中,选择哪种架构需要根据具体的需求、团队能力和技术栈等因素综合考虑。 单体架构(Monolithic Architecture) 单体架构是一种传统的软件架构风格,将整个应用程序构建为一个单一的、不可分割的单元。在这…

WebRTC服务器Coturn服务器用户管理和安全性

1、概述 Coturn服务器对用户管理和安全方面也做了很多的措施,以下会介绍到用户方面的设置 1.1、相关术语 1.1.1 realm 在 coturn 服务器中,域(realm)是一种逻辑上的分组概念,用于对不同的用户群体、应用或者服务进行区…

基于opencv和PaddleOCR识别身份证信息

1、安装组件 pip install --upgrade paddlepaddle paddleocr 2、完整code import cv2 import numpy as np from paddleocr import PaddleOCR# 初始化 PaddleOCR use_angle_clsTrue, lang"ch", det_db_thresh0.1, det_db_box_thresh0.5)def preprocess_image(image…

【6】GD32 高级通信外设 CAN、USBD

高级通信外设:CAN、USBD CAN CAN简介、主要功能与相关API回环模式收发发送特定ID的数据帧实验CAN数据帧的接收实验使用过滤器接收特定的数据帧 USBD USB通信简介USBD设备固件库架构、分层文件与库函数说明USBD模拟键盘应用USBD虚拟串口应用USBD模拟U盘应用

【LLM+Code】Windsurf Agent 模式PromptTools详细解读

一、前言 https://windsurf.com/ https://windsurf.com/blog/why-we-built-windsurf https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools/tree/main/Windsurf 二、System Prompt 相比于cursor和claude code, windsurf的system prompt非常长&am…

安全性测试常规测试点全解析:从基础到高级的实战指南

引言 安全性测试是保障软件系统免受恶意攻击的核心环节,其目标是识别系统在设计、开发、部署过程中存在的安全漏洞。本文将围绕12大常规安全测试点展开,结合具体测试方法、示例代码及防范建议,帮助读者构建完整的安全测试体系。 一、认证与授权测试 1. 认证机制测试 测试…

OpenCV 图形API(55)颜色空间转换-----将图像从 RGB 色彩空间转换为 I420 格式函数RGB2I420()

操作系统:ubuntu22.04 OpenCV版本:OpenCV4.9 IDE:Visual Studio Code 编程语言:C11 算法描述 将图像从 RGB 色彩空间转换为 I420 色彩空间。 该函数将输入图像从 RGB 色彩空间转换为 I420。R、G 和 B 通道值的常规范围是 0 到 255。 输出图…

Pycharm(十六)面向对象进阶

一、继承 概述: 实际开发中,我们发现很多类中的步分内容是相似的,或者相同的,每次写很麻烦,针对这种情况, 我们可以把这些相似(相同的)部分抽取出来,单独地放到1个类中&…

Codeforces Round 1020 (Div. 3)(题解ABCDEF)

A. Dr. TC 有n次翻转,从1到n,0->1,1->0,每次统计1的数量,设cnt1是字符串1的数量,n次就是n*cnt1, 但每个1都会被翻转一次减去一个cnt1,再统计cnt0,每个被翻转一次,答案就是(n-1)*cnt1cnt0…

HTML字符实体和转义字符串

HTML字符实体和转义字符串用于处理特殊字符,确保它们在不同上下文中正确显示或解析。以下是详细总结: HTML字符实体(Character Entities) ‌定义‌:用于在HTML中表示保留字符或不可见字符,避免与HTML语法…

FreeRTOS菜鸟入门(六)·移植FreeRTOS到STM32

目录 1. 获取裸机工程模版 2. 下载 FreeRTOS V9.0.0 源码 3. FreeRTOS文件夹内容简介 3.1 FreeRTOS文件夹 3.1.1 Demo文件夹 3.1.2 License 文件夹 3.1.3 Source 文件夹 3.2 FreeRTOS-Plus 文件夹 4. 往裸机工程添加 FreeRTOS 源码 5. 拷贝 FreeRTOSConfig…

通过 Tailwind CSS 自定义样式 实现深色模式切换

创建vite项目或者vue-cli配置大同小异 1、当前环境 Vue.js 3.5nuxtjs/tailwindcss 6.13.1nuxt3.15.4node18 这里主要依赖是tailwindcss 因为当前项目是使用nuxt开发。 2、配置颜色模式 在assets/css下创建main.css * {padding: 0;margin: 0;box-sizing: border-box; }[dat…

PWNOS:2.0(vulnhub靶机)

文章目录 靶机地址主机发现、端口扫描web渗透目录探测漏洞利用权限提升 解密工具地址总结 靶机地址 https://download.vulnhub.com/pwnos/pWnOS_v2.0.7z 这里如果是windows系统直接使用vmware或者virtubox打开可以使用,如果是mac系统需再去做一个配置,比较麻烦 这里…

Gartner魔力象限(Gartner Magic Quadrant)

Gartner魔力象限(Gartner Magic Quadrant)是由全球领先的研究和咨询公司Gartner发布的市场研究报告,广泛应用于IT行业,尤其是在技术供应商评估中。它以图形化的方式展示了不同技术领域中各个供应商的市场表现,帮助企业…

信创时代开发工具选择指南:国产替代背景下的技术生态与实践路径

🧑 博主简介:CSDN博客专家、CSDN平台优质创作者,高级开发工程师,数学专业,10年以上C/C, C#, Java等多种编程语言开发经验,拥有高级工程师证书;擅长C/C、C#等开发语言,熟悉Java常用开…

人口老龄化丨AI健康小屋如何实现防病于未然​

随着全球老龄化加剧,“银发浪潮” 对医疗资源、养老护理和健康管理提出了严峻挑战。 由此智绅科技应运而生,七彩喜智慧养老系统构筑居家养老安全网。 AI 健康小屋作为银发科技的创新载体,通过智能化健康监测、精准化风险预警、便捷化医疗衔…

【金仓数据库征文】金仓数据库:开启未来技术脑洞,探索数据库无限可能

我的个人主页 我的专栏: 人工智能领域、java-数据结构、Javase、C语言,希望能帮助到大家!!! 点赞👍收藏❤ 目录 引言:数据库进化的下一站 —— 未来科技的无限可能金仓数据库简介:国…

#什么是爬虫?——从技术原理到现实应用的全面解析 VI

什么是爬虫?——从技术原理到现实应用的全面解析 V 二十六、异构数据采集技术突破 26.1 PDF文本与表格提取 import pdfplumber import pandas as pddef extract_pdf_data(pdf_path):"""从PDF中提取文本和表格数据:param pdf_path: PDF文件路径:return: 包含…

关于Spring Boot构建项目的相关知识

一 前端框架 1 VUE框架 1.1 简介 Vue是一款流行的JavaScript框架,用于构建用户界面和单页面应用程序。它的设计初衷是为了简化Web开发过程,使开发者能够快速构建交互性强、响应速度快的Web应用。 1.2 优点 简单易用&am…