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.pswp.cn/diannao/80452.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/80452.shtml
英文地址,請注明出處:http://en.pswp.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…