From 95697a4e93eeddf75d19becb5d79acb720c22ecb Mon Sep 17 00:00:00 2001 From: David Carley Date: Thu, 4 Aug 2022 01:40:27 +0000 Subject: [PATCH] Firmware now builds in a VSCode "Remote Container" --- .devcontainer/Dockerfile | 15 +++++++++++++++ .devcontainer/devcontainer.json | 26 ++++++++++++++++++++++++++ docs/development.md | 18 ++++++++++++------ scripts/rpi-chroot.sh | 23 +++++++++++++---------- src/bbserial/Makefile | 6 ++++-- src/pug/templates/settings-view.pug | 2 +- 6 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b8fa432 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,15 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.241.1/containers/debian/.devcontainer/base.Dockerfile + +# [Choice] Debian version (use bullseye on local arm64/Apple Silicon): bullseye, buster +ARG VARIANT=bullseye +FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT} + +RUN apt update \ + && apt upgrade -y \ + && apt install -y \ + build-essential git wget binfmt-support qemu gcc-9 \ + parted gcc-avr avr-libc avrdude python3 python3-tornado curl \ + unzip python3-setuptools gcc-arm-linux-gnueabihf bc sudo \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 \ + && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && apt install -y nodejs diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..62b154a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/blob/v0.241.1/containers/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Debian version: bullseye, buster + // Use bullseye on local arm64/Apple Silicon. + "args": { "VARIANT": "bullseye" } + }, + + "runArgs": ["--privileged"], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. + // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode", + + "features": { + "sshd": "latest" + } +} diff --git a/docs/development.md b/docs/development.md index 6a82eb5..028d1b5 100644 --- a/docs/development.md +++ b/docs/development.md @@ -8,12 +8,18 @@ Debian Linux are not supported. On a Debian Linux (9.6.0 stable) system install the required packages: - 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 gcc-arm-linux-gnueabihf bc sudo - curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - - sudo apt-get install -y nodejs + apt update + apt upgrade -y + apt install -y \ + build-essential git wget binfmt-support qemu gcc-9 \ + parted gcc-avr avr-libc avrdude python3 python3-tornado curl \ + unzip python3-setuptools gcc-arm-linux-gnueabihf bc sudo + + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 + + curl -fsSL https://deb.nodesource.com/setup_18.x | bash - + + apt install -y nodejs ## Getting the Source Code diff --git a/scripts/rpi-chroot.sh b/scripts/rpi-chroot.sh index 35e15be..ef52ca6 100755 --- a/scripts/rpi-chroot.sh +++ b/scripts/rpi-chroot.sh @@ -1,7 +1,6 @@ #!/bin/bash -ex ROOT="$PWD/rpi-root" -LOOP=12 if [ $# -lt 1 ]; then echo "Usage: $0 " @@ -9,7 +8,8 @@ if [ $# -lt 1 ]; then fi IMAGE="$1" -LOOP_DEV=/dev/loop${LOOP} +LOOP_BOOT= +LOOP_ROOT= EXEC= if [ $# -gt 1 ]; then @@ -26,25 +26,28 @@ fi # Clean up on EXIT function cleanup { umount "$ROOT"/{dev/pts,dev,sys,proc,boot,mnt/host,} 2>/dev/null || true - losetup -d $LOOP_DEV 2>/dev/null || true + losetup -d $LOOP_BOOT 2>/dev/null || true + losetup -d $LOOP_ROOT 2>/dev/null || true rmdir "$ROOT" 2>/dev/null || true } trap cleanup EXIT -# set up image as loop device -losetup $LOOP_DEV "$IMAGE" -partprobe $LOOP_DEV +LOOP_BOOT=`losetup -f` +losetup -o 4194304 $LOOP_BOOT "$IMAGE" + +LOOP_ROOT=`losetup -f` +losetup -o 48234496 $LOOP_ROOT "$IMAGE" # check and fix filesystems -fsck -f ${LOOP_DEV}p1 -fsck -f ${LOOP_DEV}p2 +fsck -f $LOOP_BOOT +fsck -f $LOOP_ROOT # make dir mkdir -p "$ROOT" # mount partition -mount -o rw ${LOOP_DEV}p2 -t ext4 "$ROOT" -mount -o rw ${LOOP_DEV}p1 "$ROOT/boot" +mount -o rw $LOOP_ROOT -t ext4 "$ROOT" +mount -o rw $LOOP_BOOT "$ROOT/boot" # mount binds mount --bind /dev "$ROOT/dev/" diff --git a/src/bbserial/Makefile b/src/bbserial/Makefile index 0b7bbc6..792ddfd 100644 --- a/src/bbserial/Makefile +++ b/src/bbserial/Makefile @@ -5,7 +5,7 @@ ccflags-y:=-std=gnu99 -Wno-declaration-after-statement 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 +KDIR=/tmp/rpi-kernel export KERNEL=kernel7 KOPTS=ARCH=arm CROSS_COMPILE=$(CROSS) -C $(KDIR) @@ -14,7 +14,9 @@ all: $(KDIR) $(MAKE) $(KOPTS) M=$(DIR) modules $(KDIR): $(KPKG) - tar xf $(KPKG) + rm -rf $(KDIR) + mkdir -p $(KDIR) + tar xf $(KPKG) -C $(KDIR) --strip-components 1 $(MAKE) $(KOPTS) bcm2709_defconfig $(MAKE) $(KOPTS) modules_prepare diff --git a/src/pug/templates/settings-view.pug b/src/pug/templates/settings-view.pug index 8a0061f..4b6cf85 100644 --- a/src/pug/templates/settings-view.pug +++ b/src/pug/templates/settings-view.pug @@ -1,2 +1,2 @@ script#settings-view-template(type="text/x-template") - #settings \ No newline at end of file + #settings