Community
OpenEnergyMonitor

Community

RFM12B upgrading

Tags: #<Tag:0x00007f6e0f50e0b8> #<Tag:0x00007f6e0f50de38>

Hello,

I’m have a working system whit remote Log.

Now I am trying to make a Pi working for local Logging. Therefore have a second Pi whit a RFM112B.

I can’t get inputs on the Pi. The led on the RFM12B is not blinking but burns continued.

Therefore I tried to update the RFM12B following next lines.

Upgrading RFM12Pi Firmware Direct from the Pi

Since the Raspberry Pi lacks a DTR pin that makes it oh-so-easy to upload your hex files into the avr, we need this hack to make it just as easy. Thanks to JCW from JeLabs for working this out and Martin Harizanov for implementing it for the RFM12Pi.

$ sudo apt-get update
$ sudo apt-get install arduino
$ sudo apt-get install python-dev&&python-rpi.gpio
$ git clone https://github.com/mharizanov/avrdude-rpi.git
$ cd avrdude-rpi
$ sudo cp autoreset /usr/bin
$ sudo cp avrdude-autoreset /usr/bin
$ sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
$ sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude
$ cd /home/pi
$ git clone https://github.com/openenergymonitor/RFM2Pi
$ cd RFM2Pi/firmware/RF12_Demo_atmega328
$ sudo service emonhub stop
$ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 -U flash:w:RF12_Demo_atmega328.cpp.hex
$ sudo service emonhub start

I find out that the directory “RF12_Demo_ATmega328” in the Image 2017 not exist but is named RFM69CW_RF_Demo_ATmega328

I tried following line;

avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 -U flash:w:RFM69VW_RF_Demo_atmega328.cpp.hex

But this is not working. What I doing wrong?

Regards Frans

1 Like

You cannot use a file compiled for the RFM69CW for a RFM12B.

Are you certain that you have an RFM12B? There are pictures here.

Although the commands you use in the sketch are the same, the code that the library supplies is totally different. If you do have the RFM12B, you must either find and use the older compiled file for the RFM12B, or you must compile the file from the source code yourself, after you have changed the line
#define RF69_COMPAT 1
to
#define RF69_COMPAT 0
This is the switch that tells the library to use the correct instructions for the RFM12B.

When you have uploaded the correct version, you must not update your emonPi using the “emonPi Update” button, you must always use the “emonBase Update” button. This will cause the update of the radio module to fail, which is exactly what you want, otherwise the RFM12B code that you loaded will be overwritten, and you will have to start again.

Hello Robert, Thanks for the replay.

Its become a little complicated for me. I have the RFM12B for sure.
I look for a old image off the emoncms which i could use for the update.
could i find that somwhere?

There are old rfm12 hex files in the rfm2pi repo

RFM2Pi/firmware/old/RF12_Demo_atmega328/ RF12_Demo_atmega328.cpp.hex

RFM2Pi/firmware/RFM69CW_RF_Demo_ATmega328/ RFM12_Demo_ATmega328.cpp.hex

but they might be well out of date, versioning didn’t start until well into the rfm69 fw’s and the repo has been reshuffled so the dates may not indicate the era of the code. These early fw’s were also prone to dropout’s, I re-compiled the rfm12/rfm2pi fw with versioning and using the latest libs in the Feeds stop updating thread on the old forum but the links for all the attachments were all lost in the move to this new forum, it might be found in https://github.com/openenergymonitor/forum-archive/tree/master/sites/default/files but I can’t see anything familiar and only 2/3rds of the list is displayed (github restrictions, need to clone to see the full list), but I will keep an eye open for a local copy too and post it here if I find it.

1 Like

i have now the image 26oct17 loaded. in the directory
RFM2Pi/firmware/old/
i see several files,
Full_RF12demo_atmega328 Pre_compiled_ATtiny84_RF12_Demo_hex RF12_Demo_atmega328 RF1

can i use that

One of the 2 links I already suggested is indeed in that folder

RFM2Pi/firmware/old/RF12_Demo_atmega328/RF12_Demo_atmega328.cpp.hex

til now my problems getting bigger.

the one RFM2B that was stil was working has after a emonBase update now the same problem.

Where can i find the line #define RF69_COMPAT 0

i treit the avrdude command in the directory where the 12_Demo_atmega328.cpp.hex file is. it takes a long time but til now no succes

If you look at Paul’s post nr.3, the second link is

