Skip to content

Latest commit

 

History

History
410 lines (276 loc) · 9.95 KB

HACKING.md

File metadata and controls

410 lines (276 loc) · 9.95 KB

Install the AIY Projects software

This page describes how to install all software for an AIY Vision Bonnet or Voice Bonnet.

If you're updating an existing AIY kit or starting from scratch, we recommend you install our pre-built image. But if you have your own Raspbian system that you'd like to use with an AIY kit, then you can install our software on your existing Raspbian system.

Install our pre-build AIY Projects image

To flash our latest pre-built system image onto an SD card, follow these steps:

  1. Download the latest .img.xz file from our releases page on GitHub. (For release details, see the Change log.)
  2. Plug-in your MicroSD card to your computer with an adapter.
  3. Use a program such as balenaEtcher to flash the .img.xy file onto your MicroSD card. (balenaEtcher is free and works on Windows, Mac, and Linux.)

When flashing is done, put the MicroSD card back in your kit and you're good to go!

Install AIY software on an existing Raspbian system

Follow these steps to install the AIY drivers and software onto an existing Raspbian system.

Note: This process is compatible with Raspbian Buster 64 bits from 2021-05-07 available there : https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2021-05-28/

1. Configure the Raspberry Pi

Enable SSH :

Put a file named "ssh" (without extension) on the boot partition

Now, start the Raspberry Pi

Connect to the Raspberry Pi SSH

Setup locales and WiFi country :

sudo raspi-config

Reboot :

sudo reboot

2. Add the AIY Debian packages repo

Add AIY package repo:

echo "deb https://packages.cloud.google.com/apt aiyprojects-stable main" | sudo tee /etc/apt/sources.list.d/aiyprojects.list

Add Google package keys:

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Update sources :

sudo apt-get update

(Raspbian 64 bits) Repair VLC packages :

sudo apt install libvlc-bin vlc-plugin-qt

Install the latest system updates (including kernel) :

sudo apt-get upgrade

Install Raspberry kernel headers :

sudo apt-get install -y raspberrypi-kernel-headers

Then reboot:

sudo reboot

3. Install optional packages

RGB Button Driver

This package is needed only if you're using the light-up RGB button that's included with the Vision/Voice Bonnet:

sudo apt-get install -y leds-ktd202x-dkms

Run sudo modprobe leds_ktd202x to load the driver and sudo modprobe -r leds_ktd202x to unload it. Vision/Voice Bonnet does this automatically via built-in device tree overlay saved in the board's EEPROM.

Piezo Buzzer Driver

This package is needed only if you're using the piezo buzzer included with the Vision Bonnet:

sudo apt-get install -y pwm-soft-dkms

Pi Zero Ethernet-over-USB

This package is needed only if you're using Ethernet-over-USB on Pi Zero:

sudo apt-get install -y aiy-usb-gadget

Default Pi IP address is 192.168.11.2, host IP address will be assigned automatically.

Support for AIY Projects app

In order to make the Pi work with the AIY Projects app:

sudo apt-get install -y aiy-bt-prov-server

4. Install required packages

Use the following commands to install packages for either the Vision Bonnet or the Voice Bonnet/HAT.

Install Vision Bonnet packages

Install the bonnet drivers:

sudo apt-get install -y aiy-vision-dkms

Install the example vision models:

sudo apt-get install -y aiy-models

Install the optimized protobuf library for better performance:

sudo apt-get install -y aiy-python-wheels

Enable camera module:

echo "start_x=1" | sudo tee -a /boot/config.txt

Set GPU memory to 128MB:

echo "gpu_mem=128" | sudo tee -a /boot/config.txt

Make sure to not use GPIO6 for SPI0 (required since 5.4 kernel):

echo "dtoverlay=spi0-1cs,cs0_pin=7" | sudo tee -a /boot/config.txt

Reboot :

sudo reboot

Then verify that dmesg output contains Myriad ready message :

dmesg | grep -i "Myriad ready"

You can also verify that camera is working fine by watching video on the connected monitor:

raspivid -t 0

Or use ffplay to get video output on the host machine:

ssh pi@raspberrypi.local "raspivid --nopreview --timeout 0 -o -" | ffplay -loglevel panic -

Install Voice Bonnet/HAT packages

Voice HAT does not require any driver installation. You only need to load device tree overlay on boot:

