arduino to IDF newbie help managing mulitple apps inline

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: arduino to IDF newbie help managing mulitple apps inline

Postby ESP_Sprite » Tue Mar 19, 2024 1:25 pm

I think the vTaskDelete(x) discussion is really interesting, but probably not for this thread. Suggest starting a new one if you guys want to discuss any pros/cons.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: arduino to IDF newbie help managing mulitple apps inline

Postby chegewara » Tue Mar 19, 2024 2:46 pm

MicroController wrote:
Tue Mar 19, 2024 11:57 am
P.S.:
Dear Ché, let's not go there. I'd rather try and find the best solutions for people in a cooperative way than diminishing others. I'm not here to take anything away from anyone. I guess we could come up with excellent ideas by leveraging each other's experience.
To show you why no answer is better than wrong answer here is example, which i hope also can help OP to continue with his project.
In other topic you told me to work with only 1 task (no sense, the idea of FreeRTOS is to use tasks). Here is log from the project i am working on:

Code: Select all

"free memory":[78084,73912,73728,0],
"watermark":{
"BLE_Task":1660,
"LED":120,
"mqtt":2724,
"auxled":356,
"mainled":348,
"main2led":356,
"indiLed":396,
"mainTask":1560,
"count":20},

15:35:28.824 >  tasks count: 20
As you can see there is 20 tasks in total (including espressif internal tasks), each has its own stack 3000-4000, which is 60-80kB of ram (in some cases i am using more tasks in this project).
As you can see also there is still over 70kB free ram (worst case i saw is about 50kB).
In short, this project is using:
- wifi - AP and STA, with enterprise and roaming support
- ble
- mqtt
- sntp
- I2C master and slave
- OTA
- and optionally LTE, LORA, UWB, DSRC, and more

Your answer discouraged OP and he wants to abandon project, thats why i think no answer is better than wrong answer.
If you feel insulted then sorry, it was not my intention, but you have to take responsibility for answers and dont discourage people when you have no full knowledge about topic.

MicroController
Posts: 1702
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: arduino to IDF newbie help managing mulitple apps inline

Postby MicroController » Tue Mar 19, 2024 3:11 pm

Your answer discouraged OP and he wants to abandon project, thats why i think no answer is better than wrong answer.
I don't think I discouraged anyone, but I may have missed something and I appreciate you standing up against what you feel is needlessly discouraging to others.
In other topic you told me to work with only 1 task (no sense, the idea of FreeRTOS is to use tasks).
Now this is a great topic - I'm sure we could argue for years about the right 'size' or number of tasks :-D

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: arduino to IDF newbie help managing mulitple apps inline

Postby chegewara » Tue Mar 19, 2024 3:54 pm

mtraven wrote:
Sat Mar 16, 2024 10:22 pm

PS
on a separate but related note: the NPT example in IDF is EXACTLY what that first app should be. There are notes in there that the “example_connect” function is simplified & should not be used in real work applications. How serious should I take that note? This isn’t a commercial product or anything & the clock is not super critical, can I get away with just using the example as is? I ask because, every time I try to add NTP to a working WIFI init & connect, it refuses to connect. Also, where is the actual code behind "example_connect" ? all I can find is the prototype.
https://github.com/espressif/esp-idf/bl ... nect.c#L90

mtraven
Posts: 28
Joined: Thu Jul 07, 2022 3:34 am

Re: arduino to IDF newbie help managing mulitple apps inline

Postby mtraven » Fri Mar 22, 2024 1:19 am

hey all, FYI I haven't given up, I know I said I might, but I just cant let things go like that.

But I was compiling hard the other night and my system drive gave out on me. So here we are, a couple of days later, back up & running with a new drive.

I haven't had a chance to read all the responses, but I will for sure.

I now understand my multi "app" approach was silly and I'm becoming more familiar with task style programing.

My current predicament is, I wrote a (hopefully) proper wifi connect. Really, I just followed the examples. With a standalone chip, it runs fine*. But my chip has to be plugged into a circuit that drives an LCD. As soon as I do that, the program fails to connect. I know that sets off bells saying there is a problem with my circuit....but my Arduino framework version, with all the same hardware, is able to connect just fine. I'm gonna dig into the verbose logs and track down whatever code the arduino framework uses, I'll see what comes from that. If anyone has any general thoughts, please share.

ps -- another complication, due to library compatibility I've had to roll back to IDF 4.4.7. I dont think I need any help with that, just letting you all know, thats what I gotta use for now.

*by fine,I mean it is able to connect. It still fails exactly 2x before connecting each time, not sure what that is about.

AMENDMENT: in re-testing the hardware, I found the arduino framework did NOT connect to wifi as I thought. It does, however, run espNow and that has been thoroughly tested. Isn't espNow just wifi plus some other stuff? I dont get whats happening, and just seem to be digging myself into a deeper hole.

I just found a recording of a test where I DID successfully connect to wifi, its just not working now...theres been no hardware changes on there.
Last edited by mtraven on Fri Mar 22, 2024 2:01 am, edited 1 time in total.

mtraven
Posts: 28
Joined: Thu Jul 07, 2022 3:34 am

Re: arduino to IDF newbie help managing mulitple apps inline

Postby mtraven » Fri Mar 22, 2024 1:42 am

chegewara wrote:
Tue Mar 19, 2024 2:46 pm
As you can see there is 20 tasks in total (including espressif internal tasks), each has its own stack 3000-4000, which is 60-80kB of ram
could you explain the math on that to me? Its been a point of confusion for me for a while. What are the units of "stack" ? Somewhere I got it in my head that they were bytes, obviously thats wrong...what are they?

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: arduino to IDF newbie help managing mulitple apps inline

Postby chegewara » Fri Mar 22, 2024 2:32 am

Yes, those are bytes.
I have each task with stack 3-4kB, sometimes even more.
Of course i am assuming that espressif internal tasks have similar stacks.
Dont look at the number here, because its stack watermark (how much bytes i can still use on stack):

Code: Select all

"watermark":{
"BLE_Task":1660,
"LED":120,
"mqtt":2724,
"auxled":356,
"mainled":348,
"main2led":356,
"indiLed":396,
"mainTask":1560,

mtraven
Posts: 28
Joined: Thu Jul 07, 2022 3:34 am

Re: arduino to IDF newbie help managing mulitple apps inline

Postby mtraven » Fri Mar 22, 2024 3:56 am

man I feel so stupid, I'm still not getting it. How does a stack size of 3000 bytes equal 60kb? Or were you listing the sum of all your tasks?

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: arduino to IDF newbie help managing mulitple apps inline

Postby chegewara » Fri Mar 22, 2024 5:11 am

Its 20 tasks, each with own stack of 3kB:
20 x 3kB = 60kB

mtraven
Posts: 28
Joined: Thu Jul 07, 2022 3:34 am

Re: arduino to IDF newbie help managing mulitple apps inline

Postby mtraven » Fri Mar 22, 2024 10:16 pm

chegewara wrote:
Fri Mar 22, 2024 5:11 am
Its 20 tasks, each with own stack of 3kB:
20 x 3kB = 60kB

ahhhhhh, got it, thanks for your patients. I swear, I'm not a complete idiot! ...but I'm also not a programmer. (farmer/machinist)

So you said you have wifi running on that system, is that happening with only a 3kb stack? Or does the system bite off what it needs at esp_wifi_init() ? Or is what it needs actually memory from the heap? Still working on my understanding of memory & how it all works.

I'm having a bunch of problems with wifi, I should just open a new thread, right?

Who is online

Users browsing this forum: No registered users and 73 guests