Wireless programming - no reboot

Started by Hermann, July 06, 2014, 12:52:20 PM

Hermann

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.

Felix

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('.');
}

Hermann

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.

Felix


Hermann

Nope. Not yet. I can do it this evening when I get home.

Felix

I guess I was asking whether you're running the original bootloader (DualOptiboot).

Hermann


Felix

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.

Hermann

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.

Felix

ook :)
That could explain a few things :)
BTW make sure to set the fuses as I did too.

Hermann

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.

Felix


Hermann

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!

Hermann

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

Felix

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 :)