--- /dev/null
+This document describes how to setup a Buildbotics development environment
+on a Debian based system inside a chroot. Building in the chroot ensures that
+you have a clean and consistent build environment unaltered by other packages
+or manual changes.
+
+# Install packages required to create chroot
+
+ sudo apt-get update
+ sudo apt-get install binutils debootstrap
+
+# Create chroot environment
+
+ mkdir bbdev
+ sudo debootstrap --arch amd64 stable bbdev http://deb.debian.org/debian
+
+# Copy downloaded files (optional)
+To speed things up you can copy to large downloads, if you already have them,
+into the chroot.
+
+ sudo mkdir -p bbdev/opt/bbctrl-firmware/src/bbserial/
+ sudo cp 2017-11-29-raspbian-stretch-lite.zip bbdev/opt/bbctrl-firmware/
+ sudo cp raspberrypi-kernel_1.20171029-1.tar.gz bbdev/opt/bbctrl-firmware/src/bbserial/
+
+# Enter the chroot
+
+ sudo mount --bind /proc bbdev/proc
+ sudo mount --rbind /sys bbdev/sys
+ sudo mount --rbind /dev bbdev/dev
+ sudo chroot bbdev
+ cd /opt
+
+Now, follow the instructions in [development.md](development.md) from with in
+the chroot.
+
+# Exit the chroot
+To exit the chroot:
+
+ exit
+ sudo umount bbdev/dev
+ sudo umount bbdev/sys
+ sudo umount bbdev/proc
sudo apt-get update
sudo apt-get install -y build-essential git wget binfmt-support qemu \
parted gcc-avr avr-libc avrdude pylint3 python3 python3-tornado curl \
- unzip python3-setuptools
- curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
+ unzip python3-setuptools gcc-arm-linux-gnueabihf bc sudo
+ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs
## Getting the Source Code
git clone https://github.com/buildbotics/bbctrl-firmware
-## Install the Linux kernel source
-
-An optimized Linux serial driver is built as part of the Buildboitcs firmwere.
-A copy of the Linux kernel source for the RaspberryPi is necessary for building
-this module. [Download the kernel source](https://github.com/dbrgn/linux-rpi/releases/tag/raspberrypi-kernel_1.20171029-1)
-and move it to ``src/bbserial/kernel``.
-
## Build the Firmware
cd bbctrl-firmware
-CROSS := arm-linux-gnueabihf-
+CROSS:=arm-linux-gnueabihf-
DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
-obj-m := bbserial.o
-ccflags-y := -std=gnu99 -Wno-declaration-after-statement
+obj-m:=bbserial.o
+ccflags-y:=-std=gnu99 -Wno-declaration-after-statement
-all:
- $(MAKE) ARCH=arm CROSS_COMPILE=$(CROSS) -C kernel M=$(DIR) modules
+KPKG=raspberrypi-kernel_1.20171029-1.tar.gz
+KURL=https://github.com/dbrgn/linux-rpi/archive/$(KPKG)
+KDIR=linux-rpi-raspberrypi-kernel_1.20171029-1
+export KERNEL=kernel7
+
+KOPTS=ARCH=arm CROSS_COMPILE=$(CROSS) -C $(KDIR)
+
+all: $(KDIR)
+ $(MAKE) $(KOPTS) M=$(DIR) modules
+
+$(KDIR): $(KPKG)
+ tar xf $(KPKG)
+ $(MAKE) $(KOPTS) bcm2709_defconfig
+ $(MAKE) $(KOPTS) modules_prepare
+
+$(KPKG):
+ wget $(KURL)
clean:
- $(MAKE) ARCH=arm CROSS_COMPILE=$(CROSS) -C kernel M=$(DIR) clean
+ $(MAKE) $(KOPTS) M=$(DIR) clean
+ rm -rf $(KDIR) $(KPKG)