ลง ScratchBox สำหรับพัฒนา Nokia N770

ครั้งก่อน ได้ลง OS 2008HE ไป แต่ไม่ปลื้ม เพราะว่า พอใช้ wireless แล้วเปิดเว็บ เกิดอาหารแฮงค์ รีบูตตัวเองบ่อยครั้ง
เลยโหลด OS2007HE มาลงเหมือนเดิม สุดท้ายก็เหลือปัญหาภาษาไทย ที่ต้องจัดการ เอาไว้เขียนตอนหน้าละกัน

เริ่มต้น ต้องลง scrachbox ซึ่งเป็น development toolkit ตัวหนึ่ง สำหรับ cross compile โปรแกรมต่าง ๆ ลงบน embeded device โดยที่ตัว Maemo และ Nokia ได้สนับสนุนการทำงานโดยมี sdk เสริมเข้ามา
เท่าที่เพิ่งลองเล่น ข้อดีอีกอย่าง คือสามารถ emulate ได้เลยทันทีก่อนไปลงเครื่อง สะดวกสบายพอสมควร

สำหรับ OS2007HE ที่ลงนั้น ใช้ Maemo 3.1 หรือ bora เครื่องที่ผมใช้เป็น Ubuntu8.10 ครับ

ไปที่ http://repository.maemo.org/stable/3.1/ เพื่อโหลดสคริปในการติดตั้งมา โดยสคริป จะดาวน์โหลดตัว gz มา แต่จริง ๆ สามารถใช้เป็น .deb ได้ แต่ที่ผมลงแล้วรู้สึกเพี้ยน ๆ เลยลงแบบ gz ดีกว่า

  1. sake@sake-laptop:~/project/Embeded/N770/maemosdk$ wget http://repository.maemo.org/stable/3.1/maemo-scratchbox-install_3.1.sh
  2. sake@sake-laptop:~/project/Embeded/N770/maemosdk$ sudo ./maemo-scratchbox-install_3.1.sh -u sake -s /scratchbox
  3. This script will install Scratchbox 1.0.7 'apophis' release to your computer.
  4.  
  5. Install options
  6. ---------------
  7.  
  8. Install from packages=tgz
  9. Scratchbox install path=/scratchbox
  10. Scratchbox group=sbox
  11. armel compiler=cs2005q3.2-glibc-arm
  12. i386 compiler=cs2005q3.2-glibc-i386
  13. armel devkits=perl:debian-sarge:maemo3-debian:maemo3-tools:cputransp
  14. i386 devkits=perl:debian-sarge:maemo3-debian:maemo3-tools:doctools
  15. armel CPU transparency=qemu-arm-0.8.2-sb2
  16.  
  17. Checking for prerequisites
  18. --------------------------
  19.  
  20. Running as user root...
  21. Running as user root inside fakeroot...
  22. Running outside of scratchbox...
  23. Running on Linux kernel...
  24. Running on i386 architecture...
  25. Host kernel binfmt_misc support...
  26. Host kernel VDSO support...
  27. Host kernel SELinux extensions...
  28. Host kernel local IPv4 port range...
  29. Which wget tool in path...
  30. Scratchbox install path is sane...
  31. Scratchbox installation not existing...
  32. Scratchbox user names... sake
  33. Everything seems ok.
  34.  
  35. Downloading scratchbox packages
  36. -------------------------------
  37.  
  38. Removed earlier file 'scratchbox-core-1.0.7-i386.tar.gz'.
  39. Downloading 'scratchbox-core-1.0.7-i386.tar.gz'.
  40. --2009-01-01 08:23:14--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-core-1.0.7-i386.tar.gz
  41. Resolving scratchbox.org... 62.61.85.37
  42. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  43. HTTP request sent, awaiting response... 200 OK
  44. Length: 49932823 (48M) [application/x-tar]
  45. Saving to: `/tmp/scratchbox-core-1.0.7-i386.tar.gz'
  46.  
  47. 100%[======================================================================================================================================>] 49,932,823   136K/s   in 5m 54s  
  48.  
  49. 2009-01-01 08:29:11 (138 KB/s) - `/tmp/scratchbox-core-1.0.7-i386.tar.gz' saved [49932823/49932823]
  50.  
  51. Downloading 'scratchbox-devkit-cputransp-1.0.2-i386.tar.gz'.
  52. --2009-01-01 08:29:13--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-devkit-cputransp-1.0.2-i386.tar.gz
  53. Resolving scratchbox.org... 62.61.85.37
  54. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  55. HTTP request sent, awaiting response... 200 OK
  56. Length: 14285271 (14M) [application/x-tar]
  57. Saving to: `/tmp/scratchbox-devkit-cputransp-1.0.2-i386.tar.gz'
  58.  
  59. 100%[======================================================================================================================================>] 14,285,271   137K/s   in 1m 42s  
  60.  
  61. 2009-01-01 08:30:56 (137 KB/s) - `/tmp/scratchbox-devkit-cputransp-1.0.2-i386.tar.gz' saved [14285271/14285271]
  62.  
  63. Downloading 'scratchbox-devkit-debian-1.0.8-i386.tar.gz'.
  64. --2009-01-01 08:30:57--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-devkit-debian-1.0.8-i386.tar.gz
  65. Resolving scratchbox.org... 62.61.85.37
  66. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  67. HTTP request sent, awaiting response... 200 OK
  68. Length: 9713072 (9.3M) [application/x-tar]
  69. Saving to: `/tmp/scratchbox-devkit-debian-1.0.8-i386.tar.gz'
  70.  
  71. 100%[======================================================================================================================================>] 9,713,072    145K/s   in 70s    
  72.  
  73. 2009-01-01 08:32:07 (136 KB/s) - `/tmp/scratchbox-devkit-debian-1.0.8-i386.tar.gz' saved [9713072/9713072]
  74.  
  75. Downloading 'scratchbox-devkit-doctools-1.0.6-i386.tar.gz'.
  76. --2009-01-01 08:32:08--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-devkit-doctools-1.0.6-i386.tar.gz
  77. Resolving scratchbox.org... 62.61.85.37
  78. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  79. HTTP request sent, awaiting response... 200 OK
  80. Length: 98185611 (94M) [application/x-tar]
  81. Saving to: `/tmp/scratchbox-devkit-doctools-1.0.6-i386.tar.gz'
  82.  
  83. 100%[======================================================================================================================================>] 98,185,611   137K/s   in 11m 34s
  84.  
  85. 2009-01-01 08:43:43 (138 KB/s) - `/tmp/scratchbox-devkit-doctools-1.0.6-i386.tar.gz' saved [98185611/98185611]
  86.  
  87. Downloading 'scratchbox-devkit-perl-1.0.4-i386.tar.gz'.
  88. --2009-01-01 08:43:48--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-devkit-perl-1.0.4-i386.tar.gz
  89. Resolving scratchbox.org... 62.61.85.37
  90. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  91. HTTP request sent, awaiting response... 200 OK
  92. Length: 970158 (947K) [application/x-tar]
  93. Saving to: `/tmp/scratchbox-devkit-perl-1.0.4-i386.tar.gz'
  94.  
  95. 100%[======================================================================================================================================>] 970,158      137K/s   in 8.4s    
  96.  
  97. 2009-01-01 08:43:58 (113 KB/s) - `/tmp/scratchbox-devkit-perl-1.0.4-i386.tar.gz' saved [970158/970158]
  98.  
  99. Downloading 'scratchbox-devkit-maemo3-1.0-i386.tar.gz'.
  100. --2009-01-01 08:43:58--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-devkit-maemo3-1.0-i386.tar.gz
  101. Resolving scratchbox.org... 62.61.85.37
  102. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  103. HTTP request sent, awaiting response... 200 OK
  104. Length: 21603933 (21M) [application/x-tar]
  105. Saving to: `/tmp/scratchbox-devkit-maemo3-1.0-i386.tar.gz'
  106.  
  107. 100%[======================================================================================================================================>] 21,603,933   138K/s   in 2m 34s  
  108.  
  109. 2009-01-01 08:46:33 (137 KB/s) - `/tmp/scratchbox-devkit-maemo3-1.0-i386.tar.gz' saved [21603933/21603933]
  110.  
  111. Downloading 'scratchbox-libs-1.0.7-i386.tar.gz'.
  112. --2009-01-01 08:46:34--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-libs-1.0.7-i386.tar.gz
  113. Resolving scratchbox.org... 62.61.85.37
  114. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  115. HTTP request sent, awaiting response... 200 OK
  116. Length: 14395788 (14M) [application/x-tar]
  117. Saving to: `/tmp/scratchbox-libs-1.0.7-i386.tar.gz'
  118.  
  119. 100%[======================================================================================================================================>] 14,395,788   138K/s   in 1m 43s  
  120.  
  121. 2009-01-01 08:48:17 (137 KB/s) - `/tmp/scratchbox-libs-1.0.7-i386.tar.gz' saved [14395788/14395788]
  122.  
  123. Downloading 'scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.5-i386.tar.gz'.
  124. --2009-01-01 08:48:18--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.5-i386.tar.gz
  125. Resolving scratchbox.org... 62.61.85.37
  126. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  127. HTTP request sent, awaiting response... 200 OK
  128. Length: 49751041 (47M) [application/x-tar]
  129. Saving to: `/tmp/scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.5-i386.tar.gz'
  130.  
  131. 100%[======================================================================================================================================>] 49,751,041   141K/s   in 5m 52s  
  132.  
  133. 2009-01-01 08:54:12 (138 KB/s) - `/tmp/scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.5-i386.tar.gz' saved [49751041/49751041]
  134.  
  135. Downloading 'scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.5-i386.tar.gz'.
  136. --2009-01-01 08:54:14--  http://scratchbox.org/download/files/sbox-releases/branches/apophis/r4/tarball/scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.5-i386.tar.gz
  137. Resolving scratchbox.org... 62.61.85.37
  138. Connecting to scratchbox.org|62.61.85.37|:80... connected.
  139. HTTP request sent, awaiting response... 200 OK
  140. Length: 47935438 (46M) [application/x-tar]
  141. Saving to: `/tmp/scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.5-i386.tar.gz'
  142.  
  143. 100%[======================================================================================================================================>] 47,935,438   139K/s   in 5m 44s  
  144.  
  145. 2009-01-01 08:59:58 (136 KB/s) - `/tmp/scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.5-i386.tar.gz' saved [47935438/47935438]
  146.  
  147.  
  148. Setting up
  149. ----------
  150.  
  151. Extracting 'scratchbox-core-1.0.7-i386.tar.gz' to '/scratchbox'.
  152. Extracting 'scratchbox-devkit-cputransp-1.0.2-i386.tar.gz' to '/scratchbox'.
  153. Extracting 'scratchbox-devkit-debian-1.0.8-i386.tar.gz' to '/scratchbox'.
  154. Extracting 'scratchbox-devkit-doctools-1.0.6-i386.tar.gz' to '/scratchbox'.
  155. Extracting 'scratchbox-devkit-perl-1.0.4-i386.tar.gz' to '/scratchbox'.
  156. Extracting 'scratchbox-devkit-maemo3-1.0-i386.tar.gz' to '/scratchbox'.
  157. Extracting 'scratchbox-libs-1.0.7-i386.tar.gz' to '/scratchbox'.
  158. Extracting 'scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.5-i386.tar.gz' to '/scratchbox'.
  159. Extracting 'scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.5-i386.tar.gz' to '/scratchbox'.
  160.  
  161. Running first time script.
  162. Do you want to use sudo mode? [yes/no] (no): Give the name of the scratchbox group (sbox): Stopping Scratchbox: umount, binfmt_misc.
  163. Starting Scratchbox: binfmt_misc, mount.
  164.  
  165. Now you should add one or more users with /scratchbox/sbin/sbox_adduser
  166.  
  167. Adding scratchbox user 'sake'.
  168. ผู้ใช้ `sake' ได้เป็นสมาชิกของกลุ่ม `sbox' นี้แล้ว
  169. Scratchbox user account for user sake added
  170.  
  171. Installation was successful!
  172. ----------------------------
  173.  
  174. You now have Scratchbox 1.0.7 'apophis' release installed.
  175.  
  176. Scratchbox cannot be run as user root. Instead, use your normal login
  177. user account. Add additional scratchbox users and sandboxes with the
  178. following command (outside scratchbox with root permissions):
  179.  
  180.         # /scratchbox/sbin/sbox_adduser USER yes
  181.  
  182. Running this command will create sandbox environment for that user and
  183. add user to the 'sbox' scratchbox user group.
  184. You will need to start a new login terminal after being added to the
  185. 'sbox' group for group membership to be effective.
  186.  
  187. Scratchbox service must be started for CPU transparency to be functional.
  188. Run the following command (outside scratchbox with root permissions):
  189.  
  190.         # /scratchbox/sbin/sbox_ctl start
  191.  
  192. Add this command to e.g. /etc/rc.local file to start scratchbox service
  193. at boot time.
  194.  
  195. Login to scratchbox session using the following command (as user):
  196.  
  197.         $ /scratchbox/login
  198.  
  199. Refer to scratchbox.org documentation for more information re scratchbox:
  200. http://scratchbox.org/documentation/user/scratchbox-1.0/

