These are chat archives for esp8266/Arduino

17th
May 2015
Markus
@Links2004
May 17 2015 10:11
found another strange problem.. the memory of an class can be not aligned which lead in a Fatal exception (9).
if the class hat uint32_t or function ptr inside.
ficeto
@ficeto
May 17 2015 10:14
so on that problem
i think you diged deeper thn me bu I ran into similar thing
try to get the previous toolchain
and see if it will work with that
as stupid as it sounds... the FS class was the one that triggered it
Markus
@Links2004
May 17 2015 10:15
its a problem of the operator new and the os_malloc its not an compiler problem it is runtime
ficeto
@ficeto
May 17 2015 10:15
having called SF.mount() triggers exception
if I call just spiffs_mount() it's all fine
SF.mount does only that
the old toolchain did not have that problem
Markus
@Links2004
May 17 2015 10:18
may simple produce an other order in the startup code.
if i move the classes around in my code i can move the problem from one to an other class...
i use the compiler from the windows release, so its the oldest one.
ficeto
@ficeto
May 17 2015 10:20
sounds too similar to ignore
if sketch is simple and jus FS and a couple of Serial thongs are calledit's all fine
but my sketch has lots going on
and triggers every time (unless I premount with the C method)
Markus
@Links2004
May 17 2015 10:22
i try to write a function to get allways aligned space out of the operator new. the problem is more the free
ficeto
@ficeto
May 17 2015 10:22
bool FSClass::mount() {
  if (_mounted) 
    return true;

  _mounted = spiffs_mount();
  return _mounted;
}
Markus
@Links2004
May 17 2015 10:24
_mounted is bigger then one byte?
ficeto
@ficeto
May 17 2015 10:24
it's a bool
removing it from the code and just having spiffs_mount gave the same result
Markus
@Links2004
May 17 2015 10:26
bool FSClass::mount() {
spiffs_mount();
return true;
}
?
ficeto
@ficeto
May 17 2015 10:26
yup.. exception :)
Markus
@Links2004
May 17 2015 10:27
k strange
Markus
@Links2004
May 17 2015 11:20
ok aligne all malloc calls help
void* malloc(size_t size) {
    size = ((size + 3) & ~((size_t)0x3));
    return os_malloc(size);
}
void *operator new(size_t size) {
    size = ((size + 3) & ~((size_t)0x3));
    return os_malloc(size);
}

void *operator new[](size_t size) {
    size = ((size + 3) & ~((size_t)0x3));
    return os_malloc(size);
}
ficeto
@ficeto
May 17 2015 11:29
will give this a shot later for my case
have you pushed this to the hub?
Markus
@Links2004
May 17 2015 11:30
not yet need to clean up my git first, many debug and trace in it at the momement
Links2004/Arduino@6e08534
Markus
@Links2004
May 17 2015 11:55
may also help in you case Links2004/Arduino@5c60dcb
ficeto
@ficeto
May 17 2015 13:20
will pull and see :)
Luke Cyca
@lukecyca
May 17 2015 16:32
I've just switched from the IoT SDK to this Arduino project. It's awesome but I'm having a lot of random resets. I was wondering if there is a reference for the rst cause: 4 codes.
What do they all mean?
ficeto
@ficeto
May 17 2015 19:23
there could be many reasons for reset
what is your sketch doing at the moment of reset?
does it reset at the same moment/procedure
Luke Cyca
@lukecyca
May 17 2015 20:39
@ficeto: It is happening at different times. I can influence it by making arbitrary changes to the sketch (inserting Serial.println() or delay()) but it's an indirect effect at best.
After doing a bunch more testing, I think I have a lead... It happens when I use WifiClient to connect to a server which returns large-ish headers in the response.
I'll work on an isolated test case
ficeto
@ficeto
May 17 2015 20:44
Which version of the IDE are you using? Latest release or latest GIT?
when you get lots of incomming data, there should be some yield() at least implemented so the wifi stack can workwith the packets
else you overflow the incomming network buffer and what you say happens
to fight this we have implemented some new methods where needed to offlead the user from thinking about all those things
most have made it in the main branch and some are waiting to be pulled
Luke Cyca
@lukecyca
May 17 2015 20:47
Interesting. I will try that.
I am using sandeepmistry's fork which is tracking master pretty closely, but as an addon for the official IDE.
ficeto
@ficeto
May 17 2015 20:49
to be honest I have not yet tested a Client only scenario, but since any server uses that class, you should be fine
what is this then?
Luke Cyca
@lukecyca
May 17 2015 20:49
Thanks for the tips. I will keep investigating and report back.
ficeto
@ficeto
May 17 2015 20:49
there are no IDE customizations other than the 75000 baud option for the serial
all work is on the ESP source itself
@Links2004 are you around?
Luke Cyca
@lukecyca
May 17 2015 20:52
It's a very close fork: github.com/sandeepmistry/esp8266-Arduino but I will also try esp8266/Arduino master to rule out any difference there.
ficeto
@ficeto
May 17 2015 20:52
wait
let me look real quick through the code
ok you need not to switch
you have what you need
you mind sharing the part of the sketch that uses the client to read the response?
Luke Cyca
@lukecyca
May 17 2015 20:57
ok thanks! I will look more at the timing then. I'll try make an isolated test case using httpbin.org.
Does delay() do a yield internally?
ficeto
@ficeto
May 17 2015 20:58
yes it does
ok there is another thing to consider
since you are using the WiFiClient class to read response directly
you need to know that the TCP packet has a max data of 1460 bytes
so if your response headers and data are larger than that, you need to yield/delay at the proper time in order for the tcp to handle the next packet
and even so, you might be getting some other packets for other things as well
and those will lead to the overflow I mentioned
it's a good point to have it done internaly though :)
so you do not need to think about it
Luke Cyca
@lukecyca
May 17 2015 21:02
ok, I think I understand, but I'm going to focus on a reproducible test case that I can show you.
ficeto
@ficeto
May 17 2015 21:02
that is best :)
Luke Cyca
@lukecyca
May 17 2015 21:02
I'd like to understand what's going on instead of just peppering yield() all over the place and crossing my fingers! :D
ficeto
@ficeto
May 17 2015 21:02
true!
me too by the way