Page 1 of 1

Teething troubles

Posted: Fri May 17, 2019 4:39 am
by wevets
Many years ago, like 20, I used to write x86 Ethernet device drivers and other apps. I got convinced to take on an ESP32 development after 15 years of not doing any software, and the world has changed a lot.
I'm going through the ESP32 startup stuff, doing the examples etc. I've got Hello_World and blink running. I tried adding a printf() statement to the blink program because.... I could and wanted to see what would happen. I got a stack overflow. I took the printf() statement from hello_world_main.c There's just not that much going on in blink.c. How could the stack overflow. Is the system loading all that crap that gets compiled on a first "make flash" and is deposited in ~/esp/blink/build, rather than just what the linker thinks is required by blink.c? Can one control where the stack starts? How big could the heap possibly be?
(The ESP has 4Mb. I lived in the world where Bill Gates said no one would ever need more than 640K, and we made that 640K sing and dance.)
How do I get a handle on how to control this? Is there a book or a resource that explains what's really going on once you do the cookbook exercises to get simple programs running? And where does one find the documentation for this version of make?
Lot's of questions here. Help!

Re: Teething troubles

Posted: Fri May 17, 2019 6:49 am
by WiFive
https://github.com/espressif/esp-idf/co ... 769846ff13

So you are using an older version that had a minimal task stack. Printf eats stack like a monster, nano printf is not as bad.

https://docs.espressif.com/projects/esp ... ano-format

Also https://leanpub.com/kolban-ESP32

Re: Teething troubles

Posted: Fri May 17, 2019 1:36 pm
by username
You can also change the default stack sizes is menuconfig.

Re: Teething troubles

Posted: Fri May 17, 2019 3:48 pm
by fly135
In my experience performing a printf adds about 1K to the required stack size.

John A

Re: Teething troubles

Posted: Fri May 17, 2019 3:50 pm
by fly135
WiFive wrote:
Fri May 17, 2019 6:49 am
https://github.com/espressif/esp-idf/co ... 769846ff13

So you are using an older version that had a minimal task stack. Printf eats stack like a monster, nano printf is not as bad.

https://docs.espressif.com/projects/esp ... ano-format

Also https://leanpub.com/kolban-ESP32
Did not know about nano. Going to try that out.

John A

Re: Teething troubles

Posted: Fri May 17, 2019 4:39 pm
by username
FWIW, I have been using VisualGDB because not so long ago they added support for the ESP32. It makes life so much simpler using their platform. I am telling you guys this because when it comes to menuconfig you can see all the options there so easily this way.
I made a short video of that here.


https://www.youtube.com/watch?v=-ugwke8 ... e=youtu.be

Re: Teething troubles

Posted: Fri May 17, 2019 5:12 pm
by wevets
Thanks for the many replies. I'll check out all the pointers.
There were a couple of references to nano printf. Is this part of c library? If not, and even if it is, where can I find documentation on this and possibly other useful functions.
I see that sdkconfig is used to set up a whole pile of compile/link/flash time options. Can this file be edited directly without going through "make menuconfig"? That's seems a kludgey way to go, in addition to being pretty opaque. Does documentation exist for whats in sdkconfig?
Lastly (for now) I'm using the "stable" 3.2 version of the ESP-IDF. As a beginner just spinning up, would I be better off using the latest version, which I think is 4.0 or staying with 3.2?

Re: Teething troubles

Posted: Fri May 17, 2019 5:17 pm
by wevets
Sorry. I see some of the answers to the questions I posed in my last post in previous answers, especially pointers to configuration options. It takes a bit of time to explore the turf.