Teething troubles

wevets
Posts: 112
Joined: Sat Mar 09, 2019 2:56 am

Teething troubles

Postby wevets » Fri May 17, 2019 4:39 am

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!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Teething troubles

Postby WiFive » 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

username
Posts: 532
Joined: Thu May 03, 2018 1:18 pm

Re: Teething troubles

Postby username » Fri May 17, 2019 1:36 pm

You can also change the default stack sizes is menuconfig.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Teething troubles

Postby fly135 » Fri May 17, 2019 3:48 pm

In my experience performing a printf adds about 1K to the required stack size.

John A

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Teething troubles

Postby fly135 » Fri May 17, 2019 3:50 pm

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

username
Posts: 532
Joined: Thu May 03, 2018 1:18 pm

Re: Teething troubles

Postby username » Fri May 17, 2019 4:39 pm

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

wevets
Posts: 112
Joined: Sat Mar 09, 2019 2:56 am

Re: Teething troubles

Postby wevets » Fri May 17, 2019 5:12 pm

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?

wevets
Posts: 112
Joined: Sat Mar 09, 2019 2:56 am

Re: Teething troubles

Postby wevets » Fri May 17, 2019 5:17 pm

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.

Who is online

Users browsing this forum: Bing [Bot] and 128 guests