IllegalInstruction

LorenzoR
Posts: 2
Joined: Thu May 18, 2017 10:28 am

IllegalInstruction

Postby LorenzoR » Thu May 18, 2017 10:49 am

Hi,
I am successfully compiling and uploading a project through the official esp build system, but something unexpected happens when the app starts:

Code: Select all

I (47) boot: ESP-IDF v2.0-rc1-813-g1ddf40fe-dirty 2nd stage bootloader
I (48) boot: compile time 15:00:05
I (51) boot: Enabling RNG early entropy source...
I (67) boot: SPI Speed      : 40MHz
I (80) boot: SPI Mode       : DIO
I (92) boot: SPI Flash Size : 4MB
I (105) boot: Partition Table:
I (116) boot: ## Label            Usage          Type ST Offset   Length
I (139) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (162) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (185) boot:  2 factory          factory app      00 00 00010000 00100000
I (208) boot: End of partition table
I (221) boot: Disabling RNG early entropy source...
I (239) boot: Loading app partition at offset 00010000
I (919) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512) 
I (920) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x07a7c ( 31356) map
I (936) boot: segment 2: paddr=0x00027a8c vaddr=0x3ffb0000 size=0x02b7c ( 11132) load
I (967) boot: segment 3: paddr=0x0002a610 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _iram_start at ??:?

I (989) boot: segment 4: paddr=0x0002aa18 vaddr=0x40080400 size=0x131e4 ( 78308) load
I (1052) boot: segment 5: paddr=0x0003dc04 vaddr=0x400c0000 size=0x00000 (     0) load
I (1053) boot: segment 6: paddr=0x0003dc0c vaddr=0x00000000 size=0x023fc (  9212) 
I (1073) boot: segment 7: paddr=0x00040010 vaddr=0x400d0018 size=0x33270 (209520) map
0x400d0018: _stext at ??:?

I (1100) boot: segment 8: paddr=0x00073288 vaddr=0x00000000 size=0x0fff0 ( 65520) 
I (1125) boot: segment 9: paddr=0x00083280 vaddr=0x40103288 size=0x008d8 (  2264) map
I (1151) cpu_start: Pro cpu up.
I (1163) cpu_start: Starting app cpu, entry point is 0x40080f84
0x40080f84: call_start_cpu1 at /home/lorenzo/esp-idf/components/esp32/./cpu_start.c:174

I (0) cpu_start: App cpu up.
I (1195) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (1218) heap_alloc_caps: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (1238) heap_alloc_caps: At 3FFB6780 len 00029880 (166 KiB): DRAM
I (1259) heap_alloc_caps: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (1281) heap_alloc_caps: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1302) heap_alloc_caps: At 400935E4 len 0000CA1C (50 KiB): IRAM
I (1323) cpu_start: Pro cpu start user code
Guru Meditation Error of type IllegalInstruction occurred on core  0. Exception was unhandled.
Register dump:
PC      : 0x400f12c9  PS      : 0x00060530  A0      : 0x8008115e  A1      : 0x3ffe3c30  
0x400f12c9: esp_setup_syscall_table at /home/lorenzo/esp-idf/components/newlib/./syscall_table.c:93

A2      : 0x00000037  A3      : 0x80081166  A4      : 0x0000000c  A5      : 0xffffffff  
A6      : 0x00000000  A7      : 0xfffffff6  A8      : 0x80080e81  A9      : 0x3ffe3bb0  
A10     : 0x00000000  A11     : 0x3f401521  A12     : 0x3ffe3b7f  A13     : 0x00000033  
A14     : 0x00000000  A15     : 0x3ffe3b85  SAR     : 0x00000020  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0xffffffff 
The backtrace points me to esp_setup_syscall_table.
The strange fact is that everything works fine as long as I upload an application under 400kB, but when I exceed that size I get this error not on a new function call, but on cpu startup (where esp_setup_syscall_table is called), just like a piece of memory has been overwritten.
My partition table is set to singleapp and, using ESP32_Core_board_V2 euipped with 4MB of flash I shouldn't encounter this kind of issues...
I've also been able run other projects (not written by me) bigger than 400kB, so I am kind of confused.
Any help would be appreciated.

f.h-f.s.
Posts: 216
Joined: Thu Dec 08, 2016 2:53 pm

Re: IllegalInstruction

Postby f.h-f.s. » Fri May 19, 2017 5:32 pm

What happens with a esp-idf example?

LorenzoR
Posts: 2
Joined: Thu May 18, 2017 10:28 am

Re: IllegalInstruction

Postby LorenzoR » Fri May 19, 2017 6:59 pm

Hi f.h-f.s.,
thank you for your response, anyway everything runs as expected for example with the esp-idf hello world example, just like my application when it does not exceed that particular size (anyway I repeat that at the moment I'm not sure at all that it could be a size problem because I have been able to run bigger apps found on the web and based on esp-idf with no issue). What made me think about a memory overwrite problem was that everything works ok till I add new code which makes my bin bigger and the IllegalInstruction error occurs far before the new code point of execution :(

f.h-f.s.
Posts: 216
Joined: Thu Dec 08, 2016 2:53 pm

Re: IllegalInstruction

Postby f.h-f.s. » Thu Jun 15, 2017 12:55 pm

Lets say you flash a sample that works, it is smaller than 400kb. Then it runs and works.

Now you increase the offset of the factory image so it goes over offset+400kb, does the same problem occur? (don't forget to change the factory image offset in "make menuconfig" Partition Table)

Also what does "make size" show?

Sorry about the late response =P

Who is online

Users browsing this forum: No registered users and 113 guests