Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support devkit #86

Merged
merged 9 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ansible/roles/ovos_hardware_mark2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions ansible/roles/ovos_hardware_mark2/tasks/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}"
10 changes: 10 additions & 0 deletions ansible/roles/ovos_hardware_mark2/tasks/touchscreen.yml
Original file line number Diff line number Diff line change
@@ -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" }
2 changes: 1 addition & 1 deletion ansible/roles/ovos_hardware_mark2/tasks/vocalfusion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions ansible/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 11 additions & 17 deletions tests/bats/raspberrypi.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions tui/detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
3 changes: 2 additions & 1 deletion utils/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading