Skip to content

Instantly share code, notes, and snippets.

@fengye
Last active January 21, 2021 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengye/fed6e8729730cb94795e2254fb785575 to your computer and use it in GitHub Desktop.
Save fengye/fed6e8729730cb94795e2254fb785575 to your computer and use it in GitHub Desktop.
Revive ArduBerry in Raspberry Pi 4 and Buster

Overview

The ArduBerry is obsolete while looks handy I want to give it a try. The official installer only partially work: https://github.com/DexterInd/ArduBerry/blob/master/Script/install.sh It lacks:

  1. proper up-to-date WiringPi(they use 2.36 which doesn't recognise Pi 4B)
  2. avrdude and /etc/avrdude.conf needs to be updated.
  3. Arduino installer on buster, along with programmers.txt configuration
  4. udev rules not copied to /etc/udev/rules.d/
  5. does NOT turn off SPI in /boot/config.txt so that avrdude cannot talk to GPIO8 and GPIO9

HOWTO:

Proper WiringPi

https://github.com/WiringPi/WiringPi.git

Disable login shell access of UART/Serial port

sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.servic

Or through raspi-config, choose Interface Options -> P6 Serial Port -> Would you like a login shell to be accessible over serial? Choose No -> Would you like the serial port hardware to be enabled -> Choose Yes -> Reboot

If get permission issue, use

# first
sudo chmod a+rw /dev/serial0
# then
minicom -b 9600 -o -D /dev/serial0

/etc/avrdude.conf

#-----------------------------------------------------------
# GPIO for ArduBerry
#-----------------------------------------------------------

# Linux GPIO configuration for avrdude.
# Change the lines below to the GPIO pins connected to the AVR.
programmer
  id    = "gpio";
  desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
  type  = "linuxgpio";
  reset = 8;
  sck   = 11;
  mosi  = 10;
  miso  = 9;
;

/usr/share/arduino/hardware/arduino/programmers.txt

gpio.name=Raspberry Pi GPIO
gpio.protocol=gpio
gpio.program.tool=avrdude

/boot/config.txt

enable_uart=1
dtoverlay=pi3-miniuart-bt
dtparam=spi=off

/etc/udev/rules.d/80-arduberry.rules

KERNEL=="ttyAMA0", SYMLINK+="ttyS0",GROUP="dialout",MODE:=0666

Still not working

Strangly, I never had UART fully working on my Raspberry Pi 4B + ArduBerry. It can successfully send data from ArduBerry and Raspberry can read it properly. However data sent from Raspberry to ArduBerry was all lost. I checked the RX pin(D0) on ArduBerry and hooked it up in a oscilloscope, only found out that when no data the voltage is steadily 5V, however when data bits kick in, the voltage jumps between 2.5V to 5V, while in normal case it should be 0V to 5V. I verified that on Raspberry Pi, the UART RX and TX all behave normal, the voltage jumps from 3.3V to 0V while transmitting data(Raspberry Pi operates at a different voltage than ArduBerry(UNO) thus the level shifter). I guess something wrong with the level shifter. This caveat/bug can be worked around by using I2C, which is proved to be reliable.

If you want to uninstall...

# Remove the dt-overlay=miniuart-bt from /boot/config.txt, then

sudo systemctl enable hciuart
sudo systemctl start hciuart
sudo systemctl enable bluetooth
sudo systemctl start bluetooth
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment