2012/10/19

inside nextvod - replace busybox

[2013/03/21 更新]
busybox 是一個麻雀雖小五臟俱全的程式(佔用空間小但功能眾多).

目前高手放出的 busybox 版本是舊版的,紀錄自己編譯新版 1.20.2 歷程:

直接安裝:

  1. 建議直接安裝本站推出的 sh4twbox 較方便
  2. 下載本站封裝好的 busybox (功能較多, 且放在 bin, sbin 目錄避免與其他套件檔名衝突)
    1. .tgz 適用於網樂通原版環境(無法解壓縮 .xz格式)
    2. .txz 適用已改機網樂通(可解 .xz 格式, 例如本站的 sh4twbox)
    3. .x86_64.txz 適用於 Linux PC
  3. 放到網樂通根目錄解壓縮.
  4. cd /
  5. tar xf busybox-<version>.<ext>
  6. 若第一次替換原本網樂通的 busybox, 需要將 inittab 指到原本的 inittabBB
    1. cd /
    2. ln -s etc/inittabBB etc/inittab
    3. 若上面這行有錯誤訊息, 則先改名字, 再重作連結
      1. mv etc/inittab etc/inittab.org

編譯方式:

sudo apt-get install libncurses5-dev # under STLinux 2.3
make mrproper
make defconfig

make menuconfig
busybox settings/ General Configuration/Don't use /usr # 避免裝到 /usr 目錄
busybox settings/build options/Cross Compiler prefix:
  • 如果使用 stlinux 的編譯器, sh4-linux-
  • 如果使用 crosstool-ng 的編譯器, sh4-linux-unknown-gnu
busybox settings/Busybox Library Tuning/
  • Save history on shell exit, not after every command
  • Username completion
  • Query cursor position from terminal
  • Give more precise messages when copy fails (cp, mv etc)
Linux Module Utilities/Simplified modutils:取消後勾選下列
  • insmod
  • rmmod
  • lsmod
  • Pretty output
  • modprobe
  • Blacklist support
  • depmod
Archival Utilities: enable ar,dpkg
Linux Ext2 FS Progs: enable tune2fs
Linux System Utilities:
blkid:Print filesystem type
Write Support/Support GPT disklabels
mount/support mount helpers
Print Utilities: all off
make -j5 # assume your CPU support 4 threads
sudo make install
sudo chmod u+s _install/bin/busybox
file _install/bin/busybox # 確認 build 出正確的執行檔
  • _install/bin/busybox: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), dynamically linked (uses shared libs), stripped
# copy libnss files to let login su workable (libnss_files.* libnss_dns.*)
ldd _install/bin/busybox # 確認動態連結庫
sh4-unknown-linux-gnu-ldd --root ~/x-tools bin/busybox # crosstool-ng 使用這個方法

package (還不知道怎麼用 fakeroot 包裝,手動包裝):

sudo chown -R root:root _install/
sudo chmod u+s _install/bin/busybox
sudo tar -C _install -czf busybox.tgz .

過去失敗的經驗:

  • inittab 失敗的log,重要訊息 Bad inittab entry at line 5
    最後會一直重複:
    can't open /dev/con: No such file or directory
    can't open /dev/z6: No such file or directory
    解法:(2012/10/19) 調整開機參數 init=/bin/sh 啟動, 網樂通的 busybox 有改過,內定啟動的 script 不同
  • 無法執行busybox失敗的log,重要訊息Kernel panic - not syncing: No init found
    解法: busybox 的/sbin/init無法正確執行,缺少 dynamic library
    • 檢查方式, 先用 partition 1 開機, 放入 cross compile 環境(stlinux 2.3)中的 /opt/STM/STLinux-2.3/devkit/sh4/target/usr/bin/ldd 到網樂通裏面
    • ldd /bin/busybox
    • 從 /dev/sda1/lib 裏面 copy 所需之動態函式庫
      • 例如: ld-linux.so.2  libc.so.6 libcrypt.so.1  libm.so.6
參考資料:

4 則留言:

test 提到...

請問 "解法:(2012/10/19) 調整開機參數 init=/bin/sh 啟動, 網樂通的 busybox 有改過,內定啟動的 script 不同" 這段,因目前還沒有 TTL 線,一直無法成功編譯 busybox (可執行顯示1.20.2版,但置換後無法開機);有無其他方式可以以新版 busybox 開機呢?謝謝!

派樂靈丹 提到...

1. 若不是很熟 busybox, 沒有 TTL 線無法除錯
2. 其他新版 busybox, 請稍待, 近期釋放出我自編的環境.

Unknown 提到...

To : lod
ln -s etc/inittabBB etc/inittab
不會成功, 所以 mv 完後重開機後就.....

可直接 cp etc/inittabBB etc/inittab



可是重開後不能執行shpkg , 且找不到 shpkg ??

派樂靈丹 提到...

看不大懂不行的理由, 基本上 shpkg 只裝 busybox 不會以ㄡ. 它放在 /usr/bin/shpkg. 另外它執行之前必須要有可運作的 bash.