This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connections between RPi and nano for flashing
I'd like to be able to reflash my nano from the RPi.  I can see there's support for it:

What pins do I need to connect?

On the nano side, I think it's D11, D12 and D13.  How about on the RPi?  Can I use GPIO9/GPIO10/GPIO11, with GPIO7 as the chip enable?  Will connecting these lines result in the nano's use of these lines interfering with the LCD?  Is it possible instead to use SPI1 on GPIO19/GPIO20/GPIO21, with GPIO16 as the chip enable?

Thank you.
I reflash using the bootloader. So you can reflash the nano via usb or the hardware serial port. It's possible to use spi but why?
(2020-10-01, 12:23 AM)seandepagnier Wrote: but why?

For my autopilot I'm aiming for something about the size of a cigarette pack so I can put it directly at my helm next to the compass.  Space on my board is really tight, so I want to put the ATmega directly on the PCB (ie, no nano carrier PCB).  This means the ATmega will have no USB.  

(2020-10-01, 12:23 AM)seandepagnier Wrote: It's possible to use spi

Great!  Looking at hat/arduino.pyavrdude is called with -c linuxspi, and a device of /dev/spidev0.1, so it seems that you've already been programming it over SPI.  I can see that reset is GPIO16.  But I'm trying to confirm the pins.  I had a look in tinypilot_2020_09_30.img.xz to see if there's a special avrdude.conf, but it looks standard.  So that means for spidev0.1 it's probably going to be GPIO9, GPIO10 and GPIO11.  Do I have it right?

Something I haven't yet found a solution for is level translation.  Will an atmega328 work at 3.3V with motor.ino? What will I need to change? Brownout fuses?)
I'm using an arduino over spi on the hat to receive rf signals as well as other functions. This is not the same atmega as the motor controller.
(2020-10-01, 06:00 AM)seandepagnier Wrote: I'm using an arduino over spi on the hat to receive rf signals as well as other functions.  This is not the same atmega as the motor controller.

I see, thanks.
(2020-10-01, 06:00 AM)seandepagnier Wrote: I'm using an arduino over spi on the hat to receive rf signals as well as other functions.  This is not the same atmega as the motor controller.

Ok.  I got a bit confused because this command was in hat/

I looked into motor controller programming.  @seandepagnier, you probably know all this, so I'm half talking out loud for my own benefit, half for anyone else.

As you mentioned, if I burn optiboot into the ATmega, I'll be able to send new firmware over TX/RX with avrdude -c arduino.  The missing link is the reset signal.  I looked into avrdude, and there's no support for specifying a reset pin if you're using -c arduino.  I can see where such code could be added though.  

There are at least two terrible hacks people have done to get around this.  One uses strace to watch for the serial port ioctls that avrdude uses to pulse DTR/RTS, and when that happens, it twiddles a GPIO.  The other intercepts the serial traffic and listens for avrdude to send a particular string:

They are both awful.

What I think I'll do is rely on the fact that optiboot waits one second before falling through.  I can see in the pypilot source that GPIO16 is being used to reset the ATmega.  I'll pulse RESET, then start avrdude over the serial port, and thus I'll hit the programming window.  Sounds feasible? 

(In other news, I need to program optiboot before I solder the ATmega onto the board.  I'm planning to use thisSmile
Since the motor controller is optically isolated there is no way to send the reset pulse without an extra isolator just for that which I don't intend to ever use.

What I do is press the reset button on the arduino exactly when running avrdude, or if there is no reset button, apply power to the motor controller at this same moment.

The gpio16 is used to reset the hat arduino which is programmed over spi directly, but again, it is not optically isolated, it runs at 3.3v and is used only to receive RF, IR, and provide an extra serial port and some gpio and analog inputs.

Forum Jump:

Users browsing this thread: 1 Guest(s)