จากนั้นทำการโหลด sdk maemo มาโดยใช้สคริปเช่นเดียวกัน

  1. sake@sake-laptop:~/project/Embeded/N770/maemosdk$ wget http://repository.maemo.org/stable/3.1/maemo-sdk-install_3.1.sh
  2. sake@sake-laptop:~/project/Embeded/N770/maemosdk$ bash maemo-sdk-install_3.1.sh
  3. This script will install maemo SDK 3.1 'bora' release to your computer.
  4.  
  5. Install options
  6. Do not download or install Nokia EUSA binaries (no)
  7. Force remove of existing targets (no)
  8. Alternative sources.list ('')
  9.  
  10. Target configuration for armel (SDK_ARMEL)
  11. compiler=cs2005q3.2-glibc-arm
  12. devkits=perl:debian-sarge:maemo3-debian:maemo3-tools:cputransp
  13. cputransp=qemu-arm-0.8.2-sb2
  14.  
  15. Target configuration for i386 (SDK_X86)
  16. compiler=cs2005q3.2-glibc-i386
  17. devkits=perl:debian-sarge:maemo3-debian:maemo3-tools:doctools
  18.  
  19. Checking for prerequisites
  20. --------------------------
  21.  
  22. Which wget tool in path...
  23. Running outside of scratchbox...
  24. Script not run as user root...
  25. Scratchbox installation found...
  26. Scratchbox home directory...
  27. Scratchbox sb-conf tool...
  28. Scratchbox users bind mount...
  29. Scratchbox users /dev set up...
  30. Scratchbox home directory...
  31. Scratchbox login...
  32. Scratchbox login executable...
  33. Scratchbox sb-conf tool execute...
  34. Scratchbox version requirement...
  35. Scratchbox CPU transparency method for ARMEL is present...
  36. Scratchbox toolchains...
  37. Scratchbox required devkits...
  38. Acceptance to reset existing targets...
  39. Alternative sources.list file exists...
  40. Check for scratchbox sessions running...
  41.  
  42. # โหลดโปรแกรมมายาว ๆ ตัดออกละกัน
  43.  
  44. Installation was successful!
  45. ----------------------------
  46.  
  47. IMPORTANT! Please read this.
  48.  
  49. You now have the maemo 3.1 'bora' installed on your computer.
  50. You can now start your maemo SDK session with /scratchbox/login and
  51. then select your target with 'sb-conf select SDK_ARMEL' for armel
  52. target or 'sb-conf select SDK_X86' for i386 target.
  53.  
  54. If you have any problems with targets' package databases, you can try
  55. running 'fakeroot apt-get -f install' on your scratchbox target.
  56. This command will try to fix any problems with the package database.
  57.  
  58. Even though the SDK was successfully installed, the installation process
  59. was unable to run 'apt-get update' inside the installed targets in order
  60. to update the local package database. This could be due to a error in
  61. network configuration inside scratchbox. A common causes are incorrect proxy
  62. settings and the 'hosts' line in /scratchbox/etc/nsswitch.conf.
  63. For the 'hosts' line in /scratchbox/etc/nsswitch.conf the following should
  64. usually be enough:
  65. hosts:          files dns
  66.  
  67. Once network connections inside scratchbox are working, you should run
  68. 'apt-get update' on both targets.
  69.  
  70. Nokia EUSA binaries
  71. -------------------
  72.  
  73. The package maemo-explicit is a metapackage of Nokia EUSA licensed
  74. binaries which can be installed to scratchbox targets. It is highly
  75. recommended to install this package on both targets to ensure a fully
  76. working system.  
  77.  
  78. If you want to install these, login to scratchbox (see commands above)
  79. and run the command 'fakeroot apt-get install maemo-explicit' for both
  80. armel (SDK_ARMEL) and i386 (SDK_X86) targets.
  81.  
  82. Happy hacking!

