源碼及編譯

很高興地宣佈Banana Pi的源碼已公佈開放在GitHub BananaPi-Dev,希望透過這一小步,促成大家有興趣透過香蕉派來創造出許多有趣的、有用的的專案,大家一起來Make吧!

編譯及製作Banana Pi的image的步驟列示如下,供大家參考,敬請指教!

===== 步 驟 =====

0. Using Ubuntu Linux (12.04 or later) as the development platform, install the following packages:
  $ sudo apt-get install build-essential libncurses5-dev u-boot-tools qemu-user-static debootstrap git binfmt-support libusb-1.0-0-dev pkg-config
  $ sudo apt-get install gcc-arm-linux-gnueabihf

1. 設定工作路徑
  $ export WORKSPACE=`pwd`

2. 從github下載sunxi-bsp source code
  $ git clone https://github.com/bananapi-dev/sunxi-bsp

3. 進入sunxi-bsp目錄
  $ cd sunxi-bsp

4. 設定環境變數
  $ source bpi_env.sh

5. 更新及編譯source code
  第一次因為找不到Bananapi project,所以先configure cubietruck
    $ ./configure cubietruck
    $ make update
  正式configure Bananapi及編譯
    $ ./configure Bananapi
    $ make update
    $ make
 
6. 下載rootfs package (Ubuntu/Lubuntu/Respbian...),解壓縮放到 $WORKSPACE
  $ cd $WORKSPACE
  $ wget https://releases.linaro.org/12.11/ubuntu/precise-images/ubuntu-desktop/linaro-precise-ubuntu-desktop-20121124-560.tar.gz
  $ mkdir ROOTFS_DIR
  $ sudo tar --strip-components=3 -pzxvf linaro-precise-ubuntu-desktop-20121124-560.tar.gz -C ROOTFS_DIR

7. 將相關檔案放入ROOTFS_DIR
  $ sudo cp sunxi-bsp/build/Bananapi_hwpack/kernel/script.bin ROOTFS_DIR/boot
  $ sudo cp sunxi-bsp/build/Bananapi_hwpack/kernel/uImage ROOTFS_DIR/boot
  $ sudo gedit ROOTFS_DIR/boot/uEnv.txt
    加入內容如下:
      mmcboot=fatload mmc 0 0x43000000 script.bin || fatload mmc 0 0x43000000 evb.bin; \
      fatload mmc 0 0x48000000 uImage; if fatload mmc 0 0x43100000 uInitrd; \
      then bootm 0x48000000 0x43100000; else bootm 0x48000000; fi
      uenvcmd=run mmcboot
      bootargs=console=ttyS0,115200 console=tty0 \
      disp.screen0_output_mode=EDID:1280x720p60 \
      hdmi.audio=EDID:0 root=/dev/mmcblk0p1

  $ sudo cp -r sunxi-bsp/build/Bananapi_hwpack/rootfs/* ROOTFS_DIR
  $ sudo gedit ROOTFS_DIR/etc/network/interface
    加入內容如下:
      auto eth0
      iface eth0 inet dhcp

  $ sudo vi ROOTFS_DIR/etc/NetworkManager/NetworkManager.conf
     修改內容如下:
      [ifupdown]
      managed=true

8. 格式化sdcard (假設sdcard位置為/dev/sdb)
  $ sudo umount /dev/sdb1
  $ sudo dd if=/dev/zero of=/dev/sdb bs=1k count=1024
  $ sudo dd if=sunxi-bsp/build/Bananapi_hwpack/bootloader/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
  $ sudo fdisk /dev/sdb
     切割為一個partition
  $ sudo mkfs.ext4 /dev/sdb1

9. 將ROOTFS_DIR內容放入sdcard
  $ mkdir mnt
  $ sudo mount /dev/sdb1 mnt
  $ sudo cp -a ROOTFS_DIR/* mnt
  $ sudo sync

===== End =====

1 則留言: