Michael.S
Posts: 2
Joined: Thu Mar 12, 2015 1:11 am

Device tree and the Gertduino

Thu Mar 12, 2015 3:43 am

I have a rpi 2 with a Gertduino board, been having quit a time get this running.

1: Installed Friends of the unicorn instruction and could not get the Gertduino to program.
2: After many installs I used to avrdude 5.10-4 for the Gertboard and managed
to upload my sketch with no RC-1 error.
3: Found out that I have to remove the reset on the Gertduino to see my sketch run.
4: After reading the post here on disabling the device tree it all seems to work fine.

My knowledge is limitted but growing but the way it is right now i can not access the
Atmega 48 and disabling the device tree seems to be a short term fix. Is there another
way to do a better installation and could I adding a line in the config.txt and enable the
device tree ?

Thank You
Mike

User avatar
Gert van Loo
Posts: 2475
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Device tree and the Gertduino

Thu Mar 12, 2015 1:31 pm

The issue is being investigated.
I can't try it here and now but thus might be a SW solution script:

reset_off:
#!/usr/bin/sudo bash
# Set GPIO pin 8, high releasing Arduino reset
sudo echo "8" >/sys/class/gpio/export
sudo echo "out" >/sys/class/gpio/gpio8/direction
sudo echo "1" >/sys/class/gpio/gpio8/value
# Do not release the GPIO as the device tree reverts it to input mode : keep it in output mode
# sudo echo "8" >/sys/class/gpio/unexport

reset_on:
#!/usr/bin/sudo bash
# Set GPIO pin 8, high releasing Arduino reset
sudo echo "8" >/sys/class/gpio/export
sudo echo "out" >/sys/class/gpio/gpio8/direction
sudo echo "0" >/sys/class/gpio/gpio8/value
# Do not release the GPIO as the device tree reverts it to input mode : keep it in output mode
# sudo echo "8" >/sys/class/gpio/unexport

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Device tree and the Gertduino

Thu Mar 12, 2015 11:31 pm

Unfortunately,

Code: Select all

[email protected] ~/gertduino $ ./reset_on 
[email protected] ~/gertduino $ ./reset_off
echo: write error: Device or resource busy
[email protected]i ~/gertduino $ ./reset_on
echo: write error: Device or resource busy
[email protected] ~/gertduino $ 
An experiment: first check if the pin is already exported. If it is, unexport it before requesting it again.

reset_on:

Code: Select all

#!/usr/bin/sudo bash

if [ -d /sys/class/gpio/gpio8 ]; then
  sudo echo "8" >/sys/class/gpio/unexport
fi
sudo echo "8" >/sys/class/gpio/export
sudo echo "out" >/sys/class/gpio/gpio8/direction
sudo echo "0" >/sys/class/gpio/gpio8/value
reset_off:

Code: Select all

#!/usr/bin/sudo bash

if [ -d /sys/class/gpio/gpio8 ]; then
  sudo echo "8" >/sys/class/gpio/unexport
fi
sudo echo "8" >/sys/class/gpio/export
sudo echo "out" >/sys/class/gpio/gpio8/direction
sudo echo "1" >/sys/class/gpio/gpio8/value
At first sight, that seems to work:

Code: Select all

[email protected] ~/gertduino $ ./reset_on
[email protected] ~/gertduino $ ./reset_off
[email protected] ~/gertduino $ ./reset_on
[email protected] ~/gertduino $ ./reset_off
[email protected] ~/gertduino $ 
However, now the pin is still exported. That means avrdude isn't able to pull the reset pin to program the chip and it will yell at you. The pin needs to be unexported before programming with avrdude.

reset_unexport:

Code: Select all

#!/usr/bin/sudo bash

if [ -d /sys/class/gpio/gpio8 ]; then
  sudo echo "8" >/sys/class/gpio/unexport
fi
Or something. It may not be pretty, but here we are.
Microcontroller addon boards and software for Raspberry Pi A+/B+/Pi2:
- ARMinARM: ARM Cortex-M3 (STM32)
- AVRPi: ATmega32U4 & ATmega328 ("Arduino")
http://www.onandoffables.com

Michael.S
Posts: 2
Joined: Thu Mar 12, 2015 1:11 am

Re: Device tree and the Gertduino

Fri Mar 13, 2015 1:58 am

Thank for your prompt reply, I have tried the code and the sketch woks with the reset off sent. When I
send another sketch it automatically reset the pin to on by itself. I have to send another rest off the sketch
works.

Mike

Return to “HATs and other add-ons”