KEMBAR78
BeagleBone Black with Upstream Software | PPTX
BeagleBone Black
with upstream software
Viktoriia Taraniuk
BBB Overview
Open hardware:
● Technical Reference Manual (TRM)
● Schematic and PCB
Supported in upstream:
● Kernel
● U-boot
Cost: $55
Software components
● U-Boot
● Kernel
● Busybox
Building the software
Rules of the game
● Do all steps in one terminal
● Always check your path
● Don’t put / in the beginning of path because you can damage your rootfs
● Don’t work with root rights unless it was mentioned
● Each command should be verified (esp. export command)
Toolchains
● Main components:
○ Cross-compiler, linker, etc (gcc, ld, as, cpp)
○ libc (and other related libraries)
○ debugger (GDB), binary tools
● There are two kinds of toolchains:
○ Baremetal: for building programs being run without OS
○ Linux: for building user-space programs being run under Linux OS
Baremetal toolchain
● Download baremetal toolchain:
gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi.tar.xz
https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-eabi/
● Extract toolchain to /opt:
$ sudo tar xJvf gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi.tar.xz -C /opt/
Linux toolchain
● Download linux toolchain:
gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/
● Extract toolchain to /opt:
$ sudo tar xJvf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz -C /opt/
U-Boot: Obtain
● Obtain U-Boot source code:
$ git clone git://git.denx.de/u-boot.git
● Checkout to latest release tag:
$ git checkout v2018.03
U-Boot: Build
● Configure toolchain environment in shell:
$ export PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:$PATH
$ export CROSS_COMPILE=arm-eabi-
$ export ARCH=arm
● Build U-Boot:
$ make am335x_boneblack_defconfig
$ make -j4
Linux kernel: Obtain
● Install host build dependencies:
$ sudo apt-get install ncurses-dev libssl-dev bc bison flex
● Obtain Linux kernel source code:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Linux kernel: Configure
● Configure toolchain environment in shell:
$ export PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:$PATH
$ export CROSS_COMPILE=arm-eabi-
$ export ARCH=arm
● Generate .config:
$ make multi_v7_defconfig
Linux kernel: Build
● Build kernel image and device tree blob:
$ make -j4 zImage am335x-boneblack.dtb
Busybox: Obtain
● Obtain sources:
$ git clone git://busybox.net/busybox.git
● Setup build environment (use Linux toolchain):
$ export ARCH=arm
$ export PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin:$PATH
$ export CROSS_COMPILE=arm-linux-gnueabihf-
● Checkout to latest stable branch:
$ git checkout 1_28_stable
Linking: static vs dynamic
● Static linking: libc (.a) is compiled in your binary
○ Only “busybox” binary is needed in rootfs
○ Easier to build and minimal
○ Some networking functions won’t work (nslookup, see libnss)
● Dynamic linking: libc used as a shared library (.so)
○ Only one copy of libc is used (both in rootfs and in RAM)
○ Dynamic libraries must be copied in rootfs /lib
(libc and its dependencies)
Busybox: Build and install
● Configure BusyBox with all features:
$ make defconfig
$ make menuconfig
● Build BusyBox:
$ make -j4
● Install to _install/ dir:
$ make install
Creating rootfs
Populate root dir
● Create root directories:
$ mkdir -p _install/{boot,dev,etc/init.d,proc,root,sys,tmp}
● Make “init” link:
$ cd _install/
$ ln -s bin/busybox init
$ cd -
Init script
● Create init script (_install/etc/init.d/rcS):
#!/bin/sh
mount -t sysfs none /sys
mount -t proc none /proc
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
● Make script executable:
$ chmod +x _install/etc/init.d/rcS
Populate /boot
● Populate /boot dir with kernel files:
$ cd _install/boot
$ cp $WORK_DIR/linux/arch/arm/boot/zImage .
$ cp $WORK_DIR/linux/arch/arm/boot/dts/am335x-boneblack.dtb .
$ cd -
Resulting rootfs
/
├── bin
│ └── busybox
├── boot
│ ├── am335x-boneblack.dtb
│ └── zImage
├── dev
├── etc
│ └── init.d
│ └── rcS
├── init -> bin/busybox
├── linuxrc -> bin/busybox
├── proc
├── root
├── sbin
├── sys
├── tmp
└── usr
├── bin
└── sbin
Q&A
Thank you!

