Page 1 of 1

LoadStoreErrorCause help

Posted: Thu Oct 19, 2017 5:06 am
by smbgaiden
Hi All,

I've written some strings into spi flash and then try to access using the virtual memory addressing and have a weird behavior that I can't figure out how to cope with.

Flashed my equal sized strings with to 0x80000. Verified they're there via two ways:
char* p = (char *)0x40280000;
os_printf("%c%c%c%c\n", p[0], p[1], p[2], p[3]);

spi_flash_read(0x80000, temp, sizeof(temp));
os_printf("SPI Read: 0x%X 0x%X 0x%X 0x%X\n", temp[0], temp[1], temp[2], tem$

Compared the hex vs. the chars vs. the bin I wrote there and everything was fine.

Now if I do:
char * p =(char *)0x40280064; // this is a valid string address starting point and is smaller than the bin file written into 0x80000

os_printf(p); // This is good! See my string printed over serial.
// But if I do this:
os_printf("This is my string: %s", p); // this throws me out the following before reset:

This is my string: Fatal exception 3(LoadStoreErrorCause):
epc1=0x4000228b, epc2=0x00000000, epc3=0x00000000, excvaddr=0x40280064, depc=0x0

Closest address to 0x4000228b seems to be:
40001f00 g *ABS* 00000000 ets_vprintf
; which makes sense for os_printf to call.

Does anyone know why I can directly use a pointer to virtual indexed memory with os_printf and have a good result vs. having the printf code look it up via a va_list causes the LoadStoreErrorCause?

Re: LoadStoreErrorCause help

Posted: Thu Oct 19, 2017 6:31 am
by smbgaiden
Oh correction... the p[0] was actually int pointers. Seems you can't use l8 functions with SPI Flash addresses. When I recast the int * to char * and try to printf with %c p[0] and etc it will crash.

Re: LoadStoreErrorCause help

Posted: Sun Aug 05, 2018 10:21 pm
by sedlacek.david
I'm probably facing the same problem. Have 4MBytes of flash. I can declare a variable like

Code: Select all

const char * p = 0x40280000
and read it like

Code: Select all

int x = *p
. This works.
But when I have a pointer like this:

Code: Select all

UINT32 addr = 0x40280000;
const char * p = (const char *)addr;

it will crash:

Code: Select all

Fatal exception 3(LoadStoreErrorCause):
epc1=0x402430ec, epc2=0x00000000, epc3=0x00000000, excvaddr=0x40280000, depc=0x0

Don't understand...

Re: LoadStoreErrorCause help

Posted: Wed Aug 15, 2018 1:15 am
by sedlacek.david
Can someone help?

Re: LoadStoreErrorCause help

Posted: Wed Aug 15, 2018 8:11 am
by blubb
You have to read 4 bytes at once always. If you try to read only 1 or 2, a crash is normal behavior.

Re: LoadStoreErrorCause help

Posted: Wed Aug 15, 2018 3:32 pm
by sedlacek.david
Thank you for your reply.

So there is nothing wrong with it. What I have to do now is refactor some of my C structures mapping some UINT8 stuff stored in the FLASH.