Calling sendto() API in isr causes InstrFetchProhibited.

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Calling sendto() API in isr causes InstrFetchProhibited.

Postby roctwo » Thu Jan 12, 2017 2:40 am

Hi!
Here is my code!

Code: Select all

  static void IRAM_ATTR i2s_isr(void* arg)
{
        I2S0.int_clr.val = I2S0.int_raw.val;
	int prev_buffer=s_cur_buffer;
	s_cur_buffer = !s_cur_buffer;
  	//if (s_isr_count == s_buf_height - 2) {
  	if (s_isr_count == s_buf_height) 	
	{
        sendto(sock,frame_end,SEND_END_LEN,0,(struct sockaddr*)&toAddr,sizeof(toAddr));
    }
	else 
    {
    	++s_isr_count;
    	i2s_fill_buf(s_cur_buffer);
	//	sendto(sock,s_dma_buf[prev_buffer],(LINE_WIDTH_WE_NEED)*sizeof(uint32_t),0,(struct sockaddr*)&toAddr,sizeof(toAddr));
        sendto(sock,image1,(LINE_WIDTH_WE_NEED),0,(struct sockaddr*)&toAddr,sizeof(toAddr));
    }

}
I call API in i2s_isr.Then Exception happens.Log is:
---------------------------------------------------------------------------------------------------------------------------------------
Guru Meditation Error of type InstrFetchProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x00000000 PS : 0x00050133 A0 : 0x00000000 A1 : 0x3ffbfb80
A2 : 0x3ffbfbe0 A3 : 0x3ffbd754 A4 : 0xffffffff A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0xffffffff
A10 : 0x3ffbfbe0 A11 : 0x00000000 A12 : 0x00000000 A13 : 0xffffffff
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x40109aec LEND : 0x3ffbfc64 LCOUNT : 0x3ffbfc10

Backtrace: 0x00000000:0x3ffbfb80 0x00000000:0x3ffbfba0 0x400ed19c:0x3ffbfbe0 0x400ed58d:0x3ffbfc10 0x40109010:0x3ffbfc40 0x401090ad:0x3ffbfc60 0x40108c4d:0x3ffbfc80 0x40108c56:0x3ffbfca0 0x40108e24:0x3ffbfd00 0x40081f61:0x3ffbfd30 0x4008101c:0x3ffbfd50

Rebooting...
-------------------------------------------------------------------------------------------------------------------------------------------
According to my speculation,it is because that sendto API calls internal API,and internal API calls internal API.Sendto function nested too deeply in isr.As a result,program runaway.Is that right. Whether the interrupt function can call sendto functions?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Calling sendto() API in isr causes InstrFetchProhibited.

Postby WiFive » Thu Jan 12, 2017 3:02 am

Not only call depth but relying on code stored in flash which cannot execute because flash cache disabled in isr. Isr should be as fast and simple as possible then yield to a task to do the rest.

Actually seems there is some possibility to execute flash code in isr

Code: Select all

esp_intr_noniram_enable
but not sure of all limitations.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Calling sendto() API in isr causes InstrFetchProhibited.

Postby kolban » Thu Jan 12, 2017 3:40 am

I would say that you are completely correct. The set of activities that you may do within an ISR are curtailed and I would be astonished if attempting to interact with the TCP/IP subsystem were allowed. Normally an ISR is merely a signal were you gain control and should be in and out as quickly as possible. In the ISR you may (for example) place a message on a FreeRTOS queue (and even then using on the the ISR based APIs) such that another FreeRTOS task wakes up to process it.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: No registered users and 133 guests