Example deep sleep sketch Compile Error

Started by DonpK, January 16, 2022, 06:08:00 PM

DonpK

I am getting compile errors using the Moteino M0 Deep Sleep example

Arduino\libraries\SPIFlash\SPIFlash.cpp:84:3: error: 'SPSR' was not declared in this scope
Arduino\libraries\SPIFlash\SPIFlash.cpp:90:11: error: 'SPCR' was not declared in this scope


Suggestions?

Felix

1) Make sure you have the latest library
2) Make sure your compile target is MoteinoM0

DonpK

Here is what is installed:
Boards: (see screenshot image)
Libraries:(see screenshot image)
Compile Target: Moteino M0

I find that some sketches compile and load okay like the Read Vin sketch in the M0 Guide and some of the basic sketches in the Arduino Library like BlinkWithoutDelay.ino and ReadAnalogVoltage.ino. However many other sketches like Deep Sleep Example sketch and other Low Power Sketches as well as sketches using other libraries won't load without always first going into the Bootloader Mode (double Reset).

I looked at the hidden, unused USB Ports in the Device Manager as suggested in another thread. There were about a dozen, a number of those I would guess are other Moteinos and MEGAs that I use.

In a 2018 thread you said,

"Sometimes, depending what your sketch does, if the MCU is busy burning cycles doing other things, it will not respond to the IDE's "hey I have a new sketch for you" call. In these cases you will have to manually reset the board, and put it in bootloader mode by double-tapping the onboard button."

Is the Bootloader mode pretty much the default loading mode?  Hopefully not and I'm just missing something important.

Thanks,
   Don




Felix

If it's a compile issue, having a board plugged in is not needed to compile successfully. With SAMD boards, whenever in doubt and board is not responsive, double tap the reset to put it in a guaranteed responsive state, that's about the biggest thing to keep in mind. With AVRs entering the bootloader was done without any phisical intervention, by the FTDI DTR/RST signal.

It appears I pushed the LowPower library but forgot to publish the 2.2 release, apologies for the confusion and inconvenience. So when you look in the IDE it only shows 2.1 whereas the latest on github was 2.2.
I published 2.2 now, so it should be picked up at some point by the IDE. Manual lib install is always good as well, ensures you have the latest.
Try with 2.2 however you choose to install it. The compile error should go away.

DonpK

I should have been clearer. The main problem is downloading sketches to the M0, not compiling them. Many sketches need the double-reset bootloader method for successful downloading.

I'll install Version 2.2.

Thanks,
    Don

Felix

1st post in this thread:
Quote from: DonpKThe main problem is downloading sketches to the M0, not compiling them.

Previous post:
Quote from: DonpK on January 16, 2022, 06:08:00 PM
I am getting compile errors using the Moteino M0 Deep Sleep example

So which one is it?  ;D

The uploading of sketches to the board is done easily if the board is not sleeping and has an active USB, nothing is frozen or gone haywire, etc. When that's not the case, then double tap is how you get the board into BL mode again and ready for uploads,I mentioned that above. Just ensure you pick new serial port for upload.

DonpK

I'm talking about uploading* a sketch from the IDE to the Moteino M0 board.
Quote
if the board is not sleeping and has an active USB

By active USB are you talking about sketches that are using the IDE's Serial Monitor? What about sketches that use other serial ports?  Could they cause upload problems?

Thanks,
   Don

* I guess I should be using "uploading" not "downloading"  :-[

Felix

#7
USB device on the M0 has to be active and emulating a serial port. Otherwise the reset into bootloader won't happen.
Uploading (it's the IDE terminology, although downloading is sometimes used) is *ALWAYS* happening from the bootloader, it's its sole purpose, a sketch can't overwrite itself.
You can easily lock your board up, just do a memory or buffer overflow. Try uploading at that point ... the M0 is now in lala land, acts dead or may look functional while its actually not, and is unresponsive to any upload attempts  ::)
Especially true if you put the board to sleep (and consequently shut down the majority of devices within the MCU including the USB, now the board is appears to be "dead" because .. it mostly is).
So to do another upload, you have to bring it up in bootloader, double tap RST button.
Literally, it's the 3rd time I said this here in some form so I hope its more clear now, and you quoted it above from the guide btw 8)