Skip to content

Instantly share code, notes, and snippets.

@vinceallenvince
Last active February 28, 2021 01:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinceallenvince/7cae6fcfc78091475e81 to your computer and use it in GitHub Desktop.
Save vinceallenvince/7cae6fcfc78091475e81 to your computer and use it in GitHub Desktop.
Set up an SD Card for Raspberry Pi Audio projects

#Set up an RPi Audio project

Use the following instructions to prepare your RPi's SD Card for an audio project.

###Install an operating system. You first need to install an operating system on your RPi. Raspian should work fine. If you're using a monitor, keyboard and mouse, using an install manager is the easiest way. Just follow the instuctions for installing NOOBS.

If you are developing headless, follow the instructions for downloading and installing Raspian. You'll also need to login via ssh or a console cable. If you're on Yosemite on a Mac, this post will help.

Your SD Card should be at least 8GB to hold both the operating system and your application.

###System setup If you installed via NOOBS, you'll see raspi-config. If not, after a successful first boot, run raspi-config and set the following options.

raspi-config
  • Internationalization options

    • Update Locale (ex: en_US.UTF-8 UTF-8)

    • Update Timezone

    • Update Keyboard Layout: first set Keyboard model (ex: Macintosh), next select Keyboard layout (default is UK... if you're not in the UK, select 'other'); select Country of Origin for the keyboard (ex: English (US)); finaly, update Keyboard layout (ex: English (US) - English (Macintosh).

  • Audio out

    If you plan to use the audio jack, force audio out the 3.5mm jack instead of the HDMI port. Go to 'Advanced Options': 'Audio' and select 'Force 3.5mm jack'.

  • Font size

    If you're using an HD monitor, you'll likely want to increase the command line font size. Follow these instructions and use method #2. http://www.raspberrypi-spy.co.uk/2014/04/how-to-change-the-command-line-font-size/

  • Single Wifi point

    https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis

    Note: Use tabs to indent the wpa-ssid and wpa-psk entries, not spaces.

    After rebooting test the Wifi connection.

    ping 139.130.4.5
    
  • Multiple Wifi points

    http://www.algissalys.com/index.php/how-to/90-how-to-raspberry-pi-wifi-setup-through-command-line

    For details on using wpa_supplicant.conf

    zcat /usr/share/doc/wpasupplicant/README.Debian.gz | less
    

    To check and see which one you’re using at any given time, just use the following command.

    iwconfig
    

    Shutdown the Wifi interface.

    sudo ifdown wlan0
    

    Reload the Wifi interface.

    sudo ifup wlan0
    

###Install packages

Make sure you've configured an Internet connection before proceeding.

  • Update the list of available packages.

    sudo apt-get update
    
  • Install newer versions of the packages you already have.

    sudo apt-get upgrade
    
  • Update your Raspberry Pi's firmware via https://github.com/Hexxeh/rpi-update.

    sudo apt-get install rpi-update
    sudo rpi-update
    sudo shutdown -r now (reboot)
    
  • If your hack requires NodeJS

    • Install Node using these instructions. The latest version I found compiled for the RPi is v0.10.28.

    • If you plan on using the speaker npm module

      • If you didn't do it when installing NodeJS above, install node-gyp. You need to reference the full path to node when running the command as root. To fix this, check out this thread.
      sudo /opt/node/bin/npm install -g node-gyp
      
      • Install libasound2-dev.
      sudo apt-get install libasound2-dev
      
  • If your hack requires Python

    • Install python-dev
    sudo apt-get install python-dev
    
    • If you want to read and write to the GPIO pins using python
    sudo apt-get install python-rpi.gpio
    
  • Get avahi-utils

    sudo apt-get install avahi-utils
    
  • Get libevent-2.0-5

    sudo apt-get install libevent-2.0-5
    
  • Get portaudio19-dev

    sudo apt-get install portaudio19-dev
    
  • Get libjack-jackd2-dev

    sudo apt-get install libjack-jackd2-dev
    
  • Install git.

    sudo apt-get install git-core
    
  • If you want to use vim instead of nano.

    sudo apt-get install vim
    
  • Check your remaining disk space.

    df
    

###Configure

  • If you're building a headless project, you'll likely want the RPi to auto login.

    Update the /sbin/getty invocations for the runlevels

    sudo vim /etc/inittab
    

    Find this line.

    1:2345:respawn:/sbin/getty --noclear 38400 tty1
    

    Comment it out and add the following line as the next line.

    1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
    

    Now you should have this.

    #1:2345:respawn:/sbin/getty --noclear 38400 tty1
    1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
    
    • Note: if you are connected via a console cable, you want to add the autologin option to the corresponding line in /etc/inittab
    T0:23:respawn:/sbin/getty --autologin pi -L ttyAMA0 115200 vt100
    
  • You may need to run other scripts as root with no password. http://askubuntu.com/questions/167847/how-to-run-bash-script-as-root-with-no-password

  • You'll likely want to transfer files via a usb flash drive.

    Make a mount point first.

    sudo mkdir /mnt/usb
    

    Plug in your flash drive.

    sudo mount /dev/sdb1 /mnt/usb
    

    You can find your flash drive files via...

    /mnt/usb
    

    Remove your flash drive.

    umount /mnt/usb
    
  • If you are using a dedicated Wifi point, it's likely hidden. To connect to a hidden ssid, you need to generate a PSK version of your WLAN password with wpa_passphrase utility.

    wpa_passphrase "<Your Wifi SSID>" "<Your Wifi PASSWORD>"
    

    To continue, do not use /etc/network/interfaces... leave with the default settings. Instead, configure wpa_supllicant.conf like this: https://databoyz.wordpress.com/tag/how-to-setup-network-and-wpa_supplicant-conf-file-on-raspberry-pi/

###Troubleshooting

  • If you see an error about pcm cards, check out this thread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment