LowPowerLab Forum

Hardware support => Moteino => Topic started by: Hermann on July 06, 2014, 12:52:20 PM

Title: Wireless programming - no reboot
Post by: Hermann on July 06, 2014, 12:52:20 PM
Hi guys,
I am trying to get the wireless programming part to run but I am having a little problem:

I am using an self-made R4 board with a Microchip SST25VF040B-50-4C-S2AF flash chip (ID: BF25).
The chip works ok. I can read and write data. The wireless upload works too. All the data is transfered without problems. At the end the serial console says: Rebooting..... but nothing happens. Even when I enter "r" in the console it says again rebooting but again - nothing. The content of the flash is not deleted.
I am uploading the standard blink sketch. I generated the hex file from the Arduino IDE. In the picture you can see the first two lines of the hex file and the information from the upload. Here is a dump of the flash:

FF.FF.FF.FF.FF.FF.FF.4.3C.3A.
C.94.61.0.C.94.7E.0.C.94.7E.0.C.94.7E.0.
C.94.7E.0.C.94.7E.0.C.94.7E.0.C.94.7E.0.
C.94.7E.0.C.94.7E.0.C.94.7E.0.C.94.7E.0.
C.94.7E.0.C.94.7E.0.C.94.7E.0.C.94.7E.0.
C.94.9D.0.C.94.7E.0.C.94.7E.0.C.94.7E.0.
C.94.7E.0.C.94.7E.0.C.94.7E.0.C.94.7E.0.
C.94.7E.0.C.94.7E.0.0.0.0.0.24.0.27.0.
2A.0.0.0.0.0.25.0.28.0.2B.0.0.0.0.0.
23.0.26.0.29.0.4.4.4.4.4.4.4.4.2.2.
2.2.2.2.3.3.3.3.3.3.1.2.4.8.10.20.
40.80.1.2.4.8.10.20.1.2.4.8.10.20.0.0.
0.7.0.2.1.0.0.3.4.6.0.0.0.0.0.0.
0.0.11.24.1F.BE.CF.EF.D8.E0.DE.BF.CD.BF.11.E0.
A0.E0.B1.E0.EA.E3.F4.E0.2.C0.5.90.D.92.A2.30.
B1.7.D9.F7.11.E0.A2.E0.B1.E0.1.C0.1D.92.AB.30.
B1.7.E1.F7.E.94.C.

Does this look ok?

Can this be connected to the problem I had with the bootloader?
https://lowpowerlab.com/forum/index.php/topic,442.msg2490.html#msg2490

Any help would be appreciated.
Title: Re: Wireless programming - no reboot
Post by: Felix on July 07, 2014, 08:50:17 AM
Dualoptiboot will check if there was a watchdog reset, in which case it will look for an external hex image on the FLASH chip.
Sounds like everything is working except the watchdog reset.
Can you just try a simple sketch where you call this function, it should reset your Moteino:

/// Use watchdog to reset
void resetUsingWatchdog(boolean DEBUG)
{
  //wdt_disable();
  if (DEBUG) Serial.print("REBOOTING");
  wdt_enable(WDTO_15MS);
  while(1) if (DEBUG) Serial.print('.');
}
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 07, 2014, 09:50:06 PM
Hi Felix,

this works.
Here is what I did:
#include <avr/wdt.h>

#define SERIAL_BAUD 115200
#define LED         9

void setup(){
  pinMode(LED, OUTPUT);
  Serial.begin(SERIAL_BAUD);
  Serial.println("Start node...");
  digitalWrite(LED, HIGH);
  delay(5000);
}

void loop(){
  resetUsingWatchdog(true);
}

/// Use watchdog to reset
void resetUsingWatchdog(boolean DEBUG)
{
  //wdt_disable();
  if (DEBUG) Serial.println("REBOOTING");
  wdt_enable(WDTO_15MS);
  while(1) if (DEBUG) Serial.print('.');
}


