diff --git a/README.md b/README.md index a7e375c..bac3145 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ This is the external Buildroot repository used to build system images and updates for the MynaPlayer project. +Changelog +-------- + +A [changelog](https://git.lumina-sensum.com/LuminaSensum/buildroot-MynaPlayer/blob/stable-dev-board/changelog.md) is available so that users and developers can quickly check what changed between releases. + Building -------- @@ -89,7 +94,7 @@ ls buildroot/output_build/images/ # Find the file ending in *.raucb # You can also just flash MynaPlayer.img using dd but it takes a long time -mv buildroot/output_build/images/bundle-MynaPlayer-2020-08-06.fe2ca3ce-be36-4f33-94d4-e295cd0518be.raucb /var/www/www.jookia.org/ +mv buildroot/output_build/images/bundle-MynaPlayer.2020-09-06.raucb /var/www/www.jookia.org/ cp $PWD/easy-rsa/pki/ca.crt /var/www/www.jookia.org/ chmod a+r /var/www/www.jookia.org/ca.crt ``` @@ -100,11 +105,16 @@ wget 'https://www.jookia.org/ca.crt' cp /etc/rauc/keyring.pem{,.bak} mv ca.crt /etc/rauc/keyring.pem -rauc install https://www.jookia.org/bundle-MynaPlayer-2020-08-06.fe2ca3ce-be36-4f33-94d4-e295cd0518be.raucb +rauc install https://www.jookia.org/bundle-MynaPlayer.2020-09-06.raucb mv /etc/rauc/keyring.pem{.bak,} reboot ``` +* Notes: + * The bundle file name is derived from git describe, and might differ slightly if you use a branch with committed but not yet released work. E.g: bundle-MynaPlayer.2020-09-06-18-g3d0589f.raucb. + * If you have uncommitted work present in your branch, then the file name will have a 'dirty' tag added. + * If your git index and cache become corrupted for any reason, your bundle will have a 'broken' tag added. This doesn't indicate by any means that your image is broken! + Future updates won't need to copy the keyring, a single 'rauc install' invocation should download and install the image without trouble. diff --git a/board/myna-player-odyssey/configs/linux.config b/board/myna-player-odyssey/configs/linux.config index f619f35..db91319 100644 --- a/board/myna-player-odyssey/configs/linux.config +++ b/board/myna-player-odyssey/configs/linux.config @@ -661,10 +661,13 @@ CONFIG_NTFS_FS=m CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y -CONFIG_SQUASHFS=m +CONFIG_SQUASHFS=y CONFIG_SQUASHFS_FILE_DIRECT=y CONFIG_SQUASHFS_DECOMP_MULTI=y CONFIG_SQUASHFS_XATTR=y +CONFIG_SQUASHFS_LZ4=y +CONFIG_SQUASHFS_ZSTD=y +CONFIG_SQUASHFS_4K_DEVBLK_SIZE=y # CONFIG_NETWORK_FILESYSTEMS is not set CONFIG_NLS=y CONFIG_NLS_CODEPAGE_437=y diff --git a/board/myna-player-odyssey/rootfs_overlay/etc/NetworkManager/system-connections/Wired connection 1.nmconnection b/board/myna-player-odyssey/rootfs_overlay/etc/NetworkManager/system-connections/Wired connection 1.nmconnection deleted file mode 100644 index 55cddfb..0000000 --- a/board/myna-player-odyssey/rootfs_overlay/etc/NetworkManager/system-connections/Wired connection 1.nmconnection +++ /dev/null @@ -1,22 +0,0 @@ -[connection] -id=Wired connection 1 -uuid=bdd5a152-31c6-3bc9-b7a9-51c3f1f10535 -type=ethernet -autoconnect-priority=-999 -interface-name=eth0 -permissions= -timestamp=1598972096 - -[ethernet] -mac-address-blacklist= - -[ipv4] -dns-search= -method=auto - -[ipv6] -addr-gen-mode=eui64 -dns-search= -method=auto - -[proxy] diff --git a/board/myna-player-odyssey/rootfs_overlay/etc/NetworkManager/system-connections/Wired.nmconnection b/board/myna-player-odyssey/rootfs_overlay/etc/NetworkManager/system-connections/Wired.nmconnection new file mode 100644 index 0000000..f134453 --- /dev/null +++ b/board/myna-player-odyssey/rootfs_overlay/etc/NetworkManager/system-connections/Wired.nmconnection @@ -0,0 +1,22 @@ +[connection] +id=Wired +uuid=bdd5a152-31c6-3bc9-b7a9-51c3f1f10535 +type=ethernet +autoconnect-priority=-999 +interface-name=eth0 +permissions= +timestamp=1598972096 + +[ethernet] +mac-address-blacklist= + +[ipv4] +dns-search= +method=auto + +[ipv6] +addr-gen-mode=eui64 +dns-search= +method=auto + +[proxy] diff --git a/board/myna-player-odyssey/rootfs_overlay/etc/systemd/system/rauc-failure.service b/board/myna-player-odyssey/rootfs_overlay/etc/systemd/system/rauc-failure.service new file mode 100644 index 0000000..8cd235e --- /dev/null +++ b/board/myna-player-odyssey/rootfs_overlay/etc/systemd/system/rauc-failure.service @@ -0,0 +1,7 @@ +[Unit] +Description=Unit triggered on rauc-marking-good failing +SuccessAction=reboot + +[Service] +Type=oneshot +ExecStart=/bin/true diff --git a/board/myna-player-odyssey/rootfs_overlay/etc/systemd/system/rauc-mark-good.service b/board/myna-player-odyssey/rootfs_overlay/etc/systemd/system/rauc-mark-good.service new file mode 100644 index 0000000..48d3db5 --- /dev/null +++ b/board/myna-player-odyssey/rootfs_overlay/etc/systemd/system/rauc-mark-good.service @@ -0,0 +1,13 @@ +[Unit] +Description=Rauc marking good service +ConditionKernelCommandLine=|bootchooser.active +After=NetworkManager.service serial-getty@ttySTM0.service sshd.service +Requires=sshd.service serial-getty@ttySTM0.service NetworkManager.service +OnFailure=rauc-failure.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/rauc status mark-good + +[Install] +WantedBy=multi-user.target diff --git a/board/myna-player-odyssey/rootfs_overlay/loader/entries/myna-player.conf b/board/myna-player-odyssey/rootfs_overlay/loader/entries/myna-player.conf index 91c752b..639a08c 100644 --- a/board/myna-player-odyssey/rootfs_overlay/loader/entries/myna-player.conf +++ b/board/myna-player-odyssey/rootfs_overlay/loader/entries/myna-player.conf @@ -2,5 +2,5 @@ version 5.8rc7 linux boot/zImage devicetree boot/stm32mp157c-odyssey.dtb -options rootfstype=ext4 rw rootwait quiet systemd.log_color=off +options rootfstype=ext4 ro rootwait quiet systemd.log_color=off init=/sbin/pre-init linux-appendroot true diff --git a/board/myna-player-odyssey/rootfs_overlay/usr/sbin/pre-init b/board/myna-player-odyssey/rootfs_overlay/usr/sbin/pre-init new file mode 100755 index 0000000..1c7fb61 --- /dev/null +++ b/board/myna-player-odyssey/rootfs_overlay/usr/sbin/pre-init @@ -0,0 +1,78 @@ +#!/bin/bash +# Copyright 2020 Jookia +# SPDX-License-Identifier: GPL-3.0-or-later +# This scripts sets up an OverlayFS using a read-only rootfs mounted by Linux. +# Example usage: Save as /preinit and pass init=/preinit to your kernel. + +set -e # Safety feature: Error out if we hit any errors + +# Step 0: Check that this is running in the proper environment +# We don't want to run a bunch of complicated system-altering code accidentally +if [[ "$$" != "1" ]]; then + echo 'Usage: Run as PID 1 before booting your system!' 1>&2 + exit 1 +fi + +# Step 1: Set up a temporary root on a tmpfs on /run +# Since root is read-only, we'll use /run for our tmpfs mount +# This tmpfs will store all our temporary files used for OverlayFS operation +mount -t tmpfs none /run + +# Step 2: Mount and initialize the data partition at /run/data +# For OverlayFS we need a partition (/dev/mmcblk2p6 in our case) and two +# directories: overlay_root (contains the changes to the read-only root filesystem) +# as well as overlay_work which is used as a temporary store when writing files +# So mount and create these directories. + +mkdir /run/data +mount /dev/mmcblk2p6 /run/data +for i in overlay_root overlay_work; do + mkdir -p /run/data/$i; +done + +# Step 3: Prepare for pivoting +# In a moment we're going to move the current root to /run/old_root and +# temporarily chroot to /run for reasons explained in the next step. But this +# is going to break running applications since we don't have bin, sbin or +# lib directories in /run. So set PATH and create a /lib link them now that +# will correctly resolve once we chroot. + +PATH=$PATH:/old_root/bin:/old_root/sbin +ln -s /old_root/lib /run/lib + +# Step 4: Pivot our current root +# When using OverlayFS we have to make sure both the lower directory (in our +# case the read-only root) and upper directory (in our case the data +# partition's overlay root) don't contain each other. +# In our case the lower does: It's the root directory / which contains +# /run/data/overlay_root. +# The solution to this is to move the current root mount to /run/old_root. +# The util-linux provides a tool for this: pivot_root. +# In our case the pivot_root utility will move our read-only root filesystem +# from / to /run/old_root and chroot all running processes to /run. +# In order for this new root to work we need to have /bin, /sbin and /lib in +# /run with working programs so we can continue execution by calling a shell. +# In step 3 we set up links to the now pivoted old_root's bin, sbin and lib +# directories so everything will work fine. + +mkdir /run/old_root /run/new_root +pivot_root /run/ /run/old_root + +# Step 5: Mount OverlayFS on /new_root (previously /run/new_root) +# At this point we have the following directories of interest: +# - /old_root containing our read-only root filesystem +# - /data/overlay_root containing our writeable root filesystem +# - /data/overlay_work containing the work directory for OverlayFS root +# - /new_root which we just created to place the OverlayFS root +# When making the OverlayFS root, we use the /old_root as the lowerdir, +# /data/overlay_root as the upperdir, and /data/overlay_work as the workdir. + +mount -t overlay overlay -o lowerdir=/old_root,upperdir=/data/overlay_root,workdir=/data/overlay_work /new_root + +# Step 6: Chroot to /new_root and run /sbin/init within the root +# This finally boots the system from the overlay root. Yay! +# Since we chroot instead of pivoting root, we leave our /run tmpfs in memory +# but no longer accessible. This shouldn't take up much memory given it's just +# a few mounts and symbolic links. + +exec chroot /new_root /sbin/init diff --git a/board/myna-player-odyssey/scripts/rootfs_postimage.sh b/board/myna-player-odyssey/scripts/rootfs_postimage.sh index ab994de..67a85e0 100755 --- a/board/myna-player-odyssey/scripts/rootfs_postimage.sh +++ b/board/myna-player-odyssey/scripts/rootfs_postimage.sh @@ -8,16 +8,14 @@ mkfs.ext4 -F "${BINARIES_DIR}/rauc.ext4" # prepare for genimage - +cd "${BINARIES_DIR}" export GENIMAGE_TMP=${BR2_EXTERNAL_MynaPlayer_PATH}/board/myna-player-odyssey/utilities/genimage.tmp GENIMAGE_CFG="${BR2_EXTERNAL_MynaPlayer_PATH}/board/myna-player-odyssey/utilities/genimage.cfg" -export GENIMAGE_DATE=$(date -Idate) export GENIMAGE_USER=$(whoami) export GENIMAGE_HOST=$(hostname) -export GENIMAGE_BUILD_ID=$(uuidgen) +export GENIMAGE_BUILD_ID=$(git describe --dirty --broken) envsubst \ -\$GENIMAGE_DATE,\ \$GENIMAGE_USER,\ \$GENIMAGE_HOST,\ \$GENIMAGE_BUILD_ID \ diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/autoboot_timeout b/board/myna-player-odyssey/utilities/barebox-env/nv/autoboot_timeout new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/autoboot_timeout @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/boot.default b/board/myna-player-odyssey/utilities/barebox-env/nv/boot.default new file mode 100644 index 0000000..d31014d --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/boot.default @@ -0,0 +1 @@ +bootchooser \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.disable_on_zero_attempts b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.disable_on_zero_attempts new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.disable_on_zero_attempts @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.reset_attempts b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.reset_attempts new file mode 100644 index 0000000..f997ff9 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.reset_attempts @@ -0,0 +1 @@ +all-zero \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.retry b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.retry new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.retry @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.state_prefix b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.state_prefix new file mode 100644 index 0000000..38c56c1 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.state_prefix @@ -0,0 +1 @@ +state.bootstate \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.system0.boot b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.system0.boot new file mode 100644 index 0000000..b7e26ca --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.system0.boot @@ -0,0 +1 @@ +mmc1.2 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.system1.boot b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.system1.boot new file mode 100644 index 0000000..76ab638 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.system1.boot @@ -0,0 +1 @@ +mmc1.3 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.targets b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.targets new file mode 100644 index 0000000..cf2ba7c --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootchooser.targets @@ -0,0 +1 @@ +system0 system1 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/barebox-env/nv/bootm.provide_machine_id b/board/myna-player-odyssey/utilities/barebox-env/nv/bootm.provide_machine_id new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/board/myna-player-odyssey/utilities/barebox-env/nv/bootm.provide_machine_id @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/board/myna-player-odyssey/utilities/dev-table b/board/myna-player-odyssey/utilities/dev-table index b698d83..615b087 100644 --- a/board/myna-player-odyssey/utilities/dev-table +++ b/board/myna-player-odyssey/utilities/dev-table @@ -1 +1 @@ -/etc/NetworkManager/system-connections/Wired connection 1.nmconnection f 600 root root - - - - - +/etc/NetworkManager/system-connections/Wired.nmconnection f 600 root root - - - - - diff --git a/board/myna-player-odyssey/utilities/genimage.tmp b/board/myna-player-odyssey/utilities/genimage.tmp index 51a102e..4c883dc 100644 --- a/board/myna-player-odyssey/utilities/genimage.tmp +++ b/board/myna-player-odyssey/utilities/genimage.tmp @@ -1,5 +1,5 @@ image MynaPlayer.img { - name = "MynaPlayer-${GENIMAGE_DATE}" + name = "MynaPlayer-${GENIMAGE_BUILD_ID}" hdimage { gpt = "true" } @@ -37,8 +37,8 @@ } } -image bundle-MynaPlayer-${GENIMAGE_DATE}.${GENIMAGE_BUILD_ID}.raucb { - name = "bundle-MynaPlayer-${GENIMAGE_DATE}" +image bundle-MynaPlayer.${GENIMAGE_BUILD_ID}.raucb { + name = "bundle-MynaPlayer-${GENIMAGE_BUILD_ID}" rauc { files = { "rootfs.tar.xz" @@ -49,9 +49,8 @@ manifest = "[update] compatible=LuminaSensum MynaPlayer - version=${GENIMAGE_DATE} - build=${GENIMAGE_BUILD_ID} - description=RAUC bundle for LuminaSensum MynaPlayer version ${GENIMAGE_DATE}, built by ${GENIMAGE_USER}@${GENIMAGE_HOST}. + version=${GENIMAGE_BUILD_ID} + description=RAUC bundle for LuminaSensum MynaPlayer version ${GENIMAGE_BUILD_ID}, built by ${GENIMAGE_USER}@${GENIMAGE_HOST}. [image.rootfs] filename=rootfs.tar.xz" } diff --git a/changelog.md b/changelog.md index 789e7eb..631682f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,28 @@ +2020-09-22 / 2020-09-22 +======================= + + * Merge pull request #30 from LuminaSensum/WIP_barebox-env + * board/MynaPlayer odyssey: add default built-in barebox environment. + * Merge pull request #29 from LuminaSensum/WIP_terminfo-2 + * board/MynaPlayer odyssey: fix terminfo's additional files to include screen.linux. + * Merge pull request #28 from LuminaSensum/kernel-bump + * board/MynaPlayer odyssey: bump kernel to 5.8.10. + * Merge pull request #26 from LuminaSensum/WIP_build-id + * board/MynaPlayer odyssey: changed the way the file name and metadata of the images are constructed. + * Merge pull request #27 from LuminaSensum/WIP_changelog + * Added the changelog in the readme. + * Merge pull request #23 from LuminaSensum/WIP_preinit + * board/MynaPlayer odyssey: add pre-init script to setup overlay filesystem. + * Merge pull request #25 from LuminaSensum/WIP_terminfo + * board/MynaPlayer odyssey: add screen and tmux terminfo files into the target. + * Merge pull request #24 from LuminaSensum/WIP_rauc + * board/MynaPlayer odyssey: added basic service to mark boot as good with rauc. + * Merge pull request #22 from LuminaSensum/WIP_squashfs + * board/MynaPlayer odyssey: rework squashfs support + * Merge pull request #21 from LuminaSensum/WIP_ipv6 + * board/MynaPlayer odyssey: fix networking for good. + 2020-09-06 / 2020-09-06 ======================= diff --git a/configs/myna_player_odyssey_defconfig b/configs/myna_player_odyssey_defconfig index ba9390c..adb732d 100644 --- a/configs/myna_player_odyssey_defconfig +++ b/configs/myna_player_odyssey_defconfig @@ -31,7 +31,7 @@ BR2_ROOTFS_POST_SCRIPT_ARGS="-c $(BR2_EXTERNAL_MynaPlayer_PATH)/board/myna-player-odyssey/utilities/genimage.cfg" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.8.7" +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.8.10" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_MynaPlayer_PATH)/board/myna-player-odyssey/configs/linux.config" BR2_LINUX_KERNEL_LZ4=y @@ -72,6 +72,7 @@ BR2_PACKAGE_LIBARCHIVE_BSDCAT=y BR2_PACKAGE_CA_CERTIFICATES=y BR2_PACKAGE_NCURSES_TARGET_PROGS=y +BR2_PACKAGE_NCURSES_ADDITIONAL_TERMINFO="s/screen.linux t/tmux" BR2_PACKAGE_CRDA=y # BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set BR2_PACKAGE_IPROUTE2=y @@ -138,6 +139,7 @@ BR2_TARGET_BAREBOX_CUSTOM_GIT_VERSION="d4d3e9c87" BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG=y BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_MynaPlayer_PATH)/board/myna-player-odyssey/configs/barebox.config" +BR2_TARGET_BAREBOX_CUSTOM_EMBEDDED_ENV_PATH="$(BR2_EXTERNAL_MynaPlayer_PATH)/board/myna-player-odyssey/utilities/barebox-env" BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_DISABLED_SERVICES=y