The use of the ESP8266 in the world of IoT

User avatar
By cal
#20332 I think it's the point that you don't need to know what the compiler does if you put that in
the upper function that calls the inner logic function that may be modified and probably
returns the start function. That control function could be complete inline assembler (glue code like)
but need not be. We don't need to know how it adjusts the stack. It should be able to set the stack to fixed value
and just jump out. Nobody will come back to this function.
Have to go now and can't look into the code now.

Interesting stuff,
Cal
User avatar
By rab
#20367 Ok, I'm getting somewhere. The problem is gcc tries to give you stack space, even if you only have assembler in a function. Or at least certain things make it do that, funnily enough one of those is trying to give yourself some stack space! We do need to store the return address (it is possible for an app to return and so we should allow it to), so we can restore it when we are done. Then when we jump to the next function, it'll return to the original caller instead of us.

I've got something that works, but technically it's doing something naughty although it seems to work. I'll have to play a bit more.
User avatar
By rab
#20386 Ok, I've pushed some new assembler stubs. Stack space reserved by rBoot is now down to zero! Thanks for pushing me cal, I'd given up on that some time ago.

I am having to splat a register that should get restored, but given that the device stops when the user code returns (not that most apps ever do, but they can), it probably doesn't matter and certainly doesn't seem to from my testing. It can be disabled as well, and switched back to the C code if user prefer or uses a different compiler where it doesn't work.
User avatar
By cal
#20389 You're welcome.
I am dealing with that kind of stuff currently playing with gdb and the esp8266 and just wondered why
a boot loader needs memory after boot is finished.

But now I now where the high part of the stack comes from.

Have fun,
Cal