Every 5 seconds it says "Start node..." and then "REBOOTING... <lots of dots>". So it seems like the reboot sequence itself works.
It actually says that too when I send the sketch:


Start node...SPI Flash Init OK!
Got [1:4] > 464C583F
FLX?OK (ACK sent)
radio [22] > 464c583a303a0c9461000c947e000c947e000c947e00
FLX:0:OK
radio [22] > 464c583a313a0c947e000c947e000c947e000c947e00
FLX:1:OK
..................................
FLX:66:OK
radio [17] > 464c583a36373a0e940000f9cff894ffcf
FLX:67:OK
radio [9] > 464c583a36383a0900
FLX:68:OK
FLX?OK
FLASH IMG TRANSMISSION SUCCESS!
REBOOTING...............<.....>.........þStart node...SPI Flash Init OK!


So I think it reboots but for whatever reason it does not recognize that there is a sketch in the flash.
Title: Re: Wireless programming - no reboot
Post by: Felix on July 08, 2014, 08:26:00 AM
Have you reflashed the bootloader?
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 08, 2014, 08:38:59 AM
Nope. Not yet. I can do it this evening when I get home.
Title: Re: Wireless programming - no reboot
Post by: Felix on July 08, 2014, 08:56:45 AM
I guess I was asking whether you're running the original bootloader (DualOptiboot).
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 08, 2014, 09:54:13 AM
Yes. It is the DualOptiboot that I loaded after I solved this problem:
https://lowpowerlab.com/forum/index.php/topic,442.msg2490.html#msg2490
Title: Re: Wireless programming - no reboot
Post by: Felix on July 08, 2014, 11:26:48 AM
Do you have another "virgin" Moteino to try with?
It's very hard to guess why it's not doing the right thing, especially if you reflashed it.
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 08, 2014, 11:33:25 AM
Felix, I do not have any of your original Moteinos. I made them all myself because I needed a small change in the board design.
I will try to flash one with your original DualOptiboot hex file and try it again.
Title: Re: Wireless programming - no reboot
Post by: Felix on July 08, 2014, 12:09:20 PM
ook :)
That could explain a few things :)
BTW make sure to set the fuses as I did too.
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 08, 2014, 12:17:36 PM
Can you please tell me what your fuse settings are?
The last time I found it out myself so I am not sure if they are same as yours.
Title: Re: Wireless programming - no reboot
Post by: Felix on July 08, 2014, 12:38:50 PM
pls see diagrams www.lowpowerlab.com/moteino
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 08, 2014, 12:51:08 PM
Now I see it! The picture is so small that I did not see it immediately.
It seems that I have indeed different fuse settings.
I will try it when I get home and report back.

Thanks!
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 08, 2014, 08:06:24 PM
Now it' getting interesting:
With the fuse settings from your page: (ext: 0xFD high: 0xDC low: 0xDE) avrdude crashes the moment I hit "Install bootloader" in the Arduino IDE.  This is all it says:

Arduino: 1.0.5-r2 (Windows 7), Board: "Moteino Wireless Node"
E:\Atmel\Arduino\arduino-1.0.5-r2\hardware/tools/avr/bin/avrdude -CE:\Atmel\Arduino\arduino-1.0.5-r2\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDC:m -Ulfuse:w:0xDE:m

And this is what I put in the boards.txt:

moteinown.name=Moteino Wireless Node
moteinown.upload.protocol=arduino
moteinown.upload.maximum_size=31744
moteinown.upload.speed=115200
moteinown.bootloader.low_fuses=0xDE
moteinown.bootloader.high_fuses=0xDC
moteinown.bootloader.extended_fuses=0xFD
moteinown.bootloader.path=doptiboot_moteino_node
moteinown.bootloader.file=DualOtiboot_atmega328.hex
moteinown.bootloader.unlock_bits=0x3F
moteinown.bootloader.lock_bits=0x0F
moteinown.build.mcu=atmega328p
moteinown.build.f_cpu=16000000L
moteinow.build.core=arduino
moteinown.build.variant=standard


