open-electronics / RandA

RandA is a Bridge between Raspberry Pi and Arduino that leverages the hardware equipment and the computing power of the first with the shields and the applications of the second.
http://www.open-electronics.org/tag/randa/
12 stars 8 forks source link

Explain how to load a compiled .hex to RandA without any software #2

Open Stypox opened 5 years ago

Stypox commented 5 years ago

It makes no sense to download the whole RandA software if only uploading sketches is needed. An explanation on how to do that should be added somewhere. It took me ages to understand what makes it different from a normal Arduino (by reading the RandA scripts), but it all boils down to these lines:

gpio -g write 23 0
sleep 0.1
gpio -g write 23 1
#   ...   UPLOAD .hex USING ANY METHOD (the best one is probably arduino-cli)
gpio -g write 23 0
arduino-cli
Stypox commented 5 years ago

Forgot to add the install.sh code to setup the serial connection (to be executed once)


# enable i2c (if not already enabled)
check=$(grep -c "^dtparam=i2c_arm" /boot/config.txt)
if [ x$check == x"0" ]
then
sudo su -c 'echo -e "\n#enable i2c\ndtparam=i2c_arm=on" >> /boot/config.txt'
fi

# enable serial on GPIO14,15 (if not already enabled)
check=$(grep -c "^dtoverlay=pi3-miniuart-bt" /boot/config.txt)
if [ x$check == x"0" ]
then
sudo su -c 'echo -e "\n#switch serial1 with serial0\ndtoverlay=pi3-miniuart-bt" >> /boot/config.txt'
fi

# serial will be not a console terminal (because it will be used by RandA)
sudo su -c 'echo -e "dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait" > /boot/cmdline.txt'

# execute on startup: /etc/rc.local
sudo su -c 'sed -i "/^exit 0/ d" /etc/rc.local'
sudo su -c 'echo -e "\n# RandA serial port\n# serial no terminal\nchmod 777 /dev/ttyAMA0\n# synonym for Arduino serial port\nln -s /dev/ttyAMA0 /dev/Arduino\n\n# enable RandA reset via GPIO 23\n# soft reset pin initialization\ngpio -g mode 23 out\n\nexit 0" >> /etc/rc.local'```