diff --git a/ansible/roles/ovos_hardware_mark2/tasks/main.yml b/ansible/roles/ovos_hardware_mark2/tasks/main.yml index acf317a0..c1446276 100644 --- a/ansible/roles/ovos_hardware_mark2/tasks/main.yml +++ b/ansible/roles/ovos_hardware_mark2/tasks/main.yml @@ -8,5 +8,9 @@ - name: Include vocalfusion.yml ansible.builtin.import_tasks: vocalfusion.yml +- name: Include touchscreen.yml + ansible.builtin.import_tasks: touchscreen.yml + when: "'attiny1614' in ovos_installer_i2c_devices" + - name: Include wireplumber.yml ansible.builtin.import_tasks: wireplumber.yml diff --git a/ansible/roles/ovos_hardware_mark2/tasks/prepare.yml b/ansible/roles/ovos_hardware_mark2/tasks/prepare.yml index 5b422eaa..c39ad23a 100644 --- a/ansible/roles/ovos_hardware_mark2/tasks/prepare.yml +++ b/ansible/roles/ovos_hardware_mark2/tasks/prepare.yml @@ -10,3 +10,12 @@ - /opt/sj201 - "{{ ovos_installer_user_home }}/.config/systemd/user" - "{{ ovos_installer_user_home }}/.config/wireplumber/main.lua.d" + +- name: Check for /boot/firmware directory + ansible.builtin.stat: + path: /boot/firmware + register: _boot_config_status + +- name: Set _boot_directory fact + ansible.builtin.set_fact: + _boot_directory: "{{ '/boot/firmware' if _boot_config_status.stat.exists | bool else '/boot' }}" diff --git a/ansible/roles/ovos_hardware_mark2/tasks/touchscreen.yml b/ansible/roles/ovos_hardware_mark2/tasks/touchscreen.yml new file mode 100644 index 00000000..041eace5 --- /dev/null +++ b/ansible/roles/ovos_hardware_mark2/tasks/touchscreen.yml @@ -0,0 +1,10 @@ +--- +- name: Manage touchscreen, DevKit vs Mark II + ansible.builtin.lineinfile: + path: "{{ _boot_directory }}/config.txt" + regexp: "^{{ item.overlay }}" + line: "{{ item.overlay }}" + state: "{{ item.state }}" + loop: + - {"overlay": "dtoverlay=vc4-kms-v3d", "state": "absent" } + - {"overlay": "dtoverlay=vc4-fkms-v3d", "state": "present" } diff --git a/ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml b/ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml index ae2be32d..c5d6e9c2 100644 --- a/ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml +++ b/ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml @@ -25,7 +25,7 @@ vars: _is_rpi5: "{{ '-pi5' if 'Raspberry Pi 5' in ovos_installer_raspberrypi else '' }}" ansible.builtin.lineinfile: - path: /boot/firmware/config.txt + path: "{{ _boot_directory }}/config.txt" regexp: "^{{ item }}=" line: "{{ item }}{{ _is_rpi5 }}" loop: diff --git a/ansible/site.yml b/ansible/site.yml index 78712e95..08d34623 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -8,6 +8,8 @@ vars: ovos_installer_reboot: false + # Just a simple JSON sanitize + ovos_installer_i2c_devices: "{{ ovos_installer_i2c_devices | from_json }}" pre_tasks: - name: Gather reduced subset of facts diff --git a/tests/bats/raspberrypi.bats b/tests/bats/raspberrypi.bats index 1451cbb2..7ace0a08 100644 --- a/tests/bats/raspberrypi.bats +++ b/tests/bats/raspberrypi.bats @@ -11,35 +11,29 @@ function setup() { @test "function_is_raspeberrypi_soc_detected" { function iw() { - retun 0 + exit 0 } - export -f iw - echo "Raspberry Pi 4 Model B Rev 1.5" >"$DT_FILE" - is_raspeberrypi_soc - assert_equal "$RASPBERRYPI_MODEL" "Raspberry Pi 4 Model B Rev 1.5" - unset -f iw + run echo "Raspberry Pi 4 Model B Rev 1.5" >"$DT_FILE" + run is_raspeberrypi_soc + run assert_equal "$RASPBERRYPI_MODEL" "Raspberry Pi 4 Model B Rev 1.5" } @test "function_is_raspeberrypi_soc_file_exists_but_not_rpi" { function iw() { - retun 0 + exit 0 } - export -f iw - echo "Fake Board Name 0.0" >"$DT_FILE" - is_raspeberrypi_soc - assert_equal "$RASPBERRYPI_MODEL" "N/A" - unset -f iw + run echo "Fake Board Name 0.0" >"$DT_FILE" + run is_raspeberrypi_soc + run assert_equal "$RASPBERRYPI_MODEL" "N/A" } @test "function_is_raspeberrypi_soc_not_detected" { function iw() { - retun 0 + exit 0 } - export -f iw DT_FILE=/sys/fake/model - is_raspeberrypi_soc - assert_equal "$RASPBERRYPI_MODEL" "N/A" - unset -f iw + run is_raspeberrypi_soc + run assert_equal "$RASPBERRYPI_MODEL" "N/A" } function teardown() { diff --git a/tui/detection.sh b/tui/detection.sh index a29bd823..3fe638a6 100644 --- a/tui/detection.sh +++ b/tui/detection.sh @@ -10,6 +10,9 @@ for device in "${DETECTED_DEVICES[@]}"; do atmega328p) HARDWARE_DETECTED="Mycroft Mark 1" ;; + attiny1614) + HARDWARE_DETECTED="Mycroft DevKit" + ;; esac done export HARDWARE_DETECTED diff --git a/utils/common.sh b/utils/common.sh index 1ae39ebf..1baf3f56 100644 --- a/utils/common.sh +++ b/utils/common.sh @@ -387,6 +387,8 @@ function i2c_scan() { if i2c_get "$address"; then if [ "$device" == "atmega328p" ]; then detect_mark1_device + elif [ "$device" == "tas5806" ]; then + detect_devkit_device else DETECTED_DEVICES+=("$device") fi @@ -434,9 +436,19 @@ EOF function detect_mark1_device() { setup_avrdude atmega328p="$(avrdude -C +"$RUN_AS_HOME"/.avrduderc -p atmega328p -c linuxgpio -U signature:r:-:i -F 2>>"$LOG_FILE" | head -1)" - if [ "$atmega328p" == "$ATMEGA328P_SIGNATURE" ] ; then + if [ "$atmega328p" == "$ATMEGA328P_SIGNATURE" ]; then DETECTED_DEVICES+=("atmega328p") - return 0 fi - return 1 +} + +# This function checks if attiny1614 I2C device is present, this is only +# triggered when a tas5806 I2C device is detected. +function detect_devkit_device() { + if i2c_get "${SUPPORTED_DEVICES["attiny1614"]}"; then + DETECTED_DEVICES+=("attiny1614") + fi + # If attiny1614 is not detected then this is a Mark II device and not + # a DevKit device so we force back the DETECTED_DEVICES variable + # to tas5806. + DETECTED_DEVICES+=("tas5806") } diff --git a/utils/constants.sh b/utils/constants.sh index b72929a2..bd745bd9 100644 --- a/utils/constants.sh +++ b/utils/constants.sh @@ -49,8 +49,9 @@ export SCENARIO_ALLOWED_HIVEMIND_OPTIONS export SCENARIO_NAME="scenario.yaml" export SCENARIO_PATH="" declare -rA SUPPORTED_DEVICES=( - ["tas5806"]="2f" #https://www.ti.com/product/TAS5806MD ["atmega328p"]="1a" #https://www.microchip.com/en-us/product/atmega328p + ["attiny1614"]="04" #https://www.microchip.com/en-us/product/attiny1614 + ["tas5806"]="2f" #https://www.ti.com/product/TAS5806MD ) export SUPPORTED_DEVICES export TUI_WINDOW_HEIGHT="35"