Skip to content

Commit

Permalink
fix(audio): run the original install.sh script of `wm8960-soundcard…
Browse files Browse the repository at this point in the history
…` to make the audio work #53

build(packer): mount the first partition of the image in `/boot/firmware` instead of `/boot` to be compatible with the new linux kernel
  • Loading branch information
sassanh committed Apr 16, 2024
1 parent 5f14178 commit 4c987dd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
with:
file: ./coverage.xml
flags: integration
fail_ci_if_error: true
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

build:
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
## Version 0.12.7

- feat(notification): make the extra information screen scrollable
- build(bootstrap): add `dtoverlay=gpio-fan,gpiopin=22,temp=60000` to `/boot/config.txt`
- build(bootstrap): add `dtoverlay=gpio-fan,gpiopin=22,temp=60000` to `/boot/firmware/config.txt`
to make the fan run if CPU temperature passes 60℃ #64
- fix(audio): run the original `install.sh` script of `wm8960-soundcard` to make
the audio work #53
- build(packer): mount the first partition of the image in `/boot/firmware` instead
of `/boot` to be compatible with the new linux kernel

## Version 0.12.6

Expand Down
29 changes: 25 additions & 4 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,32 @@ deps=${deps:-"False"}
bootstrap=${bootstrap:-"False"}
run=${run:-"False"}

function run_on_pod() {
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage: run_on_pod <command> [is_root]"
exit 1
fi
if [ $# -eq 1 ]; then
ssh ubo-development-pod "sudo XDG_RUNTIME_DIR=/run/user/\$(id -u ubo) -u ubo bash -c 'source \$HOME/.profile && source /etc/profile && source /opt/ubo/env/bin/activate && $1'"
exit 0
fi
if [ "$2" == "root" ]; then
ssh ubo-development-pod "sudo bash -c '$1'"
exit 0
fi
}

scp dist/$LATEST_VERSION ubo-development-pod:/tmp/

test "$deps" == "True" && ssh ubo-development-pod "sudo -u ubo bash -c 'source /opt/ubo/env/bin/activate; pip install --upgrade /tmp/$LATEST_VERSION[default]'"
test "$deps" == "True" && run_on_pod "pip install --upgrade /tmp/$LATEST_VERSION[default]"

run_on_pod "pip install --upgrade --force-reinstal --no-deps /tmp/$LATEST_VERSION[default]"

test "$bootstrap" == "True" &&
run_on_pod "/opt/ubo/env/bin/bootstrap; systemctl restart ubo-system.service" "root"

ssh ubo-development-pod "sudo -u ubo bash -c 'source \$HOME/.profile && source /etc/profile && source /opt/ubo/env/bin/activate && pip install --upgrade --force-reinstal --no-deps /tmp/$LATEST_VERSION[default]'"
test "$run" == "True" &&
run_on_pod "systemctl --user restart ubo-app.service"

test "$bootstrap" == "True" && ssh ubo-development-pod "sudo /opt/ubo/env/bin/bootstrap; sudo systemctl restart ubo-system.service"
test "$run" == "True" && ssh ubo-development-pod "sudo XDG_RUNTIME_DIR=/run/user/\$(id -u ubo) -u ubo systemctl --user restart ubo-app.service"
test "$env" == "True" &&
scp ubo_app/.dev.env /opt/ubo/env/lib/python3.11/site-packages/ubo_app/.env
1 change: 1 addition & 0 deletions scripts/packer/image.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ source "arm-image" "raspberry_pi_os" {
iso_checksum = var.image_checksum
output_filename = "/build/image.img"
target_image_size = var.target_image_size
image_mounts = ["/boot/firmware", "/"]
}

build {
Expand Down
32 changes: 23 additions & 9 deletions ubo_app/system/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def enable_services() -> None:

def configure_fan() -> None:
"""Configure the behavior of the fan."""
with Path('/boot/config.txt').open('a') as config_file:
with Path('/boot/firmware/config.txt').open('a') as config_file:
config_file.write('dtoverlay=gpio-fan,gpiopin=22,temp=60000\n')


Expand Down Expand Up @@ -208,6 +208,27 @@ def install_docker() -> None:
stdout.flush()


def install_audio_driver(*, for_packer: bool) -> None:
"""Install the audio driver."""
if for_packer:
# Convincing the installer that we are on a Raspberry Pi as /proc is not created
# in packer build
Path('/proc/device-tree').mkdir(parents=True, exist_ok=True)
Path('/proc/device-tree/model').write_text('Raspberry Pi')
stdout.write('Installing wm8960...\n')
stdout.flush()
subprocess.run(
[Path(__file__).parent.joinpath('install_wm8960.sh').as_posix()], # noqa: S603
check=True,
)
stdout.write('Done installing wm8960\n')
stdout.flush()
if for_packer:
Path('/proc/device-tree/model').unlink()
Path('/proc/device-tree').rmdir()
Path('/proc').rmdir()


def bootstrap(*, with_docker: bool = False, for_packer: bool = False) -> None:
"""Create the service files and enable the services."""
# Ensure we have the required permissions
Expand Down Expand Up @@ -243,11 +264,4 @@ def bootstrap(*, with_docker: bool = False, for_packer: bool = False) -> None:
stdout.write('Done installing docker\n')
stdout.flush()

stdout.write('Installing wm8960...\n')
stdout.flush()
subprocess.run(
[Path(__file__).parent.joinpath('install_wm8960.sh').as_posix()], # noqa: S603
check=True,
)
stdout.write('Done installing wm8960\n')
stdout.flush()
install_audio_driver(for_packer=for_packer)
57 changes: 1 addition & 56 deletions ubo_app/system/install_wm8960.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,10 @@ set -o errexit
set -o pipefail
set -o nounset

if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi

if [ ! -f /etc/rpi-issue ]; then
echo "Sorry, this drivers only works on raspberry pi"
exit 1
fi


#download the archive
git clone https://github.com/waveshare/WM8960-Audio-HAT
cd WM8960-Audio-HAT

# install dtbos
#cp wm8960-soundcard.dtbo /boot/overlays


#set kernel modules
grep -q "^i2c-dev$" /etc/modules || \
echo "i2c-dev" >> /etc/modules
grep -q "^snd-soc-wm8960$" /etc/modules || \
echo "snd-soc-wm8960" >> /etc/modules
grep -q "^snd-soc-wm8960-soundcard$" /etc/modules || \
echo "snd-soc-wm8960-soundcard" >> /etc/modules

# set modprobe blacklist
grep -q "^blacklist snd_bcm2835$" /etc/modprobe.d/raspi-blacklist.conf || \
echo "blacklist snd_bcm2835" >> /etc/modprobe.d/raspi-blacklist.conf

#set dtoverlays
sed -i -e 's:#dtparam=i2s=on:dtparam=i2s=on:g' /boot/config.txt || true
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' /boot/config.txt || true
grep -q "^dtoverlay=i2s-mmap$" /boot/config.txt || \
echo "dtoverlay=i2s-mmap" >> /boot/config.txt

grep -q "^dtparam=i2s=on$" /boot/config.txt || \
echo "dtparam=i2s=on" >> /boot/config.txt

grep -q "^dtoverlay=wm8960-soundcard$" /boot/config.txt || \
echo "dtoverlay=wm8960-soundcard" >> /boot/config.txt

#install config files
mkdir -p /etc/wm8960-soundcard
cp *.conf /etc/wm8960-soundcard
cp *.state /etc/wm8960-soundcard

#set service
cp wm8960-soundcard /usr/bin/
chmod -x wm8960-soundcard.service
cp wm8960-soundcard.service /lib/systemd/system/
systemctl enable wm8960-soundcard.service
#systemctl start wm8960-soundcard
./install.sh

cd ..
rm -rf WM8960-Audio-HAT

echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings"
echo "Enjoy!"
echo "------------------------------------------------------"

0 comments on commit 4c987dd

Please sign in to comment.