Crash on upload by including <SPI.h>

RogerClark
Wed Sep 09, 2015 10:53 am
Guys,

I’ve discovered a bug that seems to crash the Generic F103C (and I suspect the Maple mini as well, but I’ve not tested it yet)

If you upload an run this, using the bootloader, then upload again, the board will hang just after it gets the reset sequence via Serial USB

[code
#include <SPI.h>
void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
[/code]

Basically including SPI seems to cause it to crash, yet if you have a full sketch like the ILI9341 graphics test it doesn’t crash when you upload a new version.

BTW. This is a stripped down example, I initially had this

#include <SPI.h>
void setup()
{
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);

unsigned char c;
while (1)
{
Serial.println(SPI.transfer(c++));
delay(100);
}
SPI.end();

}

void loop() {
// put your main code here, to run repeatedly:

}


madias
Wed Sep 09, 2015 11:02 am
could you insert a
Serial.begin(9600);
delay(100);

RogerClark
Wed Sep 09, 2015 11:09 am
#include <SPI.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(100);
}

void loop() {
// put your main code here, to run repeatedly:

}


madias
Wed Sep 09, 2015 11:13 am
…could it be a problem caused by the new class?
so a
SPIClass SPI_1(1);

RogerClark
Wed Sep 09, 2015 11:16 am
Hi Matthias

This problem may have been in the code for some time. I tested a real sketch and its OK, its just this minimal sketch that fails

However I don’t have time to debug it at the moment. I may have time tomorrow.

But I dont think its an urgent problem as it only occurs when its not a full sketch


madias
Wed Sep 09, 2015 11:21 am
Yes, but we must keep in mind that problem (maybe this occurs with other code than the minimal also!), so I opened an issue on github as reminder

RogerClark
Wed Sep 09, 2015 12:12 pm
thanks

stevestrong
Tue Jun 20, 2017 7:15 pm
[RogerClark – Wed Sep 09, 2015 11:09 am] –
#include <SPI.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(100);
}

void loop() {
// put your main code here, to run repeatedly:

}


RogerClark
Tue Jun 20, 2017 10:19 pm
There is the ERROR_LED config in boards.txt, which was discussed in another thread a few days ago.

victor_pv
Mon Jul 03, 2017 11:05 pm
[stevestrong – Tue Jun 20, 2017 7:15 pm] –

[RogerClark – Wed Sep 09, 2015 11:09 am] –
#include <SPI.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(100);
}

void loop() {
// put your main code here, to run repeatedly:

}


RogerClark
Tue Jul 04, 2017 1:08 am
There is an open issue about the inclusion of SPI.h into a blank sketch seemed to cause a crash

This sounds similar


Leave a Reply

Your email address will not be published. Required fields are marked *