Powered by Drupal, an open source content management system

การสร้าง Ångström Distribution ด้วย Openembedded

 

บทความนี้จะแสดงการสร้าง Linux Ångström Distribution ด้วย Openembedded ซึ่ง Ångström Distribution เป็นระบบที่ออกแบบมาสำหรับงานด้าน Embedded Linux โดยเฉพาะ ส่วน Openembedded เป็นระบบช่วยสร้าง Linux Distribution ทั้งระบบ นอกจากจะใช้สร้าง Ångström Distribution แล้ว ยังสามารถใช้สร้าง Distribution อื่นๆอีกมากมาย

ตัวอย่าง Linux Distribution ที่สามารถสร้างได้โดย Openembedded

altboot-console-image.bb           mokogateway-image.bb
altboot-x11-image.bb               mythfront-image.bb
base-image.bb                      nas-server-image.bb
beagleboard-demo-image.bb          native-sdk-console-image.bb
bootmanager-image.bb               neuros-osd-base-image.bb
bootstrap-image.bb                 nslu2-base-image.bb
bootstrap-image-bootchart.bb       nslu2-linksys-image.bb
console-base-image.bb              nylon-image-base.bb
console-image.bb                   nylon-image-extended.bb
console-mipv6-image.bb             nylon-image-extra.bb
devimage-image.bb                  nylon-image-mini.bb
distcc-slave-image.bb              nylon-image-standard.bb
dsplink-test-image.bb              openmoko-devel-image.bb
dvb-image.bb                       openmoko-image.bb
e-image.bb                         openmoko-minimal-image.bb
e-image-core.bb                    openmoko-python-devel-image.bb
fso-console-image.bb               openmoko-sdk-image.bb
fso-illume-image.bb                openprotium-image.bb
fso-image.inc                      opie-image-16mb.bb
fso-image-light.bb                 opie-image.bb
fso-image-nox.bb                   opie-kdepim-image.bb
fso-paroli-image.bb                opie-xqtlauncher-image.bb
fso-zhone-image.bb                 ossie-image.bb
gateway-image.bb                   pivotboot-image.bb
gnuradio-image.bb                  qtopia-core-console-image.bb
gpe-image.bb                       qtopia-core-gui-image.bb
gpe-image-blank-user.bb            sdl-image.bb
gpephone-image.bb                  sdr-image.bb
gpephone-image-vm.bb               sectest-gpe-image.bb
helloworld-image.bb                slugos-image.bb
illume-image.bb                    sugar-image.bb
initramfs-bootmenu-debug-image.bb  twin-image.bb
initramfs-bootmenu-image.bb        udumpty-image.bb
initramfs-image.bb                 uml-image.bb
initramfs-minimal-image.bb         unslung-image.bb
jalimo-beagleboard-demo-image.bb   x11-gpe-image.bb
jlime-opie.bb                      x11-gpe-java-image.bb
liveramdisk-image.bb               x11-image.bb
maemo-image.bb                     x11-office-image.bb
mini2440-image.bb                  x11-pimlico-image.bb
minimal-gpe-image.bb               x11-sato-image.bb
minimal-image.bb                   xfce-image.bb
minimal-image-with-mtd-utils.bb    xorg-image.bb
minimal-openmoko-image.bb          xterminal-image.bb

 1. เตรียมพร้อมระบบสำหรับการใช้งาน Openembedded ซึ่งจะแตกต่างกันไปตาม Linux Distribution ที่ใช้ ในกรณีนี้เราจะใช้ Ubuntu9.10 สำหรับ Distribution อื่นๆให้ทำตามลิงค์นี้ http://wiki.openembedded.net/index.php/OEandYourDistro

 

ก่อนอื่นให้ติดตั้งโปรแกรมที่จำเป็นสำหรับการใช้งาน

$ sudo apt-get install sed wget cvs subversion git-core coreutils unzip texi2html texinfo libsdl1.2-dev docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++
$ sudo apt-get install libxml2-utils xmlto python-psyco
$ sudo apt-get install docbook

 

 ตรวจสอบว่า /bin/sh link ไปหา dash หรือเปล่า ถ้าใช่ให้ใช้คำสั่ง "sudo dpkg-reconfigure dash" แล้วเลือก No

 

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2010-01-12 15:57 /bin/sh -> dash
$ sudo dpkg-reconfigure dash
Removing `diversion of /bin/sh to /bin/sh.distrib by dash'
Removing `diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'

 

 

2. เตรียม Directory สำหรับการสร้าง

$ mkdir -p ~/stuff/build/conf
$ cd ~/stuff

 

 

3. ติดตั้งโปรแกรม bitbake ซึ่งเป็นโปรแกรมสำหรับการดึงสูตร (recipes) การสร้างมาตีความเพื่อสร้าง Distribution ต่างๆ ซึ่ง bitbake จะติดตั้งไปยัง directory ~/stuff/bitbake

$ wget http://download.berlios.de/bitbake/bitbake-1.8.18.tar.gz
$ tar xvzf bitbake-1.8.18.tar.gz
$ mv bitbake-1.8.18 bitbake

 

 4. ใช้ git เพื่อดึงระบบ Openembedded สำหรับ Mini2440

$ cd ~/stuff
$ git clone git://repo.or.cz/openembedded/mini2440.git
Initialized empty Git repository in /home/mini2440/stuff/mini2440/.git/
remote: Counting objects: 270955, done.
remote: Compressing objects: 100% (85811/85811), done.
remote: Total 270955 (delta 179865), reused 267535 (delta 178033)
Receiving objects: 100% (270955/270955), 96.14 MiB | 1025 KiB/s, done.
Resolving deltas: 100% (179865/179865), done.
Checking out files: 100% (18975/18975), done.

