# Installing Jessie

### Kamino base

This is my routine for getting a fresh Jessie installation up and running. It includes a section on how to install the Arduino IDE as well.  Originally used the 9-24-2015 image of Jessie, it has now been updated for the 3-18-2016 version and I am using a Raspberry Pi 3.  Since this is a set of tasks I run on all of my RPis, I have an image with all of these changes already in place so I can rapidly generate a “fresh” install.  If you don’t know why I refer to this image as Kamino base, you need to freshen up on your Star Wars factoids.

First, follow the installation guide for downloading and installing the disk image.  I use Win32 Disk Imager on a Windows 10 computer to do this part.

On initial boot, the Pi starts X.  Press F2 and type lxterminal to get the terminal.

### raspi-config

The first step is to do some basic system configuration using raspi-config.  Type sudo raspi-config  in the terminal.  I use the following order:

• Expand filesystem
• Set boot options (only if you don’t want to boot to X)
• Set Internationalization options
• Here you should update the keyboard, timezone, local and wifi internationalization (which is a recent addition to raspi-config).
• Reboot now to ensure these changes are in effect, then go back to raspi-config
• Set hostname
• Enable SSH
• Set Serial to no (if setting up Arduino, for example)
• Set overclock if desired (No overclocking on the RPi3)

### Set up wireless

Your experience may be different here.  I have had some recent problems with a set of WiFi adapters using the Realtek chipset and I am pretty sure, although not certain, that the problem is the hardware.

Assuming the RPi has an Edimax WiFi adapter, turn off power management by creating a file /etc/modprobe.d/8192cu.conf with the following text:

It is best to check if the wifi applet in X works for you, as it requires no effort.  If you are on the command line, then  sudo iwlist wlan0 scan  will find available WiFi networks.  Then edit “/etc/wpa_supplicant/wpa_supplicant.conf” to include the appropriate SSID and psk information

On some of my RPis I need to explicitly load the WiFi module by adding 8192cu to the end of /etc/modules.  I’m not really sure why this would be the case (or if it is even true at this time).

Reboot.

## Packages to install

This is a set of packages that I use frequently enough to have on a base system.  Before installing packages, it is always good to start with sudo apt-get update && sudo apt-get upgrade.

### Always

• These are no longer necessary now that raspi-config takes care of the problem.
• wireless-regdb
• iw crda *deals with the CRDA problem*
• wicd wicd-curses *console programs for network configurations*
• mysql-client mysql-server
• minicom
• x11vnc
• update I now use these instructions for setting up x11vnc to run automatically.  If truly headless (I have one Pi connected to a monitor, so I haven’t altered config.txt for that one) I refer to eLinux.org for the correct/desired HDMI modes.
• Summary of this process:
• Add x11vnc -bg -nevershared -forever -tightfilexfer -usepw -display :0 to “~/.xsessrionrc”
• Execute  chmod 775 ~/.xsessionrc
• Modify “/boot/config.txt” by setting  hdmi_force_hotplug=1 and setting the mode parameters (hdmi_group and hdmi_mode) to the appropriate values.
• I prefer over other vnc servers as it allows you to control the same X session currently running on the RPi.  See this forum for some configuration options that I have not yet tried.
• If running headless, then starting x11vnc may give a very low resolution screen by default.  I used this post to fix the issue, which involves setting hdmi_group=2 and hdmi_mode=35 in /boot/config.txt.
• I’m starting to like xfce4 which benefits from xcompmgr

#### Minicom config

I use minicom to talk to AMA0 and that requires:

Create file /etc/minicom/minirc.ama0:

Also remember that for simple operations echo -n " " &gt; /dev/ttyAMA0 works as well.

#### Grab custom config files

This is the end of Kamino base.  Below are additions I make to RPis that will be used for physical computing (which is many, but not all of them).

### Arduino

It looks like there is some decent activity on maintaining a 1.6.5 version that works on the RPi. These instructions install that version.

There will be many unmet dependencies, and the dpkg-buildpackage command will highlight them. Add them with:

The dpkg-buildpackage command takes a while. Once completed, arduino should work. Set up a ATMega328p for testing. At this point, gpio programming still needs to be set up. Need the patched version of avrdude, first remove the currently installed one and replace it with the one from drogon

Sub section below may not be necessary, since I’m not interested in the IDE

##### Configuring IDE

Now configure the gpio programmer by adding the following two lines to /usr/share/arduino/hardware/arduino/avr/programmers.txt (I’d like to find out if this can go into a user-owned directory;  looks like I can put something in ~/Arduino/hardware/dirname/avr/{programmers,boards}.txte)

(* May not be terribly interested in getting the IDE to work better, as it appears to crash over SSH, and it’s slow anyway *)

Get Arduino-Makefile and place it in an accessible directory. Create a simple makefile in the sketch directory containing variables with location of Arduino, this makefile and a command to actually include the makefile.

#### Configuring bare ATMega328

Right now, I don’t know of any method other than to modify /usr/share/arduino/hardware/arduino/avr/boards.txt

At this point, the ATMega328p can be programmed. To get make upload to work reliably, I had to force flash erase (no -D flag in avrdude) which was hardcoded into Arduino.mk around line 1313. Search for BTC to find comments to my changes. A serial monitor can be created using minicom ama0 As far as I can tell, programming the ATMega328p is complete.

#### Configuring the ATTiny85

First get the files from github:

The makefile requires a few extra components: first indicate that an alternate core is being used, then add the sub tag and specify the CPU frequency.

Compiling throws a bunch of warnings (BIN already defined) but it doesn’t seem to stop the compile from completing. To get make upload to function properly, two lines need to be added to the tiny boards.txt.

At this point, it looks like I can successfully program ATTiny85 chips.

When playing with RF transmitter/receivers, I had problems with the above attiny code; however this variant seems to work much better.

### References Some possibly useful links and why

• Adafruit has some general instructions that apply to non-Raspberry Pi installations. Good tutorial info.
• RPi forum entry on the approach I am using here. – This github repository has some good background information. It is what I followed when I tried to upgrade Wheezy. Ultimately, it worked for an ATMega328p but I had problems trying to program an ATTiny85 and gave up at that point. After completing the fresh install, I learned that the original problem here was the lack of additional variables (e.g. BOARD_SUB) in the makefile. I suspect the original plan was going to work.
• Installing the patched version of avrdude. Here’s where the correct chmod command is found. I noticed that I may be able to avoid a custom avrdude but I have not yet explored this option.
• The reference for custom board specifications. – Setting up Arduino from the command line can be found here and here.
• Instructions used to set up ATTiny programming