diff --git a/pi-gen-sources/00-teslausb-tweaks/00-patches/01-cmdline-update.diff b/pi-gen-sources/00-teslausb-tweaks/00-patches/01-cmdline-update.diff deleted file mode 100644 index 720c9fb15..000000000 --- a/pi-gen-sources/00-teslausb-tweaks/00-patches/01-cmdline-update.diff +++ /dev/null @@ -1,5 +0,0 @@ ---- stage_teslausb/rootfs/boot/cmdline.txt -+++ stage_teslausb/rootfs/boot/cmdline.txt -@@ -1 +1 @@ --console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait quiet init=/usr/lib/raspberrypi-sys-mods/firstboot -+dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait modules-load=dwc2,g_ether diff --git a/pi-gen-sources/00-teslausb-tweaks/00-patches/02-config-update.diff b/pi-gen-sources/00-teslausb-tweaks/00-patches/02-config-update.diff deleted file mode 100644 index 0a4174449..000000000 --- a/pi-gen-sources/00-teslausb-tweaks/00-patches/02-config-update.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- stage_teslausb/rootfs/boot/config.txt -+++ stage_teslausb/rootfs/boot/config.txt -@@ -54,6 +54,7 @@ - - # Enable audio (loads snd_bcm2835) - dtparam=audio=on -+dtoverlay=dwc2 - - [pi4] - # Enable DRM VC4 V3D driver on top of the dispmanx display stack diff --git a/pi-gen-sources/00-teslausb-tweaks/00-patches/series b/pi-gen-sources/00-teslausb-tweaks/00-patches/series deleted file mode 100644 index 99365a8ec..000000000 --- a/pi-gen-sources/00-teslausb-tweaks/00-patches/series +++ /dev/null @@ -1,2 +0,0 @@ -01-cmdline-update.diff -02-config-update.diff diff --git a/pi-gen-sources/00-teslausb-tweaks/00-run.sh b/pi-gen-sources/00-teslausb-tweaks/00-run.sh index d94d637db..4e6a4d190 100755 --- a/pi-gen-sources/00-teslausb-tweaks/00-run.sh +++ b/pi-gen-sources/00-teslausb-tweaks/00-run.sh @@ -1,74 +1,23 @@ #!/bin/bash -e touch "${ROOTFS_DIR}/boot/ssh" -install -m 666 files/userconf.txt "${ROOTFS_DIR}/boot/" install -m 755 files/rc.local "${ROOTFS_DIR}/etc/" -install -m 666 files/teslausb_setup_variables.conf.sample "${ROOTFS_DIR}/boot/teslausb_setup_variables.conf" -install -m 666 files/wpa_supplicant.conf.sample "${ROOTFS_DIR}/boot/" -install -m 666 files/run_once "${ROOTFS_DIR}/boot/" +install -m 666 files/teslausb_setup_variables.conf.sample "${ROOTFS_DIR}/boot/firmware/teslausb_setup_variables.conf" +install -m 666 files/wpa_supplicant.conf.sample "${ROOTFS_DIR}/boot/firmware" +install -m 666 files/run_once "${ROOTFS_DIR}/boot/firmware" install -d "${ROOTFS_DIR}/root/bin" -# work around shortcoming in pi-gen that causes ca-certificates to be -# misconfigured -on_chroot << EOF -/usr/bin/c_rehash /etc/ssl/certs/ -EOF +# ensure dwc2 module is loaded +echo "dtoverlay=dwc2" >> "${ROOTFS_DIR}/boot/firmware/config.txt" +# remove unwanted packages, disable unwanted services, and disable swap on_chroot << EOF -apt-get remove -y --force-yes --purge triggerhappy bluez alsa-utils -rm -rf /boot/kernel8.img -rm -rf /lib/modules/*-v8+ -echo "pi ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/pi-nopassword -EOF - -# disable various interactive setup dialogs -on_chroot << EOF +apt-get remove -y --force-yes --purge triggerhappy bluez userconf-pi dphys-swapfile firmware-libertas firmware-realtek firmware-atheros mkvtoolnix +apt-get -y --force-yes autoremove systemctl disable keyboard-setup -systemctl disable userconfig +systemctl disable resize2fs_once +systemctl disable dpkg-db-backup +update-rc.d resize2fs_once remove +rm /etc/init.d/resize2fs_once +rm /usr/share/initramfs-tools/scripts/local-premount/firstboot +update-initramfs -u EOF - -# Below here is the rest of the stage2 (builds the Stretch lite image) -# run script commented out just to give guidance on things that can be done. - -# install -m 755 files/teslausb_setup_scripts/bin/* "${ROOTFS_DIR}/root/bin/" -# install -d "${ROOTFS_DIR}/root/bin/tmp" -# install -m 755 files/teslausb_setup_scripts/tmp/* "${ROOTFS_DIR}/root/bin/tmp/" - -# on_chroot << EOF -# systemctl disable hwclock.sh -# systemctl disable nfs-common -# systemctl disable rpcbind -# systemctl disable ssh -# systemctl enable regenerate_ssh_host_keys -# EOF - -# if [ "${USE_QEMU}" = "1" ]; then -# echo "enter QEMU mode" -# install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" -# on_chroot << EOF -# systemctl disable resize2fs_once -# EOF -# echo "leaving QEMU mode" -# else -# on_chroot << EOF -# systemctl enable resize2fs_once -# EOF -# fi - -# on_chroot << \EOF -# for GRP in input spi i2c gpio; do -# groupadd -f -r "$GRP" -# done -# for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do -# adduser pi $GRP -# done -# EOF - -# on_chroot << EOF -# setupcon --force --save-only -v -# EOF - -# on_chroot << EOF -# usermod --pass='*' root -# EOF - -# rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key* diff --git a/pi-gen-sources/00-teslausb-tweaks/files/userconf.txt b/pi-gen-sources/00-teslausb-tweaks/files/userconf.txt deleted file mode 100644 index 036664ef1..000000000 --- a/pi-gen-sources/00-teslausb-tweaks/files/userconf.txt +++ /dev/null @@ -1 +0,0 @@ -pi:$6$JBQDChgFm34IIoOZ$rmTlqwCpgPwOHwmxAmmBLIlSojxxj8x7JHd9hGlNJ0hxsXVqDKFoP.xXcUPVyi6uXCMXZKqoVqwbL6wa9rLtT0 diff --git a/pi-gen-sources/Readme.md b/pi-gen-sources/Readme.md index f88dbe6da..a591f57b7 100644 --- a/pi-gen-sources/Readme.md +++ b/pi-gen-sources/Readme.md @@ -4,18 +4,8 @@ To build a ready to flash one-step setup image for CIFS, do the following: 1. Clone pi-gen from https://github.com/RPi-Distro/pi-gen 2. Follow the instructions in the pi-gen readme to install the required dependencies -3. In the pi-gen folder, run: - ``` - echo 'IMG_NAME=teslausb' > config - echo 'HOSTNAME=teslausb' >> config - echo 'STAGE_LIST="stage0 stage1 stage2 stage_teslausb"' >> config - rm -rf stage2/EXPORT_NOOBS stage2/EXPORT_IMAGE - mkdir stage_teslausb - touch stage_teslausb/EXPORT_IMAGE - cp stage2/prerun.sh stage_teslausb/prerun.sh - ``` -4. Copy teslausb/pi-gen-sources/00-teslausb-tweaks to the pi-gen/stage_teslausb folder -5. Adjust `DATA_SIZE` in scripts/qcow2_handling to have more free space on the root partition. For the prebuilt image, it was hardcoded to 2 GB by inserting `let DATA_SIZE=2*1024*1024*1024/$BLOCK_SIZE` before the call to `resize2fs -p`. -6. Run `build.sh` or `build-docker.sh`, depending on how you configured pi-gen to build the image -7. Sit back and relax, this could take a while (for reference, on a dual-core 2.6 Ghz Intel Core i3 and 50 Mbps internet connection, it took under an hour) +3. From the RPi-Distro/pi-gen folder, run the `prepare.sh` script from TeslaUSB's pi-gen-sources folder +4. If needed, adjust ROOT_MARGIN or ROOT_PART_SIZE in pi-gen/export-image/prerun.sh to ensure sufficient free space left on the root partition of the generated image +5. Run `build.sh` or `build-docker.sh`, depending on how you want to build the image. The Docker build is recommended +6. Sit back and relax, this could take a while (for reference, on a dual-core 2.6 Ghz Intel Core i3 and 50 Mbps internet connection, it took under an hour) If all went well, the image will be in the `deploy` folder. Use Raspberry Pi Imager or a similar tool to flash it. diff --git a/pi-gen-sources/pi-gen-config b/pi-gen-sources/pi-gen-config new file mode 100644 index 000000000..c73460fc1 --- /dev/null +++ b/pi-gen-sources/pi-gen-config @@ -0,0 +1,14 @@ +IMG_NAME=teslausb +PI_GEN_RELEASE=teslausb-prebuilt +LOCALE_DEFAULT=en_US.UTF-8 +TARGET_HOSTNAME=teslausb +KEYBOARD_KEYMAP=us +KEYBOARD_LAYOUT="English (US)" +TIMEZONE_DEFAULT="America/Los_Angeles" +FIRST_USER_NAME=pi +FIRST_USER_PASS=raspberry +DISABLE_FIRST_BOOT_USER_RENAME=1 +WPA_COUNTRY=US +ENABLE_SSH=1 +STAGE_LIST="stage0 stage1 stage2 stage_teslausb" +RELEASE=bookworm diff --git a/pi-gen-sources/prepare.sh b/pi-gen-sources/prepare.sh new file mode 100755 index 000000000..4ca3e9914 --- /dev/null +++ b/pi-gen-sources/prepare.sh @@ -0,0 +1,21 @@ +#!/bin/bash -eu + +SRC=$(dirname $(readlink -f $0)) +DEST=$(readlink -f .) + +if [[ "$DEST" != */pi-gen ]] +then + echo "$0 should be called from the RPi-Distro pi-gen folder" + exit 1 +fi + +cp "$SRC/pi-gen-config" config +rm -rf stage2/EXPORT_NOOBS stage2/EXPORT_IMAGE export-image/01-user-rename/00-packages +mkdir -p stage_teslausb +touch stage_teslausb/EXPORT_IMAGE +cp stage2/prerun.sh stage_teslausb/prerun.sh +cp -r "$SRC/00-teslausb-tweaks" stage_teslausb + +echo 'Build config set. Now use "./build.sh" or "./build-docker.sh" to build the TeslaUSB image.' + +