Latest SDK causes IllegalInstruction exception

BuddyCasino
Posts: 262
Joined: Sun Jun 19, 2016 12:00 am

Latest SDK causes IllegalInstruction exception

Postby BuddyCasino » Fri Jan 13, 2017 2:35 pm

I just updated everything from 1.0 to master, fixed compile errors and got an exception when re-flashing.

SDK git commit: ca9f62ad77db58c2b4813981632d17ef2101add9
Toolchain: gcc version 5.2.0 (crosstool-NG crosstool-ng-1.22.0-61-gab8375a)

This is the boot log:

Code: Select all

Rebooting...
ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0008,len:8
load:0x3fff0010,len:2276
load:0x40078000,len:6344
load:0x40080000,len:252
entry 0x40080034
I (891) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (891) heap_alloc_caps: At 3FFBA248 len 00025DB8 (151 KiB): DRAM
I (901) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM
I (922) heap_alloc_caps: At 4009C650 len 000039B0 (14 KiB): IRAM
check b=0x3ffba254 size=155040 ok
check b=0x3ffdfff4 size=0 ok
check b=0x3ffe800c size=98280 ok
check b=0x3ffffff4 size=0 ok
check b=0x4009c65c size=14744 ok
I (986) cpu_start: Pro cpu up.
I (998) cpu_start: Starting app cpu, entry point is 0x40080bd4
I (0) cpu_start: App cpu up.
I (1029) cpu_start: Pro cpu start user code
Guru Meditation Error of type IllegalInstruction occurred on core  0. Exception was unhandled.
Register dump:
PC      : 0x400ff5b6
PS      : 0x00060330
A0      : 0x80081c38
A1      : 0x3ffe3af0
A2      : 0x3ffbb630
A3      : 0x40081894
A4      : 0x00000000
A5      : 0x00000000
A6      : 0x3f4014f4
A7      : 0x3f4014f4
A8      : 0x800ff5b4
A9      : 0x3ffe3ad0
A10     : 0x00000214
A11     : 0x00000214
A12     : 0x00000000
A13     : 0x00000000
A14     : 0x1a2b3c4d
A15     : 0x0000002c
SAR     : 0x00000000
EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000
LBEG    : 0x40001699
LEND    : 0x400016aa
LCOUNT  : 0xfffffffd

Backtrace: 0x400ff5b6:0x3ffe3af0 0x40081c38:0x3ffe3b10 0x400ff1c0:0x3ffe3b60 0x400ff3f1:0x3ffe3bc0 0x400fe1fc:0x3ffe3c20 0x400fe0d4:0x3ffe3c70 0x400fe11e:0x3ffe3c90 0x40080add:0x3ffe3cc0 0x40080d0b:0x3ffe3cf0 0x400787d6:0x3ffe3d10 0x400800f9:0x3ffe3e70 0x40007c34:0x3ffe3eb0 0x40000740:0x3ffe3f20

Rebooting...

Disassembly hints at a problem in the spi_flash_guard_start() function:

Code: Select all

static inline void spi_flash_guard_start()
{
400ff5a4:	004136        	entry	a1, 32
    if (s_flash_guard_ops)
400ff5a7:	449881        	l32r	a8, 400d0808 <_stext+0x7f0>
400ff5aa:	0888      	l32i.n	a8, a8, 0
400ff5ac:	488c      	beqz.n	a8, 400ff5b4 <spi_flash_guard_start+0x10>
        s_flash_guard_ops->start();
400ff5ae:	002882        	l32i	a8, a8, 0
400ff5b1:	0008e0        	callx8	a8
400ff5b4:	f01d      	retw.n
	...

400ff5b8 <spi_flash_guard_end>:
}
I have no idea what to do. Can I prevent the function from being called by some menuconfig settings?

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

Re: Latest SDK causes IllegalInstruction exception

Postby kolban » Fri Jan 13, 2017 2:48 pm

Howdy BuddyCasino,
I upgraded to the latest and greatest and the end of my evening last night including bringing in the latest toolchain. I sniff tested rebuilds of some of my apps and so far so good ... no obvious issues. This makes me think that there might be something going on in your application logic. Can you try and compile and run a minimal ESP-IDF application such as the template app. Does that compile and run cleanly for you? If it does, then I'd suggest starting to put debug statements into your code to find the offending statement that was last executed that throws the exception.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

BuddyCasino
Posts: 262
Joined: Sun Jun 19, 2016 12:00 am

Re: Latest SDK causes IllegalInstruction exception

Postby BuddyCasino » Fri Jan 13, 2017 2:52 pm

Thats a good idea, will do that. Maybe I was too quick to assume that an "IllegalInstruction" exception usually hints at a problem in the sdk/toolchain.

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

Re: Latest SDK causes IllegalInstruction exception

Postby WiFive » Fri Jan 13, 2017 2:59 pm

spi_flash_guard_start/end not in iram? They are inline and only called from iram functions but looks like flash address.
Last edited by WiFive on Fri Jan 13, 2017 3:34 pm, edited 1 time in total.

BuddyCasino
Posts: 262
Joined: Sun Jun 19, 2016 12:00 am

Re: Latest SDK causes IllegalInstruction exception

Postby BuddyCasino » Fri Jan 13, 2017 3:29 pm

So I've changed nearly all menuconfig parameters to their default values, this made the error go away. The exception was thrown shortly before executing any user code, it seems there was a problem with some flash init routine.

I don't think any of the original config values were erroneous, I'll try to find the culprit. Thanks for the replies so far!

Who is online

Users browsing this forum: No registered users and 4 guests