-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hspi in slave mode with Wifi enabled produce crash dump #5914
Comments
Is that correct? Or are you using 2.5.0? |
try the examples of the SPISlave library |
@JAndrassy I have used the example of the SPISLave and add the WiFi.mode(WIFI_STA) and the WiFi.begin(). When adding this, sometime you get crash dump and sometime spi status values are not correct. @devyte Yes we have use both in our test, git latest and 2.5.0. Both have the same behaviour. |
and what is the |
@JAndrassy I updated the Master sketch to add the MasterSafe object |
Check the timing of the SPI bus. The SPISlave library has bad timing on MOSI. About the crashes - do you have stable enough power supply? |
@JiriBilek Yes we have a Laboratory power supply. Not a problem here. I'm looking into the timing right now. Maybe this is related. |
Here the decoded crash dump. From what I understand, the WiFi library is reading information from Flash while an ISR of the HSPI is comming. This look like the problem. I'm not really familiar with the tensila MCU to know why this is causing the crash. But maybe related with Caching system of the MCU.
|
Every function that is called from an interrupt has to be declared ICACHE_RAM_ATTR. |
@JiriBilek You right. The crash is caused by the non RAM function. The first one is the operator() I think. The use of the std::function is not the right choice. We have modified the code to use directly the hspi_slave_onStatusSent() and pass our RAM function to test and we don't have any crash dump. So I'm pretty sure this is the main problem. here the code that don't crash dump. void ICACHE_RAM_ATTR SPI_ON_STATUSSENT_CB(void*){
}
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
SPISlave.begin();
hspi_slave_onStatusSent(SPI_ON_STATUSSENT_CB);
SPISlave.setStatus(0x55);
WiFi.mode(WIFI_STA);
WiFi.begin("MySSID","Password");
}
|
CC @hreintke |
@dumarjo can you please provide the MCVE sketch that reproduces the crash, and a detailed explanation on the change you described which you say fixes it? |
@devyte both sketch are in the First post. The new code that bypass the std::function is in that post #5914 (comment) What else do you need ? I can put more information but I think all is there. From what I understand, all the callback called from the _hspi_slave_isr_handler are stored in a std::function. Since the std::function::operator() is use to dereference the underline function and the std::function::operator is not in RAM buy in Flash, cause the issue. I'm not very familiar with the esp8266 so I just think from the core dump, that 0x402xxxx is in flash section and 0x401 is in RAM section. If I remove the std::function callbacks and using only fonction stored in RAM, like in #5914 (comment) I never seen a crash since. Let me know if you need more information. |
I hadn't seen the edit to the first post. And I now also understand what you meant by code change: you meant just change the slave sketch. Notes:
|
@devyte One way to put the operator() in ram is to modify the linker script to put that specitic section into RAM instead of the Flash. The other way is instead of storing the function into an std::function is to use a plain function pointer. This has the draw back to not be able to use lambda with capture, lambda without capture will work. If this is OK, could be a simple fix. |
@dumarjo, that's what we were discussing on the maintainers' channel yesterday. It was a little more complicated than I'd hoped due to GNU ld's limited pattern matching (no negation as far as I could find in MAN and INFO). Please give #5922 a try. It manually places the single |
Basic Infos
Platform
Settings in IDE
Problem Description
Hi all,
We try to get the spi in slave mode working without crash and we cannot get it. We use 2 esp8266 (one in master and one in slave). We use only the read status command to simplify the setup. Here the Master code. We use the Example SPI Safe Master Demo and modify it to only use the readStatus method.
On the slave we use this code.
With this configuration, the data of the status is 0x55 (checked with an MSO) and as soon as the WiFi is connected, the data of the status is 0x00. No more 0x55 is returned.
Does anyone can try the same setup and give feedback ? We have been able to have a reliable communication in SPI mode.
Jonathan
The text was updated successfully, but these errors were encountered: