Skip to content

Commit

Permalink
[ansible] Fix bugs and some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Mar 25, 2024
1 parent 296cb0a commit e3c92e3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
8 changes: 5 additions & 3 deletions ansible/roles/ovos_hardware_mark2/tasks/firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This block is only meaningful until kernel 6.6.22 becomes
# the default Raspberry Pi kernel.
- name: Block kernel upgrade
when: ansible_kernel is version("6.6.22", "<")
block:
- name: Kernel headers packages requirement
ansible.builtin.apt:
Expand All @@ -16,11 +17,13 @@
- name: Update kernel and firmware
ansible.builtin.shell:
cmd: |
set -o pipefail
echo y | rpi-update
executable: /bin/bash
environment:
PRUNE_MODULES: "1"
SKIP_BACKUP: "1"
UPDATE_SELF: "1"
changed_when: no

- name: Retrieve rpi-source Python script
Expand All @@ -35,10 +38,9 @@
ansible.builtin.shell:
cmd: |
rpi-source -q --tag-update
rpi-source -d /usr/src
echo -e -n "\r" | rpi-source -d /usr/src
executable: /bin/bash
changed_when: no
when: ansible_kernel is version("6.6.22", "<")

- name: Install kernel headers
ansible.builtin.apt:
Expand All @@ -50,7 +52,7 @@
ansible.builtin.lineinfile:
path: /etc/default/rpi-eeprom-update
regexp: "^FIRMWARE_RELEASE_STATUS="
line: 'FIRMWARE_RELEASE_STATUS="{{ ovos_hardware_mark2_eeprom }}"'
line: 'FIRMWARE_RELEASE_STATUS="{{ ovos_hardware_mark2_eeprom_release }}"'

- name: Update EEPROM
ansible.builtin.command: |
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/ovos_hardware_mark2/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ ovos_installer_user_home }}"
group: "{{ ovos_installer_user_home }}"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
mode: "0755"
loop:
- /opt/sj201
Expand Down
33 changes: 25 additions & 8 deletions ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
owner: root
group: root
mode: "0755"
remote: true
remote_src: true
loop:
- sj201
- sj201-buttons-overlay
- sj201-rev10-pwm-fan-overlay

- name: Manage VocalFusion overlays
- name: Manage sj201, buttons and PWM overlays
ansible.builtin.lineinfile:
path: /boot/firmware/config.txt
regexp: "^{{ item }}="
Expand All @@ -39,8 +39,9 @@
depmod -a
executable: /bin/bash
chdir: /usr/src/vocalfusion/driver
changed_when: false

- name: Create vocalfusion module file
- name: Create /etc/modules-load.d/vocalfusion.conf file
ansible.builtin.copy:
content: |
vocalfusion-soundcard
Expand All @@ -54,24 +55,35 @@
name:
- Adafruit-Blinka
- smbus2
- RPi.GPIO
virtualenv: "{{ ovos_installer_user_home }}/.venvs/sj201"
virtualenv_command: "{{ ansible_python.executable }} -m venv"

- name: Download SJ201 firmware and scripts
ansible.builtin.get_url:
url: "{{ item }}"
dest: "/opt/sj201/{{ item }}"
url: "{{ item.url }}"
dest: "/opt/sj201/{{ item.dest }}"
owner: root
group: root
mode: "0755"
loop:
- https://raw.githubusercontent.com/OpenVoiceOS/ovos-buildroot/0e464466194f58553af11c34f7435dba76ec70a3/buildroot-external/package/vocalfusion/xvf3510-flash
- https://github.com/OpenVoiceOS/ovos-buildroot/blob/c67d7f0b7f2a3eff5faab96d6adf7495e9b48b93/buildroot-external/package/vocalfusion/app_xvf3510_int_spi_boot_v4_2_0.bin
- {
"url": "https://raw.githubusercontent.com/OpenVoiceOS/ovos-buildroot/0e464466194f58553af11c34f7435dba76ec70a3/buildroot-external/package/vocalfusion/xvf3510-flash",
"dest": "xvf3510-flash",
}
- {
"url": "https://github.com/OpenVoiceOS/ovos-buildroot/blob/c67d7f0b7f2a3eff5faab96d6adf7495e9b48b93/buildroot-external/package/vocalfusion/app_xvf3510_int_spi_boot_v4_2_0.bin",
"dest": "app_xvf3510_int_spi_boot_v4_2_0.bin",
}
- {
"url": "https://raw.githubusercontent.com/MycroftAI/mark-ii-hardware-testing/main/utils/init_tas5806.py",
"dest": "init_tas5806",
}

- name: Copy SJ201 systemd unit file
ansible.builtin.template:
src: sj201.service.j2
dest: "{{ ovos_installer_user }}/.config/systemd/user/sj201.service"
dest: "{{ ovos_installer_user_home }}/.config/systemd/user/sj201.service"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
mode: "0644"
Expand All @@ -89,3 +101,8 @@
enabled: true
force: true
scope: user

- name: Delete /usr/src/vocalfusion once compiled
ansible.builtin.file:
path: /usr/src/vocalfusion
state: absent
2 changes: 1 addition & 1 deletion ansible/roles/ovos_hardware_mark2/tasks/wireplumber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Configure ALSA for WirePlumber
ansible.builtin.copy:
src: 50-alsa-config.lua
dest: "{{ ovos_installer_user }}/.config/wireplumber/main.lua.d"
dest: "{{ ovos_installer_user_home }}/.config/wireplumber/main.lua.d"
owner: "{{ ovos_installer_user }}"
group: "{{ ovos_installer_user }}"
mode: "0644"
2 changes: 1 addition & 1 deletion ansible/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- role: ovos_hardware_mark2
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('11' '>=')
- ansible_distribution_major_version is version('11', '>=')
- "'Raspberry Pi 4' in ovos_installer_raspberrypi or 'Raspberry Pi 5' in ovos_installer_raspberrypi"
- "'tas5806' in ovos_installer_i2c_devices"
- role: ovos_installer
2 changes: 1 addition & 1 deletion utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function i2c_get() {
# This function will only run if a Raspberry Pi board is detected.
function i2c_scan() {
if [ "$RASPBERRYPI_MODEL" != "N/A" ]; then
echo -ne "➤ Scan I2C bus... "
echo -ne "➤ Scan I2C bus for auto-detection... "
for device in "${!SUPPORTED_DEVICES[@]}"; do
address="${SUPPORTED_DEVICES[$device]}"
if i2c_get "$address"; then
Expand Down

0 comments on commit e3c92e3

Please sign in to comment.