在Linux下為嵌入式Linux核心編譯busybox

來源:互聯網
上載者:User

 筆者所用的是一塊ARM9 Atmel 9200的開發板,Linux核心為2.4.27, 交叉編譯器為2.95.3,編譯環境為RedHat9 Linux下。

1、從http://www.busybox.net/downloads下載到busybox,筆者下載的為busybox1.1.3,下載後解壓到一個目錄下,如 /tmp 目錄下;

2、進入解壓後的目錄,輸入make menuconfig 進行編譯配置,基本的配置如下:
Busybox Settings >                                                              
          General Configuration >                                                
                     [*] Support for devfs                                       
          Build Options >                                                        
                     [*] Build BusyBox as a static binary (no shared libs)       
                           /* 將busybox編譯為靜態串連,少了啟動時找動態庫的麻煩 */     
                     [*] Do you want to build BusyBox with a Cross Compiler?     
                       (/usr/local/arm/3.3.2/bin/armlinux)                       
                       Cross Compiler prefix                                     
                          /* 指定交叉編譯工具路徑 */                                
          Init Utilities >                                                       
                    [*] init                                                     
                    [*] Support reading an inittab file                          
                         /* 支援init讀取/etc/inittab設定檔,一定要選上 */          
          Shells >                                                               
                    Choose your default shell (ash) >                            
                        /* (X) ash 選中ash,這樣產生的時候才會產生bin/sh檔案          
                         * 看看我們前頭的linuxrc指令碼的頭一句:                       
                         * #!/bin/sh 是由bin/sh來解釋執行的*/                       
                    [*] ash                                                      
          Coreutils >                                                            
                    [*] cp                                                       
                    [*] cat                                                      
                    [*] ls                                                       
                    [*] mkdir                                                    
                    [*] echo (basic SuSv3 version taking no options)             
                    [*] env                                                      
                    [*] mv                                                       
                    [*] pwd                                                      
                    [*] rm                                                       
                    [*] touch                                                    
         Editors >                                                               
                    [*] vi                                                       
         Linux System Utilities >                                                
                    [*] mount                                                     
                    [*] umount                                                   
                    [*] Support loopback mounts                                  
                    [*] Support for the old /etc/mtab file                       
         Networking Utilities >                                                  
                    [*] inetd                                                    
                       /* 支援inetd超級伺服器inetd的設定檔為/etc/inetd.conf檔案,   
                        * "在該部分的4: 相關設定檔的建立"一節會有說明*/             

3、編譯並安裝Busybox
[arm@localhost busybox1.1.3]$make TARGET_ARCH=arm CROSS=/usr/local/arm/2.85.3/bin/arm-linux- PREFIX=/root/arm_9200/rdmnt/ all install

CROSS 為交叉編譯器的路徑。
PREFIX指明安裝路徑:就是我們根檔案系統所在路徑。
* 這裡需要注意一點的是,只要install busybox,我們根檔案系統下先前建好的linuxrc就會被覆蓋為一同名二進
制檔案。所以要事先備份我們自己的linuxrc,在安裝完busybox後,將linuxrc複製回去就好。
* 如果在編譯的過程中出現錯誤,這可能是某些支援問題,可以在配置的時候把相關的選項去掉試試。
* 如果出現找不到核心版本號碼的編譯錯誤,可以有兩種方法解決:(1)把你的核心源碼中的version.h檔案拷貝到交叉編譯器的包含檔案的linux目錄下(該方法筆者實驗成功);(2)該方法來源於論壇上面的一位朋友,做法為刪掉#include <linux/version.h>換成#define UTS_RELEASE "2.4.27"  #define LINUX_VERSION_CODE 132123

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.