LowPowerLab Forum

Hardware support => Moteino => Topic started by: sraillard on August 07, 2018, 05:50:02 PM

Title: Transforming a normal Moteino in Moteino 8MHz
Post by: sraillard on August 07, 2018, 05:50:02 PM
I have a bunch of classic Moteino (running at 16MHz using the onboard crystal). I'm now powering them using battery (3v CR123) and I would like to "transform" them in 8MHz so they can run correctly under 3v.

From a hardware point of view, I have already removed the linear regulator from the board and I'm able to manage sleep to limit the consumption to 4.5uA, so this is really fine.

But for the software, I need to change the bootloader and the fuse setup.
I have done some tests using the ArduinoISP sketch, but without any success for now.
Is there an easy way to reprogram the Moteino using the Arduino IDE and another Moteino?
It maybe already documented somewhere, but I didn't find it.

Title: Re: Transforming a normal Moteino in Moteino 8MHz
Post by: TomWS on August 07, 2018, 06:14:17 PM
I use the Sparkfun Pocket AVR programmer (https://www.sparkfun.com/products/9825) which is low cost and has been reliable for me.  I've reprogrammed bootloader and fuses on Moteinos plugged into breadboards, or in the case of soldered in Moteinos, I've hard wired some temporary jumper wires to the ISP pins.  Note that you also need to add pull up resistors on the Radio CS and, if you're using Flash memory, on its CS as well.

You can do this with other ISP programmers as well, I just find this one effective and low cost.

Tom
Title: Re: Transforming a normal Moteino in Moteino 8MHz
Post by: sraillard on August 08, 2018, 05:46:58 PM
Once you have the ISP programmer, can you program the bootloader and the correct fuses from the Arduino IDE?
In the IDE, we can chosse the board "Moteino (8Mhz)" and there is an option called "Burn Bootloader".
Title: Re: Transforming a normal Moteino in Moteino 8MHz
Post by: TomWS on August 08, 2018, 06:19:46 PM
Quote from: sraillard on August 08, 2018, 05:46:58 PM
Once you have the ISP programmer, can you program the bootloader and the correct fuses from the Arduino IDE?
In the IDE, we can chosse the board "Moteino (8Mhz)" and there is an option called "Burn Bootloader".
To  burn fuses and the bootloader I use a command line access to avrdude, rather than the IDE.  I have an inherent distrust in the IDE's low level operations (ie, choice of directories for files, etc) whereas, with the command line I KNOW what files I'm using.

This process is documented in the Sparkfun hookup guide for the programmer I mentioned.  They also talk about using the IDE, but, for this to work, the board files need to be 100% accurate (something that isn't necessarily guaranteed if you've installed board files that aren't current with the whimsical IDE de jour)...

Tom

Title: Re: Transforming a normal Moteino in Moteino 8MHz
Post by: sraillard on January 05, 2019, 05:44:23 AM
I have finally managed to reprogram the original Moteino in Moteino 8MHz.

It wasn't an easy path, so I would to share how I did it.
First, I didn't use the Arduino IDE, as it's mostly a black box.

One issue is the older programmer "AVRISP mkII" from Atmel is discontinued, but the good news is there is a perfect copy of this older programmer made by Waveshare (model "USB AVRISP XPII"):
https://www.waveshare.com/usb-avrisp-xpii.htm (https://www.waveshare.com/usb-avrisp-xpii.htm)
I bought it from Amazon and it's working perfectly.

Once you have the programmer, you need (on Windows) to use the "Zadig" software to force the device in "libusb-win32" mode.

You can download a portable avrduded version for Windows from here:
http://download.savannah.gnu.org/releases/avrdude/ (http://download.savannah.gnu.org/releases/avrdude/)
I have used the "avrdude-6.3-mingw32.zip" file, that is containing the executable plus the configuration file for using the different programmers.

To erase then upload the correct bootloader for the Moteino 8MHZ (with the correct fuse options), this command line is working:
avrdude.exe -C avrdude.conf -p m328p -c avrispmkII -v -e -U flash:w:Dualoptiboot_v5.0_atmega328_8mhz_57600baud_BlinkD9_SPIdisable.hex -U lfuse:w:0xD2:m -U hfuse:w:0xDC:m -U efuse:w:0xFE:m -U lock:w:0xCF:m

I made a breakout board in order to add an ICSP connector (HE10 with 6 pins) and also to provide a pull-up option (10K resistors) for the Chip Select (CS) of the SPI flash and RFM69 module that are installed. Check the attachments if interessed.

Title: Re: Transforming a normal Moteino in Moteino 8MHz
Post by: Felix on January 05, 2019, 07:40:46 PM
sraillard,
Great work, nice to see a good old Moteino R4  :D