aboutsummaryrefslogtreecommitdiff
path: root/beaglebone
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-12 15:21:19 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-12 15:21:19 +0200
commit891595b9307eb2695411d8e32e4addd9cd927ec8 (patch)
treeb24c323ad3e09f05ca75386ac8fef38a6fff3e74 /beaglebone
parent6926a88695ce2e9fca51e01a1bf6fded3e4cbcca (diff)
rename folders
Diffstat (limited to 'beaglebone')
-rw-r--r--beaglebone/.gitignore3
-rw-r--r--beaglebone/Containerfile13
-rw-r--r--beaglebone/makefile36
-rw-r--r--beaglebone/module/Makefile12
l---------beaglebone/module/config.h1
l---------beaglebone/module/fopdrv.c1
l---------beaglebone/module/fopdrv.h1
l---------beaglebone/module/main.c1
-rw-r--r--beaglebone/readme.md18
-rwxr-xr-xbeaglebone/rice.sh132
-rw-r--r--beaglebone/test/.gitignore1
-rw-r--r--beaglebone/test/main.c6
-rw-r--r--beaglebone/test/makefile1
13 files changed, 226 insertions, 0 deletions
diff --git a/beaglebone/.gitignore b/beaglebone/.gitignore
new file mode 100644
index 0000000..5b74d26
--- /dev/null
+++ b/beaglebone/.gitignore
@@ -0,0 +1,3 @@
+*.deb
+*.tar.xz
+headers
diff --git a/beaglebone/Containerfile b/beaglebone/Containerfile
new file mode 100644
index 0000000..cc368d8
--- /dev/null
+++ b/beaglebone/Containerfile
@@ -0,0 +1,13 @@
+from docker.io/library/debian:sid
+
+run apt-get update
+
+# packages (in separate steps to optimize caching)
+run apt-get install -y gcc-arm-linux-gnueabi
+run apt-get install -y gcc
+run apt-get install -y make
+run apt-get install -y git
+
+# container directory on which the working directory on host is mounted
+workdir /workdir
+
diff --git a/beaglebone/makefile b/beaglebone/makefile
new file mode 100644
index 0000000..06c2552
--- /dev/null
+++ b/beaglebone/makefile
@@ -0,0 +1,36 @@
+# see ./rice.sh
+RELEASE = 6.6.15-ti-rt-arm32-r1
+DEB_URL = https://repos.rcn-ee.com/debian/pool/main/l/linux-upstream/linux-headers-$(RELEASE)_1sid_armhf.deb
+
+.PHONY: FORCE
+
+kernel-headers.deb:
+ curl -sLo- $(DEB_URL) > $@
+
+data.tar.xz: kernel-headers.deb
+ ar x $< $@
+
+headers: data.tar.xz
+ mkdir -p $@
+ tar xf $< -C $@ --strip-components 4 ./usr/src/linux-headers-$(RELEASE)
+
+CTR := podman
+# CTR := sudo podman # rootless not set up or unsupported
+CTR_IMG_TAG := avans-drvo
+
+CTRIZE := $(CTR) run
+CTRIZE += --rm
+CTRIZE += --tty
+CTRIZE += --volume /tmp:/tmp:rw
+CTRIZE += --volume .:/workdir:rw
+# CTRIZE += --env-file ./env
+CTRIZE += --env MAKE*
+CTRIZE += $(CTR_IMG_TAG)
+export
+
+container: FORCE
+ $(CTR) build --tag $(CTR_IMG_TAG) .
+
+build_test: FORCE
+ $(CTRIZE) $(MAKE) -C module
+
diff --git a/beaglebone/module/Makefile b/beaglebone/module/Makefile
new file mode 100644
index 0000000..01b2177
--- /dev/null
+++ b/beaglebone/module/Makefile
@@ -0,0 +1,12 @@
+RELEASE = 6.6.15-ti-rt-arm32-r1
+KERNEL := ../headers/
+ARCH := arm
+CROSS_COMPILE := arm-linux-gnueabi-
+
+obj-m += lork.o
+lork-y += main.o
+lork-y += fopdrv.o
+
+all:
+ $(MAKE) -C $(KERNEL) M=$(PWD) modules
+
diff --git a/beaglebone/module/config.h b/beaglebone/module/config.h
new file mode 120000
index 0000000..bad07c3
--- /dev/null
+++ b/beaglebone/module/config.h
@@ -0,0 +1 @@
+../../1/config.h \ No newline at end of file
diff --git a/beaglebone/module/fopdrv.c b/beaglebone/module/fopdrv.c
new file mode 120000
index 0000000..cbe1e0f
--- /dev/null
+++ b/beaglebone/module/fopdrv.c
@@ -0,0 +1 @@
+../../1/fopdrv.c \ No newline at end of file
diff --git a/beaglebone/module/fopdrv.h b/beaglebone/module/fopdrv.h
new file mode 120000
index 0000000..f9b9e9f
--- /dev/null
+++ b/beaglebone/module/fopdrv.h
@@ -0,0 +1 @@
+../../1/fopdrv.h \ No newline at end of file
diff --git a/beaglebone/module/main.c b/beaglebone/module/main.c
new file mode 120000
index 0000000..6180bb4
--- /dev/null
+++ b/beaglebone/module/main.c
@@ -0,0 +1 @@
+../../1/main.c \ No newline at end of file
diff --git a/beaglebone/readme.md b/beaglebone/readme.md
new file mode 100644
index 0000000..5231d8f
--- /dev/null
+++ b/beaglebone/readme.md
@@ -0,0 +1,18 @@
+I used [this][img] image as a base, and riced the shit out of it using the
+steps recorded in [rice.sh](./rice.sh). This script can be run from the above
+image by doing the following:
+
+```
+ (login as `debian` with password `temppwd`)
+
+$ curl -sLo- https://git.pipeframe.xyz/school/drvo/plain/2/rice.sh | sudo sh -s
+```
+
+This will upgrade the kernel to version `6.6.15-ti-rt-arm32-r1`, which supports
+some fancy new features like the new `class_create` method introduced in 6.4. I
+actually recommend you *do not do this*, and instead just start writing a
+kernel module targeting version 5.10 from week 1, as this kernel version is way
+more common.
+
+[img]: https://www.beagleboard.org/distros/am335x-11-7-2023-09-02-4gb-emmc-xfce-flasher
+
diff --git a/beaglebone/rice.sh b/beaglebone/rice.sh
new file mode 100755
index 0000000..ea1e7d2
--- /dev/null
+++ b/beaglebone/rice.sh
@@ -0,0 +1,132 @@
+#!/bin/sh
+if [ $(id -u) -ne 0 ] ; then
+ echo 'this script should be run as root instead!'
+ exit 1
+fi
+
+USER_NAME='loek'
+HOST_NAME='drvo'
+KERNEL_VERSION='6.6.15-ti-rt-arm32-r1' # latest i could find for ti
+
+# fail ok
+fok() { "$@" 1> /dev/null 2> /dev/null ; }
+
+echo "setting hostname to $HOST_NAME..."
+hostname $HOST_NAME
+hostname > /etc/hostname
+sed -i 's/\<BeagleBone\>/'"$HOST_NAME"'/g' /etc/hosts
+
+echo "creating user $USER_NAME..."
+fok userdel debian
+rm -rf /home/debian
+fok id -u $USER_NAME || fok adduser $USER_NAME
+
+echo "removing all security..."
+rm -f /etc/sudoers.d/admin
+cat << "EOF" > /etc/sudoers.d/nopasswd
+%sudo ALL=(ALL:ALL) NOPASSWD: ALL
+EOF
+usermod -aG sudo $USER_NAME
+cat << "EOF" > /etc/ssh/sshd_config.d/rice.conf
+PasswordAuthentication yes
+PermitEmptyPasswords yes
+PermitRootLogin yes
+PrintLastLog no
+EOF
+systemctl restart ssh
+fok passwd -d root
+fok passwd -d $USER_NAME
+
+echo "fixing terminal colors & default editor..."
+cat << "EOF" > /etc/profile.d/rice.sh
+export TERM="xterm-256color"
+export EDITOR="nvim"
+EOF
+
+echo "removing bloatware..."
+fok apt remove -y --allow-change-held-packages \
+ libruby2.7 libgl1-mesa-dri python3-numpy mesa-vulkan-drivers \
+ bb-beagle-config libflite1 firmware-libertas python3-mypy libgtk-3-common \
+ adwaita-icon-theme firmware-atheros firmware-misc-nonfree \
+ pocketsphinx-en-us scratch libwebkit2gtk-4.0-37 firmware-iwlwifi \
+ bb-node-red-installer firefox-esr bb-code-server plymouth xserver-xorg-core \
+ xserver-xorg xserver-xorg-legacy x11-common x11-server-utils x11-utils \
+ lightdm-gtk-greeter lightdm xfce4-session xfce4-panel xfce4-settings \
+ xfce4-helpers fonts-dejavu-core nodejs nodejs-doc nginx-core nginx-common \
+ nginx mesa-va-drivers bluetooth bluez pipewire-bin pipewire pulseaudio-utils \
+ pulseaudio gtk-update-icon-cache wpasupplicant fontconfig-config fontconfig \
+ hostapd adwaita-icon-theme hicolor-icon-theme polkitd whiptail
+echo "removing more bloatware..."
+fok apt autoremove -y
+echo "cleaning up trash..."
+fok apt clean -y
+
+echo "updating system..."
+fok apt-get update
+fok apt-get upgrade -y
+
+echo "preparing for debian sid update..."
+export DEBIAN_FRONTEND=noninteractive
+echo "usrmerge usrmerge/autoconvert boolean true" | debconf-set-selections
+fok apt-get install usrmerge -y
+cat << "EOF" > /etc/apt/sources.list
+deb http://deb.debian.org/debian sid main contrib non-free
+deb [arch=armhf signed-by=/usr/share/keyrings/rcn-ee-archive-keyring.gpg] http://repos.rcn-ee.com/debian/ sid main
+EOF
+fok apt-get update
+echo "updating to debian sid..."
+apt-get dist-upgrade -y
+
+echo "removing noisy banners..."
+rm -f /etc/motd /etc/issue /etc/issue.net /etc/dogtag
+
+echo "install newer linux kernel..."
+fok apt-get install -y linux-image-$KERNEL_VERSION linux-headers-$KERNEL_VERSION
+
+echo "install based software..."
+fok apt-get install -y neovim zsh git systemd-resolved
+fok chsh -s /bin/zsh $USER_NAME
+fok chsh -s /bin/zsh root
+
+cp /etc/zsh/newuser.zshrc.recommended "/home/$USER_NAME/.zshrc"
+chown "$USER_NAME:$USER_NAME" "/home/$USER_NAME/.zshrc"
+cat << "EOF" > /root/.zshrc
+# Set up the prompt
+autoload -Uz promptinit
+promptinit
+prompt redhat
+
+setopt histignorealldups sharehistory
+
+# Use emacs keybindings even if our EDITOR is set to vi
+bindkey -e
+
+# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
+HISTSIZE=1000
+SAVEHIST=1000
+HISTFILE=~/.zsh_history
+
+# Use modern completion system
+autoload -Uz compinit
+compinit
+
+zstyle ':completion:*' auto-description 'specify: %d'
+zstyle ':completion:*' completer _expand _complete _correct _approximate
+zstyle ':completion:*' format 'Completing %d'
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*' menu select=2
+zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
+zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
+zstyle ':completion:*' menu select=long
+zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
+zstyle ':completion:*' use-compctl false
+zstyle ':completion:*' verbose true
+
+zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
+EOF
+echo "emulate sh -c 'source /etc/profile'" >> /etc/zsh/zprofile
+
+echo "cleaning up trash..."
+fok apt clean -y
+
+echo "all done!"
diff --git a/beaglebone/test/.gitignore b/beaglebone/test/.gitignore
new file mode 100644
index 0000000..ba2906d
--- /dev/null
+++ b/beaglebone/test/.gitignore
@@ -0,0 +1 @@
+main
diff --git a/beaglebone/test/main.c b/beaglebone/test/main.c
new file mode 100644
index 0000000..04ce434
--- /dev/null
+++ b/beaglebone/test/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main() {
+ printf("Hello world!\n");
+ return 0;
+}
diff --git a/beaglebone/test/makefile b/beaglebone/test/makefile
new file mode 100644
index 0000000..cd6a8c6
--- /dev/null
+++ b/beaglebone/test/makefile
@@ -0,0 +1 @@
+main: main.c