echo "dtoverlay=googlevoicehat-soundcard" | sudo tee -a /boot/config.txt

Voice Bonnet requires driver installation:

sudo apt-get install -y dkms aiy-voicebonnet-soundcard-dkms

Disable built-in audio:

sudo sed -i -e "s/^dtparam=audio=on/#\0/" /boot/config.txt

Install PulseAudio:

sudo apt-get install -y pulseaudio
sudo mkdir -p /etc/pulse/daemon.conf.d/
echo "default-sample-rate = 48000" | sudo tee /etc/pulse/daemon.conf.d/aiy.conf

You may also need to disable module-suspend-on-idle PulseAudio module for the Voice HAT:

sudo sed -i -e "s/^load-module module-suspend-on-idle/#load-module module-suspend-on-idle/" /etc/pulse/default.pa

Disable the "To install the screen reader press control alt spce" audio message :

sudo rm /etc/xdg/autostart/piwiz.desktop

If you want to use Google Assistant, install the Raspberry-Pi-compatible google-assistant-library python library from aiy-python-wheels package:

sudo apt-get install -y aiy-python-wheels

(64 bits) Then install protobuf:

pip3 download protobuf
pip3 install ./protobuf-*.whl
sudo nano /var/lib/dpkg/info/aiy-python-wheels.postinst

(64 bits) Comment out the lines containing

# pip3 install --no-deps --no-cache-dir --disable-pip-version-check \
       #     /opt/aiy/python-wheels/protobuf-3.6.1-cp35-cp35m-linux_armv6l.whl

(64 bits) Finish installation :

sudo dpkg --configure --force-overwrite --force-overwrite-dir -a

Reboot:

sudo reboot

Check Voice bonnet is working :

aplay -l

Note : if Voice Bonnet is not detected after a reboot, try again after a complete shutdown. In my case, the Voice Bonnet works only after a complete shutdown, and is not detected after a reboot.

Then verify that you can record audio:

arecord -f cd test.wav

...and play a sound:

aplay test.wav

Additionally, the Voice Bonnet/HAT requires access to Google Cloud APIs. To complete this setup, follow the Voice Kit setup instructions.

5. Install the AIY Projects Python library

Finally, you need to install the AIY Projects Python library.

First make sure you have git installed:

sudo apt-get install -y git

Then clone this aiyprojects-raspbian repo from GitHub:

git clone https://github.com/google/aiyprojects-raspbian.git AIY-projects-python

And now install the Python library in editable mode:

pip3 install --upgrade google-assistant-grpc

Copy aiy library to examples folders :

cp -R ~/AIY-projects-python/src/aiy/ ~/AIY-projects-python/src/examples/voice/
cp -R ~/AIY-projects-python/src/aiy/ ~/AIY-projects-python/src/examples/vision/

(32 bits) Install google-assistant-library :

pip3 install google-assistant-library

(64 bits) Install google-auth :

pip3 install google-auth

(64 bits) Install google-auth-oauthlib :

pip3 install google-auth-oauthlib

Test audio :

python3 checkpoints/check_audio.py

Appendix: List of all AIY Debian packages

The following is just a reference of all packages that are installed when you follow the above steps.

Vision and Voice Bonnets

  • aiy-dkms contains MCU drivers:

    • aiy-io-i2c — firmware update support
    • pwm-aiy-ioPWM sysfs interface
    • gpio-aiy-ioGPIO sysfs interface
    • aiy-adcIndustrial I/O ADC interface
  • aiy-io-mcu-firmware contains MCU firmware update service

  • leds-ktd202x-dkms contains leds-ktd202x LED driver

  • pwm-soft-dkms contains pwm-soft software PWM driver

  • aiy-python-wheels contains optimized protobuf python wheel (until this issue is fixed) along with Google Assistant Library for different Raspberry Pi boards.

Vision Bonnet

  • aiy-vision-dkms contains aiy-vision Myriad driver

  • aiy-vision-firmware contains Myriad firmware

  • aiy-models contains models for on-device inference:

    • Face Detection
    • Object Detection
    • Image Classification
    • Dish Detection
    • Dish Classification
    • iNaturalist Classification (plants, insects, birds)

Voice Bonnet

  • aiy-voicebonnet-soundcard-dkms contains sound drivers:

    • rl6231
    • rt5645
    • snd_aiy_voicebonnet