Skip to content

Commit

Permalink
Merge pull request #49 from xmos/release/v5.3.0
Browse files Browse the repository at this point in the history
Release/v5.3.0
  • Loading branch information
xluciano authored Sep 20, 2022
2 parents b8c04b6 + f5a7b70 commit d972c09
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# VocalFusion Raspberry Pi Setup Change Log

## 5.3.0

* Fix setup_dac.py script for XVF3615
* Build I2S slave drivers for UA XVF3610 setup
* Save crontab settings in 'resources' directory
* Use different names for I2S slave and master scripts

## 5.2.0

* Added copying of asoundrc file at bootup
Expand Down
12 changes: 6 additions & 6 deletions resources/clk_dac_setup/setup_dac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!usr/bin/python
# Copyright (c) 2018-2021, XMOS Ltd, All rights reserved
# Copyright (c) 2018-2022, XMOS Ltd, All rights reserved

#run this on the raspberry pi to program the DAC

Expand All @@ -23,7 +23,7 @@ def setup_dac(args):

I2C_EXPANDER_ADDRESS = 0x20

if args.hw == "xvf3600" or args.hw == "xvf3610" :
if "xvf36" in args.hw:

# I2C expander register addresses
I2C_EXPANDER_OUTPUT_PORT_REG = 0x01
Expand Down Expand Up @@ -55,12 +55,12 @@ def setup_dac(args):
# Configure pin directions. Setting to 1 means input, or Hi-Z. So anything not mentioned
# below will be an output. Note reset, int and boot_sel NOT driven because they are set high in the mask
# use DAC_RST_N and level shift OE as driven outputs
# Configure the mute pin as input only for XVF3610
# Configure the mute pin as input only for XVF361x
if args.hw == "xvf3600":
CONFIGURATION_MASK = (1<<XVF_RST_N_PIN) | \
(1<<INT_N_PIN) | \
(1<<BOOT_SEL_PIN)
elif args.hw == "xvf3610":
elif "xvf361" in args.hw:
CONFIGURATION_MASK = (1<<XVF_RST_N_PIN) | \
(1<<INT_N_PIN) | \
(1<<BOOT_SEL_PIN) | \
Expand All @@ -69,8 +69,8 @@ def setup_dac(args):
bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_CONFIGURATION_REG, CONFIGURATION_MASK)
time.sleep(0.1)

# Enable the interrupt on INT_N pin for XVF3610
if args.hw == "xvf3610":
# Enable the interrupt on INT_N pin for XVF361x
if "xvf361" in args.hw:
# Interrupts are enabled by setting corresponding mask bits to logic 0
INTERRUPT_MASK = 0xFF & ~(1<<INT_N_PIN)
bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_INTERRUPT_MASK_REG, INTERRUPT_MASK)
Expand Down
30 changes: 19 additions & 11 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ else
fi

# Configure device-specific settings
case $XMOS_DEVICE in
case $XMOS_DEVICE in
xvf3510-ua|xvf3610-ua|xvf3615-ua)
UA_MODE=y
USB_MODE=y
I2S_MODE=slave
ASOUNDRC_TEMPLATE=$RPI_SETUP_DIR/resources/asoundrc_vf_xvf3510_ua
;;

Expand Down Expand Up @@ -126,7 +127,7 @@ fi
echo "Installing necessary packages for dev kit"
packages=$PACKAGES_TO_INSTALL
# Add packages for UA mode
if [[ -n "$UA_MODE" ]]; then
if [[ -n "$USB_MODE" ]]; then
packages="$packages $PACKAGES_TO_INSTALL_ONLY_FOR_UA"
fi
for package in $packages; do
Expand Down Expand Up @@ -183,7 +184,7 @@ fi
popd > /dev/null

# Copy the udev rules files if device is UA
if [[ -n "$UA_MODE" ]]; then
if [[ -n "$USB_MODE" ]]; then
echo "Add UDEV rules for XMOS devices"
sudo cp $RPI_SETUP_DIR/resources/99-xmos.rules /etc/udev/rules.d/
fi
Expand All @@ -208,7 +209,7 @@ sudo /etc/init.d/alsa-utils restart

if [[ -n "$I2S_MODE" ]]; then
# Create the script to run after each reboot and make the soundcard available
i2s_driver_script=$RPI_SETUP_DIR/resources/load_i2s_driver.sh
i2s_driver_script=$RPI_SETUP_DIR/resources/load_i2s_${I2S_MODE}_driver.sh
rm -f $i2s_driver_script

# Sometimes with Buster on RPi3 the SYNC bit in the I2S_CS_A_REG register is not set before the drivers are loaded
Expand Down Expand Up @@ -256,27 +257,34 @@ if [[ -n "$DAC_SETUP" ]]; then
fi

# Regenerate crontab file with new commands
rm -f $RPI_SETUP_DIR/resources/crontab
crontab_file=$RPI_SETUP_DIR/resources/crontab
if [ -n "$USB_MODE" ]; then
crontab_file="${crontab_file}_usb"
elif [ -n "$I2S_MODE" ]; then
crontab_file="${crontab_file}_i2s_${I2S_MODE}"
fi

rm -f $crontab_file

# Setup the crontab to restart I2S at reboot
if [ -n "$I2S_MODE" ] || [ -n "$DAC_SETUP" ]; then
if [[ -n "$I2S_MODE" ]]; then
echo "@reboot sh $i2s_driver_script" >> $RPI_SETUP_DIR/resources/crontab
echo "@reboot sh $i2s_driver_script" >> $crontab_file
fi

if [[ -n "$DAC_SETUP" ]]; then
echo "@reboot sh $dac_and_clks_script" >> $RPI_SETUP_DIR/resources/crontab
echo "@reboot sh $dac_and_clks_script" >> $crontab_file
fi
popd > /dev/null
fi

# Setup the crontab to copy the .asoundrc file at reboot
# Delay the action by 10 seconds to allow the host to boot up
# This is needed to address the known issue in Raspian Buster:
# https://forums.raspberrypi.com/viewtopic.php?t=295008
echo "@reboot sleep 15 && cp $ASOUNDRC_TEMPLATE ~/.asoundrc" >> $RPI_SETUP_DIR/resources/crontab
echo "@reboot sleep 15 && cp $ASOUNDRC_TEMPLATE ~/.asoundrc" >> $crontab_file

# Update crontab
crontab $RPI_SETUP_DIR/resources/crontab
crontab $crontab_file

echo "To enable all interfaces, this Raspberry Pi must be rebooted."

0 comments on commit d972c09

Please sign in to comment.