Re: What is the right way to add PM to esp32c6

2024-11-13 Thread Tiago Medicci Serrano
Hi Felipe,

Please check the occurrences of `CONFIG_PM_ENABLE`

on ESP-IDF's Wi-Fi driver of ESP32-C6. Its counterpart in NuttX would be
`CONFIG_PM`
.
Note that `wifi_apb80m_request`

is not defined anywhere in NuttX, so I suppose `CONFIG_PM` is not enabled
in your configuration.

My suggestion: using ESP-IDF, try the Wi-Fi "as-is" (without the light
sleep enabled) and save the generated `sdkconfig.h`. Try the same with
light sleep enabled: validate its behavior/power consumption and save the
newer `sdkconfig.h`. Compare both to check which variables were introduced
and, then, check the Wi-Fi-related sources (especially under
`components/esp-wifi`
,
but check other occurrences outside this folder too!). The same
implementation should be introduced in NuttX (the one related to `
wifi_apb80m_request
`
is just one of them, others may be necessary). Also, I recommend adding the
configs to `esp-hal-3rdparty/nuttx/esp32c6/include/sdkconfig.h`
conditionally (if NuttX's `CONFIG_PM` is defined, you define ESP-IDF's
related configs on it).

I hope this helps.

Best regards,

Em ter., 12 de nov. de 2024 às 09:33, Felipe Moura Oliveira <
moura@gmail.com> escreveu:

