Raspberry Pi Stand-Alone Programmer

Pages
Contributors: QCPete
Favorited Favorite 12

RC.LOCAL + Python + HAT = Headless Operation!

RC.LOCAL

A quick modification to rc.local to call Python at bootup means we can run this thing headless. Wahoo!

language:bash
#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
python /home/pi/test.py &
exit 0

Python Script

Note the most important line here:

language:bash
python /home/pi/test.py &

And don't forget that "&" and the end of the command - that will actually let your pi continue on to bootup and run the OS!

Test.py basically waits to see a "button" pressed to engage programming (pi_program.sh). In this case, it is actually a capsense IC that is sending HIGH/LOW to a GPIO on the pi. To read the entire test.py, you can check it out on the repo here:

And the pi_program.sh file is basically the single call to avrdude to actually do the programming. It looks something like this on most of our production machines:

language:bash
#program flash and lock bits
sudo avrdude -p $DEVICE -C /home/pi/avrdude_gpio.conf -c linuxspi -P /dev/spidev0.0 -b 2000000 -D -v -u -U flash:w:$firmware:i -u -U lock:w:$LOCK:m 2>/home/pi/flash_results.txt

Pi_Grammer HAT

The last ingredient is a custom hat that allows for triggering and LED indicators to the user. Also, added a shutdown button, for goodness sake!

Eagle Pi_programmer Board Layout