Hi,
I have read on OpenEnergyMonitor Wiki that it is possible to flash RFM12Pi directly on a Raspberry Pi.
I have everthing installed and I folled the instructions on the Wiki page, but it does not work.
Do I need to connect ISP Pins also to the raspberry Pi GPIO or is this not necessary for flashing?
Best regards,
Christian
Re: Flashing RFM12Pi with Raspberry
No you don't need any additional connections, the rfm2pi is programmed via the serial port. Only if the bootloader is missing or damaged would you need an in-circuit programmer or SPI connection.
See this thread for a recent use of the wiki method, 2 things spring to mind, are you stopping the (correct software) rfm2pi being accessed ? and is the power supply stable enough ?
Paul
Re: Flashing RFM12Pi with Raspberry
Hi Paul,
thank you! When I try to flash RFM12Pi the console outputs the following error message:
root@raspberrypi:/home/pi/RFM2Pi/firmware/Full_RF12demo_atmega328# sudo avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 9600 -U flash:w:Full_RF12demo_atmega328.cpp.hex
avrdude: Version 5.10, compiled on Jun 18 2012 at 12:38:29
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyAMA0
Using Programmer : arduino
Overriding Baud Rate : 9600
avrdude: stk500_recv(): programmer is not responding
avrdude done. Thank you.
root@raspberrypi:/home/pi/RFM2Pi/firmware/Full_RF12demo_atmega328#
What is wrong?
Best regards,
Christian
Re: Flashing RFM12Pi with Raspberry
I switched the programmer to gpio because I work from a raspberry pi.
But no luck until now!
root@raspberrypi:/home/pi/RFM2Pi/firmware/Full_RF12demo_atmega328# sudo avrdude -v -c gpio -p ATMEGA328P -P /dev/ttyAMA0 -b 9600 -U flash:w:Full_RF12demo_atmega328.cpp.hex
avrdude: Version 5.10, compiled on Jun 18 2012 at 12:38:29
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyAMA0
Using Programmer : gpio
Overriding Baud Rate : 9600
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 5 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 : GPIO
Description : Use sysfs interface to bitbang GPIO lines
avrdude: AVR device not responding
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Re: Flashing RFM12Pi with Raspberry
It appears you don't have the needed "avrdude-rpi" part worrking, Any messages from avrdude would be prefixed "avrdude-original" not "avrdude" this shows the original version is being used.
There should also be a message section "using auto-reset .........." which isn't there (see previously linked threads message logs)
The "avrdude-rpi" is a mod to provide a DTR (reset) to rfm2pi on gpio4 by intercepting the avrdude command and providing the DTR whilst running the original avrdude.
Selecting "gpio" as a programmer will attempt to bit bang via the Pi's SPI on the gpio (P1-19,21,23&24) which would require connections to the ISP conn on the rfm2pi,
You need to recheck the wiki guidee, specifically the installing of "rpi-avrdude".
Just use this line until you get a successful read
this will just attempt to read the fuses and check connectivity without attempting and possibly failing tp program the avr, so it minimizes the chance of any damage. Once you are able to read the avr with no errors returned add the "-U flash:w:/path/filename" back to the command line and it should work ok.
Paul
Re: Flashing RFM12Pi with Raspberry
Hi Paul,
thank you for your answer! Very helpful.
I followed exactly the instructions on the wiki page and installed avrdude-rpi but it did not work. I will try it again and post the error message.
The only thing I noticed, after installing avrdude-rpi and doing all the steps written on the wiki page was, that my arduino ide became very very slow when uploading sketches e.g. to Attiny84 (normaly: 20 seconds, after doing the steps on the wiki page it took > 15 minutes!), my CPU level was 100% and the task manager was full of tasks with "reset". So I uninstalled everything again, reinstalled arduino ide and now it is working and fast again.
Best regards,
Christian
Re: Flashing RFM12Pi with Raspberry
I don't think the fuses do get successfully read since we're uploading over serial via the GPIO not ISP. Here's an example of a successful upload:
Re: Flashing RFM12Pi with Raspberry
Hi Glyn,
how can I do an upload using ISP?
Is it possible using raspberry pi? Or do I have to buy an USB/ISP programmer.
On eBay for example there are programmer made in China http://www.ebay.de/itm/USB-ISP-Programmer-For-ATMEL-AVR-51-ATMega-ATTiny...
But which software can I use? On Mac / Windows PC? Or does the programmer also work on my raspberry pi?
Best regards,
Christian
Re: Flashing RFM12Pi with Raspberry
It is possible to use Pi as an ISP, aside from the additional gpio connections, you will also need to solder the header pins on to the rfm2pi and further modify arduino IDE's settings files (board.txt and programmer.txt), it's not straight forward and only really advantageous if you will be doing frequent bootloader uploads or have several permanently connected avr's.
I'm also unsure whether this would definitely resolve your issue as the wiki method is proven to work by many users which may also mean the issue carries over to the ISP method.
Glyn's printout is from a successful "write" using the method from the wiki. My previous suggestion to just "read" still stands, although although as Glyn points out you will not actually see the value of the fuses (see his successful print) it will be quite clear that the "read" was successful as there are no error messages and the "read" progress bar will reach 100% and the fuses will be "read as 0" (as in Glyn's print).
The wiki method is designed for direct use with avrdude from the command line, I would of expected it to be able work with Arduino IDE but haven't tried it myself, however I am aware that the IDE tries to address the serial port in linux as /dev/ttyS0 so a redirect will be needed to /dev/ttyAMA0 (I've seen guides online but not tried any).
With this in mind does the "read" of the rfm2pi work from the command line ?
Once the avrdude-rpi works as intended you could then try to get the IDE to work with it or if that's not possible, change the symlink arrangement in the wiki guide so that the avrdude-rpi mod is only utilized from the avrdude ........ command line by using "avrdude-rpi" instead of "avrdude" , leaving the IDE method unmodified.
If you post some details of the results when using the current wiki method we can help get that part working 1st.
Paul
Re: Flashing RFM12Pi with Raspberry
Yes, as Paul explained the method 'direct from the Pi' as is on the wiki us just a serial upload just the same as Arduino IDE with a standard Arduino. The RFM12Pi already has the Optiboot bootloder in place so flashing a bootloder via ISP is not required if all you want is to upload some new code. I've not done it but using the IDE on the Pi should work. Might need the changes Paul mentions above, or maybe the correct port will be selectable in the IDE..
Re: Flashing RFM12Pi with Raspberry
Hi Paul, Hi Glyn,
ok, thank you both for your detailed descriptions.
I will try to re-install avrdude-rpi and try to get a successful read.
Just a simple (newbie) question: How do I change the symlink back to the "normal" avrdude so that the whole installation process has no effect on my Ardiuno IDE?
Best regards,
Christian
Re: Flashing RFM12Pi with Raspberry
I wouldn't worry about symlinking just yet
step 1 - get IDE and standard avrdude working - done !
step 2 - get avrdude-rpi working from the command line
step 3 - try IDE with "known to be working" avrdude-rpi, if it breaks IDE try and resolve it
step 4 - if unable to get them to play nicely together, try and get around it with symlinks by either
a) symlink serial port address so IDE can be used with avrdude-rpi & rfm2pi
or
b) change symlinks to initiate "avrdude-rpi" from the command line only
I do not know 100% if either will work, I think they should, but it is unchartered territory.
If you do it in controlled steps and test each one when it doesn't work you know when the issue got introduced and can go back a step, If you change from the wiki guided steps and do not know if all parts work correctly independently it makes tackling an issue much harder, you need to know the standard "avrdude-rpi" works from the command line before changing anything.
Re: Flashing RFM12Pi with Raspberry
Just to let you know I have tried this out and can now upload a sketch to an arduino based board (haven't tried rfm2pi yet) from a Pi using the arduino IDE either via a usb attached programmer or directly via the serial UART using gpio4 as a DTR/reset (as per rfm2pi).
I did have to symlink the serial port and also add pi to a couple of groups.
So it is possible to use IDE once you get the "wiki method" sorted.
Paul
Re: Flashing RFM12Pi with Raspberry
Hi Christian
Did you try this again ?
There is another consideration to be made for these to work in harmony, the avrdude-autoreset script should be modified to only kick-in IF the command-line includes a reference to the serial port other wise when using a usb FTDI lead for example the rfm2pi would also get reset, it wouldn't get programmed as the IDE/avrdude would specify a target but I think currently gpio4 would go low regardless of the method used.
I think adding an IF statement around the "strace" in "avrdude-autoreset" to look for the serial ports address would work,
it could also incorporate changing the address used by the IDE eliminating the need for an additional symlink.something like
if command line contains " /dev/ttyS0 "
replace " /dev/ttyS0 " with " /dev/ttyAMA0 "if command line contains " /dev/ttyAMA0 "
sudo strace etc to run autoreset and send gpio4 low for rfm2pi
else
run avrdude-original without autoreset
If I get a chance I will try to write a modified version to try, but thought I would just document this in case I didn't get round to it.
Paul
Re: Flashing RFM12Pi with Raspberry
I have now experienced the extremely long upload times and found it's due to the "autoreset" code being unnecessarily triggered when not using the serial/gpio4. There is a 5 second timeout and the script is triggered multiple times during one upload.
The change I suggest above may also prevent this happening as the "autoreset" should only run if the serial port is defined as the port (-P) in the command line from the IDE to avrdude.
Having pondered on the thought of using an additional IF function instead of a symlink I now realize that won't work as the symlink is required so that the IDE can recognize there is an active port to use before the IDE can send the upload command so I have removed that part from my last post.
Paul
Re: Flashing RFM12Pi with Raspberry
So I had a go at putting this together this afternoon, I have forked the avrdude-rpi repo and added some changes
1. The installation is simpler, the basic "autoreset" mod can be done by just cutting and pasting 5 lines in one go.
2. The "autoreset" only runs when using the Pi's gpio serial port so other upload methods can stiil be used.
3. Includes instruction to symlink /dev/ttyAMA0 used on the Pi in place of the IDE's default /dev/ttyS0
4. The "autoreset confirmation message" now informs user which gpio pin is being used for DTR (reset)
5. Instructions on how to add the "RFM2Pi" board details so "RFM2Pi" can be selected in IDE > boards
6. Instructions on how to add the 8MHz optiboot bootloader files
I haven't tested the bootloader part yet, maybe someone more knowledgeable in this area with a spare rfm2pi kicking around could try it, (mentioning no names, Glyn) :-)
Seems the integration of the "autoreset" and "Normal" Arduino IDE operation works well. no extended delays while uploading and the rfm2pi is no longer reset when using the IDE with a USB/FTDI programmer lead or other programmer.
As well as the RFM2Pi v2's this can be used to program a emonTx over a direct-serial connection by just adding another link between the Pi's P1-7 (gpio4) and the DTR pin of the 6-pin FTDI header on the Tx.
Paul
Re: Flashing RFM12Pi with Raspberry
I'll tag this on here since I've got a (sort of?) related issue.
I've tried the steps in the wiki but the upload falls over. Any tips on troubleshooting this would be appreciated.
This is on my second Pi and I've never tried to use this particular Rfm12Pi board before at all, so I don't know for sure that it's a firmware issue as opposed to a bad board etc.
Re: Flashing RFM12Pi with Raspberry
Figured it out... I had reset the Pi at some point while grappling with this and emonhub had kicked off in the background. Oops!
Re: Flashing RFM12Pi with Raspberry
Just a quick update on the RFM2Pi firmware uploads from a pi.
Using a modified version of rpi-avrdude and the Arduino IDE I have now tested this on a RFM2Pi, Editing and uploading sketches in the normal way on a Pi using windows remote desktop from a PC. This negates the need to compile the hex and use avrdude.
I have just uploaded the latest 38400 baud rf69 firmware by copying and pasting the sketch content directly into a blank ino from git, save and upload, a little slow on a Pi maybe but so much more convenient.
Paul
Re: Flashing RFM12Pi with Raspberry
Hi there,
I just had the same problem as in the 3rd post here, but using the correct avrdude-rpi from pb66 and openenergymonitor.
I've added some code to display exceptions within autoreset (https://github.com/openenergymonitor/avrdude-rpi/pull/1), but I still get errors and have submitted an issue upstream: https://github.com/deanmao/avrdude-rpi/issues/3
This might be related to differences with the RPi B+? I'm running.
The latest emonSD-23-02-15.img.zip
Using the local data recording instructions.
A RPi B+ v1.2.
The RFM12Pi v2.6 extension board
I've had some problems with autobauding with that setup (and can only connect at 9600 baud). https://github.com/deanmao/avrdude-rpi/issues/3#issuecomment-78561531
Re: Flashing RFM12Pi with Raspberry
Hi Jun, The issue in the 3rd post was caused by an error in the symlinking, the wiki guide was a little harder to follow then. If you are using the version from the 'pb66' repo (which is slightly different to the OpenEnergyMonitor version) and have used the commands provided by the repo, the symlinks should be correct, as I use it frequently myself.
I'm unsure if you are still having an issue I have read your posts and issues on openenergymonitor/avrdude-rpi, deanmao/avrdude-rpi, opendroplet/opendroplet-avr, opendroplet/droplet-hub-config and emonhub's git repo as well as here and it's difficult to establish I timeline, so I'm not sure where you're at.
I am aware of an occasional issue with the auto-baud detection in emonHub and I will expand on that a little more on the emonhub repo as it is of no consequence here as emonHub must be stopped before trying to access the serial port with any other software, more so when you are uploading firmware.
I will help if you if I can and will also post some points in the relative threads where I can. If you are still having an issue please post the symptoms specific to your issue (preferably in one place would help),
An incorrect baud speed will ALSO result in a quite common "stk500_recv(): programmer is not responding" but that wasn't the issue in the 3rd post the symlinking issue is evident by the "avrdude" rather than the expected "original-avrdude" preceding that error message in those logs.
Paul