Electron SPI1 DMA fails in 0.5.1

I use SPI DMA in my SdFat library. DMA transfers now fail in 0.5.1 for Electron SPI1.

Here is a test program that shows the calls I use. This program runs on Photon but has a hard fault on Electron.

#include "application.h"

SYSTEM_MODE(MANUAL);
uint8_t buf[512];

volatile bool spiDone;

void spiCallback() {
  spiDone = true;
}

void setup() {
  Serial.begin(9600);
  SPI1.begin();
}

void loop() {
  spiDone = false;
  Serial.println("read");
  SPI1.transfer(0, buf, sizeof(buf), spiCallback);
  while (!spiDone) {
    delay(1);
  }

  Serial.println("write");
  spiDone = false;

  SPI1.transfer(buf, 0, sizeof(buf), spiCallback);
  while (!spiDone) {
    delay(1);
  }
  Serial.println("done");  
  delay(1000);
}

Can you test on 0.5.3-rc.3 too and open an issue on GitHub if it exists there too?

Currently Particle staff is busy in the background and hence not around the forum very much, but new issues get more attention.

If you haven’t got the time, I could to, but would need to set up an SD test rig, which you already have :wink:

Testing this code, I’ve found that:

  • This code works on a Photon (0.5.2)
  • It causes an SOS fault on the Electron running 0.5.3rc1
  • It causes an SOS fault on the Electron running 0.5.0
  • It works on the Electron running 0.4.8.
3 Likes

Guess who’s just volunteered to open the issue ^@^

That’s the issue opened by @whg - Thanks!

2 Likes

Hi I’m new at all of this but some what savvy I’m also having problems with the SPI interface on my Electron core running 0.4.8. Trying to communicate with a BMP280 using the online BMP280 library. It hangs, does a magenta and reboots. Able to do the following statements

Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
  if (bmp.begin()) {
    Particle.publish("DEBUG", "starting the environment timer...");

It then crashes on this next statement

 Particle.publish("environment/temperature", String(cToF(bmp.readTemperature()))); 

Regards,
Dan

First I'd update the device to 0.6.0.

And next, what kind of crash do you see?
If it's a proper crash, you should see an SOS pattern followed by a number of slower blinks. That number is important to "guess" the reason.

But the magenta bit here would suggest that you are trying to flash a firmware that's not compatible with your system firmware (0.4.8). So back to line 1 :wink:

Another puzzling bit in your first code block ist the lack of context.
Are you declaring bmp() in the same block as you are executing the following if() block?
And what's cToF() for and where is it from?

Yes it’s does a SOS then 1 blink. Will try to install 0.6.0. I was only
able to locate 5.0 binaries on GIT under the directory of Firmware. Is
it located in a different place?
regards,
dan

You can always find a link to the most recent versions in here

and also under

Here is the current default