I need to program Moteinos using the Rpi3 and SPI. I've connected MISO, MOSI, SCLK, GND, 5V power to Vin and the Reset pin to GPIO18 on the RPi. The Moteino has the radio soldered on, no flash chip.
The OS is Raspbian 8/Jessie, using stock avrdude from the standard Debian repo. I have the following override for avrdude in ~/.avrduderc:
programmer
id = "linuxspi2";
desc = "Use Linux SPI device in /dev/spidev*";
type = "linuxspi";
reset = 18;
baudrate=400000;
;
When I run avrdude, I always get the same error:
root@raspberrypi:~# avrdude -F -v -p m328p -c linuxspi2 -P /dev/spidev0.0
avrdude: Version 6.1, compiled on Jul 7 2015 at 10:29:47
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
Using Port : /dev/spidev0.0
Using Programmer : linuxspi2
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : linuxspi
Description : Use Linux SPI device in /dev/spidev*
avrdude: error: AVR device not responding
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x0c05de
avrdude: Expected signature for ATmega328P is 1E 95 0F
avrdude done. Thank you.
I'm completely clueless. I've double-triple checked connections. Is it at all possible to program the Moteino with the radio soldered on? It seems to me that avrdude doesn't even bother resetting as the sketch on the mote continues to run without interuption. I know because this sketch only runs after it's initialized using serial commands. After a reset it just idles.
Any help is greatly appreciated.
So you're trying to program using a ISP protocol?
Anyway, try a 10K pullup on D10 (to keep radio SPI quiet).
Yes, that's right, I'm using the ISP protocol via Rpi SPI. In the meantime I found the thread where you mentioned a pullup is necessary. I added a 10k pullup but still the same error... It still says:
avrdude: error: AVR device not responding
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
I uploaded a blink .hex via serial (that works, using the reset trick) and checked the voltage at the module's NSS pin, it's at Vcc, no problems there. Still refuses to work.
It just occurred to me: can I "fry" the RPi's SPI lines by omitting the pullup and/or letting the radio and the chip talk while connected to the RPi?
Quote from: kobuki on May 11, 2017, 03:38:45 PM
It just occurred to me: can I "fry" the RPi's SPI lines by omitting the pullup and/or letting the radio and the chip talk while connected to the RPi?
I dont think so. It would just garble the SPI communication but they are both 3.3v.
Did you try an ISP programmer to check that works?
Do you have to overwrite the bootloader I put on them or .. what's the purpose?
Well, it's a prototype I'm building and testing using Moteinos. I wanted to test burning the bootloader, since the Pi would be preparing it in the final board's chip. But none of the supported methods work. Not the linuxspi mode, not the GPIO bitbanging mode. Something's off.
I never tried ISP via Pi so ... not sure what to suggest :-\
I only used ISP programmers before.
I found the mistake. As usual, it was a very small but stupid overlook... I tied the GPIO line used for reset to the serial header's reset pin, but that's connected to the ATMega's reset line through a capacitor. It's good for general programming use but definitely not for ISP programming. So I changed the connection to the RST pin of the moteino and now it just works.