0
votes

I am using the Arduino IDE and RasPiArduino (https://github.com/me-no-dev/RasPiArduino) to compile sketches for my Raspberry Pi Zero. It's working fine.

I figured that the Pi's USB OTG port could be used to directly upload the sketches via USB. So I have set up g_serial on the Pi and successfully logged into it using minicom. The Arduino IDE also lists the port under Tools -> Port. So far so good.

However, I am not yet able to actually upload a sketch over that port or to open the Serial Monitor. As far as I know, the IDE uses avrdude to upload sketches, but it seems that only works for Atmel chips? I am completely stuck here. Can this be done at all? Any ideas or pointers are greatly appreciated.

Thanks!

1
It sounds like uploads are done over the network, not USB/serial (from github.com/me-no-dev/RasPiArduino#instructions-for-arduino-ide): "Select the RespberryPi from the list of Ports (will show the IP address)". You can also manually copy the compiled binary to the RPi, See the "Copying the executable" section of github.com/me-no-dev/RasPiArduino/wiki/Installation.per1234
Thanks, I read this too. Thing is, I plan to use this setup in a classroom context. So in the end, there will be 10+ Pis on the local network and I don't want students to constantly override each other's programs (be it intentionally or by accident). This is why I want to use the USB port. Manually copying the exec is a fallback, but using the IDE upload would be much more convenient.Michael Rücker
RPi zero support ethernet over USB with g_ether kernel module. Not sure if that's your hardware.jikuja
Yeah, g_ether works on my Pi. I'll see if I can get the IDE to upload code that way. Thanks for the tip. :)Michael Rücker

1 Answers

0
votes

OK, I got it working as follows, thanks to the tip from jikuja:

  1. Set up ethernet over USB using the gadget driver g_ether You may also have to set up a DHCP server (e.g. dnsmasq) on the Raspberry Pi in order to assign IPs to the Pi and the host. Details can be found here, for instance: https://gist.github.com/gbaman/50b6cca61dd1c3f88f41
  2. Configure avahi to only provide the arduino service over the USB interface. To do this, modify /etc/avahi/avahi-daemon.conf and set options allow-interfaces=usb0 and deny-interfaces=wlan0.

The Arduino IDE (using RaspiArduino) should not be able to detect the Pi on the USB interface, but not the WiFi. Uploading sketches and serial monitor all work fine for me that way. :)