搜尋
首頁系統教程Linux嵌入式Linux專案開發的幾個步驟

嵌入式Linux專案開發的幾個步驟

Feb 05, 2024 pm 12:51 PM
linuxlinux教程linux系統linux作業系統linux指令shell腳本記憶體佔用系統版本linux工具嵌入式linux良許linux入門linux學習

微控制器製造商提供的開發板和相關的軟體專案例程,在工程師開始新設計時通常能提供很大的幫助。然而,在設計專案的早期階段完成後,在進一步設計時,製造商提供的軟體可能會引發一些問題。

對於使用即時作業系統作為應用程式碼平台的設計來說,也面臨許多挑戰。例如,如何有效地將功能分配給不同的平行任務,如何設計可靠的進程間通信,以及如何在硬體上對整個軟體包進行測試等問題。

越來越多的OEM廠商發現,避免上述問題的最佳方式是使用基於開源、經過驗證、可擴展,並能運行在各種硬體平台上的Linux作業系統來開始新的設計。 Linux作業系統在各種電腦硬體平台上的移植數量也是首屈一指的。

Linux的衍生版本已被廣泛應用於各種嵌入式系統中,包括網路路由器、行動電話、建築自動化控制、電視機以及電玩控制台。

雖然Linux被廣泛應用並取得成功,但這並不意味著它易於使用。 Linux包含的程式碼超過一百萬行,並且運行方式具有明顯的“Linux方式”,初學者可能需要一定時間來適應。

因此,本文的目的是為了幫助使用Linux嵌入式作業系統版本-μClinux,來啟動一個新的設計專案。本指南將分為五個步驟。為了說明該指南,文中介紹了在意法半導體的STM32F429微控制器上實現的一個μClinux項目,該微控制器採用ARMCortex-M4內核,最高主頻為180MHz,並使用了Emcraft的STM32F429DiscoveryLinux板支援包(BSP )。

步驟1:Linux工具與專案佈局

#每個嵌入式軟體設計都從選擇合適的工具開始。

工具鍊是一組連接(或連結)在一起的軟體開發工具,它包含諸如GNU編譯器集合(GCC)、binutils(一組包括連接器、彙編器和其它用於目標檔案和檔案工具的開發工具)和glibc(提供系統呼叫和基本函數的C函式庫)等元件;在某些情況下,還可能包括編譯器和偵錯器等其它工具。

用於嵌入式開發的工具鍊是一個交叉工具鏈,更常見的叫法是交叉編譯器。

GNUBinutils是嵌入式Linux工具鏈的第一個元件。 GNUBinutils包含兩款重要工具:

●“as”,彙編器,將彙編程式碼(GCC所產生)轉換成二進位程式碼

●“ld”,連接器,將離散目標程式碼段連接到庫或形成可執行檔

編譯器是工具鏈的第二個重要組成部分。在嵌入式Linux,它被稱為GCC,支援許多種微控制器和處理器架構。

接下來是C函數庫。它實作Linux的傳統POSIX應用程式介面(API),該API可被用來開發使用者空間應用。它透過系統呼叫與核心對接,並提供高階服務。

工程師有幾種C函數庫選擇:

●glibc是開源GNU專案提供的可用C函數庫。該庫是全功能、可移植的,它符合Linux標準。

●嵌入式GLIBC(EGLIBC)是一款針對嵌入式系統最佳化的衍生版。其程式碼是精簡的,支援交叉編譯和交叉測試,其原始程式碼和二進位程式碼與GLIBC的相容。

●uClibc是另一個C函數庫,可在快閃記憶體空間有限、和/或記憶體佔用必須最小的情況下使用。

偵錯器通常也是工具鏈的一部分,因為在目標機上偵錯應用程式運行時,需要一個交叉偵錯器。在嵌入式Linux領域,GDB是常用偵錯器。

上述工具是如此地不可或缺,但當它們各自為戰時,會花太長時間來編譯Linux原始碼並將其整合成最終映像(image)。幸運的是,Buildroot(自動產生交叉編譯工具的工具)會自動完成建構一個完整嵌入式系統的過程,並透過產生下述任一或所有任務,簡化了交叉編譯:

●交叉編譯工具鏈

●根檔案系統

●核心映像

●引導映像

For embedded system designers, it is also convenient to use a tool (utility) aggregation tool, such as BusyBox, which integrates the tools that are usually most needed. According to BusyBox's information page, "It combines tiny versions of many common UNIX tools into a small executable. It provides an alternative to most of the tools you would typically see in tools like GNU fileutils and shellutils. BusyBox The tools in BusyBox are generally less selective than their full-featured GNU counterparts; but the included options provide expected functionality and behavior that is almost identical to that provided by the GNU counterpart. For any small or embedded system, BusyBox provides The environment is quite complete.”

The last important tool is a BSP, which is specially made for the motherboard equipped with the project target MCU or processor.

The BSP includes pre-configured tools, as well as a bootloader to load the operating system onto the motherboard. It also provides source code for the kernel and device drivers (see Figure 1).

嵌入式Linux專案開發的幾個步驟

