opendroplet / droplet-hub-config

Ansible configuration for Open Droplet hub
0 stars 0 forks source link

Use the hub as a wireless programming gateway for the sensor #3

Closed jmatsushita closed 9 years ago

jmatsushita commented 9 years ago

Downloaded https://github.com/LowPowerLab/WirelessProgramming

But it looks like its made for a moteino gateway rather than an onboard RFM12Pi. I'll try to use avrdude with this patch to upload the moteino gateway code on the RFM12Pi - i.e. Open Droplet Hub - Programming Mode. Hope I can then restore the original code to switch back to Open Droplet Hub - Operating Mode.

jmatsushita commented 9 years ago

Following these much more recent instructions instead.

shulter commented 9 years ago

I have a suitable ISP for the RFM12Pi if you can't flash it back to it original state. Pay attention to the fuses, the RFM12pi uses the internal RC oscillator and not an external xtal or resonator, you can easily lock yourself out from reflashing and brick the MCU when you set the fuses to the wrong settings. I guess the Moteino does use an external xtal in contrast to the RFM12pi. F_CPU has to be adjusted too if the Moteino firmware is made for 16000000, because the RFM12pi runs on 8000000.

jmatsushita commented 9 years ago

Good to know, but I'm stuck as described here: https://github.com/deanmao/avrdude-rpi/issues/3#issuecomment-78561531 and here: http://openenergymonitor.org/emon/node/6121 (comment in the moderation queue).

jmatsushita commented 9 years ago

But I don't want to flash the bootloader, can I still brick the RFM12Pi just by uploading the hex of this sketch?

I'll try on a Raspberry Pi B to see if I can make more progress...

shulter commented 9 years ago

Yes go for it, can't brick it if you don't flash the bootloader. Alter the code so it's suitable for the low precision RC oscillator, ie #define SERIAL_BAUD 115200 sure is too high, try 9600 and hardcoded delays might not have the precision. Don't take a built .hex though, you have to build it with against a compiler with the F_CPU 8000000 setting. Without any hacking, that should be possible if you use the Pro Mini 3.3V 8Mhz setting in the Arduino IDE.

jmatsushita commented 9 years ago

Hmmm... I'm getting the same error:

avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 9600 

avrdude-original: Version 5.11.1, compiled on May 23 2012 at 11:08:25
                  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-original: Using autoreset DTR on GPIO 4
avrdude-original: stk500_getsync(): not in sync: resp=0x61

Could it be the RFM12Pi ? It is acting weird (it does receive but only on 9600 baud) https://github.com/emonhub/emonhub/issues/135#issuecomment-78467390

jmatsushita commented 9 years ago

Ok cool, thanks for the tip. Got to be able to program that RFM12Pi though...

shulter commented 9 years ago

The bootloader starts with the UART synced to a hard 38400, only the actual program in the lower flash range is synced to a hard 9600, hence the difference.

pb66 commented 9 years ago

"""

Hmmm... I'm getting the same error:

avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 9600

avrdude-original: Version 5.11.1, compiled on May 23 2012 at 11:08:25 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-original: Using autoreset DTR on GPIO 4 avrdude-original: stk500_getsync(): not in sync: resp=0x61 Could it be the RFM12Pi ? It is acting weird (it does receive but only on 9600 baud) emonhub/emonhub#135 (comment)

""" Where did you find that commandline? The bootloader is hardcoded at 38400, when uploading to an rfm2pi the baud of 38400 is always used. The serial baud for ongoing communication can be set within the sketch. up to ~ late 2014 they were all 9600, then a few prototype "rfm69" rfm2pi's @ 57600 and since then the "common" baud is 38400. The rfm2pi doesn't receive at "9600" it passes recieved data out via the serial port at the baud defined in the sketch (9600 for rrm12 & 38400 rfm69 compat).

Use the command line

avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400

and ensure emonHub and all other serial accessing softwares are stopped before uploading.

Paul

shulter commented 9 years ago

This issue was resolved