หลังจากนั้น เราเริ่มเข้าใช้งาน scratch box กันครับ

  1. #/scratchbox/login
  2. Welcome to Scratchbox, the cross-compilation toolkit!
  3.  
  4. Use 'sb-menu' to change your compilation target.
  5. See /scratchbox/doc/ for documentation.
  6.  
  7. [sbox-SDK_X86: ~] >

เราสามารถเปลี่ยนระหว่าง host กับ target ได้ โดย

  1. [sbox-SDK_X86: ~] >  sb-conf select SDK_ARMEL
  2.  
  3. [sbox-SDK_ARMEL: ~] >
  4.  
  5.  
  6. [sbox-SDK_ARMEL: ~] > sb-conf select SDK_X86
  7.  
  8. [sbox-SDK_X86: ~] >

ตัว sdk ของ maemo นั้น แนะนำให้อัพเกรด เป็น version ใหม่ คือ 3.2 สามารถใช้ apt ในการปรับปรุงได้เลยครับ

  1. [sbox-SDK_X86: ~] > apt-get update
  2.  
  3.  
  4. Err http://repository.maemo.org bora/free Packages
  5.   Could not resolve 'repository.maemo.org'
  6. Err http://repository.maemo.org bora/free Release
  7.   Could not resolve 'repository.maemo.org'

เกิดปัญหาขึ้น เนื่องมาจากการค้น DNS ที่คัดลอกมาจาก /etc เราสามารแก้ไปได้โดยไปที่นอก scratchbox แล้วแก้ไฟล์ /scratchbox/etc/nsswitch.conf
แก้ให้บรรทัด
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
ให้เป็น
hosts : file dns

ลองใหม่ ผ่านแล้ว เริ่มอัพเกรดได้ ต้องทำทั้ง host และ target

  1. [sbox-SDK_X86: ~] > apt-get update
  2.  
  3. [sbox-SDK_X86: ~] > PAGER=less fakeroot apt-get dist-upgrade
  4.  
  5. [sbox-SDK_X86: ~] > sb_conf select SDK_ARMEL
  6.  
  7. [sbox-SDK_ARMEL: ~] > PAGER=less fakeroot apt-get dist-upgrade
  8. sb-conf select SDK_X86
  9. ...
  10. mmap: permission denied when building
  11. dpkg: error processing /var/cache/apt/archives/maemo-af-desktop_2.9.99.25-1_armel.deb (--unpack)

เกิดปัญหาในขั้นตอนที่สอง เราสามารถแก้ไขได้ โดย ปิด vdso และ limit memory map ให้เหลือ 4096 แทนค่ามาตรฐาน 65535

  1. [sbox-SDK_ARMEL: ~] >  echo 0 | sudo tee /proc/sys/vm/vdso_enabled
  2.  
  3.  
  4. [sbox-SDK_ARMEL: ~] >  echo 4096 | sudo tee /proc/sys/vm/mmap_min_addr

จากนั้น อัพเกรดอีกครั้ง จะพบว่า สามารถลงได้เรียบร้อย

จากนั้น เปิดเทอร์มินอลมาลง xserver-xephyr สำหรับรัน X อีกตัว และให้ scratchbox ติดต่อ และ

  1. sake@sake-laptop:~/project/Embeded/N770/maemosdk$  sudo apt-get install xserver-xephyr
  2. sake@sake-laptop:~/project/Embeded/N770/maemosdk$ Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac

และเรียกสคริปที่ scratchbox ให้เริ่มทำงาน gui

  1. [sbox-SDK_ARMEL:~] > export DISPLAY=:2
  2. [sbox-SDK_ARMEL:~] > af-sb-init.sh start

ผลที่ได้

ในครั้งต่อไป เราจะมาติดตั้งฟอนต์และคีย์บอร์ดไทยกัน
อ้างอิง:
http://ianlawrence.info/random-stuff/maemo-3-1-bora-on-ubuntu-feisty

ความเห็น

พอดีผมอ่านแล้ววิธีการติดตั้งแล้วยังงอยู่ครับ

รูปภาพของ sake

ไม่ทราบว่า สงสัยตรงส่วนไหนครับ ถ้าตอบได้จะอธิบายให้ครับ