-
-
Notifications
You must be signed in to change notification settings - Fork 1
Fixed detection and upload of driver for Mark 2 device #24
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
base: dev
Are you sure you want to change the base?
Changes from all commits
50ed58a
e2af2b3
4de31b1
5e6aec1
3341703
3f76107
f94bc48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,48 +62,33 @@ get_board_version() { | |
| done | ||
| } | ||
|
|
||
| # Better version comparison | ||
| sort_version() { | ||
| [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" != "$1" ] | ||
| } | ||
|
|
||
| # Checks for kernal compat | ||
| compare_kernel_version() { | ||
| current_kernel=$(uname -r | cut -d '-' -f1) | ||
| if sort_version "$current_kernel" "$1"; then | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # Check for a Mark 1 device | ||
| check_mark_1() { | ||
| local timeout=3 | ||
| local dev="/dev/ttyAMA0" | ||
|
|
||
| # Check if device exists and is accessible | ||
| if [[ ! -c "$dev" ]] || [[ ! -r "$dev" ]] || [[ ! -w "$dev" ]]; then | ||
| echo "Error: $dev not accessible" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| # Use file descriptor to ensure proper cleanup | ||
| exec 3<>"$dev" | ||
|
|
||
| # Clear any pending input | ||
| read -t 1 -n 1000 <&3 || true | ||
|
|
||
| # Send command | ||
| echo "system.version" >&3 | ||
|
|
||
| # Read response with timeout | ||
| read -t "$timeout" -n 128 RESP <&3 | ||
| local status=$? | ||
|
|
||
| # Cleanup | ||
| exec 3>&- | ||
|
|
||
| # Check response | ||
| if [[ $status -eq 0 ]] && [[ "$RESP" == *"Command"* ]]; then | ||
| echo "true" | ||
|
|
@@ -118,6 +103,9 @@ main() { | |
| local i2c_device_name | ||
| local i2c_device_file="/etc/OpenVoiceOS/i2c_platform" | ||
|
|
||
| # Variable to hold current kernel | ||
| local current_kernel=$(uname -r | sed -re 's/(^[0-9]*\.[0-9]*\.[0-9]*-[0-9]*)(.*)/\1/') | ||
|
|
||
| # Check for an existing file and remove it if there | ||
| if [[ -f $i2c_device_file ]]; then | ||
| rm -f $i2c_device_file | ||
|
|
@@ -225,7 +213,7 @@ main() { | |
| amixer -c "seeed4micvoicec" cset numid=8 13 | ||
| fi | ||
| i2c_device_name="RESPEAKER4" | ||
| fi | ||
| fi | ||
|
|
||
| if [[ ${detection_results[RESPEAKER6]} == true ]] && [[ ${detection_results[RESPEAKER4]} == true ]] ; then | ||
| echo "Installing and configuring ReSpeaker 6mic" | ||
|
Comment on lines
218
to
219
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 6-mic ReSpeaker condition is unreachable; fix the logic. Requiring both RESPEAKER6 and RESPEAKER4 to be true makes this block never execute. Likely intended: run when 6-mic is present and 4-mic is not. Apply: - if [[ ${detection_results[RESPEAKER6]} == true ]] && [[ ${detection_results[RESPEAKER4]} == true ]] ; then
+ if [[ ${detection_results[RESPEAKER6]} == true ]] && [[ ${detection_results[RESPEAKER4]} == false ]] ; then🤖 Prompt for AI Agents |
||
|
|
@@ -257,12 +245,15 @@ fi | |
| i2c_device_name="ADAFRUIT" | ||
| fi | ||
|
|
||
| # This is called when a Mycroft Mark 2 device is detected | ||
| # It will only work if the VocalFusion drivers are correctly installed | ||
| # For more information see https://github.com/OpenVoiceOS/VocalFusionDriver | ||
| if [[ ${detection_results[TAS5806]} == true ]] ; then | ||
| echo "Installing and configuring SJ-201 HAT" | ||
| # Initializing XMOS xvf3510 | ||
|
|
||
| # Check for kernel version | ||
| if $(compare_kernel_version "6.6"); then | ||
| if [[ $current_kernel =~ "6.6." ]]; then | ||
| dtoverlay xvf3510 | ||
| else | ||
| if [[ "$board_result" == "RPI5" ]]; then | ||
|
|
@@ -272,7 +263,7 @@ fi | |
| fi | ||
| fi | ||
|
|
||
| /usr/libexec/xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_1_0.bin" | ||
| /usr/libexec/xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin" | ||
| # Initializing Texas Instruments 5806 Amplifier | ||
| /usr/bin/tas5806-init | ||
| if [[ ${detection_results[SJ201LED]} == true ]] ; then | ||
|
Comment on lines
+266
to
269
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainGuard firmware flashing with existence checks and actionable errors. Hard fails here can brick the flow. Verify binary and firmware are present/executable/readable and surface a clear error. Apply this diff: - /usr/libexec/xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin"
+ if [[ -x /usr/libexec/xvf3510-flash && -r /usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin ]]; then
+ /usr/libexec/xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin"
+ else
+ echo "Error: Missing xvf3510 flasher or firmware image; cannot initialize XMOS" >&2
+ fiIf you want, I can add retries/backoff or a pre-check that the xvf3510 device node is present before flashing. 🏁 Script executed: #!/bin/bash
set -eux
# Locate the flashing call and its surrounding context
rg -nP "/usr/libexec/xvf3510-flash" -C3
# Check for existing guards around the amplifier initializer
rg -nP "tas5806-init" -C3Length of output: 969 Add safety checks before flashing firmware The • File: ovos-i2csound Suggested diff: - /usr/libexec/xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin"
+ if [[ -x /usr/libexec/xvf3510-flash && -r /usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin ]]; then
+ /usr/libexec/xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_2_0.bin"
+ else
+ echo "Error: xvf3510 flasher or firmware image missing/unreadable; cannot initialize XMOS" >&2
+ exit 1
+ fiThis ensures any missing executable or firmware is caught early with an actionable message. |
||
|
|
@@ -292,7 +283,7 @@ fi | |
| i2c_device_name="SJ201V10" | ||
| fi | ||
| echo "Configuring buttons" | ||
| dtoverlay sj201-buttons-overlay | ||
|
|
||
| if [[ "$board_result" == "RPI5" ]]; then | ||
| dtoverlay sj201-buttons-overlay-pi5 | ||
| else | ||
|
|
@@ -337,16 +328,12 @@ fi | |
| amixer -c "aiyvoicebonnet" cset numid=27 on | ||
| i2c_device_name="AIYVOICEBONNET" | ||
| fi | ||
|
|
||
| if [[ ${detection_results[HIFIBERRYPRO]} == true ]] ; then | ||
| echo "Installing HiFi Berry Pro" | ||
| if $(compare_kernel_version "6.1.77"); then | ||
| dtoverlay hifiberry-dacplus | ||
| else | ||
| dtoverlay hifiberry-dacplus-pro | ||
| fi | ||
| dtoverlay hifiberry-dacplus-pro | ||
| i2c_device_name="HIFIBERRYPRO" | ||
|
|
||
| if [[ ${detection_results[HIFIBERRYAMP]} == true ]] ; then | ||
| echo "Enabling hifi berry headphone jack" | ||
| /usr/sbin/i2cset -y 1 0x60 0x01 0xc0 | ||
|
|
@@ -361,6 +348,7 @@ fi | |
| else | ||
| echo "Error: Directory $(dirname "$i2c_device_file") does not exist" >&2 | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| # Run the main function | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close both ends of FD 3 to avoid a persistent TTY handle leak
exec 3<>"$dev"opens FD 3 for read+write, but only the write end is closed. This leaks the read end and can hold the serial device open past function scope.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents