mharizanov / RFM2Pi

RFM12B to Raspberry Pi board
39 stars 52 forks source link

Update RF12_Demo_atmega328.cpp.hex #9

Closed Bra1nK closed 10 years ago

Bra1nK commented 10 years ago

Updated precompiled hex file to go with updated source (ino) file

glynhudson commented 10 years ago

I've just done the same, compiling the hex file myself including your update. I'll go with using my file for now. Let me know if you notice any difference. Is there a way to compare file size on github?

Bra1nK commented 10 years ago

That's fine I'm happy to go with yours, they're liable to be different anyway judging by Jérôme's experience. Maybe different compiler or library versions ? It's no good asking me about github, I'm very much a noob with it, I just about manage to do pull requests :)

lafrech commented 10 years ago

Hi guys.

Talking about my problems, I tried to compile again today. I realize I forgot to mention something that might be relevant.

When I compile, I get the following error:

RF12_Demo_atmega328.ino:72:18: error: variable ‘helpText1’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

This is an easy fix.

- char helpText1[] PROGMEM = 
+ const char helpText1[] PROGMEM = 

But if you don't have this error, I guess you must be using another compiler, or other compiling options...

My arduino version is 2:1.0.5+dfsg2-3. Which version are you using ?

By the way, I use master latest version of the Jeelink lib.

Bra1nK commented 10 years ago

I'm on windows and using Arduino 1.0.5 and a recent version of Jeelib (NOT Jeelink), I don't get any compilation errors that I'm aware of.

lafrech commented 10 years ago

Hmmm, I meant this Jeelib.

lafrech commented 10 years ago

My compilation command line is

/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=8000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/home/jerome/projets/arduino/hardware/RFM2Pi_v2/cores/arduino -I/home/jerome/projets/arduino/hardware/RFM2Pi_v2/variants/standard -I/home/jerome/projets/arduino/libraries/jeelib /tmp/build2563865855454426416.tmp/RF12_Demo_atmega328.cpp -o /tmp/build2563865855454426416.tmp/RF12_Demo_atmega328.cpp.o 

And my avr-g++ version is 1:4.8-2.1.

Bra1nK commented 10 years ago

The Jeelib version I'm using was downloaded in December so not as recent as I thought but this may not be relevant. I would focus in on why you're getting a compilation error but you probably need someone using Debian to compare against.

Bra1nK commented 10 years ago

and looking at the Arduino compilation window it would appear mine is C:\Program Files\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=8000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -IC:\Program Files\Arduino\hardware\arduino\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\variants\standard -IH:\My Documents\Arduino\Sketches\libraries\JeeLib G:\temp\build3316566372854033780.tmp\RF12_Demo_atmega328_dev.cpp -o G:\temp\build3316566372854033780.tmp\RF12_Demo_atmega328_dev.cpp.o

Bra1nK commented 10 years ago

I'm thinking the problem may be something to do with avr/pgmspace.h but that's just a wild guess based on your compilation error

Bra1nK commented 10 years ago

This may (or may not) be relevant http://arduino.cc/en/Reference/PROGMEM

glynhudson commented 10 years ago

Compiled and worked fine for me. Feel free to use my previous compiled hex. Couple of things. I compiled using modified opti boot bootloader for 8mhz oscillator http://wiki.openenergymonitor.org/index.php?title=RFM12Pi_V2#Modified_OptiBoot_Bootloader and I had to use the 'old' per rfm69 jeelib, it's a tagged download. Info here http://openenergymonitor.org/emon/node/3850. My pre compiled hex should upload fine direct on the pi following http://wiki.openenergymonitor.org/index.php?title=RFM12Pi_V2#Upgrading_RFM12Pi_Firmware_Direct_from_the_Pi

lafrech commented 10 years ago

I'm thinking the problem may be something to do with avr/pgmspace.h but that's just a wild guess based on your compilation error

And the difference between our compilation commands is -DPROG_TYPES_COMPAT

In jeelib/RF69_avr.h,

// prog_uint8_t appears to be deprecated in avr libc, this resolves it for now
#define __PROG_TYPES_COMPAT__
#include <avr/pgmspace.h>

In jeelib, I did

git checkout v11

and I don't have RF69_avr.h anymore, but I still have the -DPROG_TYPES_COMPAT in the command line, and the compilation error.

This is interesting, but I don't think it is the rootcause of my problems anyway.

Glyn, the reason I'm trying to rebuild it in the first place is that I'd like to modify it. That's why I'm not looking for the build but for the method.

There's still dodgy stuff I'd like to figure out. My post here seems to indicate that the hex I compiled corresponds to the code in some aspect more than the distributed hex.

It is possible that my compilation error is due to that flag being passed, which would be due to my compilation environment. It is also quite likely that adding const would not hurt, and perhaps would improve the build for anyone (although I don't think we seek performance so greedily).

That aside, maybe my real problems come from the issues Glyn is talking about in his post. I should check this by compiling against Jeelib v11 (done, after adding const in said line) and testing.

To be continued...

Thank you for your answers.

lafrech commented 10 years ago

I couldn't help it...

Test -> OK.

I suppose my problems came from Jeelib version too recent.

Maybe this would deserve a note in the wiki (last time I checked I didn't have access), or let the wiki point to the doc you're talking about when saying

Thanks for letting us know, I've added git checkout v11 to the documentaion

Well, good news. This means I should be able to modify the bitrate and solve my range issue, hopefully.

Let's call it a day. We'll see this later on.

Thanks, guys.

lafrech commented 10 years ago

And perhaps also a note in the readme here ? A complete note or a link.

And should I send a pull request about the "const" ? Do you mind trying that when you get the time ? I'm afraid this issue is bound to reappear and I don't think it'd hurt to add it anyway.

glynhudson commented 10 years ago

Good to hear that you have made progress. Yes, we should add this info to the readme / wiki.

What's the const issue?

-sent from my mobile device On 14 Apr 2014 23:55, "Jérôme Lafréchoux" notifications@github.com wrote:

And perhaps also a note in the readme here ? A complete note or a link.

And should I send a pull request about the "const" ? Do you mind trying that when you get the time ? I'm afraid this issue is bound to reappear and I don't think it'd hurt to add it anyway.

— Reply to this email directly or view it on GitHubhttps://github.com/mharizanov/RFM2Pi/pull/9#issuecomment-40428058 .

lafrech commented 10 years ago

Well I didn't dig into the details, but basically, in this line:

char helpText1[] PROGMEM = 

The PROGMEM keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "put this information into flash memory", instead of into SRAM, where it would normally go.

Apparently, this part of memory is read-only, and the compiler expects the variable to be explicitely declared as const, which makes sense in this specific case.

I guess former versions of gcc-avr didn't check this, or perhaps put the code somewhere else, in a RW area.

We could try to understand that better, but if helpText1 is guaranteed not to change, why not tell the compiler and let it think for us ?

Bra1nK commented 10 years ago

"I suppose my problems came from Jeelib version too recent."

Does this impact on using the RM69 on the RFM12Pi (RM69Pi ??) as that would be a useful upgrade ?

glynhudson commented 10 years ago

To use the RFM69 on the RFM12Pi the latest JeeLib would need to be used. I think we should make a fork of the RFM12Pi code for thee RFM69 as there might need to be other changes, I don't think the one version of the firmware will work for both. I would be keen to hear how you get on using the RFM69 on the RFM12Pi. Let me know..

On 15 April 2014 08:58, Brian Kelly notifications@github.com wrote:

"I suppose my problems came from Jeelib version too recent."

Does this impact on using the RM69 on the RFM12Pi (RM69Pi ??) as that would be a useful upgrade ?

— Reply to this email directly or view it on GitHubhttps://github.com/mharizanov/RFM2Pi/pull/9#issuecomment-40454940 .

Glyn Hudson

Home: +44(0)1286479462 Mobile: +44(0)7769871550 Office: +44(0)1248672607

http://openenergymonitor.org http://megni.co.uk http://adventuresplusnorthwales.blogspot.com

Bra1nK commented 10 years ago

I agree with that, however it may be some time before I get round to trying the RFM69Pi as I tend to do that kind of stuff during the winter months, summer is for fishing :)