I can still install my "old" Moteino bootloader and the original Arduino bootloader but not the DualOtiboot_atmega328_1k_d9LED_debugOFF.hex
Title: Re: Wireless programming - no reboot
Post by: Felix on July 09, 2014, 08:17:14 AM
Did you use an AVR programmer or another Arduino as ISP programmer?
You should not have to mess with the boards file. Unless you are using avrdude to do the burning i suppose. I use an AVR ISP MKii.
I don't know mate ... it's a mistery :)
Title: Re: Wireless programming - no reboot
Post by: Hermann on July 09, 2014, 08:41:58 AM
I always used an USBasp programmer and the Arduino IDE to burn bootloaders.
I can try to use an Arduino as a programmer. I'll do some more testing and report back.
Title: Re: Wireless programming - no reboot
Post by: gpi on September 12, 2014, 10:38:49 AM
Hello
I had the same idea ... and the same problems ;°)) (Flash W25X40BV instead of W25X40CL the difference is on the lower supply voltage on ..CL release.)
I wanted to test the functionality of the wireless programming.

The fuses are in the Moteino ex=0xFD  low=0xDE  high=0xDC
My config file board.txt in EDI Arduino is as follows

moteinow.name=Moteino Wireless
moteinow.upload.protocol=arduino
moteinow.upload.maximum_size=31744
moteinow.upload.speed=115200
moteinow.bootloader.low_fuses=0xDE
moteinow.bootloader.high_fuses=0xDC
moteinow.bootloader.extended_fuses=0x05
moteinow.bootloader.path=DualOptiboot
moteinow.bootloader.file=DualOptiboot_V5.0_atmega328_BlinkD9.hex
moteinow.bootloader.unlock_bits=0x3F
moteinow.bootloader.lock_bits=0x0F
moteinow.build.mcu=atmega328p
moteinow.build.f_cpu=16000000L
moteinow.build.core=arduino
moteinow.build.variant=standard


Explanation of the difference ex = 0xFD on STK500 and ex = 0x05 on AVRDUDE => http://www.engbedded.com/fusecalc/
0xFD! = 0x05

the USBASP works fine. The messages "avrdude: warning:. Can not set sck period please check for usbasp firmware update." are not disturbing. It is not necessary to update the USBASP. My firmware version is 1.2.4.0

How to find the firmware version of USBASP? => http://forum.arduino.cc/index.php?PHPSESSID=lsnri596667kkjrqttep3mvd37&topic=153036.0

The transfer is done under windows seven with python27. Everything was going well but the flash dump was corrupt: 7 bytes to 0xFF (look at the picture attached). So to reboot, nothing changed.
To avoid the reboot and see the dump, you have to comment out the "resetUsingWatchdog (DEBUG)" line of the void "CheckForWirelessHEX" in the library WirelessHex.cpp

I made numerous attempts to find a logical connection that would lead to the problem. The phenomenon was not repetitive. Having already been the case with the wired RF12M Module "in the air", I added a capacity of 100 nF on the flash (pin 3 and 4). It was therefore a problem of filtering seen the extent of the wiring.

Attached file versions that I transferred, by varying the length of BLINKPERIODE

In conclusion, this is a fantastic work that has been done by the author of Moteino. I strongly advise buying the original module if you want to save time. In addition the price difference between a DIY Version / original remains low.

Thank you to the author and Hermann, for helping me through other post:
https://lowpowerlab.com/forum/index.php/topic,442.msg2490.html#msg2490
https://lowpowerlab.com/forum/index.php/topic,279.0.html




Title: Re: Wireless programming - no reboot
Post by: Felix on September 12, 2014, 11:18:53 AM
Hey gpi - thank you for sharing your experience and feedback, much appreciated.