> Hello Tiago.
>
> When I am using WIFI config and enabling Auto-Sleep, the mcu can no longer
> wake up from light sleep, so it ends up restarting because of WD.
>
> Em ter., 12 de nov. de 2024 às 08:47, Tiago Medicci Serrano <
> tiago.medi...@gmail.com> escreveu:
>
> > Hi Felipe,
> >
> > What exactly is your problem regarding light sleep and Wi-Fi?
> >
> > If I'm not mistaken, some hooks must be implemented in the Wi-Fi driver
> > too. My suggestion: take a look at IDF's implementation and try light
> sleep
> > with/without Wi-Fi: compare the `sdkconfig.h` enabling/disabling light
> > sleep. Then, check which configs are on the Wi-Fi related files.
> >
> > Looking towards hearing from you soon.
> >
> > Best regards,
> >
> > Em seg., 11 de nov. de 2024 às 17:52, Felipe Moura Oliveira <
> > moura@gmail.com> escreveu:
> >
> > > Hello everyone,
> > >
> > > Tiago, actually I am able to compile and run light sleep using nsh
> > > configuration, but it's failing when I am using wifi configuration. I
> > tried
> > > it by myself but I cannot solve it, can you give some help please?
> > > I push a draft to you look it easely:
> > > https://github.com/apache/nuttx/pull/14726
> > >
> > > You can config a work example running the following cmd:
> > > ./tools/configure.sh esp32c6-devkitc:sleep_test
> > >
> > > This config basically is nsh + CONFIG_ESP_AUTO_SLEEP=y and
> > > CONFIG_EXAMPLES_HELLO=y. Auto_sleep is new config done by me,
> > >
> > > Please, change hello_main.c with the code below:
> > >
> > >
> > >
> >
> /
> > > * apps/examples/hello/hello_main.c
> > > */
> > >
> > > #include 
> > > #include 
> > > #include 
> > > #include 
> > > #include 
> > > #include 
> > > #include 
> > >
> > >
> > >
> >
> /
> > > * Definitions
> > >
> > >
> >
> /
> > >
> > > #define NUM_THREADS 5
> > >
> > >
> > >
> >
> /
> > > * Private Data
> > >
> > >
> >
> /
> > >
> > > struct thread_info {
> > > int thread_id;
> > > unsigned int sleep_time;
> > > };
> > >
> > >
> > >
> >
> /
> > > * Private Functions
> > >
> > >
> >
> /
> > >
> > > void *thread_func(void *arg)
> > > {
> > > struct thread_info *tinfo = (struct thread_info *)arg;
> > > volatile uint32_t i = 0;
> > > struct timespec ts_start, ts_end;
> > > time_t elapsed;
> > >
> > > // Get the start time
> > > clock_gettime(CLOCK_MONOTONIC, &ts_start);
> > >
> > > while (1)
> > > {
> > > i++;
> > > clock_gettime(CLOCK_MONOTONIC, &ts_end);
> > > elapsed = ts_end.tv_sec - ts_start.tv_sec;
> > > printf("Hello, World!! [Thread %d] Iteration: %lu | Elapsed time: %ld
> > > seconds\n",
> > > tinfo->thread_id, i, (long)elapsed);
> > > ts_start = ts_end;
> > > sleep(tinfo->sleep_time);
> > > }
> > 

Re: What is the right way to add PM to esp32c6

2024-11-13 Thread Tiago Medicci Serrano
Hi Felipe,

I don't think they are separate features, please check this documentation:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-reference/system/sleep_modes.html

If I understood correctly, you still need PM for using light sleep with RF.

Best regards,

Em qua., 13 de nov. de 2024 às 10:36, Felipe Moura Oliveira <
moura@gmail.com> escreveu:

> Hi Tiago,
>
> I believe the issue isn’t related to the CONFIG_PM macro. From what I
> understand, it’s possible to independently put both the MCU and the WiFi
> transceiver into low-power mode.
>
> For now, I’d like to focus on putting only the MCU to sleep by calling the
> esp_light_sleep_start() function, similar to what was done here: https
> ://github.com/roblatour/SolarWeatherStationII/blob
> /cdf04e0e0bd931095254a0b11b61f24d7053ff7d/main/main.c#L845
>
> As you can see in the code above, the implementation simply calls the sleep
> function without handling any power manager related to WiFi, and in this
> case, the MCU can wake from sleep. However, in my implementation, this
> isn’t happening. I’ve implemented wake-up via timer and button and
> validated it using a standard configuration. When using WiFi, though, the
> MCU isn’t receiving interrupts.
>
> I’m concerned that something similar to what happened here might be
> occurring: https://github.com/apache/nuttx/issues/13303
>
> Do you think I should investigate the configurations further, or could
> there be something in NuttX that’s masking interrupts during sleep
> (possibly related to the RTC)?
>
> Em qua., 13 de nov. de 2024 às 09:45, Tiago Medicci Serrano <
> tiago.medi...@gmail.com> escreveu:
>
> > Hi Felipe,
> >
> > Please check the occurrences of `CONFIG_PM_ENABLE`
> > <
> >
> https://github.com/espressif/esp-idf/blob/2c8de044a3c61a060c70d4072d2606e216be81d4/components/esp_wifi/esp32c6/esp_adapter.c#L282
> > >
> > on ESP-IDF's Wi-Fi driver of ESP32-C6. Its counterpart in NuttX would be
> > `CONFIG_PM`
> > <
> >
> https://github.com/apache/incubator-nuttx/blob/b3727f67bee3ab1550157c1bd4101168a7689ff3/arch/risc-v/src/esp32c6/esp_wifi_adapter.c#L1544
> > >.
> > Note that `wifi_apb80m_request`
> > <
> >
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> > >
> > is not defined anywhere in NuttX, so I suppose `CONFIG_PM` is not enabled
> > in your configuration.
> >
> > My suggestion: using ESP-IDF, try the Wi-Fi "as-is" (without the light
> > sleep enabled) and save the generated `sdkconfig.h`. Try the same with
> > light sleep enabled: validate its behavior/power consumption and save the
> > newer `sdkconfig.h`. Compare both to check which variables were
> introduced
> > and, then, check the Wi-Fi-related sources (especially under
> > `components/esp-wifi`
> > <
> >
> https://github.com/espressif/esp-idf/tree/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi
> > >,
> > but check other occurrences outside this folder too!). The same
> > implementation should be introduced in NuttX (the one related to `
> > wifi_apb80m_request
> > <
> >
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> > >`
> > is just one of them, others may be necessary). Also, I recommend adding
> the
> > configs to `esp-hal-3rdparty/nuttx/esp32c6/include/sdkconfig.h`
> > conditionally (if NuttX's `CONFIG_PM` is defined, you define ESP-IDF's
> > related configs on it).
> >
> > I hope this helps.
> >
> > Best regards,
> >
> > Em ter., 12 de nov. de 2024 às 09:33, Felipe Moura Oliveira <
> > moura@gmail.com> escreveu:
> >
> > > Hello Tiago.
> > >
> > > When I am using WIFI config and enabling Auto-Sleep, the mcu can no
> > longer
> > > wake up from light sleep, so it ends up restarting because of WD.
> > >
> > > Em ter., 12 de nov. de 2024 às 08:47, Tiago Medicci Serrano <
> > > tiago.medi...@gmail.com> escreveu:
> > >
> > > > Hi Felipe,
> > > >
> > > > What exactly is your problem regarding light sleep and Wi-Fi?
> > > >
> > > > If I'm not mistaken, some hooks must be implemented in the Wi-Fi
> driver
> > > > too. My suggestion: take a look at IDF's implementation and try light
> > > sleep
> > > > with/without Wi-Fi: compare the `sdkconfig.h` enabling/disabling
> light
> > > > sleep. Then, check which configs are on the Wi-Fi related files.
> > > >
> > > > Looking towards hearing from you soon.
> > > >
> > > > Best regards,
> > > >
> > > > Em seg., 11 de nov. de 2024 às 17:52, Felipe Moura Oliveira <
> > > > moura@gmail.com> escreveu:
> > > >
> > > > > Hello everyone,
> > > > >
> > > > > Tiago, actually I am able to compile and run light sleep using nsh
> > > > > configuration, but it's failing when I am using wifi
> configuration. I
> > > > tried
> > > > > it by myself but I cannot solve it, can you give some help please?
> > > > > I push a draft to you look it easely:
> > > > > https://github.com/apache/nuttx/pull/14726
> > > > >
> > > 

Re: What is the right way to add PM to esp32c6

2024-11-13 Thread Felipe Moura Oliveira
Hi Tiago,

I realize I didn’t express myself clearly before. What I meant to say is
that I believe it’s possible to put the MCU to sleep without modifying the
WiFi power manager settings. Looking at this post: https://github.com
/espressif/esp-idf/issues/11550, you’ll notice that putting the MCU to
sleep without managing the wireless connection will cause it to lose
communication, but the MCU should still be able to wake up.

I’m hesitant to fully implement the power manager at this stage because I
really believe the issue is related to the lack of interrupt detection
during sleep when WiFi is in the project.

Could you check the link I sent and let me know if you really think it’s
necessary to have the power manager active to put the MCU to sleep while
the wireless communication drivers are still running?

Em qua., 13 de nov. de 2024 às 11:26, Tiago Medicci Serrano <
tiago.medi...@gmail.com> escreveu:

> Hi Felipe,
>
> I don't think they are separate features, please check this documentation:
>
> https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-reference/system/sleep_modes.html
>
> If I understood correctly, you still need PM for using light sleep with RF.
>
> Best regards,
>
> Em qua., 13 de nov. de 2024 às 10:36, Felipe Moura Oliveira <
> moura@gmail.com> escreveu:
>
> > Hi Tiago,
> >
> > I believe the issue isn’t related to the CONFIG_PM macro. From what I
> > understand, it’s possible to independently put both the MCU and the WiFi
> > transceiver into low-power mode.
> >
> > For now, I’d like to focus on putting only the MCU to sleep by calling
> the
> > esp_light_sleep_start() function, similar to what was done here: https
> > ://github.com/roblatour/SolarWeatherStationII/blob
> > /cdf04e0e0bd931095254a0b11b61f24d7053ff7d/main/main.c#L845
> >
> > As you can see in the code above, the implementation simply calls the
> sleep
> > function without handling any power manager related to WiFi, and in this
> > case, the MCU can wake from sleep. However, in my implementation, this
> > isn’t happening. I’ve implemented wake-up via timer and button and
> > validated it using a standard configuration. When using WiFi, though, the
> > MCU isn’t receiving interrupts.
> >
> > I’m concerned that something similar to what happened here might be
> > occurring: https://github.com/apache/nuttx/issues/13303
> >
> > Do you think I should investigate the configurations further, or could
> > there be something in NuttX that’s masking interrupts during sleep
> > (possibly related to the RTC)?
> >
> > Em qua., 13 de nov. de 2024 às 09:45, Tiago Medicci Serrano <
> > tiago.medi...@gmail.com> escreveu:
> >
> > > Hi Felipe,
> > >
> > > Please check the occurrences of `CONFIG_PM_ENABLE`
> > > <
> > >
> >
> https://github.com/espressif/esp-idf/blob/2c8de044a3c61a060c70d4072d2606e216be81d4/components/esp_wifi/esp32c6/esp_adapter.c#L282
> > > >
> > > on ESP-IDF's Wi-Fi driver of ESP32-C6. Its counterpart in NuttX would
> be
> > > `CONFIG_PM`
> > > <
> > >
> >
> https://github.com/apache/incubator-nuttx/blob/b3727f67bee3ab1550157c1bd4101168a7689ff3/arch/risc-v/src/esp32c6/esp_wifi_adapter.c#L1544
> > > >.
> > > Note that `wifi_apb80m_request`
> > > <
> > >
> >
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> > > >
> > > is not defined anywhere in NuttX, so I suppose `CONFIG_PM` is not
> enabled
> > > in your configuration.
> > >
> > > My suggestion: using ESP-IDF, try the Wi-Fi "as-is" (without the light
> > > sleep enabled) and save the generated `sdkconfig.h`. Try the same with
> > > light sleep enabled: validate its behavior/power consumption and save
> the
> > > newer `sdkconfig.h`. Compare both to check which variables were
> > introduced
> > > and, then, check the Wi-Fi-related sources (especially under
> > > `components/esp-wifi`
> > > <
> > >
> >
> https://github.com/espressif/esp-idf/tree/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi
> > > >,
> > > but check other occurrences outside this folder too!). The same
> > > implementation should be introduced in NuttX (the one related to `
> > > wifi_apb80m_request
> > > <
> > >
> >
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> > > >`
> > > is just one of them, others may be necessary). Also, I recommend adding
> > the
> > > configs to `esp-hal-3rdparty/nuttx/esp32c6/include/sdkconfig.h`
> > > conditionally (if NuttX's `CONFIG_PM` is defined, you define ESP-IDF's
> > > related configs on it).
> > >
> > > I hope this helps.
> > >
> > > Best regards,
> > >
> > > Em ter., 12 de nov. de 2024 às 09:33, Felipe Moura Oliveira <
> > > moura@gmail.com> escreveu:
> > >
> > > > Hello Tiago.
> > > >
> > > > When I am using WIFI config and enabling Auto-Sleep, the mcu can no
> > > longer
> > > > wake up from light sleep, so it ends up restarting because of WD.
> > > >
> > > > Em ter., 12 de nov. d

Re: What is the right way to add PM to esp32c6

2024-11-13 Thread Tiago Medicci Serrano
Hi Felipe, thanks for making it clearer.

I don't see any reason why Wi-Fi would interfere with the interruption
detection (that issue I solved earlier regarding the interrupt allocator
isn't related here). You can check if the interruption is triggered by
checking it on GDB. Did you check that?

Another "quick" test would be disabling (perhaps `ifdown wlanX` would be
enough) the Wi-Fi before entering light-sleep.

But, at the end of the day, Ivan stated that:

To conclude, if you need to keep Wi-Fi connection (especially with Wi-Fi 6
> and ITWT), do not use esp_light_sleep_start) and let the system use the
> automatic light sleep mode, instead. In this case association with the AP
> will be maintained.


We can't assume how light sleep would work on NuttX with Wi-Fi/BT enabled:
we can't say it would work the same way. He said clearly that it isn't
supposed to be used like that, even on ESP-IDF. Automatic light sleep would
be more appropriate in that case.

Best regards,

Em qua., 13 de nov. de 2024 às 13:36, Felipe Moura Oliveira <
moura@gmail.com> escreveu:

> Hi Tiago,
>
> I realize I didn’t express myself clearly before. What I meant to say is
> that I believe it’s possible to put the MCU to sleep without modifying the
> WiFi power manager settings. Looking at this post: https://github.com
> /espressif/esp-idf/issues/11550, you’ll notice that putting the MCU to
> sleep without managing the wireless connection will cause it to lose
> communication, but the MCU should still be able to wake up.
>
> I’m hesitant to fully implement the power manager at this stage because I
> really believe the issue is related to the lack of interrupt detection
> during sleep when WiFi is in the project.
>
> Could you check the link I sent and let me know if you really think it’s
> necessary to have the power manager active to put the MCU to sleep while
> the wireless communication drivers are still running?
>
> Em qua., 13 de nov. de 2024 às 11:26, Tiago Medicci Serrano <
> tiago.medi...@gmail.com> escreveu:
>
> > Hi Felipe,
> >
> > I don't think they are separate features, please check this
> documentation:
> >
> >
> https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-reference/system/sleep_modes.html
> >
> > If I understood correctly, you still need PM for using light sleep with
> RF.
> >
> > Best regards,
> >
> > Em qua., 13 de nov. de 2024 às 10:36, Felipe Moura Oliveira <
> > moura@gmail.com> escreveu:
> >
> > > Hi Tiago,
> > >
> > > I believe the issue isn’t related to the CONFIG_PM macro. From what I
> > > understand, it’s possible to independently put both the MCU and the
> WiFi
> > > transceiver into low-power mode.
> > >
> > > For now, I’d like to focus on putting only the MCU to sleep by calling
> > the
> > > esp_light_sleep_start() function, similar to what was done here: https
> > > ://github.com/roblatour/SolarWeatherStationII/blob
> > > /cdf04e0e0bd931095254a0b11b61f24d7053ff7d/main/main.c#L845
> > >
> > > As you can see in the code above, the implementation simply calls the
> > sleep
> > > function without handling any power manager related to WiFi, and in
> this
> > > case, the MCU can wake from sleep. However, in my implementation, this
> > > isn’t happening. I’ve implemented wake-up via timer and button and
> > > validated it using a standard configuration. When using WiFi, though,
> the
> > > MCU isn’t receiving interrupts.
> > >
> > > I’m concerned that something similar to what happened here might be
> > > occurring: https://github.com/apache/nuttx/issues/13303
> > >
> > > Do you think I should investigate the configurations further, or could
> > > there be something in NuttX that’s masking interrupts during sleep
> > > (possibly related to the RTC)?
> > >
> > > Em qua., 13 de nov. de 2024 às 09:45, Tiago Medicci Serrano <
> > > tiago.medi...@gmail.com> escreveu:
> > >
> > > > Hi Felipe,
> > > >
> > > > Please check the occurrences of `CONFIG_PM_ENABLE`
> > > > <
> > > >
> > >
> >
> https://github.com/espressif/esp-idf/blob/2c8de044a3c61a060c70d4072d2606e216be81d4/components/esp_wifi/esp32c6/esp_adapter.c#L282
> > > > >
> > > > on ESP-IDF's Wi-Fi driver of ESP32-C6. Its counterpart in NuttX would
> > be
> > > > `CONFIG_PM`
> > > > <
> > > >
> > >
> >
> https://github.com/apache/incubator-nuttx/blob/b3727f67bee3ab1550157c1bd4101168a7689ff3/arch/risc-v/src/esp32c6/esp_wifi_adapter.c#L1544
> > > > >.
> > > > Note that `wifi_apb80m_request`
> > > > <
> > > >
> > >
> >
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> > > > >
> > > > is not defined anywhere in NuttX, so I suppose `CONFIG_PM` is not
> > enabled
> > > > in your configuration.
> > > >
> > > > My suggestion: using ESP-IDF, try the Wi-Fi "as-is" (without the
> light
> > > > sleep enabled) and save the generated `sdkconfig.h`. Try the same
> with
> > > > light sleep enabled: validate its behavior/power consumption and save
> > the
> > > > newer `s

Re: What is the right way to add PM to esp32c6

2024-11-13 Thread Alan C. Assis
Hi Tiago,

I think the issue could be related to the GPIO RTC: the GPIO pins have
different interruption configurations in normal mode and low power mode
(called GPIO RTC mode).

Maybe it could be the root cause of the issue, but not idea why WiFi is
interfering on it (since it works when WiFi is not used).

BR,

Alan

On Wed, Nov 13, 2024 at 2:11 PM Tiago Medicci Serrano <
tiago.medi...@gmail.com> wrote:

> Hi Felipe, thanks for making it clearer.
>
> I don't see any reason why Wi-Fi would interfere with the interruption
> detection (that issue I solved earlier regarding the interrupt allocator
> isn't related here). You can check if the interruption is triggered by
> checking it on GDB. Did you check that?
>
> Another "quick" test would be disabling (perhaps `ifdown wlanX` would be
> enough) the Wi-Fi before entering light-sleep.
>
> But, at the end of the day, Ivan stated that:
>
> To conclude, if you need to keep Wi-Fi connection (especially with Wi-Fi 6
> > and ITWT), do not use esp_light_sleep_start) and let the system use the
> > automatic light sleep mode, instead. In this case association with the AP
> > will be maintained.
>
>
> We can't assume how light sleep would work on NuttX with Wi-Fi/BT enabled:
> we can't say it would work the same way. He said clearly that it isn't
> supposed to be used like that, even on ESP-IDF. Automatic light sleep would
> be more appropriate in that case.
>
> Best regards,
>
> Em qua., 13 de nov. de 2024 às 13:36, Felipe Moura Oliveira <
> moura@gmail.com> escreveu:
>
> > Hi Tiago,
> >
> > I realize I didn’t express myself clearly before. What I meant to say is
> > that I believe it’s possible to put the MCU to sleep without modifying
> the
> > WiFi power manager settings. Looking at this post: https://github.com
> > /espressif/esp-idf/issues/11550, you’ll notice that putting the MCU to
> > sleep without managing the wireless connection will cause it to lose
> > communication, but the MCU should still be able to wake up.
> >
> > I’m hesitant to fully implement the power manager at this stage because I
> > really believe the issue is related to the lack of interrupt detection
> > during sleep when WiFi is in the project.
> >
> > Could you check the link I sent and let me know if you really think it’s
> > necessary to have the power manager active to put the MCU to sleep while
> > the wireless communication drivers are still running?
> >
> > Em qua., 13 de nov. de 2024 às 11:26, Tiago Medicci Serrano <
> > tiago.medi...@gmail.com> escreveu:
> >
> > > Hi Felipe,
> > >
> > > I don't think they are separate features, please check this
> > documentation:
> > >
> > >
> >
> https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-reference/system/sleep_modes.html
> > >
> > > If I understood correctly, you still need PM for using light sleep with
> > RF.
> > >
> > > Best regards,
> > >
> > > Em qua., 13 de nov. de 2024 às 10:36, Felipe Moura Oliveira <
> > > moura@gmail.com> escreveu:
> > >
> > > > Hi Tiago,
> > > >
> > > > I believe the issue isn’t related to the CONFIG_PM macro. From what I
> > > > understand, it’s possible to independently put both the MCU and the
> > WiFi
> > > > transceiver into low-power mode.
> > > >
> > > > For now, I’d like to focus on putting only the MCU to sleep by
> calling
> > > the
> > > > esp_light_sleep_start() function, similar to what was done here:
> https
> > > > ://github.com/roblatour/SolarWeatherStationII/blob
> > > > /cdf04e0e0bd931095254a0b11b61f24d7053ff7d/main/main.c#L845
> > > >
> > > > As you can see in the code above, the implementation simply calls the
> > > sleep
> > > > function without handling any power manager related to WiFi, and in
> > this
> > > > case, the MCU can wake from sleep. However, in my implementation,
> this
> > > > isn’t happening. I’ve implemented wake-up via timer and button and
> > > > validated it using a standard configuration. When using WiFi, though,
> > the
> > > > MCU isn’t receiving interrupts.
> > > >
> > > > I’m concerned that something similar to what happened here might be
> > > > occurring: https://github.com/apache/nuttx/issues/13303
> > > >
> > > > Do you think I should investigate the configurations further, or
> could
> > > > there be something in NuttX that’s masking interrupts during sleep
> > > > (possibly related to the RTC)?
> > > >
> > > > Em qua., 13 de nov. de 2024 às 09:45, Tiago Medicci Serrano <
> > > > tiago.medi...@gmail.com> escreveu:
> > > >
> > > > > Hi Felipe,
> > > > >
> > > > > Please check the occurrences of `CONFIG_PM_ENABLE`
> > > > > <
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-idf/blob/2c8de044a3c61a060c70d4072d2606e216be81d4/components/esp_wifi/esp32c6/esp_adapter.c#L282
> > > > > >
> > > > > on ESP-IDF's Wi-Fi driver of ESP32-C6. Its counterpart in NuttX
> would
> > > be
> > > > > `CONFIG_PM`
> > > > > <
> > > > >
> > > >
> > >
> >
> https://github.com/apache/incubator-nuttx/blob/b3727f67bee3ab1550157c1bd4101168a7689ff3/arch/r

Re: What is the right way to add PM to esp32c6

2024-11-13 Thread Felipe Moura Oliveira
Hi Tiago,

I believe the issue isn’t related to the CONFIG_PM macro. From what I
understand, it’s possible to independently put both the MCU and the WiFi
transceiver into low-power mode.

For now, I’d like to focus on putting only the MCU to sleep by calling the
esp_light_sleep_start() function, similar to what was done here: https
://github.com/roblatour/SolarWeatherStationII/blob
/cdf04e0e0bd931095254a0b11b61f24d7053ff7d/main/main.c#L845

As you can see in the code above, the implementation simply calls the sleep
function without handling any power manager related to WiFi, and in this
case, the MCU can wake from sleep. However, in my implementation, this
isn’t happening. I’ve implemented wake-up via timer and button and
validated it using a standard configuration. When using WiFi, though, the
MCU isn’t receiving interrupts.

I’m concerned that something similar to what happened here might be
occurring: https://github.com/apache/nuttx/issues/13303

Do you think I should investigate the configurations further, or could
there be something in NuttX that’s masking interrupts during sleep
(possibly related to the RTC)?

Em qua., 13 de nov. de 2024 às 09:45, Tiago Medicci Serrano <
tiago.medi...@gmail.com> escreveu:

> Hi Felipe,
>
> Please check the occurrences of `CONFIG_PM_ENABLE`
> <
> https://github.com/espressif/esp-idf/blob/2c8de044a3c61a060c70d4072d2606e216be81d4/components/esp_wifi/esp32c6/esp_adapter.c#L282
> >
> on ESP-IDF's Wi-Fi driver of ESP32-C6. Its counterpart in NuttX would be
> `CONFIG_PM`
> <
> https://github.com/apache/incubator-nuttx/blob/b3727f67bee3ab1550157c1bd4101168a7689ff3/arch/risc-v/src/esp32c6/esp_wifi_adapter.c#L1544
> >.
> Note that `wifi_apb80m_request`
> <
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> >
> is not defined anywhere in NuttX, so I suppose `CONFIG_PM` is not enabled
> in your configuration.
>
> My suggestion: using ESP-IDF, try the Wi-Fi "as-is" (without the light
> sleep enabled) and save the generated `sdkconfig.h`. Try the same with
> light sleep enabled: validate its behavior/power consumption and save the
> newer `sdkconfig.h`. Compare both to check which variables were introduced
> and, then, check the Wi-Fi-related sources (especially under
> `components/esp-wifi`
> <
> https://github.com/espressif/esp-idf/tree/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi
> >,
> but check other occurrences outside this folder too!). The same
> implementation should be introduced in NuttX (the one related to `
> wifi_apb80m_request
> <
> https://github.com/espressif/esp-idf/blob/cf2bdb08f4aa583a816771eb99aa2815c2434cc1/components/esp_wifi/src/wifi_init.c#L456
> >`
> is just one of them, others may be necessary). Also, I recommend adding the
> configs to `esp-hal-3rdparty/nuttx/esp32c6/include/sdkconfig.h`
> conditionally (if NuttX's `CONFIG_PM` is defined, you define ESP-IDF's
> related configs on it).
>
> I hope this helps.
>
> Best regards,
>
> Em ter., 12 de nov. de 2024 às 09:33, Felipe Moura Oliveira <
> moura@gmail.com> escreveu:
>
> > Hello Tiago.
> >
> > When I am using WIFI config and enabling Auto-Sleep, the mcu can no
> longer
> > wake up from light sleep, so it ends up restarting because of WD.
> >
> > Em ter., 12 de nov. de 2024 às 08:47, Tiago Medicci Serrano <
> > tiago.medi...@gmail.com> escreveu:
> >
> > > Hi Felipe,
> > >
> > > What exactly is your problem regarding light sleep and Wi-Fi?
> > >
> > > If I'm not mistaken, some hooks must be implemented in the Wi-Fi driver
> > > too. My suggestion: take a look at IDF's implementation and try light
> > sleep
> > > with/without Wi-Fi: compare the `sdkconfig.h` enabling/disabling light
> > > sleep. Then, check which configs are on the Wi-Fi related files.
> > >
> > > Looking towards hearing from you soon.
> > >
> > > Best regards,
> > >
> > > Em seg., 11 de nov. de 2024 às 17:52, Felipe Moura Oliveira <
> > > moura@gmail.com> escreveu:
> > >
> > > > Hello everyone,
> > > >
> > > > Tiago, actually I am able to compile and run light sleep using nsh
> > > > configuration, but it's failing when I am using wifi configuration. I
> > > tried
> > > > it by myself but I cannot solve it, can you give some help please?
> > > > I push a draft to you look it easely:
> > > > https://github.com/apache/nuttx/pull/14726
> > > >
> > > > You can config a work example running the following cmd:
> > > > ./tools/configure.sh esp32c6-devkitc:sleep_test
> > > >
> > > > This config basically is nsh + CONFIG_ESP_AUTO_SLEEP=y and
> > > > CONFIG_EXAMPLES_HELLO=y. Auto_sleep is new config done by me,
> > > >
> > > > Please, change hello_main.c with the code below:
> > > >
> > > >
> > > >
> > >
> >
> /
> > > > * apps/examples/hello/hello_main.c
> > > > */
> > > >
> > > > #include 
> > > > #include 
> > > > #include 
> > > > #include 
> > > > #include 
> > > > #inc

Porting NuttX to Pine64's new Oz64 SG2000 RISC-V SBC

2024-11-13 Thread Lee, Lup Yuen
Today we have a barebones port of NuttX to Sophgo SG2000 RISC-V SoC. But
many drivers are missing: GPIO, WiFi, Ethernet, MIPI CSI / DSI, ...
https://lupyuen.github.io/articles/sg2000

Pine64 has offered to sponsor some Oz64 SG2000 SBCs for porting these
drivers: https://pine64.org/documentation/Oz64/

Interested? Please drop me a note. Thanks!

Lup


rcS startup-script

2024-11-13 Thread Simon Filgis
Dear all,

I have a board with rcS startup-script and etc/init.d automount.

After updating nuttx it does not work any more.

https://github.com/apache/nuttx/pull/11498
https://github.com/apache/nuttx/pull/11572

Following the guidance in the PR I was able to have my rsS script again
automated. And I can run it from nsh with ". rcS".

But it is not autostarting any more. Before nsh there is the following
output:
"init: open failed: 2"

Does anybody have a thought about this?

Regards,

Simon


--
Hard- and Softwaredevelopment Consultant

Geschäftsführung: Simon Filgis
USt-IdNr.: DE305343278
ISO9001:2015