Step 2: Boot Sequence, Clock System, Memory and Serial Interface

The typical embedded Linux startup sequence is as follows:

1) The bootloader firmware (U-Boot in the example project) runs in the target MCU's built-in flash memory (no external memory required), and after power-on/reset, performs all necessary initialization work, including setting up the serial port and using Memory controller for external memory (RAM) access.

2) U-Boot can transfer the Linux image from external Flash to external RAM and transfer control to the kernel entry point in RAM. Linux images can be compressed to save flash space at the expense of decompression time at boot time.

3) Linux boots and installs a RAM-based file system (initramfs) as the root file system. When the project is built, the Initramfs is populated with the required files and directories and then simply linked to the kernel.

4) Under the Linux kernel, execute /sbin/init. The /sbin/init program initializes the system according to the description of the configuration file in /etc/inittab.

5) Once the initialization process completes run-level execution and commands in /sbin/init, it starts a login process.

6) The execution of the shell initialization file /etc/profile marks the completion of the startup process.

You can significantly shorten startup time and improve overall performance by enabling in-place execution (ExecuteInPlace—XIP), which is a method of executing code from flash memory. Typically, Linux code is loaded from flash memory to external memory and then executed from the external memory. By executing from flash memory, less memory is required because this copying step is no longer required, and read-only memory no longer takes up program space.

以上是嵌入式Linux專案開發的幾個步驟的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:良许Linux教程网。如有侵權,請聯絡admin@php.cn刪除
為什麼Windows通常用於桌面計算和遊戲?為什麼Windows通常用於桌面計算和遊戲?Apr 27, 2025 am 12:01 AM

Windowsispreferredfordesktopcomputingandgamingdueto:1)ITVASTSOFTSOFTWAREANDGAMELIBRARY,2)用戶友好型和customizableInterface,3)廣泛的hardwarecompatibility,and4)PerformanceOptimizationCapities,demalloPtimizationCapities,DespitesomeSomeSomeSomeSourceOmeSourceOmeSourceource-HeaevyAndupDateupdate-uperated。

Linux軟件的未來:Flatpak和Snap會替換本機桌面應用程序嗎?Linux軟件的未來:Flatpak和Snap會替換本機桌面應用程序嗎?Apr 25, 2025 am 09:10 AM

多年來,Linux軟件分佈依賴於DEB和RPM等本地格式,並深深地根深蒂固。 但是,Flatpak和Snap已經出現,有望成為應用程序包裝的通用方法。 本文考試

Linux和Windows處理設備驅動程序的區別有什麼區別?Linux和Windows處理設備驅動程序的區別有什麼區別?Apr 25, 2025 am 12:13 AM

Linux和Windows在處理設備驅動程序上的差異主要體現在驅動管理的靈活性和開發環境上。 1.Linux採用模塊化設計,驅動可以動態加載和卸載,開發者需深入理解內核機制。 2.Windows依賴微軟生態,驅動需通過WDK開發並簽名認證,開發相對複雜但保證了系統的穩定性和安全性。

比較和對比Linux和Windows的安全模型。比較和對比Linux和Windows的安全模型。Apr 24, 2025 am 12:03 AM

Linux和Windows的安全模型各有優勢。 Linux提供靈活性和可定制性,通過用戶權限、文件系統權限和SELinux/AppArmor實現安全。 Windows則注重用戶友好性,依賴WindowsDefender、UAC、防火牆和BitLocker保障安全。

Linux和Windows之間的硬件兼容性有何不同?Linux和Windows之間的硬件兼容性有何不同?Apr 23, 2025 am 12:15 AM

Linux和Windows在硬件兼容性上不同:Windows有廣泛的驅動程序支持,Linux依賴社區和廠商。解決Linux兼容性問題可通過手動編譯驅動,如克隆RTL8188EU驅動倉庫、編譯和安裝;Windows用戶需管理驅動程序以優化性能。

Linux和Windows之間虛擬化支持有哪些差異?Linux和Windows之間虛擬化支持有哪些差異?Apr 22, 2025 pm 06:09 PM

Linux和Windows在虛擬化支持上的主要區別在於:1)Linux提供KVM和Xen,性能和靈活性突出,適合高定制環境;2)Windows通過Hyper-V支持虛擬化,界面友好,與Microsoft生態系統緊密集成,適合依賴Microsoft軟件的企業。

Linux系統管理員的主要任務是什麼?Linux系統管理員的主要任務是什麼?Apr 19, 2025 am 12:23 AM

Linux系統管理員的主要任務包括系統監控與性能調優、用戶管理、軟件包管理、安全管理與備份、故障排查與解決、性能優化與最佳實踐。 1.使用top、htop等工具監控系統性能,並進行調優。 2.通過useradd等命令管理用戶賬戶和權限。 3.利用apt、yum管理軟件包,確保系統更新和安全。 4.配置防火牆、監控日誌、進行數據備份以確保系統安全。 5.通過日誌分析和工具使用進行故障排查和解決。 6.優化內核參數和應用配置,遵循最佳實踐提升系統性能和穩定性。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!