On that page are three files:

  1. Optiboot328_8mhz_RF12_Demo.hex
  2. RF12_Demo_atmega328.cpp.hex
  3. RF12_Demo_atmega328.ino

Nr.3 is the source file - it is only for the RFM12B, it does not need #define RF69_COMPAT 0 (because “0” is the same as not having that line).

I believe the compiled version of that file is nr.2. Is this the file that you tried? If it is not, I suggest you try loading this - file nr.2.

I treid now to update the RFM12b several times, no succes.
The last time become repeated the call

avrdude-original: Using autoreset DTR on GPIO Pin 7

have to find out what thad means

it says also another thing

strace: fork: Cannot allocate memory

[email protected]:/home/pi/RFM2Pi/firmware/old/RF12_Demo_atmega328# avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 -U flash:w:RF12_Demo_atmega328.cpp.hex
strace: fork: Cannot allocate memory
[email protected]:/home/pi/RFM2Pi/firmware/old/RF12_Demo_atmega328# avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO

This is not a fault I’ve come across before, a quick web search suggests it is as the error suggests, out of RAM resources.

What model Pi is this and what other services are you running? is it an emonSD?

Have you tried rebooting the Pi incase there are phantom tasks running cusing a shortage of memory? Or try running top in another ssh window whilst doing the update to see what is using the resources.

I doubt it is the reason, but I have never tried this command as root either, have you tried running it as Pi? Using sudo if required.

It’s not unusual to see multiple “avrdude-original: Using autoreset DTR on GPIO Pin 7” messages so don’t worry too much about that until you get some other activity.

First many thanks for the support.

I have 2 Pi model B and 2 RFM2B with 3 EmonTX

Now I tried a new image on a new Pi3 using all the lines as explain by upgrade

After several hours it says 3 times killed and then there is no further activity

I wonder as it is so easy to corrupt the RFM2B by an update, why it seems so difficult to restore it.

Sorry, I’m not quite sure what you mean there.

Are you saying your rfm2pi works for a while then stops? If so the firmware has been loaded and you have another issue causing it to stop, the fw will not change unless you use the wrong update button or reboot a fresh emonSD (firstboot) with the rfm2pi attached.

That is a very good question, a question worthy of a good answer, but AFAIK there isn’t a good reason, but I have to say that although it isn’t an easy fix, I’m not aware of anyone having the troubles you are seeing.

Are you stopping the emonhub service when trying to upload from the Pi?

I had one Pi completely working for several years with remote logging

Then I start to make the other work for local log. That’s where my problem starts and one RFM2B stopped working. I surely have started a new image with the RFM on board. Did not know that’s a problem.

Sorting out my problem, I put the good RFM12B in the Pi with a new image to see if the input shows up. No success. Then I push the emonBase Update Butten. Since then, my second RFM12B stopped working. The green led is continuously on.

Hello Frans, There is a script on the emonSD image for uploading either RFM12 or RFM69 firmware:

$ /home/pi/RFM2Pi/update-RFM12.sh

or for the RFM69

$ /home/pi/RFM2Pi/update-RFM69.sh
1 Like

cd to where?

here the result;

[email protected]:/home/pi/RFM2Pi/firmware# cd
[email protected]:~# /home/pi/RFM2Pi/update-RFM12.sh
[ ok ] Stopping OpenEnergyMonitor emonHub: emonhub has been stopped ok.
strace: execl: /bin/sh: Cannot allocate memory
ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so' from /etc/ld.so.preload cannot be preloaded: ignored.
/bin/sh: error while loading shared libraries: libc.so.6: failed to map segment from shared object: Cannot allocate memory
[ ok ] Starting OpenEnergyMonitor emonHub: emonhub has been started ok.

Did you try rebooting as @pb66 suggested?

Is your SD card also full by any chance? What do you see if you run:

$ df -h

without doing anything, there came more

[email protected]:~# [ ok ] Starting OpenEnergyMonitor emonHub: emonhub has been started ok.
bash: [: missing `]'
[email protected]:~# avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-orig

by

[email protected]:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          2.6G  2.5G     0 100% /
/dev/root       2.6G  2.5G     0 100% /
devtmpfs        215M     0  215M   0% /dev
tmpfs            44M  240K   44M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            88M     0   88M   0% /run/shm
tmpfs            30M  4.0K   30M   1% /tmp
tmpfs            30M  304K   30M   1% /var/log
/dev/mmcblk0p1   56M  9.5M   47M  17% /boot
/dev/mmcblk0p3  885M   32M  808M   4% /home/pi/data

by the way this is the older image, running remote log