$ ls
bitbake  bitbake-1.8.18.tar.gz  build  mini2440

  

มาถึงจุดนี้ภายใต้ Directory ~/stuff จะประกอบไปด้วย Directory หลักๆ สามตัวคือ

  • bitbake - บรรจุโปรแกรมสร้างระบบ
  • mini2440 - ระบบ Openembedded ที่เก็บสูตรในการสร้าง Linux Distribution ต่างๆสำหรับ mini2440
  • build - Working Directory ที่ใช้ในการสร้าง Distriubution

 5. ขั้นตอนต่อไปเป็นการเตรียม Working Directory

  • สมมติให้ Home Directory ของผู้ใช้คือ /home/mini2440
  • สร้างไฟล์ /home/mini2440/stuff/build/conf/local.conf โดยมีข้อมูลดังนี้

DL_DIR = "/home/mini2440/stuff/sources"
DISTRO = "angstrom-2008.1"
BBFILES = "/home/mini2440/stuff/mini2440/recipes/*/*.bb"
MACHINE = "mini2440"

  • รายละเอียดเพิ่มเติมของoptionต่างๆสำหรับ local.conf สามารถดูได้จากไฟล์   ~/stuff/mini2440/mini2440_local_conf_example.conf และ ~/stuff/mini2440/conf/local.conf.sample
  • รายละเอียดเพิ่มเติมของ MACHINE ที่ Openembedded รองรับดูได้จาก ~/stuff/mini2440/conf/machine
  • รายละเอียดเพิ่มเติมของ DISTRO ที่ Openembedded รองรับดูได้จาก ~/stuff/mini2440/conf/distro
  • สร้างไฟล์ /home/mini2440/stuff/build/profile.sh โดยมีข้อมูลดังนี้

export BBPATH=/home/mini2440/stuff/build:/home/mini2440/stuff/mini2440
export PATH=/home/mini2440/stuff/bitbake/bin:$PATH

 

 

  • สร้าง Directory สำหรับเก็บ Source code ที่ download มาระหว่างสร้างระบบ

$ mkdir -p ~/stuff/sources

 

 

6. มาถึงจุดนี้ เราก็พร้อมที่จะทำการสร้าง Ångström Distribution แล้วครับโดยเราจะทำการสร้างระบบที่มีขนาดเล็กที่สุดคือ console-image ซึ่งเป็นระบบเล็กที่ไม่มี GUI

การรัน bitbake ให้ทำการรันภายใต้ directory ~/stuff/build

$ cd ~/stuff/build
$ source profile.sh
$ bitbake console-image

 

หมายเหตุ

Ubuntu9.1 ต้องทำการแก้ไขไฟล์ /etc/sysctl.conf เพื่อเพิ่มบรรทัดข้างล่างนี้ แล้วรีบูทก่อนทำการรัน bitbake

vm.mmap_min_addr = 0

 

bitbake จะทำการมองหาสูตรการสร้าง console-image จากDirectory ~/stuff/mini2440/recipes/images แล้วทำการดึง Source Code ต่างๆที่เกี่ยวข้องมาเก็บไว้ที่ directory ที่กำหนดไว้ที่ DL_DIR หลังจากนั้นจะทำการ Compile สร้างระบบทั้งระบบให้กับเราโดยอัตโนมัติ ในการcompileระบบครั้งแรกค่อนข้างใช้เวลานานมาก เพราะวิธีการสร้างระบบของ Openembedded จะ Compile จาก Source code แต่จะเร็วขึ้นในรอบหลังๆ

หลังจากใช้เวลายาวนานเราก็จะได้ระบบ Embeded Linux Ångström ทั้งระบบภายใต้ Directory ~/stuff/build/tmp/deploy/glibc/images/mini2440 ซึ่งประกอบด้วยไฟล์ดังนี้

Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440.rootfs.ext3
Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440.rootfs.jffs2
Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440.rootfs.tar.gz
Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440-testlab
console-image-mini2440.ext3 -> Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440.rootfs.ext3
console-image-mini2440.jffs2 -> Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440.rootfs.jffs2
console-image-mini2440.tar.gz -> Angstrom-console-image-glibc-ipk-2009.X-stable-mini2440.rootfs.tar.gz
modules-2.6.32+git-r1-mini2440.tgz
u-boot-mini2440.bin -> u-boot-mini2440-git-r30.bin
u-boot-mini2440-git-r30.bin
uImage-2.6.32+git-r1-mini2440.bin
uImage-mini2440.bin -> uImage-2.6.32+git-r1-mini2440.bin

 

เราจะได้ไฟล์ทุกตัวที่สามารถนำไปสร้างระบบEmbedded Linux Ångström ทั้งระบบ หลักๆก็คือ

1. บูทโหลดเดอร์ u-boot-mini2440.bin ซึ่งลิงค์ไปหาไฟล์ u-boot-mini2440-git-r30.bin

2. ลินุกซ์เคอร์แนล  uImage-mini2440.bin ซึ่งลิงค์ไปหาไฟล์ uImage-2.6.32+git-r1-mini2440.bin

3. ไฟล์ซิสเต็มในรูปแบบต่างๆ ถ้านำไปเขียนลง nand flash ก็ใช้ console-image-mini2440.jffs2 ถ้านำไปเขียนลง sd card ก็ใช้ console-image-mini2440.tar.gz เป็นต้น

 

 

อ้างอิง

http://linuxtogo.org/gowiki/AngstromManual

http://wiki.openembedded.net/index.php/Getting_started

http://repo.or.cz/w/openembedded/mini2440.git

www.linuxtogo.org/gowiki/OeDeviceList