BeagleBone Black with Upstream Software

  • 1.
    BeagleBone Black with upstreamsoftware Viktoriia Taraniuk
  • 2.
    BBB Overview Open hardware: ●Technical Reference Manual (TRM) ● Schematic and PCB Supported in upstream: ● Kernel ● U-boot Cost: $55
  • 3.
  • 4.
  • 5.
    Rules of thegame ● Do all steps in one terminal ● Always check your path ● Don’t put / in the beginning of path because you can damage your rootfs ● Don’t work with root rights unless it was mentioned ● Each command should be verified (esp. export command)
  • 6.
    Toolchains ● Main components: ○Cross-compiler, linker, etc (gcc, ld, as, cpp) ○ libc (and other related libraries) ○ debugger (GDB), binary tools ● There are two kinds of toolchains: ○ Baremetal: for building programs being run without OS ○ Linux: for building user-space programs being run under Linux OS
  • 7.
    Baremetal toolchain ● Downloadbaremetal toolchain: gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi.tar.xz https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-eabi/ ● Extract toolchain to /opt: $ sudo tar xJvf gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi.tar.xz -C /opt/
  • 8.
    Linux toolchain ● Downloadlinux toolchain: gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/ ● Extract toolchain to /opt: $ sudo tar xJvf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz -C /opt/
  • 9.
    U-Boot: Obtain ● ObtainU-Boot source code: $ git clone git://git.denx.de/u-boot.git ● Checkout to latest release tag: $ git checkout v2018.03
  • 10.
    U-Boot: Build ● Configuretoolchain environment in shell: $ export PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:$PATH $ export CROSS_COMPILE=arm-eabi- $ export ARCH=arm ● Build U-Boot: $ make am335x_boneblack_defconfig $ make -j4
  • 11.
    Linux kernel: Obtain ●Install host build dependencies: $ sudo apt-get install ncurses-dev libssl-dev bc bison flex ● Obtain Linux kernel source code: $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
  • 12.
    Linux kernel: Configure ●Configure toolchain environment in shell: $ export PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:$PATH $ export CROSS_COMPILE=arm-eabi- $ export ARCH=arm ● Generate .config: $ make multi_v7_defconfig
  • 13.
    Linux kernel: Build ●Build kernel image and device tree blob: $ make -j4 zImage am335x-boneblack.dtb
  • 14.
    Busybox: Obtain ● Obtainsources: $ git clone git://busybox.net/busybox.git ● Setup build environment (use Linux toolchain): $ export ARCH=arm $ export PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin:$PATH $ export CROSS_COMPILE=arm-linux-gnueabihf- ● Checkout to latest stable branch: $ git checkout 1_28_stable
  • 15.
    Linking: static vsdynamic ● Static linking: libc (.a) is compiled in your binary ○ Only “busybox” binary is needed in rootfs ○ Easier to build and minimal ○ Some networking functions won’t work (nslookup, see libnss) ● Dynamic linking: libc used as a shared library (.so) ○ Only one copy of libc is used (both in rootfs and in RAM) ○ Dynamic libraries must be copied in rootfs /lib (libc and its dependencies)
  • 16.
    Busybox: Build andinstall ● Configure BusyBox with all features: $ make defconfig $ make menuconfig ● Build BusyBox: $ make -j4 ● Install to _install/ dir: $ make install
  • 17.
  • 18.
    Populate root dir ●Create root directories: $ mkdir -p _install/{boot,dev,etc/init.d,proc,root,sys,tmp} ● Make “init” link: $ cd _install/ $ ln -s bin/busybox init $ cd -
  • 19.
    Init script ● Createinit script (_install/etc/init.d/rcS): #!/bin/sh mount -t sysfs none /sys mount -t proc none /proc echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s ● Make script executable: $ chmod +x _install/etc/init.d/rcS
  • 20.
    Populate /boot ● Populate/boot dir with kernel files: $ cd _install/boot $ cp $WORK_DIR/linux/arch/arm/boot/zImage . $ cp $WORK_DIR/linux/arch/arm/boot/dts/am335x-boneblack.dtb . $ cd -
  • 21.
    Resulting rootfs / ├── bin │└── busybox ├── boot │ ├── am335x-boneblack.dtb │ └── zImage ├── dev ├── etc │ └── init.d │ └── rcS ├── init -> bin/busybox ├── linuxrc -> bin/busybox ├── proc ├── root ├── sbin ├── sys ├── tmp └── usr ├── bin └── sbin
  • 22.

Editor's Notes

  • #11 Output files: MLO (first-stage bootloader) u-boot.img (second-stage bootloader)
  • #14 Output files: arch/arm/boot/zImage arch/arm/boot/dts/am335x-boneblack.dtb