2016年6月21日 星期二

Buildroot - 打造Embedded Linux 工作環境

Buildroot for ARM


Buildroot 是一套用來打造 Embedded Linux System工具, 可以在此平台上編譯產生不同系統的Root File System, Toolchain。

打造工作環境:Embedded Linux for ARM

1. 下載Buildroot
     官方網站: https://buildroot.org/download.html

      下載檔案:buildroot-2012.11.1.tar.bz2 / buildroot-2012.11.1.tar.gz

2. 解壓縮
     $tar zxvf buildroot-2012.11.1.tar.gz
2.1安裝其它package

EX:     [GM8138S install package: 64bit ubuntu]
$ sudo apt-get install g++

$ sudo apt-get install lib32z1-dev //compression library - 32 bit runtime

$ sudo apt-get install lib32z1
$ sudo apt-get install libncurses5-dev //shared libraries for terminal handling
$ sudo apt-get install libncurses5
$ sudo apt-get install bison //YACC-compatible parser generator - development library
$ sudo apt-get install flex //A fast lexical analyzer generator.
$ sudo apt-get install texinfo //Documentation system for on-line information and printed output

EX:     [GM8138S install package: 32bit ubuntu]
$ sudo apt-get install g++
$ sudo apt-get install bison
$ sudo apt-get install flex
$ sudo apt-get install texinfo


3. 設定組態
  
      $ make menuconfig
    #組態選擇
    (1)選擇 arm
Target Architecture (arm)  ---> 
    (2)選擇 generic_arm
Target Architecture Variant (generic_arm)  ---> 
    (3)選擇 EABI
Target ABI (EABI)  --->

   ABI:  application binary interface
OABI: old application binary interface
    (4)選擇 Linux kernel 3.2 / busybox 1.19.x/ binutils 2.21.1 / uClibc 0.9.32.x /gcc 4.6.4 


    $ make
    $ ls -al output/                             //編譯成功輸出於output folder
   
   

[Note ***]
   #if 編譯錯誤1:
   buildroot You may have to install 'g++' on your build machine
   
   #[解決1] 安裝上述提示軟體套件:
   $ sudo apt-get install g++
   $ sudo apt-get install texinfo
   $ sudo apt-get install unzip

  #if 編譯錯誤2: ./output/build/host-m4-1.4.16/lib/stdio.in.h

In file included from clean-temp.h:22:0,
                 from clean-temp.c:23:
./stdio.h:477:1: error: 'gets' undeclared here (not in a function)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 ^
mv -f .deps/c-stack.Tpo .deps/c-stack.Po
/usr/bin/gcc -std=gnu99  -I.     -O2 -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/include -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c
mv -f .deps/close-hook.Tpo .deps/close-hook.Po
/usr/bin/gcc -std=gnu99  -I.     -O2 -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/include -I/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/host/usr/include -MT execute.o -MD -MP -MF .deps/execute.Tpo -c -o execute.o execute.c
make[4]: *** [clean-temp.o] Error 1
make[4]: *** Waiting for unfinished jobs....
mv -f .deps/execute.Tpo .deps/execute.Po

   #[解決2]patch file下:
   +diff -purN host-m4-1.4.16.orig/lib/stdio.in.h host-m4-1.4.16/lib/stdio.in.h
+--- host-m4-1.4.16.orig/lib/stdio.in.h 2012-07-21 19:11:40.196541826 +0200
++++ host-m4-1.4.16/lib/stdio.in.h 2012-07-21 20:46:05.405850751 +0200
+@@ -162,7 +162,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif

  #if 編譯錯誤3: ./output/build/host-autoconf-2.65/doc/autoconf.texi 
conftest.c:14625: must be after `@defmac' to use `@defmacx'
make[3]: *** [autoconf.info] Error 1
make[3]: Leaving directory `/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/build/host-autoconf-2.65/doc'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/home/paddy/workspace/project/GM/gm8138s/arm-linux-3.3/buildroot-2012.02/output/build/host-autoconf-2.65'
make[1]: *** [install] Error 2

 #[解決3]patch file下:
--- autoconf-2.65/doc/autoconf.texi 2009-11-05 10:42:15.000000000 +0800
+++ autoconf-2.65/doc/autoconf.texi.new 2013-05-28 05:41:09.243770263 +0800
@@ -15,7 +15,7 @@
 @c The ARG is an optional argument.  To be used for macro arguments in
 @c their documentation (@defmac).
 @macro ovar{varname}
-@r{[}@var{\varname\}@r{]}@c
+@r{[}@var{\varname\}@r{]}
 @end macro
 @c @dvar(ARG, DEFAULT)
@@ -23,7 +23,7 @@
 @c The ARG is an optional argument, defaulting to DEFAULT.  To be used
 @c for macro arguments in their documentation (@defmac).
 @macro dvar{varname, default}
-@r{[}@var{\varname\} = @samp{\default\}@r{]}@c
+@r{[}@var{\varname\} = @samp{\default\}@r{]}
 @end macro

以上!


沒有留言:

張貼留言