I hope this is the right forum to discuss this issue.
Code produced by the gcc causes a fatal crash on a following:
// app.c
#include "user_interface.h"
#include "osapi.h"
void user_init(void)
{
uint32 ip = 17082560;
os_printf("%d.%d.%d.%d\n", IP2STR(ip));
}
SDK ver: 1.5.3(aec24ac9) compiled @ Apr 18 2016 13:20:18
phy ver: 9281, pp ver: 9.9
Fatal exception 28(LoadProhibitedCause):
epc1=0x4020103c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0104a8c0, depc=0x00000000
(user_init is at 0x40201020)
gcc flags:
xtensa-lx106-elf-gcc flags=-c -Wall -Wextra -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -fno-exceptions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
When IP2STR is redifned, the issue goes away:
void user_init(void)
{
uint32 ip = 17082560;
#define IP2STR(addr) (uint8_t)(addr & 0xFF), (uint8_t)((addr >> 8) & 0xFF), (uint8_t)((addr >> 16) & 0xFF), (uint8_t)((addr >> 24) & 0xFF)
os_printf("%d.%d.%d.%d\n", IP2STR(ip));
}
When IP2STR is referenced from the ip_addr.h (Crash!)
Disassembly of section .text.user_init:
00000000 <user_init-0x18>:
0: 000000 ill
3: a8c000 excw
6: c10104 excw
9: 04a8 l32i.n a10, a4, 0
b: a8c201 l32r a0, fffea314 <user_init+0xfffea2fc>
e: c30104 excw
11: 04a8 l32i.n a10, a4, 0
13: 000001 l32r a0, fffc0014 <user_init+0xfffbfffc>
...
00000018 <user_init>:
18: f0c112 addi a1, a1, -16
1b: fffa31 l32r a3, 4 <user_init-0x14>
1e: fffa41 l32r a4, 8 <user_init-0x10>
21: fffa51 l32r a5, c <user_init-0xc>
24: fffb61 l32r a6, 10 <user_init-0x8>
27: 3109 s32i.n a0, a1, 12
29: fff521 l32r a2, 0 <user_init-0x18>
2c: 000332 l8ui a3, a3, 0
2f: 000442 l8ui a4, a4, 0
32: 000552 l8ui a5, a5, 0
35: 000662 l8ui a6, a6, 0
38: fff701 l32r a0, 14 <user_init-0x4>
3b: 0000c0 callx0 a0
3e: 3108 l32i.n a0, a1, 12
40: 10c112 addi a1, a1, 16
43: f00d ret.n
When IP2STR is redefined (No Crash!)
Disassembly of section .text.user_init:
00000000 <user_init-0x8>:
...
00000008 <user_init>:
8: fffe21 l32r a2, 0 <user_init-0x8>
b: f0c112 addi a1, a1, -16
e: c0a032 movi a3, 192
11: a8a042 movi a4, 168
14: 450c movi.n a5, 4
16: 160c movi.n a6, 1
18: 3109 s32i.n a0, a1, 12
1a: fffa01 l32r a0, 4 <user_init-0x4>
1d: 0000c0 callx0 a0
20: 3108 l32i.n a0, a1, 12
22: 10c112 addi a1, a1, 16
25: f00d ret.n
Any insight as to what might be going on here?
Thanks,
Lcf