You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Felipe Moura Oliveira <mo...@gmail.com> on 2024/10/23 15:37:18 UTC
What is the right way to add PM to esp32c6
Hello everyone,
Our project has reached a point where we need the Power Manager
functionality, which is not yet available in the ESP32C6. I am studying to
start the implementation, but I am confused about the correct way to
approach this.
There is a Power Manager implementation for the ESP32C3, but it seems to
follow the legacy methodology. In fact, the file esp32c3_idle.c is located
in the path arch/risc-v/src/esp32c3-legacy. In this methodology, functions
are re-implemented from the Espressif driver. For example, the function
esp32c3_light_sleep_start(), which is currently available in
esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
I tried using the implementations from esp-hal-3rdparty to develop the
Power Manager for the ESP32C6 in NuttX, but the files still have many
dependencies on items that are not present in NuttX.
My question is: Should I try to make the Power Manager work using the
functions in esp-hal-3rdparty, even if it requires making changes to the
3rd-party code? Or should I re-implement the functions within NuttX, even
if, in this case, there are functions with the same scope and
implementation in different files, where one is compiled, and the other is
not?
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hello Felipe,
We have plans to do that, but for now, we have been investing in bug
fixes and adding more peripherals, so we don't have a schedule for it.
I suggest you open an issue on the repository and report the feature you
want and what you have done so far. Eventually, other users may try to
implement it or, hopefully, more users can engage and it may become a
priority.
Thanks!
Em ter., 3 de dez. de 2024 às 12:42, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello Tiago,
>
> Do you have any expectation to add this feature to esp32c6?
> I am planning my tasks and I may be better waiting for Espressif to provide
> it.
>
>
> Em qua., 13 de nov. de 2024 às 16:38, Alan C. Assis <ac...@gmail.com>
> escreveu:
>
> > 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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > > > > > > > #include <stdio.h>
> > > > > > > > > > #include <stdint.h>
> > > > > > > > > > #include <time.h>
> > > > > > > > > > #include <unistd.h>
> > > > > > > > > > #include <pthread.h>
> > > > > > > > > > #include <stdlib.h>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > > > * 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);
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > return NULL;
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > > > * Public Functions
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > > > * main
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > > > > >
> > > > > > > > > > int main(int argc, FAR char *argv[])
> > > > > > > > > > {
> > > > > > > > > > pthread_t threads[NUM_THREADS];
> > > > > > > > > > struct thread_info tinfo[NUM_THREADS];
> > > > > > > > > > int ret;
> > > > > > > > > >
> > > > > > > > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70,
> > 25};
> > > > > > > > > >
> > > > > > > > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > > > > > > > {
> > > > > > > > > > tinfo[i].thread_id = i + 1;
> > > > > > > > > > tinfo[i].sleep_time = sleep_times[i];
> > > > > > > > > >
> > > > > > > > > > ret = pthread_create(&threads[i], NULL, thread_func,
> > > > &tinfo[i]);
> > > > > > > > > > if (ret != 0)
> > > > > > > > > > {
> > > > > > > > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > > > > > > > exit(EXIT_FAILURE);
> > > > > > > > > > }
> > > > > > > > > > }
> > > > > > > > > > int app_ret = 0;
> > > > > > > > > > if (app_ret == -1) {
> > > > > > > > > > printf("Error executing command\n");
> > > > > > > > > > } else {
> > > > > > > > > > printf("Application finished with return code: %d\n",
> > > app_ret);
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > while (1)
> > > > > > > > > > {
> > > > > > > > > > printf("Hello, World!! [Main Thread]\n");
> > > > > > > > > > sleep(10);
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > return 0;
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > You will see output below:
> > > > > > > > > > nsh> hello
> > > > > > > > > > Aplicação finalizou com código de retorno: 0
> > > > > > > > > > Hello, World!! [Main Thread]
> > > > > > > > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido:
> 0
> > > > > segundos
> > > > > > > > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo
> > > decorrido:
> > > > 0
> > > > > > > > segundos
> > > > > > > > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido:
> 0
> > > > > segundos
> > > > > > > > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido:
> 0
> > > > > segundos
> > > > > > > > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido:
> 0
> > > > > segundos
> > > > > > > > > > *pmu_*Hello, World!! [Main Thread]
> > > > > > > > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido:
> 11
> > > > > > segundos
> > > > > > > > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido:
> 16
> > > > > > segundos
> > > > > > > > > >
> > > > > > > > > > I was able to power consumption below 1 mA when mcu is in
> > > idle
> > > > > > mode,
> > > > > > > so
> > > > > > > > > it
> > > > > > > > > > is in light sleep.
> > > > > > > > > >
> > > > > > > > > > Later, making a distclean, running wifi config and adding
> > > > > > > > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you
> > will
> > > > see
> > > > > > > that
> > > > > > > > > the
> > > > > > > > > > mcu goes to sleep and not return.
> > > > > > > > > >
> > > > > > > > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci
> Serrano
> > <
> > > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >
> > > > > > > > > > > Hi Felipe, good to hear about your progress here!
> > > > > > > > > > >
> > > > > > > > > > > These functions are ROM-defined functions. By checking
> > the
> > > > TRM,
> > > > > > you
> > > > > > > > can
> > > > > > > > > > see
> > > > > > > > > > > a read-only flash partition that holds some functions
> > > (widely
> > > > > > used
> > > > > > > > > > > functions, like malloc and internal functions).
> > > > > > > > > > >
> > > > > > > > > > > ets_get_cpu_frequency
> > > > > > > > > > > <
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > > > > > > > >
> > > > > > > > > > > is
> > > > > > > > > > > one of these internal functions. They are defined
> > directly
> > > at
> > > > > the
> > > > > > > > > linker
> > > > > > > > > > > script.
> > > > > > > > > > >
> > > > > > > > > > > If I understood correctly, these functions are crashing
> > > when
> > > > > it's
> > > > > > > > being
> > > > > > > > > > > called, right? If so, can you:
> > > > > > > > > > >
> > > > > > > > > > > 1. Share the crash dump
> > > > > > > > > > > 2. Use GDB and try to check where/why it fails: it
> may
> > > > > trying
> > > > > > to
> > > > > > > > > > access
> > > > > > > > > > > some prohibited memory region or even trying to call
> > an
> > > > > > > > unregistered
> > > > > > > > > > > callback.
> > > > > > > > > > >
> > > > > > > > > > > Thanks!
> > > > > > > > > > >
> > > > > > > > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura
> > Oliveira
> > > <
> > > > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >
> > > > > > > > > > > > Hello everyone,
> > > > > > > > > > > >
> > > > > > > > > > > > Tiago, I am trying to work with light sleep for now,
> > > after
> > > > it
> > > > > > > work
> > > > > > > > > will
> > > > > > > > > > > go
> > > > > > > > > > > > ahead with deep sleep. To run in light sleep I don't
> > need
> > > > to
> > > > > > > change
> > > > > > > > > > > linker
> > > > > > > > > > > > so I was able to build and flash without "image"
> > issues.
> > > > > > > > > > > > Now I am facing other kind of issue:
> > > > > > > > > > > > Some functions refers to "ets" function and I don't
> > know
> > > > how
> > > > > > > handle
> > > > > > > > > > this,
> > > > > > > > > > > > for instance:
> > > > > > > > > > > >
> > > > > > > > > > > > /**
> > > > > > > > > > > > * @brief Get the real CPU ticks per us
> > > > > > > > > > > > *
> > > > > > > > > > > > * @return CPU ticks per us
> > > > > > > > > > > > */
> > > > > > > > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > > > > > > > >
> > > > > > > > > > > > This function is necessary in the *sleep_modes.c*
> file.
> > > > > During
> > > > > > > > > execute
> > > > > > > > > > > code
> > > > > > > > > > > > I am facing crash when this function is called, its
> > > happen
> > > > > > > because
> > > > > > > > > its
> > > > > > > > > > > > implementation is a reference to other function:
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > > > > > > > ( *esp_rom_get_cpu_ticks_per_us* =
> > ets_get_cpu_frequency
> > > );
> > > > > > > > > > > >
> > > > > > > > > > > > I cannot find *ets_get_cpu_frequency*, so how should
> I
> > > > handle
> > > > > > it?
> > > > > > > > > > > >
> > > > > > > > > > > > PS: I have another situation like this, when I try to
> > > call
> > > > > > > > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards.
> > > > > > > > > > > >
> > > > > > > > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura
> > > > Oliveira <
> > > > > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >
> > > > > > > > > > > > > Hello Tiago.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Please look de draft here:
> > > > > > > > > > https://github.com/apache/nuttx/pull/14548
> > > > > > > > > > > > >
> > > > > > > > > > > > > This branch will refer to the updated 3rd-party in
> my
> > > > repo.
> > > > > > > > > > > > >
> > > > > > > > > > > > > You only need to enable PM in menuconfig and it
> will
> > be
> > > > > > enough
> > > > > > > to
> > > > > > > > > see
> > > > > > > > > > > > > changes.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci
> > > > > Serrano <
> > > > > > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > > >
> > > > > > > > > > > > >> Hi Felipe,
> > > > > > > > > > > > >>
> > > > > > > > > > > > >> Can you share your PR as a draft on GH to make it
> > > easier
> > > > > to
> > > > > > > > check
> > > > > > > > > > the
> > > > > > > > > > > > >> files
> > > > > > > > > > > > >> (and the build process)?
> > > > > > > > > > > > >>
> > > > > > > > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura
> > > > > Oliveira
> > > > > > <
> > > > > > > > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > > >>
> > > > > > > > > > > > >> > Hello Tiago,
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >> > I "finished" the port, but after it my esp32c6
> dev
> > > kit
> > > > > is
> > > > > > > > > > resetting.
> > > > > > > > > > > > >> Maybe
> > > > > > > > > > > > >> > the issue is related my changes in
> > > > > > > > > > > > >> >
> > > > > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> > > > > > > Can
> > > > > > > > > you
> > > > > > > > > > > give
> > > > > > > > > > > > >> some
> > > > > > > > > > > > >> > tips about how to go ahead?
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >> > Below you can see nuttx report:
> > > > > > > > > > > > >> > Build:Sep 19 2022
> > > > > > > > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f
> > > > (SPI_FAST_FLASH_BOOT)
> > > > > > > > > > > > >> > Saved PC:0x40018bea
> > > > > > > > > > > > >> > SPIWP:0xee
> > > > > > > > > > > > >> > mode:DIO, clock div:2
> > > > > > > > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > > > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > > > > > > > >> > load:0x50000000,len:0x20
> > > > > > > > > > > > >> > load:0x5000001e,len:0x24
> > > > > > > > > > > > >> > Invalid image block, can't boot.
> > > > > > > > > > > > >> > ets_main.c 331
> > > > > > > > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe
> Moura
> > > > > > Oliveira
> > > > > > > <
> > > > > > > > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >> > > Hello everyone,
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> > > I was able to solve linker issues, editing the
> > > > linker
> > > > > by
> > > > > > > > > > myself. I
> > > > > > > > > > > > >> need
> > > > > > > > > > > > >> > to
> > > > > > > > > > > > >> > > finish more than one build issue before
> testing
> > > it,
> > > > > so I
> > > > > > > > will
> > > > > > > > > > see
> > > > > > > > > > > > if I
> > > > > > > > > > > > >> > made
> > > > > > > > > > > > >> > > the right changes in linker.
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe
> > Moura
> > > > > > > Oliveira
> > > > > > > > <
> > > > > > > > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> I have made progress with the build issue I
> was
> > > > > > > > encountering
> > > > > > > > > > and
> > > > > > > > > > > am
> > > > > > > > > > > > >> now
> > > > > > > > > > > > >> > >> "stuck" at what I believe is one of the final
> > > > > stages. I
> > > > > > > am
> > > > > > > > > > > > >> experiencing
> > > > > > > > > > > > >> > the
> > > > > > > > > > > > >> > >> following compilation error:
> > > > > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > > > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > > > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > > > > >>
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > > > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > > > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > > > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined
> > > > reference
> > > > > to
> > > > > > > > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > sleep_modes.c:(.rtc.text.4+0x4):
> > > > > > > > undefined
> > > > > > > > > > > > >> reference
> > > > > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > sleep_modes.c:(.rtc.text.4+0x8):
> > > > > > > > undefined
> > > > > > > > > > > > >> reference
> > > > > > > > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > sleep_modes.c:(.rtc.text.4+0xc):
> > > > > > > > undefined
> > > > > > > > > > > > >> reference
> > > > > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >>
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > > > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > > > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined
> > reference
> > > > to
> > > > > > > > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > sleep_cpu.c:(.iram1.8+0x21e):
> > > > > > > undefined
> > > > > > > > > > > > reference
> > > > > > > > > > > > >> to
> > > > > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > sleep_cpu.c:(.iram1.8+0x226):
> > > > > > > undefined
> > > > > > > > > > > > reference
> > > > > > > > > > > > >> to
> > > > > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> Focusing on the item _rtc_text_start, I see
> > that
> > > it
> > > > > is
> > > > > > > > > defined
> > > > > > > > > > in
> > > > > > > > > > > > the
> > > > > > > > > > > > >> > >> file:
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > >
> > > > >
> > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > > > > >> > >> sections.ld.in
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> However, I am unsure how to add this file to
> > the
> > > > > > complete
> > > > > > > > > > linking
> > > > > > > > > > > > >> > >> process. I added this file to hal_esp32c6.mk
> ,
> > > but
> > > > I
> > > > > > > > received
> > > > > > > > > > the
> > > > > > > > > > > > >> > >> following error:
> > > > > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >>
> > > > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > > > > > > > >> > >>
> > > > > > > src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > > > > >> > >> sections.ld.in.tmp:113 cannot move location
> > > counter
> > > > > > > > backwards
> > > > > > > > > > > (from
> > > > > > > > > > > > >> > >> 40809800 to 40800000)
> > > > > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> Does anyone have any tips or suggestions that
> > > could
> > > > > > help
> > > > > > > me
> > > > > > > > > > move
> > > > > > > > > > > > >> forward
> > > > > > > > > > > > >> > >> with this process?
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> Thank you in advance for your help.
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> *Best regards,*
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago
> > > Medicci
> > > > > > > > Serrano <
> > > > > > > > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >>> Hi Felipe,
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC
> > > driver,
> > > > > so a
> > > > > > > > > > > substitute
> > > > > > > > > > > > >> for
> > > > > > > > > > > > >> > >>> this
> > > > > > > > > > > > >> > >>> function should be part
> > > > > > > > > > > > >> > >>> of
> > > > > > > > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > > > > > > > That
> > > > > > > > > > > > >> being
> > > > > > > > > > > > >> > >>> said, you can either implement it (and
> define
> > it
> > > > as
> > > > > a
> > > > > > > > macro,
> > > > > > > > > > on
> > > > > > > > > > > > >> HAL) or
> > > > > > > > > > > > >> > >>> you
> > > > > > > > > > > > >> > >>> can either ignore these functions related to
> > > GPIO
> > > > > > wakeup
> > > > > > > > > from
> > > > > > > > > > > > sleep
> > > > > > > > > > > > >> for
> > > > > > > > > > > > >> > >>> now
> > > > > > > > > > > > >> > >>> (using, for instance, the `#ifndef
> > __NuttX__`).
> > > > It's
> > > > > > up
> > > > > > > to
> > > > > > > > > > you:
> > > > > > > > > > > if
> > > > > > > > > > > > >> the
> > > > > > > > > > > > >> > >>> GPIO
> > > > > > > > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps,
> > > > removing
> > > > > > > this
> > > > > > > > > > > feature
> > > > > > > > > > > > >> for
> > > > > > > > > > > > >> > >>> now.
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >> > >>> Best regards,
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe
> > > Moura
> > > > > > > > Oliveira
> > > > > > > > > <
> > > > > > > > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >> > >>> > Hello Tiago,
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > I would like to discuss further the
> > necessity
> > > of
> > > > > the
> > > > > > > > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file,
> which
> > > is
> > > > > only
> > > > > > > > > > available
> > > > > > > > > > > > in
> > > > > > > > > > > > >> the
> > > > > > > > > > > > >> > >>> IDF.
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > In sleep_modes.c, there is the following
> > code
> > > > > > snippet:
> > > > > > > > > > > > >> > >>> > esp_err_t
> > > > esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > > > > > > > io_mask,
> > > > > > > > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > > > > > > > >> > >>> > {
> > > > > > > > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > > > > > > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > > >> > >>> > // Translate bit map of GPIO numbers into
> > the
> > > > bit
> > > > > > map
> > > > > > > of
> > > > > > > > > RTC
> > > > > > > > > > > IO
> > > > > > > > > > > > >> > numbers
> > > > > > > > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > > > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio,
> io_mask
> > > >>=
> > > > > 1) {
> > > > > > > > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > > > > > > > >> > >>> > continue;
> > > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > > >> > >>> > if
> (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > > > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d",
> > gpio);
> > > > > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > > >> > >>> > rtc_gpio_mask |=
> > BIT(rtc_io_number_get(gpio));
> > > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > I believe this code is essential for
> > > > compilation.
> > > > > > The
> > > > > > > > > > function
> > > > > > > > > > > > >> > >>> > rtc_io_number_get is located at the
> > following
> > > > path
> > > > > > in
> > > > > > > > the
> > > > > > > > > > IDF:
> > > > > > > > > > > > >> > >>> >
> > > > > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > However, the esp_driver_gpio folder is not
> > > > present
> > > > > > in
> > > > > > > > the
> > > > > > > > > > > > >> 3rd-party
> > > > > > > > > > > > >> > >>> > directory. In this case, what is the
> > > recommended
> > > > > > > > procedure
> > > > > > > > > > to
> > > > > > > > > > > > >> > proceed?
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > Thank you again for your support.
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52,
> Tiago
> > > > > Medicci
> > > > > > > > > Serrano
> > > > > > > > > > <
> > > > > > > > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > > Hi Felipe,
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the
> > > component
> > > > > > > `esp_pm`
> > > > > > > > > of
> > > > > > > > > > > > >> ESP-IDF,
> > > > > > > > > > > > >> > >>> which
> > > > > > > > > > > > >> > >>> > is
> > > > > > > > > > > > >> > >>> > > a driver directly. Same for
> > > > > > > > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > > > > > > > >> > >>> (here, a
> > > > > > > > > > > > >> > >>> > > detail: I wasn't able to find this path
> on
> > > > IDF,
> > > > > so
> > > > > > > > make
> > > > > > > > > > sure
> > > > > > > > > > > > you
> > > > > > > > > > > > >> > are
> > > > > > > > > > > > >> > >>> > > checking under the `release/v5.1`
> branch,
> > > > which
> > > > > > the
> > > > > > > > HAL
> > > > > > > > > > was
> > > > > > > > > > > > >> based).
> > > > > > > > > > > > >> > >>> The
> > > > > > > > > > > > >> > >>> > HAL
> > > > > > > > > > > > >> > >>> > > repository doesn't contain ESP-IDF
> > drivers,
> > > > > which
> > > > > > > are
> > > > > > > > > > always
> > > > > > > > > > > > >> > >>> implemented
> > > > > > > > > > > > >> > >>> > on
> > > > > > > > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on
> > HAL
> > > > (at
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >
> > > > > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > The files under
> > > > > > > > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > > > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be
> > used
> > > to
> > > > > > > > implement
> > > > > > > > > > the
> > > > > > > > > > > > >> > driver.
> > > > > > > > > > > > >> > >>> This
> > > > > > > > > > > > >> > >>> > > is, mostly, a wrapping layer under the
> > > > function
> > > > > of
> > > > > > > > > > `esp_rom`
> > > > > > > > > > > > and
> > > > > > > > > > > > >> > >>> `hal`
> > > > > > > > > > > > >> > >>> > > components. However, they still may
> refer
> > to
> > > > > > ESP-IDF
> > > > > > > > > > > drivers.
> > > > > > > > > > > > >> That
> > > > > > > > > > > > >> > >>> being
> > > > > > > > > > > > >> > >>> > > said, you can check if removing such
> > > > > dependencies
> > > > > > is
> > > > > > > > > > > possible.
> > > > > > > > > > > > >> We
> > > > > > > > > > > > >> > >>> usually
> > > > > > > > > > > > >> > >>> > > do that with conditional macros. A good
> > > > starting
> > > > > > > point
> > > > > > > > > is
> > > > > > > > > > to
> > > > > > > > > > > > >> check
> > > > > > > > > > > > >> > >>> for
> > > > > > > > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and
> > > > headers:
> > > > > > we
> > > > > > > > use
> > > > > > > > > > them
> > > > > > > > > > > > to
> > > > > > > > > > > > >> > >>> > remove/add
> > > > > > > > > > > > >> > >>> > > headers and functions that aren't
> > available
> > > on
> > > > > > > > > > NuttX/needed
> > > > > > > > > > > by
> > > > > > > > > > > > >> > NuttX.
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > Best regards,
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46,
> > Felipe
> > > > > Moura
> > > > > > > > > > Oliveira
> > > > > > > > > > > <
> > > > > > > > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > > Hello all,
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > Tiago,
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > I have a question regarding the
> porting
> > > > > process.
> > > > > > > > > > > > >> Specifically, I
> > > > > > > > > > > > >> > >>> need
> > > > > > > > > > > > >> > >>> > to
> > > > > > > > > > > > >> > >>> > > > add the sleep_modes.c file to the
> > > > compilation
> > > > > > > > process.
> > > > > > > > > > Am
> > > > > > > > > > > I
> > > > > > > > > > > > on
> > > > > > > > > > > > >> > the
> > > > > > > > > > > > >> > >>> > right
> > > > > > > > > > > > >> > >>> > > > path with this approach?
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > To achieve this, I modified the
> > > > > hal_esp32c6.mk
> > > > > > > file
> > > > > > > > > by
> > > > > > > > > > > > adding
> > > > > > > > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > > > > > > > >> > >>> > > > However, I am facing some issues:
> within
> > > > > > > > > sleep_modes.c,
> > > > > > > > > > > some
> > > > > > > > > > > > >> > >>> #include
> > > > > > > > > > > > >> > >>> > > > statements reference files that are
> not
> > > > > > available
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > > > >> > 3rd-party
> > > > > > > > > > > > >> > >>> > > > directory but are only present in the
> > IDF.
> > > > For
> > > > > > > > > example:
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > > > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > > > > > > > >> > >>> > > > -
> > > > > components/esp_driver_gpio/include/rtc_io.h
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > I need those includes because
> > > sleep_modes.c
> > > > > uses
> > > > > > > > > > function
> > > > > > > > > > > > from
> > > > > > > > > > > > >> > >>> there.
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > Could you please advise if it's
> possible
> > > to
> > > > > > > > > incorporate
> > > > > > > > > > > > these
> > > > > > > > > > > > >> IDF
> > > > > > > > > > > > >> > >>> > folders
> > > > > > > > > > > > >> > >>> > > > into the 3rd-party directory, or if
> that
> > > > > > approach
> > > > > > > is
> > > > > > > > > not
> > > > > > > > > > > > >> > >>> recommended?
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > Best regards,
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21,
> > > Tiago
> > > > > > > Medicci
> > > > > > > > > > > Serrano
> > > > > > > > > > > > <
> > > > > > > > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > > Hi,
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > Just another note to guide your
> > > > development:
> > > > > > we
> > > > > > > > > don't
> > > > > > > > > > > > >> develop
> > > > > > > > > > > > >> > >>> > anything
> > > > > > > > > > > > >> > >>> > > on
> > > > > > > > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code
> > we
> > > > use
> > > > > > from
> > > > > > > > it
> > > > > > > > > is
> > > > > > > > > > > > >> derived
> > > > > > > > > > > > >> > >>> from
> > > > > > > > > > > > >> > >>> > the
> > > > > > > > > > > > >> > >>> > > > > path
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >>
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > > > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > > > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > > > > > > > >> > >>> > > > except
> > > > > > > > > > > > >> > >>> > > > > for some of the sources files that
> use
> > > the
> > > > > hal
> > > > > > > > > > functions
> > > > > > > > > > > > at
> > > > > > > > > > > > >> > >>> > > > > `components/hal` to implement some
> > > > function
> > > > > we
> > > > > > > may
> > > > > > > > > > use).
> > > > > > > > > > > > You
> > > > > > > > > > > > >> > can
> > > > > > > > > > > > >> > >>> > take a
> > > > > > > > > > > > >> > >>> > > > > look at the branch `
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> >
> > > > > > > > > > >
> > > > > > > >
> > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > > > <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > > > <
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > > > <
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > > > > <
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > > > > > > > <
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > > > > > > > >> <
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > > >
> > > > > > > > > > > > >> > <
> > > > > > > > > > >
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > > > >
> > > > > > > > > > > > >> > >>> <
> > > > > > > > > > > > >>
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >
> > > > > > > > > > > > >> > >>> > <
> > > > > > > > > > > > >> >
> > > > > > > > > > >
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > >
> > > > > > > > > > > > >> > >>> > > <
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >>
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > <
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >>
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > <
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >>
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> > >>> > > > and
> > > > > > > > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > > > > > > > >> > >>> > > > > with
> > > > > faaa46ebfb37fba4250de831efbbf2862958c344
> > > > > > to
> > > > > > > > > check
> > > > > > > > > > > the
> > > > > > > > > > > > >> kind
> > > > > > > > > > > > >> > >>> of
> > > > > > > > > > > > >> > >>> > > > changes
> > > > > > > > > > > > >> > >>> > > > > we do in hal. Essentially, we
> create a
> > > > > wrapper
> > > > > > > > layer
> > > > > > > > > > to
> > > > > > > > > > > > >> make it
> > > > > > > > > > > > >> > >>> > > > independent
> > > > > > > > > > > > >> > >>> > > > > of the host OS.
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > *Drivers must always be implemented
> on
> > > > > NuttX!*
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > That being said, you can either 1)
> try
> > > to
> > > > > > adapt
> > > > > > > > the
> > > > > > > > > > > > >> > >>> implementation of
> > > > > > > > > > > > >> > >>> > > > other
> > > > > > > > > > > > >> > >>> > > > > devices to use the HAL functions or
> 2)
> > > get
> > > > > > some
> > > > > > > > > > > > inspiration
> > > > > > > > > > > > >> on
> > > > > > > > > > > > >> > >>> how
> > > > > > > > > > > > >> > >>> > IDF
> > > > > > > > > > > > >> > >>> > > > > implements PM. I'd stick with the
> 2nd
> > > > option
> > > > > > > > before
> > > > > > > > > > > simply
> > > > > > > > > > > > >> > >>> trying to
> > > > > > > > > > > > >> > >>> > > > adapt
> > > > > > > > > > > > >> > >>> > > > > an existing implementation (from
> > > ESP32-C3
> > > > > > legacy
> > > > > > > > or
> > > > > > > > > > from
> > > > > > > > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > Best regards,
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às
> 13:35,
> > > > Felipe
> > > > > > > Moura
> > > > > > > > > > > > Oliveira
> > > > > > > > > > > > >> <
> > > > > > > > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > > >> > >>> > > > > > Thank you for clarification, I
> will
> > > > follow
> > > > > > > your
> > > > > > > > > > > > >> instructions.
> > > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às
> > 13:01,
> > > > > Tiago
> > > > > > > > > Medicci
> > > > > > > > > > > > >> Serrano <
> > > > > > > > > > > > >> > >>> > > > > > tiago.medicci@gmail.com>
> escreveu:
> > > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > Just complementing: use your
> > forked
> > > > > > version
> > > > > > > of
> > > > > > > > > the
> > > > > > > > > > > HAL
> > > > > > > > > > > > >> > >>> during the
> > > > > > > > > > > > >> > >>> > > > > > > development. As soon as you
> have a
> > > > > working
> > > > > > > > > > version,
> > > > > > > > > > > > you
> > > > > > > > > > > > >> can
> > > > > > > > > > > > >> > >>> > submit
> > > > > > > > > > > > >> > >>> > > on
> > > > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > > > >> > >>> > > > > > > official repository.
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > Best regards,
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às
> > > 12:58,
> > > > > > Tiago
> > > > > > > > > > Medicci
> > > > > > > > > > > > >> > Serrano <
> > > > > > > > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com>
> > escreveu:
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > Thanks for asking! You should
> > > follow
> > > > > the
> > > > > > > > path
> > > > > > > > > > > using
> > > > > > > > > > > > >> the
> > > > > > > > > > > > >> > >>> > functions
> > > > > > > > > > > > >> > >>> > > > on
> > > > > > > > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork
> > the
> > > > > > > > repository
> > > > > > > > > > and
> > > > > > > > > > > > use
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >>
> > > > > > > >
> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="
> > > > git@github.com:
> > > > > > > > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > > > > > > > >> > >>> > > > > > env
> > > > > > > > > > > > >> > >>> > > > > > > > vars (globally or before the
> > make
> > > > > > command)
> > > > > > > > to
> > > > > > > > > > use
> > > > > > > > > > > > your
> > > > > > > > > > > > >> > >>> version
> > > > > > > > > > > > >> > >>> > of
> > > > > > > > > > > > >> > >>> > > > the
> > > > > > > > > > > > >> > >>> > > > > > > HAL.
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > I just wanted to share some
> > > > thoughts:
> > > > > > > using
> > > > > > > > > the
> > > > > > > > > > > HAL
> > > > > > > > > > > > >> > >>> enables us
> > > > > > > > > > > > >> > >>> > to
> > > > > > > > > > > > >> > >>> > > > > make
> > > > > > > > > > > > >> > >>> > > > > > > the
> > > > > > > > > > > > >> > >>> > > > > > > > feature available for all the
> > > > > Espressif
> > > > > > > > > devices
> > > > > > > > > > > > >> (please
> > > > > > > > > > > > >> > >>> don't
> > > > > > > > > > > > >> > >>> > > > bother
> > > > > > > > > > > > >> > >>> > > > > > with
> > > > > > > > > > > > >> > >>> > > > > > > > that now, as soon as you
> submit
> > > it,
> > > > we
> > > > > > can
> > > > > > > > > test
> > > > > > > > > > > for
> > > > > > > > > > > > >> the
> > > > > > > > > > > > >> > >>> other
> > > > > > > > > > > > >> > >>> > > > devices
> > > > > > > > > > > > >> > >>> > > > > > and
> > > > > > > > > > > > >> > >>> > > > > > > > eventually make any
> > adjustments).
> > > > > > Although
> > > > > > > > > it's
> > > > > > > > > > > > >> possible
> > > > > > > > > > > > >> > to
> > > > > > > > > > > > >> > >>> > > > > reimplement
> > > > > > > > > > > > >> > >>> > > > > > > > these functions on NuttX, we
> > don't
> > > > > > > recommend
> > > > > > > > > > that
> > > > > > > > > > > > >> because
> > > > > > > > > > > > >> > >>> of
> > > > > > > > > > > > >> > >>> > the
> > > > > > > > > > > > >> > >>> > > > > first
> > > > > > > > > > > > >> > >>> > > > > > > > statement (the ability to use
> > for
> > > > the
> > > > > > > other
> > > > > > > > > > > > devices):
> > > > > > > > > > > > >> in
> > > > > > > > > > > > >> > >>> that
> > > > > > > > > > > > >> > >>> > > case
> > > > > > > > > > > > >> > >>> > > > we
> > > > > > > > > > > > >> > >>> > > > > > > > wouldn't be able to support
> the
> > > > > feature.
> > > > > > > You
> > > > > > > > > can
> > > > > > > > > > > > take
> > > > > > > > > > > > >> a
> > > > > > > > > > > > >> > >>> look on
> > > > > > > > > > > > >> > >>> > > IDF
> > > > > > > > > > > > >> > >>> > > > > for
> > > > > > > > > > > > >> > >>> > > > > > > > some inspiration on how it's
> > > > > > implemented.
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > Please let me know if you have
> > any
> > > > > > > > questions.
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às
> > > > 12:38,
> > > > > > > Felipe
> > > > > > > > > > Moura
> > > > > > > > > > > > >> > >>> Oliveira <
> > > > > > > > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com>
> escreveu:
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >> Our project has reached a
> point
> > > > where
> > > > > > we
> > > > > > > > need
> > > > > > > > > > the
> > > > > > > > > > > > >> Power
> > > > > > > > > > > > >> > >>> > Manager
> > > > > > > > > > > > >> > >>> > > > > > > >> functionality, which is not
> yet
> > > > > > available
> > > > > > > > in
> > > > > > > > > > the
> > > > > > > > > > > > >> > ESP32C6.
> > > > > > > > > > > > >> > >>> I am
> > > > > > > > > > > > >> > >>> > > > > > studying
> > > > > > > > > > > > >> > >>> > > > > > > to
> > > > > > > > > > > > >> > >>> > > > > > > >> start the implementation,
> but I
> > > am
> > > > > > > confused
> > > > > > > > > > about
> > > > > > > > > > > > the
> > > > > > > > > > > > >> > >>> correct
> > > > > > > > > > > > >> > >>> > > way
> > > > > > > > > > > > >> > >>> > > > to
> > > > > > > > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >> There is a Power Manager
> > > > > implementation
> > > > > > > for
> > > > > > > > > the
> > > > > > > > > > > > >> ESP32C3,
> > > > > > > > > > > > >> > >>> but
> > > > > > > > > > > > >> > >>> > it
> > > > > > > > > > > > >> > >>> > > > > seems
> > > > > > > > > > > > >> > >>> > > > > > to
> > > > > > > > > > > > >> > >>> > > > > > > >> follow the legacy
> methodology.
> > In
> > > > > fact,
> > > > > > > the
> > > > > > > > > > file
> > > > > > > > > > > > >> > >>> > esp32c3_idle.c
> > > > > > > > > > > > >> > >>> > > is
> > > > > > > > > > > > >> > >>> > > > > > > located
> > > > > > > > > > > > >> > >>> > > > > > > >> in the path
> > > > > > > arch/risc-v/src/esp32c3-legacy.
> > > > > > > > > In
> > > > > > > > > > > this
> > > > > > > > > > > > >> > >>> > methodology,
> > > > > > > > > > > > >> > >>> > > > > > > functions
> > > > > > > > > > > > >> > >>> > > > > > > >> are re-implemented from the
> > > > Espressif
> > > > > > > > driver.
> > > > > > > > > > For
> > > > > > > > > > > > >> > >>> example, the
> > > > > > > > > > > > >> > >>> > > > > > function
> > > > > > > > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(),
> > > which
> > > > is
> > > > > > > > > currently
> > > > > > > > > > > > >> > available
> > > > > > > > > > > > >> > >>> in
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >> I tried using the
> > implementations
> > > > > from
> > > > > > > > > > > > >> esp-hal-3rdparty
> > > > > > > > > > > > >> > to
> > > > > > > > > > > > >> > >>> > > develop
> > > > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6
> > in
> > > > > NuttX,
> > > > > > > but
> > > > > > > > > the
> > > > > > > > > > > > files
> > > > > > > > > > > > >> > >>> still
> > > > > > > > > > > > >> > >>> > have
> > > > > > > > > > > > >> > >>> > > > > many
> > > > > > > > > > > > >> > >>> > > > > > > >> dependencies on items that
> are
> > > not
> > > > > > > present
> > > > > > > > in
> > > > > > > > > > > > NuttX.
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >> My question is: Should I try
> to
> > > > make
> > > > > > the
> > > > > > > > > Power
> > > > > > > > > > > > >> Manager
> > > > > > > > > > > > >> > >>> work
> > > > > > > > > > > > >> > >>> > > using
> > > > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > > > >> > >>> > > > > > > >> functions in
> esp-hal-3rdparty,
> > > even
> > > > > if
> > > > > > it
> > > > > > > > > > > requires
> > > > > > > > > > > > >> > making
> > > > > > > > > > > > >> > >>> > > changes
> > > > > > > > > > > > >> > >>> > > > to
> > > > > > > > > > > > >> > >>> > > > > > the
> > > > > > > > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I
> > > > > > re-implement
> > > > > > > > the
> > > > > > > > > > > > >> functions
> > > > > > > > > > > > >> > >>> within
> > > > > > > > > > > > >> > >>> > > > NuttX,
> > > > > > > > > > > > >> > >>> > > > > > > even
> > > > > > > > > > > > >> > >>> > > > > > > >> if, in this case, there are
> > > > functions
> > > > > > > with
> > > > > > > > > the
> > > > > > > > > > > same
> > > > > > > > > > > > >> > scope
> > > > > > > > > > > > >> > >>> and
> > > > > > > > > > > > >> > >>> > > > > > > >> implementation in different
> > > files,
> > > > > > where
> > > > > > > > one
> > > > > > > > > is
> > > > > > > > > > > > >> > compiled,
> > > > > > > > > > > > >> > >>> and
> > > > > > > > > > > > >> > >>> > > the
> > > > > > > > > > > > >> > >>> > > > > > other
> > > > > > > > > > > > >> > >>> > > > > > > is
> > > > > > > > > > > > >> > >>> > > > > > > >> not?
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >> --
> > > > > > > > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > >>> > > > > > > >> *Universidade Federal de
> Minas
> > > > > Gerais*
> > > > > > > > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > > > > > > > >> > >>> >
> > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > > >> > >>> > > > > > > >> <
> > > > > > > > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > --
> > > > > > > > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > > > > > > > >> > >>> > > > > > > > MSc
> Electronics/Microelectronics
> > > > > > > > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886
> > > > > > <+55+(19)+981403886>
> > > > > > > > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > > > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > > > > > > > >> > >>> > > > > > > > <
> > > > > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > --
> > > > > > > > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > > > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > > > > >> > >>> > > > > > > m: +55 (19) 981403886
> > > > > <+55+(19)+981403886>
> > > > > > > > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > > > > > > > >> > >>> > > > > > > Follow me:
> > > > > > > > > > > > >> > >>> > > > > > > <
> > > > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > > >> > >>> > > > > > --
> > > > > > > > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > >>> > > > > > *Universidade Federal de Minas
> > Gerais*
> > > > > > > > > > > > >> > >>> > > > > > Linkedin <
> > > > > > > > > > > > >> >
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > > > > > <
> > > > > > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > --
> > > > > > > > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > > > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > > > > > > > >> > >>> > > > > m: +55 (19) 981403886
> > > <+55+(19)+981403886>
> > > > > > > > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > > > > > > > >> > >>> > > > > Follow me:
> > > > > > > > > > > > >> > >>> > > > > <
> > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > >
> > > > > > > > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > > > --
> > > > > > > > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > >> > >>> > > > Linkedin <
> > > > > > > > > > > > >>
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > > >> > >>> > > > <
> > > > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > --
> > > > > > > > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > > > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > > > > > > > >> > >>> > > m: +55 (19) 981403886
> <+55+(19)+981403886>
> > > > > > > > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > > > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > > > > > > > >> > >>> > > Follow me:
> > > > > > > > > > > > >> > >>> > > <
> > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > >
> > > > > > > > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>> > --
> > > > > > > > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > >> > >>> > Linkedin <
> > > > > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > > >> > >>> > <
> > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > > >> > >>> >
> > > > > > > > > > > > >> > >>>
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >> --
> > > > > > > > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > >> > >> Linkedin <
> > > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > > > >
> > > > > > > > > > > > >> > >> <
> https://twitter.com/FelipeMOliveir?lang=pt-br
> > >
> > > > > > > > > > > > >> > >>
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> > > --
> > > > > > > > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > >> > > Linkedin <
> > > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > > >> > > <
> https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > > >> > >
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >> > --
> > > > > > > > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > > > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > >> > Linkedin <
> > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > > >> >
> > > > > > > > > > > > >>
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > > Linkedin <
> > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > >
> > > > > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > Linkedin <
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > >
> > > > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > >
> > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >
> > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *Felipe Moura de Oliveira*
> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello Tiago,
Do you have any expectation to add this feature to esp32c6?
I am planning my tasks and I may be better waiting for Espressif to provide
it.
Em qua., 13 de nov. de 2024 às 16:38, Alan C. Assis <ac...@gmail.com>
escreveu:
> 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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > > > > > > #include <stdio.h>
> > > > > > > > > #include <stdint.h>
> > > > > > > > > #include <time.h>
> > > > > > > > > #include <unistd.h>
> > > > > > > > > #include <pthread.h>
> > > > > > > > > #include <stdlib.h>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > > * 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);
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > return NULL;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > > * Public Functions
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > > * main
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > > > >
> > > > > > > > > int main(int argc, FAR char *argv[])
> > > > > > > > > {
> > > > > > > > > pthread_t threads[NUM_THREADS];
> > > > > > > > > struct thread_info tinfo[NUM_THREADS];
> > > > > > > > > int ret;
> > > > > > > > >
> > > > > > > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70,
> 25};
> > > > > > > > >
> > > > > > > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > > > > > > {
> > > > > > > > > tinfo[i].thread_id = i + 1;
> > > > > > > > > tinfo[i].sleep_time = sleep_times[i];
> > > > > > > > >
> > > > > > > > > ret = pthread_create(&threads[i], NULL, thread_func,
> > > &tinfo[i]);
> > > > > > > > > if (ret != 0)
> > > > > > > > > {
> > > > > > > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > > > > > > exit(EXIT_FAILURE);
> > > > > > > > > }
> > > > > > > > > }
> > > > > > > > > int app_ret = 0;
> > > > > > > > > if (app_ret == -1) {
> > > > > > > > > printf("Error executing command\n");
> > > > > > > > > } else {
> > > > > > > > > printf("Application finished with return code: %d\n",
> > app_ret);
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > while (1)
> > > > > > > > > {
> > > > > > > > > printf("Hello, World!! [Main Thread]\n");
> > > > > > > > > sleep(10);
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > return 0;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You will see output below:
> > > > > > > > > nsh> hello
> > > > > > > > > Aplicação finalizou com código de retorno: 0
> > > > > > > > > Hello, World!! [Main Thread]
> > > > > > > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0
> > > > segundos
> > > > > > > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo
> > decorrido:
> > > 0
> > > > > > > segundos
> > > > > > > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0
> > > > segundos
> > > > > > > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0
> > > > segundos
> > > > > > > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0
> > > > segundos
> > > > > > > > > *pmu_*Hello, World!! [Main Thread]
> > > > > > > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11
> > > > > segundos
> > > > > > > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16
> > > > > segundos
> > > > > > > > >
> > > > > > > > > I was able to power consumption below 1 mA when mcu is in
> > idle
> > > > > mode,
> > > > > > so
> > > > > > > > it
> > > > > > > > > is in light sleep.
> > > > > > > > >
> > > > > > > > > Later, making a distclean, running wifi config and adding
> > > > > > > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you
> will
> > > see
> > > > > > that
> > > > > > > > the
> > > > > > > > > mcu goes to sleep and not return.
> > > > > > > > >
> > > > > > > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano
> <
> > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > >
> > > > > > > > > > Hi Felipe, good to hear about your progress here!
> > > > > > > > > >
> > > > > > > > > > These functions are ROM-defined functions. By checking
> the
> > > TRM,
> > > > > you
> > > > > > > can
> > > > > > > > > see
> > > > > > > > > > a read-only flash partition that holds some functions
> > (widely
> > > > > used
> > > > > > > > > > functions, like malloc and internal functions).
> > > > > > > > > >
> > > > > > > > > > ets_get_cpu_frequency
> > > > > > > > > > <
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > > > > > > >
> > > > > > > > > > is
> > > > > > > > > > one of these internal functions. They are defined
> directly
> > at
> > > > the
> > > > > > > > linker
> > > > > > > > > > script.
> > > > > > > > > >
> > > > > > > > > > If I understood correctly, these functions are crashing
> > when
> > > > it's
> > > > > > > being
> > > > > > > > > > called, right? If so, can you:
> > > > > > > > > >
> > > > > > > > > > 1. Share the crash dump
> > > > > > > > > > 2. Use GDB and try to check where/why it fails: it may
> > > > trying
> > > > > to
> > > > > > > > > access
> > > > > > > > > > some prohibited memory region or even trying to call
> an
> > > > > > > unregistered
> > > > > > > > > > callback.
> > > > > > > > > >
> > > > > > > > > > Thanks!
> > > > > > > > > >
> > > > > > > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura
> Oliveira
> > <
> > > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >
> > > > > > > > > > > Hello everyone,
> > > > > > > > > > >
> > > > > > > > > > > Tiago, I am trying to work with light sleep for now,
> > after
> > > it
> > > > > > work
> > > > > > > > will
> > > > > > > > > > go
> > > > > > > > > > > ahead with deep sleep. To run in light sleep I don't
> need
> > > to
> > > > > > change
> > > > > > > > > > linker
> > > > > > > > > > > so I was able to build and flash without "image"
> issues.
> > > > > > > > > > > Now I am facing other kind of issue:
> > > > > > > > > > > Some functions refers to "ets" function and I don't
> know
> > > how
> > > > > > handle
> > > > > > > > > this,
> > > > > > > > > > > for instance:
> > > > > > > > > > >
> > > > > > > > > > > /**
> > > > > > > > > > > * @brief Get the real CPU ticks per us
> > > > > > > > > > > *
> > > > > > > > > > > * @return CPU ticks per us
> > > > > > > > > > > */
> > > > > > > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > > > > > > >
> > > > > > > > > > > This function is necessary in the *sleep_modes.c* file.
> > > > During
> > > > > > > > execute
> > > > > > > > > > code
> > > > > > > > > > > I am facing crash when this function is called, its
> > happen
> > > > > > because
> > > > > > > > its
> > > > > > > > > > > implementation is a reference to other function:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > > > > > > ( *esp_rom_get_cpu_ticks_per_us* =
> ets_get_cpu_frequency
> > );
> > > > > > > > > > >
> > > > > > > > > > > I cannot find *ets_get_cpu_frequency*, so how should I
> > > handle
> > > > > it?
> > > > > > > > > > >
> > > > > > > > > > > PS: I have another situation like this, when I try to
> > call
> > > > > > > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > > > > > > >
> > > > > > > > > > > Regards.
> > > > > > > > > > >
> > > > > > > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura
> > > Oliveira <
> > > > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >
> > > > > > > > > > > > Hello Tiago.
> > > > > > > > > > > >
> > > > > > > > > > > > Please look de draft here:
> > > > > > > > > https://github.com/apache/nuttx/pull/14548
> > > > > > > > > > > >
> > > > > > > > > > > > This branch will refer to the updated 3rd-party in my
> > > repo.
> > > > > > > > > > > >
> > > > > > > > > > > > You only need to enable PM in menuconfig and it will
> be
> > > > > enough
> > > > > > to
> > > > > > > > see
> > > > > > > > > > > > changes.
> > > > > > > > > > > >
> > > > > > > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci
> > > > Serrano <
> > > > > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > >
> > > > > > > > > > > >> Hi Felipe,
> > > > > > > > > > > >>
> > > > > > > > > > > >> Can you share your PR as a draft on GH to make it
> > easier
> > > > to
> > > > > > > check
> > > > > > > > > the
> > > > > > > > > > > >> files
> > > > > > > > > > > >> (and the build process)?
> > > > > > > > > > > >>
> > > > > > > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura
> > > > Oliveira
> > > > > <
> > > > > > > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >>
> > > > > > > > > > > >> > Hello Tiago,
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > I "finished" the port, but after it my esp32c6 dev
> > kit
> > > > is
> > > > > > > > > resetting.
> > > > > > > > > > > >> Maybe
> > > > > > > > > > > >> > the issue is related my changes in
> > > > > > > > > > > >> >
> > > > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> > > > > > Can
> > > > > > > > you
> > > > > > > > > > give
> > > > > > > > > > > >> some
> > > > > > > > > > > >> > tips about how to go ahead?
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > Below you can see nuttx report:
> > > > > > > > > > > >> > Build:Sep 19 2022
> > > > > > > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f
> > > (SPI_FAST_FLASH_BOOT)
> > > > > > > > > > > >> > Saved PC:0x40018bea
> > > > > > > > > > > >> > SPIWP:0xee
> > > > > > > > > > > >> > mode:DIO, clock div:2
> > > > > > > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > > > > > > >> > load:0x50000000,len:0x20
> > > > > > > > > > > >> > load:0x5000001e,len:0x24
> > > > > > > > > > > >> > Invalid image block, can't boot.
> > > > > > > > > > > >> > ets_main.c 331
> > > > > > > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura
> > > > > Oliveira
> > > > > > <
> > > > > > > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > > Hello everyone,
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > I was able to solve linker issues, editing the
> > > linker
> > > > by
> > > > > > > > > myself. I
> > > > > > > > > > > >> need
> > > > > > > > > > > >> > to
> > > > > > > > > > > >> > > finish more than one build issue before testing
> > it,
> > > > so I
> > > > > > > will
> > > > > > > > > see
> > > > > > > > > > > if I
> > > > > > > > > > > >> > made
> > > > > > > > > > > >> > > the right changes in linker.
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe
> Moura
> > > > > > Oliveira
> > > > > > > <
> > > > > > > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> I have made progress with the build issue I was
> > > > > > > encountering
> > > > > > > > > and
> > > > > > > > > > am
> > > > > > > > > > > >> now
> > > > > > > > > > > >> > >> "stuck" at what I believe is one of the final
> > > > stages. I
> > > > > > am
> > > > > > > > > > > >> experiencing
> > > > > > > > > > > >> > the
> > > > > > > > > > > >> > >> following compilation error:
> > > > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined
> > > reference
> > > > to
> > > > > > > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > sleep_modes.c:(.rtc.text.4+0x4):
> > > > > > > undefined
> > > > > > > > > > > >> reference
> > > > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > sleep_modes.c:(.rtc.text.4+0x8):
> > > > > > > undefined
> > > > > > > > > > > >> reference
> > > > > > > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > sleep_modes.c:(.rtc.text.4+0xc):
> > > > > > > undefined
> > > > > > > > > > > >> reference
> > > > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> >
> > > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined
> reference
> > > to
> > > > > > > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> sleep_cpu.c:(.iram1.8+0x21e):
> > > > > > undefined
> > > > > > > > > > > reference
> > > > > > > > > > > >> to
> > > > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > > > >> > >> riscv-none-elf-ld:
> sleep_cpu.c:(.iram1.8+0x226):
> > > > > > undefined
> > > > > > > > > > > reference
> > > > > > > > > > > >> to
> > > > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> Focusing on the item _rtc_text_start, I see
> that
> > it
> > > > is
> > > > > > > > defined
> > > > > > > > > in
> > > > > > > > > > > the
> > > > > > > > > > > >> > >> file:
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >>
> > > > > > > > > >
> > > > > > >
> > > >
> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > > > >> > >> sections.ld.in
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> However, I am unsure how to add this file to
> the
> > > > > complete
> > > > > > > > > linking
> > > > > > > > > > > >> > >> process. I added this file to hal_esp32c6.mk,
> > but
> > > I
> > > > > > > received
> > > > > > > > > the
> > > > > > > > > > > >> > >> following error:
> > > > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> >
> > > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > > > > > > >> > >>
> > > > > > src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > > > >> > >> sections.ld.in.tmp:113 cannot move location
> > counter
> > > > > > > backwards
> > > > > > > > > > (from
> > > > > > > > > > > >> > >> 40809800 to 40800000)
> > > > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> Does anyone have any tips or suggestions that
> > could
> > > > > help
> > > > > > me
> > > > > > > > > move
> > > > > > > > > > > >> forward
> > > > > > > > > > > >> > >> with this process?
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> Thank you in advance for your help.
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> *Best regards,*
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago
> > Medicci
> > > > > > > Serrano <
> > > > > > > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >>> Hi Felipe,
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC
> > driver,
> > > > so a
> > > > > > > > > > substitute
> > > > > > > > > > > >> for
> > > > > > > > > > > >> > >>> this
> > > > > > > > > > > >> > >>> function should be part
> > > > > > > > > > > >> > >>> of
> > > > > > > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > > > > > > That
> > > > > > > > > > > >> being
> > > > > > > > > > > >> > >>> said, you can either implement it (and define
> it
> > > as
> > > > a
> > > > > > > macro,
> > > > > > > > > on
> > > > > > > > > > > >> HAL) or
> > > > > > > > > > > >> > >>> you
> > > > > > > > > > > >> > >>> can either ignore these functions related to
> > GPIO
> > > > > wakeup
> > > > > > > > from
> > > > > > > > > > > sleep
> > > > > > > > > > > >> for
> > > > > > > > > > > >> > >>> now
> > > > > > > > > > > >> > >>> (using, for instance, the `#ifndef
> __NuttX__`).
> > > It's
> > > > > up
> > > > > > to
> > > > > > > > > you:
> > > > > > > > > > if
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > >>> GPIO
> > > > > > > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps,
> > > removing
> > > > > > this
> > > > > > > > > > feature
> > > > > > > > > > > >> for
> > > > > > > > > > > >> > >>> now.
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >> > >>> Best regards,
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe
> > Moura
> > > > > > > Oliveira
> > > > > > > > <
> > > > > > > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >> > >>> > Hello Tiago,
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > I would like to discuss further the
> necessity
> > of
> > > > the
> > > > > > > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which
> > is
> > > > only
> > > > > > > > > available
> > > > > > > > > > > in
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > >>> IDF.
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > In sleep_modes.c, there is the following
> code
> > > > > snippet:
> > > > > > > > > > > >> > >>> > esp_err_t
> > > esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > > > > > > io_mask,
> > > > > > > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > > > > > > >> > >>> > {
> > > > > > > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > > > > > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > >> > >>> > // Translate bit map of GPIO numbers into
> the
> > > bit
> > > > > map
> > > > > > of
> > > > > > > > RTC
> > > > > > > > > > IO
> > > > > > > > > > > >> > numbers
> > > > > > > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask
> > >>=
> > > > 1) {
> > > > > > > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > > > > > > >> > >>> > continue;
> > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d",
> gpio);
> > > > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > >> > >>> > rtc_gpio_mask |=
> BIT(rtc_io_number_get(gpio));
> > > > > > > > > > > >> > >>> > }
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > I believe this code is essential for
> > > compilation.
> > > > > The
> > > > > > > > > function
> > > > > > > > > > > >> > >>> > rtc_io_number_get is located at the
> following
> > > path
> > > > > in
> > > > > > > the
> > > > > > > > > IDF:
> > > > > > > > > > > >> > >>> >
> > > > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > However, the esp_driver_gpio folder is not
> > > present
> > > > > in
> > > > > > > the
> > > > > > > > > > > >> 3rd-party
> > > > > > > > > > > >> > >>> > directory. In this case, what is the
> > recommended
> > > > > > > procedure
> > > > > > > > > to
> > > > > > > > > > > >> > proceed?
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > Thank you again for your support.
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago
> > > > Medicci
> > > > > > > > Serrano
> > > > > > > > > <
> > > > > > > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > > Hi Felipe,
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the
> > component
> > > > > > `esp_pm`
> > > > > > > > of
> > > > > > > > > > > >> ESP-IDF,
> > > > > > > > > > > >> > >>> which
> > > > > > > > > > > >> > >>> > is
> > > > > > > > > > > >> > >>> > > a driver directly. Same for
> > > > > > > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > > > > > > >> > >>> (here, a
> > > > > > > > > > > >> > >>> > > detail: I wasn't able to find this path on
> > > IDF,
> > > > so
> > > > > > > make
> > > > > > > > > sure
> > > > > > > > > > > you
> > > > > > > > > > > >> > are
> > > > > > > > > > > >> > >>> > > checking under the `release/v5.1` branch,
> > > which
> > > > > the
> > > > > > > HAL
> > > > > > > > > was
> > > > > > > > > > > >> based).
> > > > > > > > > > > >> > >>> The
> > > > > > > > > > > >> > >>> > HAL
> > > > > > > > > > > >> > >>> > > repository doesn't contain ESP-IDF
> drivers,
> > > > which
> > > > > > are
> > > > > > > > > always
> > > > > > > > > > > >> > >>> implemented
> > > > > > > > > > > >> > >>> > on
> > > > > > > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on
> HAL
> > > (at
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > >
> > > > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > The files under
> > > > > > > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be
> used
> > to
> > > > > > > implement
> > > > > > > > > the
> > > > > > > > > > > >> > driver.
> > > > > > > > > > > >> > >>> This
> > > > > > > > > > > >> > >>> > > is, mostly, a wrapping layer under the
> > > function
> > > > of
> > > > > > > > > `esp_rom`
> > > > > > > > > > > and
> > > > > > > > > > > >> > >>> `hal`
> > > > > > > > > > > >> > >>> > > components. However, they still may refer
> to
> > > > > ESP-IDF
> > > > > > > > > > drivers.
> > > > > > > > > > > >> That
> > > > > > > > > > > >> > >>> being
> > > > > > > > > > > >> > >>> > > said, you can check if removing such
> > > > dependencies
> > > > > is
> > > > > > > > > > possible.
> > > > > > > > > > > >> We
> > > > > > > > > > > >> > >>> usually
> > > > > > > > > > > >> > >>> > > do that with conditional macros. A good
> > > starting
> > > > > > point
> > > > > > > > is
> > > > > > > > > to
> > > > > > > > > > > >> check
> > > > > > > > > > > >> > >>> for
> > > > > > > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and
> > > headers:
> > > > > we
> > > > > > > use
> > > > > > > > > them
> > > > > > > > > > > to
> > > > > > > > > > > >> > >>> > remove/add
> > > > > > > > > > > >> > >>> > > headers and functions that aren't
> available
> > on
> > > > > > > > > NuttX/needed
> > > > > > > > > > by
> > > > > > > > > > > >> > NuttX.
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > Best regards,
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46,
> Felipe
> > > > Moura
> > > > > > > > > Oliveira
> > > > > > > > > > <
> > > > > > > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > > Hello all,
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > Tiago,
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > I have a question regarding the porting
> > > > process.
> > > > > > > > > > > >> Specifically, I
> > > > > > > > > > > >> > >>> need
> > > > > > > > > > > >> > >>> > to
> > > > > > > > > > > >> > >>> > > > add the sleep_modes.c file to the
> > > compilation
> > > > > > > process.
> > > > > > > > > Am
> > > > > > > > > > I
> > > > > > > > > > > on
> > > > > > > > > > > >> > the
> > > > > > > > > > > >> > >>> > right
> > > > > > > > > > > >> > >>> > > > path with this approach?
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > To achieve this, I modified the
> > > > hal_esp32c6.mk
> > > > > > file
> > > > > > > > by
> > > > > > > > > > > adding
> > > > > > > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > > > > > > >> > >>> > > > However, I am facing some issues: within
> > > > > > > > sleep_modes.c,
> > > > > > > > > > some
> > > > > > > > > > > >> > >>> #include
> > > > > > > > > > > >> > >>> > > > statements reference files that are not
> > > > > available
> > > > > > in
> > > > > > > > the
> > > > > > > > > > > >> > 3rd-party
> > > > > > > > > > > >> > >>> > > > directory but are only present in the
> IDF.
> > > For
> > > > > > > > example:
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > > > > > > >> > >>> > > > -
> > > > components/esp_driver_gpio/include/rtc_io.h
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > I need those includes because
> > sleep_modes.c
> > > > uses
> > > > > > > > > function
> > > > > > > > > > > from
> > > > > > > > > > > >> > >>> there.
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > Could you please advise if it's possible
> > to
> > > > > > > > incorporate
> > > > > > > > > > > these
> > > > > > > > > > > >> IDF
> > > > > > > > > > > >> > >>> > folders
> > > > > > > > > > > >> > >>> > > > into the 3rd-party directory, or if that
> > > > > approach
> > > > > > is
> > > > > > > > not
> > > > > > > > > > > >> > >>> recommended?
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > Best regards,
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21,
> > Tiago
> > > > > > Medicci
> > > > > > > > > > Serrano
> > > > > > > > > > > <
> > > > > > > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > > Hi,
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > Just another note to guide your
> > > development:
> > > > > we
> > > > > > > > don't
> > > > > > > > > > > >> develop
> > > > > > > > > > > >> > >>> > anything
> > > > > > > > > > > >> > >>> > > on
> > > > > > > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code
> we
> > > use
> > > > > from
> > > > > > > it
> > > > > > > > is
> > > > > > > > > > > >> derived
> > > > > > > > > > > >> > >>> from
> > > > > > > > > > > >> > >>> > the
> > > > > > > > > > > >> > >>> > > > > path
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >> >
> > > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > > > > > > >> > >>> > > > except
> > > > > > > > > > > >> > >>> > > > > for some of the sources files that use
> > the
> > > > hal
> > > > > > > > > functions
> > > > > > > > > > > at
> > > > > > > > > > > >> > >>> > > > > `components/hal` to implement some
> > > function
> > > > we
> > > > > > may
> > > > > > > > > use).
> > > > > > > > > > > You
> > > > > > > > > > > >> > can
> > > > > > > > > > > >> > >>> > take a
> > > > > > > > > > > >> > >>> > > > > look at the branch `
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> >
> > > > > > > > > >
> > > > > > >
> > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > > > <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > > > <
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > > > <
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > > > > <
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > > > > > > >> <
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > >
> > > > > > > > > > > >> > <
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > > >
> > > > > > > > > > > >> > >>> <
> > > > > > > > > > > >>
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > > > > > > >> > >>> > <
> > > > > > > > > > > >> >
> > > > > > > > > >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >
> > > > > > > > > > > >> > >>> > > <
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >>
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > > > > > > >> > >>> > > > <
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >>
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > > > > > > >> > >>> > > > > <
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >>
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > >>> > > > and
> > > > > > > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > > > > > > >> > >>> > > > > with
> > > > faaa46ebfb37fba4250de831efbbf2862958c344
> > > > > to
> > > > > > > > check
> > > > > > > > > > the
> > > > > > > > > > > >> kind
> > > > > > > > > > > >> > >>> of
> > > > > > > > > > > >> > >>> > > > changes
> > > > > > > > > > > >> > >>> > > > > we do in hal. Essentially, we create a
> > > > wrapper
> > > > > > > layer
> > > > > > > > > to
> > > > > > > > > > > >> make it
> > > > > > > > > > > >> > >>> > > > independent
> > > > > > > > > > > >> > >>> > > > > of the host OS.
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > *Drivers must always be implemented on
> > > > NuttX!*
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > That being said, you can either 1) try
> > to
> > > > > adapt
> > > > > > > the
> > > > > > > > > > > >> > >>> implementation of
> > > > > > > > > > > >> > >>> > > > other
> > > > > > > > > > > >> > >>> > > > > devices to use the HAL functions or 2)
> > get
> > > > > some
> > > > > > > > > > > inspiration
> > > > > > > > > > > >> on
> > > > > > > > > > > >> > >>> how
> > > > > > > > > > > >> > >>> > IDF
> > > > > > > > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd
> > > option
> > > > > > > before
> > > > > > > > > > simply
> > > > > > > > > > > >> > >>> trying to
> > > > > > > > > > > >> > >>> > > > adapt
> > > > > > > > > > > >> > >>> > > > > an existing implementation (from
> > ESP32-C3
> > > > > legacy
> > > > > > > or
> > > > > > > > > from
> > > > > > > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > Best regards,
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35,
> > > Felipe
> > > > > > Moura
> > > > > > > > > > > Oliveira
> > > > > > > > > > > >> <
> > > > > > > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > >> > >>> > > > > > Thank you for clarification, I will
> > > follow
> > > > > > your
> > > > > > > > > > > >> instructions.
> > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às
> 13:01,
> > > > Tiago
> > > > > > > > Medicci
> > > > > > > > > > > >> Serrano <
> > > > > > > > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > Just complementing: use your
> forked
> > > > > version
> > > > > > of
> > > > > > > > the
> > > > > > > > > > HAL
> > > > > > > > > > > >> > >>> during the
> > > > > > > > > > > >> > >>> > > > > > > development. As soon as you have a
> > > > working
> > > > > > > > > version,
> > > > > > > > > > > you
> > > > > > > > > > > >> can
> > > > > > > > > > > >> > >>> > submit
> > > > > > > > > > > >> > >>> > > on
> > > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > > >> > >>> > > > > > > official repository.
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > Best regards,
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às
> > 12:58,
> > > > > Tiago
> > > > > > > > > Medicci
> > > > > > > > > > > >> > Serrano <
> > > > > > > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com>
> escreveu:
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > Thanks for asking! You should
> > follow
> > > > the
> > > > > > > path
> > > > > > > > > > using
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > >>> > functions
> > > > > > > > > > > >> > >>> > > > on
> > > > > > > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork
> the
> > > > > > > repository
> > > > > > > > > and
> > > > > > > > > > > use
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >>
> > > > > > >
> > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="
> > > git@github.com:
> > > > > > > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > > > > > > >> > >>> > > > > > env
> > > > > > > > > > > >> > >>> > > > > > > > vars (globally or before the
> make
> > > > > command)
> > > > > > > to
> > > > > > > > > use
> > > > > > > > > > > your
> > > > > > > > > > > >> > >>> version
> > > > > > > > > > > >> > >>> > of
> > > > > > > > > > > >> > >>> > > > the
> > > > > > > > > > > >> > >>> > > > > > > HAL.
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > I just wanted to share some
> > > thoughts:
> > > > > > using
> > > > > > > > the
> > > > > > > > > > HAL
> > > > > > > > > > > >> > >>> enables us
> > > > > > > > > > > >> > >>> > to
> > > > > > > > > > > >> > >>> > > > > make
> > > > > > > > > > > >> > >>> > > > > > > the
> > > > > > > > > > > >> > >>> > > > > > > > feature available for all the
> > > > Espressif
> > > > > > > > devices
> > > > > > > > > > > >> (please
> > > > > > > > > > > >> > >>> don't
> > > > > > > > > > > >> > >>> > > > bother
> > > > > > > > > > > >> > >>> > > > > > with
> > > > > > > > > > > >> > >>> > > > > > > > that now, as soon as you submit
> > it,
> > > we
> > > > > can
> > > > > > > > test
> > > > > > > > > > for
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > >>> other
> > > > > > > > > > > >> > >>> > > > devices
> > > > > > > > > > > >> > >>> > > > > > and
> > > > > > > > > > > >> > >>> > > > > > > > eventually make any
> adjustments).
> > > > > Although
> > > > > > > > it's
> > > > > > > > > > > >> possible
> > > > > > > > > > > >> > to
> > > > > > > > > > > >> > >>> > > > > reimplement
> > > > > > > > > > > >> > >>> > > > > > > > these functions on NuttX, we
> don't
> > > > > > recommend
> > > > > > > > > that
> > > > > > > > > > > >> because
> > > > > > > > > > > >> > >>> of
> > > > > > > > > > > >> > >>> > the
> > > > > > > > > > > >> > >>> > > > > first
> > > > > > > > > > > >> > >>> > > > > > > > statement (the ability to use
> for
> > > the
> > > > > > other
> > > > > > > > > > > devices):
> > > > > > > > > > > >> in
> > > > > > > > > > > >> > >>> that
> > > > > > > > > > > >> > >>> > > case
> > > > > > > > > > > >> > >>> > > > we
> > > > > > > > > > > >> > >>> > > > > > > > wouldn't be able to support the
> > > > feature.
> > > > > > You
> > > > > > > > can
> > > > > > > > > > > take
> > > > > > > > > > > >> a
> > > > > > > > > > > >> > >>> look on
> > > > > > > > > > > >> > >>> > > IDF
> > > > > > > > > > > >> > >>> > > > > for
> > > > > > > > > > > >> > >>> > > > > > > > some inspiration on how it's
> > > > > implemented.
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > Please let me know if you have
> any
> > > > > > > questions.
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às
> > > 12:38,
> > > > > > Felipe
> > > > > > > > > Moura
> > > > > > > > > > > >> > >>> Oliveira <
> > > > > > > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >> Our project has reached a point
> > > where
> > > > > we
> > > > > > > need
> > > > > > > > > the
> > > > > > > > > > > >> Power
> > > > > > > > > > > >> > >>> > Manager
> > > > > > > > > > > >> > >>> > > > > > > >> functionality, which is not yet
> > > > > available
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > > >> > ESP32C6.
> > > > > > > > > > > >> > >>> I am
> > > > > > > > > > > >> > >>> > > > > > studying
> > > > > > > > > > > >> > >>> > > > > > > to
> > > > > > > > > > > >> > >>> > > > > > > >> start the implementation, but I
> > am
> > > > > > confused
> > > > > > > > > about
> > > > > > > > > > > the
> > > > > > > > > > > >> > >>> correct
> > > > > > > > > > > >> > >>> > > way
> > > > > > > > > > > >> > >>> > > > to
> > > > > > > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >> There is a Power Manager
> > > > implementation
> > > > > > for
> > > > > > > > the
> > > > > > > > > > > >> ESP32C3,
> > > > > > > > > > > >> > >>> but
> > > > > > > > > > > >> > >>> > it
> > > > > > > > > > > >> > >>> > > > > seems
> > > > > > > > > > > >> > >>> > > > > > to
> > > > > > > > > > > >> > >>> > > > > > > >> follow the legacy methodology.
> In
> > > > fact,
> > > > > > the
> > > > > > > > > file
> > > > > > > > > > > >> > >>> > esp32c3_idle.c
> > > > > > > > > > > >> > >>> > > is
> > > > > > > > > > > >> > >>> > > > > > > located
> > > > > > > > > > > >> > >>> > > > > > > >> in the path
> > > > > > arch/risc-v/src/esp32c3-legacy.
> > > > > > > > In
> > > > > > > > > > this
> > > > > > > > > > > >> > >>> > methodology,
> > > > > > > > > > > >> > >>> > > > > > > functions
> > > > > > > > > > > >> > >>> > > > > > > >> are re-implemented from the
> > > Espressif
> > > > > > > driver.
> > > > > > > > > For
> > > > > > > > > > > >> > >>> example, the
> > > > > > > > > > > >> > >>> > > > > > function
> > > > > > > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(),
> > which
> > > is
> > > > > > > > currently
> > > > > > > > > > > >> > available
> > > > > > > > > > > >> > >>> in
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >> I tried using the
> implementations
> > > > from
> > > > > > > > > > > >> esp-hal-3rdparty
> > > > > > > > > > > >> > to
> > > > > > > > > > > >> > >>> > > develop
> > > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6
> in
> > > > NuttX,
> > > > > > but
> > > > > > > > the
> > > > > > > > > > > files
> > > > > > > > > > > >> > >>> still
> > > > > > > > > > > >> > >>> > have
> > > > > > > > > > > >> > >>> > > > > many
> > > > > > > > > > > >> > >>> > > > > > > >> dependencies on items that are
> > not
> > > > > > present
> > > > > > > in
> > > > > > > > > > > NuttX.
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >> My question is: Should I try to
> > > make
> > > > > the
> > > > > > > > Power
> > > > > > > > > > > >> Manager
> > > > > > > > > > > >> > >>> work
> > > > > > > > > > > >> > >>> > > using
> > > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty,
> > even
> > > > if
> > > > > it
> > > > > > > > > > requires
> > > > > > > > > > > >> > making
> > > > > > > > > > > >> > >>> > > changes
> > > > > > > > > > > >> > >>> > > > to
> > > > > > > > > > > >> > >>> > > > > > the
> > > > > > > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I
> > > > > re-implement
> > > > > > > the
> > > > > > > > > > > >> functions
> > > > > > > > > > > >> > >>> within
> > > > > > > > > > > >> > >>> > > > NuttX,
> > > > > > > > > > > >> > >>> > > > > > > even
> > > > > > > > > > > >> > >>> > > > > > > >> if, in this case, there are
> > > functions
> > > > > > with
> > > > > > > > the
> > > > > > > > > > same
> > > > > > > > > > > >> > scope
> > > > > > > > > > > >> > >>> and
> > > > > > > > > > > >> > >>> > > > > > > >> implementation in different
> > files,
> > > > > where
> > > > > > > one
> > > > > > > > is
> > > > > > > > > > > >> > compiled,
> > > > > > > > > > > >> > >>> and
> > > > > > > > > > > >> > >>> > > the
> > > > > > > > > > > >> > >>> > > > > > other
> > > > > > > > > > > >> > >>> > > > > > > is
> > > > > > > > > > > >> > >>> > > > > > > >> not?
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >> --
> > > > > > > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas
> > > > Gerais*
> > > > > > > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > > > > > > >> > >>> >
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > >> > >>> > > > > > > >> <
> > > > > > > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > --
> > > > > > > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > > > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886
> > > > > <+55+(19)+981403886>
> > > > > > > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > > > > > > >> > >>> > > > > > > > <
> > > > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > --
> > > > > > > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > > > >> > >>> > > > > > > m: +55 (19) 981403886
> > > > <+55+(19)+981403886>
> > > > > > > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > > > > > > >> > >>> > > > > > > Follow me:
> > > > > > > > > > > >> > >>> > > > > > > <
> > > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > > >
> > > > > > > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > >> > >>> > > > > > --
> > > > > > > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > >>> > > > > > *Universidade Federal de Minas
> Gerais*
> > > > > > > > > > > >> > >>> > > > > > Linkedin <
> > > > > > > > > > > >> >
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > > > > > <
> > > > > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > --
> > > > > > > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > > > > > > >> > >>> > > > > m: +55 (19) 981403886
> > <+55+(19)+981403886>
> > > > > > > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > > > > > > >> > >>> > > > > Follow me:
> > > > > > > > > > > >> > >>> > > > > <
> > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > >
> > > > > > > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > > > --
> > > > > > > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > >> > >>> > > > Linkedin <
> > > > > > > > > > > >>
> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > >> > >>> > > > <
> > > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >> > >>> > > >
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > --
> > > > > > > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > > > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > > > > > > >> > >>> > > Follow me:
> > > > > > > > > > > >> > >>> > > <
> > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > >
> > > > > > > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > > > > > > >> > >>> > >
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>> > --
> > > > > > > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > >> > >>> > Linkedin <
> > > > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > >> > >>> > <
> > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >> > >>> >
> > > > > > > > > > > >> > >>>
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >> --
> > > > > > > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > > > > > > >> > >> Linkedin <
> > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > > >
> > > > > > > > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br
> >
> > > > > > > > > > > >> > >>
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > --
> > > > > > > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > >> > > Linkedin <
> > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> >
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > --
> > > > > > > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > >> > Linkedin <
> > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >> >
> > > > > > > > > > > >>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > > Linkedin <
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > >
> > > > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > Linkedin <
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > >
> > > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > >
> > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > *Felipe Moura de Oliveira*
> > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >
> > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Felipe Moura de Oliveira*
> > > > > *Universidade Federal de Minas Gerais*
> > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by "Alan C. Assis" <ac...@gmail.com>.
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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > > > > > #include <stdio.h>
> > > > > > > > #include <stdint.h>
> > > > > > > > #include <time.h>
> > > > > > > > #include <unistd.h>
> > > > > > > > #include <pthread.h>
> > > > > > > > #include <stdlib.h>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > * 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);
> > > > > > > > }
> > > > > > > >
> > > > > > > > return NULL;
> > > > > > > > }
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > * Public Functions
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > > * main
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > > >
> > > > > > > > int main(int argc, FAR char *argv[])
> > > > > > > > {
> > > > > > > > pthread_t threads[NUM_THREADS];
> > > > > > > > struct thread_info tinfo[NUM_THREADS];
> > > > > > > > int ret;
> > > > > > > >
> > > > > > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> > > > > > > >
> > > > > > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > > > > > {
> > > > > > > > tinfo[i].thread_id = i + 1;
> > > > > > > > tinfo[i].sleep_time = sleep_times[i];
> > > > > > > >
> > > > > > > > ret = pthread_create(&threads[i], NULL, thread_func,
> > &tinfo[i]);
> > > > > > > > if (ret != 0)
> > > > > > > > {
> > > > > > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > > > > > exit(EXIT_FAILURE);
> > > > > > > > }
> > > > > > > > }
> > > > > > > > int app_ret = 0;
> > > > > > > > if (app_ret == -1) {
> > > > > > > > printf("Error executing command\n");
> > > > > > > > } else {
> > > > > > > > printf("Application finished with return code: %d\n",
> app_ret);
> > > > > > > > }
> > > > > > > >
> > > > > > > > while (1)
> > > > > > > > {
> > > > > > > > printf("Hello, World!! [Main Thread]\n");
> > > > > > > > sleep(10);
> > > > > > > > }
> > > > > > > >
> > > > > > > > return 0;
> > > > > > > > }
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > You will see output below:
> > > > > > > > nsh> hello
> > > > > > > > Aplicação finalizou com código de retorno: 0
> > > > > > > > Hello, World!! [Main Thread]
> > > > > > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0
> > > segundos
> > > > > > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo
> decorrido:
> > 0
> > > > > > segundos
> > > > > > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0
> > > segundos
> > > > > > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0
> > > segundos
> > > > > > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0
> > > segundos
> > > > > > > > *pmu_*Hello, World!! [Main Thread]
> > > > > > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11
> > > > segundos
> > > > > > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16
> > > > segundos
> > > > > > > >
> > > > > > > > I was able to power consumption below 1 mA when mcu is in
> idle
> > > > mode,
> > > > > so
> > > > > > > it
> > > > > > > > is in light sleep.
> > > > > > > >
> > > > > > > > Later, making a distclean, running wifi config and adding
> > > > > > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will
> > see
> > > > > that
> > > > > > > the
> > > > > > > > mcu goes to sleep and not return.
> > > > > > > >
> > > > > > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > >
> > > > > > > > > Hi Felipe, good to hear about your progress here!
> > > > > > > > >
> > > > > > > > > These functions are ROM-defined functions. By checking the
> > TRM,
> > > > you
> > > > > > can
> > > > > > > > see
> > > > > > > > > a read-only flash partition that holds some functions
> (widely
> > > > used
> > > > > > > > > functions, like malloc and internal functions).
> > > > > > > > >
> > > > > > > > > ets_get_cpu_frequency
> > > > > > > > > <
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > > > > > >
> > > > > > > > > is
> > > > > > > > > one of these internal functions. They are defined directly
> at
> > > the
> > > > > > > linker
> > > > > > > > > script.
> > > > > > > > >
> > > > > > > > > If I understood correctly, these functions are crashing
> when
> > > it's
> > > > > > being
> > > > > > > > > called, right? If so, can you:
> > > > > > > > >
> > > > > > > > > 1. Share the crash dump
> > > > > > > > > 2. Use GDB and try to check where/why it fails: it may
> > > trying
> > > > to
> > > > > > > > access
> > > > > > > > > some prohibited memory region or even trying to call an
> > > > > > unregistered
> > > > > > > > > callback.
> > > > > > > > >
> > > > > > > > > Thanks!
> > > > > > > > >
> > > > > > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira
> <
> > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > >
> > > > > > > > > > Hello everyone,
> > > > > > > > > >
> > > > > > > > > > Tiago, I am trying to work with light sleep for now,
> after
> > it
> > > > > work
> > > > > > > will
> > > > > > > > > go
> > > > > > > > > > ahead with deep sleep. To run in light sleep I don't need
> > to
> > > > > change
> > > > > > > > > linker
> > > > > > > > > > so I was able to build and flash without "image" issues.
> > > > > > > > > > Now I am facing other kind of issue:
> > > > > > > > > > Some functions refers to "ets" function and I don't know
> > how
> > > > > handle
> > > > > > > > this,
> > > > > > > > > > for instance:
> > > > > > > > > >
> > > > > > > > > > /**
> > > > > > > > > > * @brief Get the real CPU ticks per us
> > > > > > > > > > *
> > > > > > > > > > * @return CPU ticks per us
> > > > > > > > > > */
> > > > > > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > > > > > >
> > > > > > > > > > This function is necessary in the *sleep_modes.c* file.
> > > During
> > > > > > > execute
> > > > > > > > > code
> > > > > > > > > > I am facing crash when this function is called, its
> happen
> > > > > because
> > > > > > > its
> > > > > > > > > > implementation is a reference to other function:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > > > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency
> );
> > > > > > > > > >
> > > > > > > > > > I cannot find *ets_get_cpu_frequency*, so how should I
> > handle
> > > > it?
> > > > > > > > > >
> > > > > > > > > > PS: I have another situation like this, when I try to
> call
> > > > > > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > > > > > >
> > > > > > > > > > Regards.
> > > > > > > > > >
> > > > > > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura
> > Oliveira <
> > > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >
> > > > > > > > > > > Hello Tiago.
> > > > > > > > > > >
> > > > > > > > > > > Please look de draft here:
> > > > > > > > https://github.com/apache/nuttx/pull/14548
> > > > > > > > > > >
> > > > > > > > > > > This branch will refer to the updated 3rd-party in my
> > repo.
> > > > > > > > > > >
> > > > > > > > > > > You only need to enable PM in menuconfig and it will be
> > > > enough
> > > > > to
> > > > > > > see
> > > > > > > > > > > changes.
> > > > > > > > > > >
> > > > > > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci
> > > Serrano <
> > > > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > >
> > > > > > > > > > >> Hi Felipe,
> > > > > > > > > > >>
> > > > > > > > > > >> Can you share your PR as a draft on GH to make it
> easier
> > > to
> > > > > > check
> > > > > > > > the
> > > > > > > > > > >> files
> > > > > > > > > > >> (and the build process)?
> > > > > > > > > > >>
> > > > > > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura
> > > Oliveira
> > > > <
> > > > > > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >>
> > > > > > > > > > >> > Hello Tiago,
> > > > > > > > > > >> >
> > > > > > > > > > >> > I "finished" the port, but after it my esp32c6 dev
> kit
> > > is
> > > > > > > > resetting.
> > > > > > > > > > >> Maybe
> > > > > > > > > > >> > the issue is related my changes in
> > > > > > > > > > >> >
> > > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> > > > > Can
> > > > > > > you
> > > > > > > > > give
> > > > > > > > > > >> some
> > > > > > > > > > >> > tips about how to go ahead?
> > > > > > > > > > >> >
> > > > > > > > > > >> > Below you can see nuttx report:
> > > > > > > > > > >> > Build:Sep 19 2022
> > > > > > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f
> > (SPI_FAST_FLASH_BOOT)
> > > > > > > > > > >> > Saved PC:0x40018bea
> > > > > > > > > > >> > SPIWP:0xee
> > > > > > > > > > >> > mode:DIO, clock div:2
> > > > > > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > > > > > >> > load:0x50000000,len:0x20
> > > > > > > > > > >> > load:0x5000001e,len:0x24
> > > > > > > > > > >> > Invalid image block, can't boot.
> > > > > > > > > > >> > ets_main.c 331
> > > > > > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > > > > > >> >
> > > > > > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura
> > > > Oliveira
> > > > > <
> > > > > > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >> >
> > > > > > > > > > >> > > Hello everyone,
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > I was able to solve linker issues, editing the
> > linker
> > > by
> > > > > > > > myself. I
> > > > > > > > > > >> need
> > > > > > > > > > >> > to
> > > > > > > > > > >> > > finish more than one build issue before testing
> it,
> > > so I
> > > > > > will
> > > > > > > > see
> > > > > > > > > > if I
> > > > > > > > > > >> > made
> > > > > > > > > > >> > > the right changes in linker.
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura
> > > > > Oliveira
> > > > > > <
> > > > > > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >> > >
> > > > > > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> I have made progress with the build issue I was
> > > > > > encountering
> > > > > > > > and
> > > > > > > > > am
> > > > > > > > > > >> now
> > > > > > > > > > >> > >> "stuck" at what I believe is one of the final
> > > stages. I
> > > > > am
> > > > > > > > > > >> experiencing
> > > > > > > > > > >> > the
> > > > > > > > > > >> > >> following compilation error:
> > > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined
> > reference
> > > to
> > > > > > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > > > > > >> > >> riscv-none-elf-ld:
> sleep_modes.c:(.rtc.text.4+0x4):
> > > > > > undefined
> > > > > > > > > > >> reference
> > > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > > >> > >> riscv-none-elf-ld:
> sleep_modes.c:(.rtc.text.4+0x8):
> > > > > > undefined
> > > > > > > > > > >> reference
> > > > > > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > > > > > >> > >> riscv-none-elf-ld:
> sleep_modes.c:(.rtc.text.4+0xc):
> > > > > > undefined
> > > > > > > > > > >> reference
> > > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > > >> > >>
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference
> > to
> > > > > > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e):
> > > > > undefined
> > > > > > > > > > reference
> > > > > > > > > > >> to
> > > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226):
> > > > > undefined
> > > > > > > > > > reference
> > > > > > > > > > >> to
> > > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> Focusing on the item _rtc_text_start, I see that
> it
> > > is
> > > > > > > defined
> > > > > > > > in
> > > > > > > > > > the
> > > > > > > > > > >> > >> file:
> > > > > > > > > > >> > >>
> > > > > > > > > > >>
> > > > > > > > >
> > > > > >
> > > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > > >> > >> sections.ld.in
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> However, I am unsure how to add this file to the
> > > > complete
> > > > > > > > linking
> > > > > > > > > > >> > >> process. I added this file to hal_esp32c6.mk,
> but
> > I
> > > > > > received
> > > > > > > > the
> > > > > > > > > > >> > >> following error:
> > > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > > >> > >>
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > > > > > >> > >>
> > > > > src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > > >> > >> sections.ld.in.tmp:113 cannot move location
> counter
> > > > > > backwards
> > > > > > > > > (from
> > > > > > > > > > >> > >> 40809800 to 40800000)
> > > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> Does anyone have any tips or suggestions that
> could
> > > > help
> > > > > me
> > > > > > > > move
> > > > > > > > > > >> forward
> > > > > > > > > > >> > >> with this process?
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> Thank you in advance for your help.
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> *Best regards,*
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago
> Medicci
> > > > > > Serrano <
> > > > > > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >>> Hi Felipe,
> > > > > > > > > > >> > >>>
> > > > > > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC
> driver,
> > > so a
> > > > > > > > > substitute
> > > > > > > > > > >> for
> > > > > > > > > > >> > >>> this
> > > > > > > > > > >> > >>> function should be part
> > > > > > > > > > >> > >>> of
> > > > > > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > > > > > That
> > > > > > > > > > >> being
> > > > > > > > > > >> > >>> said, you can either implement it (and define it
> > as
> > > a
> > > > > > macro,
> > > > > > > > on
> > > > > > > > > > >> HAL) or
> > > > > > > > > > >> > >>> you
> > > > > > > > > > >> > >>> can either ignore these functions related to
> GPIO
> > > > wakeup
> > > > > > > from
> > > > > > > > > > sleep
> > > > > > > > > > >> for
> > > > > > > > > > >> > >>> now
> > > > > > > > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`).
> > It's
> > > > up
> > > > > to
> > > > > > > > you:
> > > > > > > > > if
> > > > > > > > > > >> the
> > > > > > > > > > >> > >>> GPIO
> > > > > > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps,
> > removing
> > > > > this
> > > > > > > > > feature
> > > > > > > > > > >> for
> > > > > > > > > > >> > >>> now.
> > > > > > > > > > >> > >>>
> > > > > > > > > > >> > >>> Best regards,
> > > > > > > > > > >> > >>>
> > > > > > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe
> Moura
> > > > > > Oliveira
> > > > > > > <
> > > > > > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >> > >>>
> > > > > > > > > > >> > >>> > Hello Tiago,
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > I would like to discuss further the necessity
> of
> > > the
> > > > > > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which
> is
> > > only
> > > > > > > > available
> > > > > > > > > > in
> > > > > > > > > > >> the
> > > > > > > > > > >> > >>> IDF.
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > In sleep_modes.c, there is the following code
> > > > snippet:
> > > > > > > > > > >> > >>> > esp_err_t
> > esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > > > > > io_mask,
> > > > > > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > > > > > >> > >>> > {
> > > > > > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > > > > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > > >> > >>> > }
> > > > > > > > > > >> > >>> > // Translate bit map of GPIO numbers into the
> > bit
> > > > map
> > > > > of
> > > > > > > RTC
> > > > > > > > > IO
> > > > > > > > > > >> > numbers
> > > > > > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask
> >>=
> > > 1) {
> > > > > > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > > > > > >> > >>> > continue;
> > > > > > > > > > >> > >>> > }
> > > > > > > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > > >> > >>> > }
> > > > > > > > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > > > > > > > >> > >>> > }
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > I believe this code is essential for
> > compilation.
> > > > The
> > > > > > > > function
> > > > > > > > > > >> > >>> > rtc_io_number_get is located at the following
> > path
> > > > in
> > > > > > the
> > > > > > > > IDF:
> > > > > > > > > > >> > >>> >
> > > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > However, the esp_driver_gpio folder is not
> > present
> > > > in
> > > > > > the
> > > > > > > > > > >> 3rd-party
> > > > > > > > > > >> > >>> > directory. In this case, what is the
> recommended
> > > > > > procedure
> > > > > > > > to
> > > > > > > > > > >> > proceed?
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > Thank you again for your support.
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago
> > > Medicci
> > > > > > > Serrano
> > > > > > > > <
> > > > > > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > > Hi Felipe,
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the
> component
> > > > > `esp_pm`
> > > > > > > of
> > > > > > > > > > >> ESP-IDF,
> > > > > > > > > > >> > >>> which
> > > > > > > > > > >> > >>> > is
> > > > > > > > > > >> > >>> > > a driver directly. Same for
> > > > > > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > > > > > >> > >>> (here, a
> > > > > > > > > > >> > >>> > > detail: I wasn't able to find this path on
> > IDF,
> > > so
> > > > > > make
> > > > > > > > sure
> > > > > > > > > > you
> > > > > > > > > > >> > are
> > > > > > > > > > >> > >>> > > checking under the `release/v5.1` branch,
> > which
> > > > the
> > > > > > HAL
> > > > > > > > was
> > > > > > > > > > >> based).
> > > > > > > > > > >> > >>> The
> > > > > > > > > > >> > >>> > HAL
> > > > > > > > > > >> > >>> > > repository doesn't contain ESP-IDF drivers,
> > > which
> > > > > are
> > > > > > > > always
> > > > > > > > > > >> > >>> implemented
> > > > > > > > > > >> > >>> > on
> > > > > > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL
> > (at
> > > > > > > > > > >> > >>> > >
> > > > > > > > > >
> > > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > The files under
> > > > > > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used
> to
> > > > > > implement
> > > > > > > > the
> > > > > > > > > > >> > driver.
> > > > > > > > > > >> > >>> This
> > > > > > > > > > >> > >>> > > is, mostly, a wrapping layer under the
> > function
> > > of
> > > > > > > > `esp_rom`
> > > > > > > > > > and
> > > > > > > > > > >> > >>> `hal`
> > > > > > > > > > >> > >>> > > components. However, they still may refer to
> > > > ESP-IDF
> > > > > > > > > drivers.
> > > > > > > > > > >> That
> > > > > > > > > > >> > >>> being
> > > > > > > > > > >> > >>> > > said, you can check if removing such
> > > dependencies
> > > > is
> > > > > > > > > possible.
> > > > > > > > > > >> We
> > > > > > > > > > >> > >>> usually
> > > > > > > > > > >> > >>> > > do that with conditional macros. A good
> > starting
> > > > > point
> > > > > > > is
> > > > > > > > to
> > > > > > > > > > >> check
> > > > > > > > > > >> > >>> for
> > > > > > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and
> > headers:
> > > > we
> > > > > > use
> > > > > > > > them
> > > > > > > > > > to
> > > > > > > > > > >> > >>> > remove/add
> > > > > > > > > > >> > >>> > > headers and functions that aren't available
> on
> > > > > > > > NuttX/needed
> > > > > > > > > by
> > > > > > > > > > >> > NuttX.
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > Best regards,
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe
> > > Moura
> > > > > > > > Oliveira
> > > > > > > > > <
> > > > > > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > > Hello all,
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > Tiago,
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > I have a question regarding the porting
> > > process.
> > > > > > > > > > >> Specifically, I
> > > > > > > > > > >> > >>> need
> > > > > > > > > > >> > >>> > to
> > > > > > > > > > >> > >>> > > > add the sleep_modes.c file to the
> > compilation
> > > > > > process.
> > > > > > > > Am
> > > > > > > > > I
> > > > > > > > > > on
> > > > > > > > > > >> > the
> > > > > > > > > > >> > >>> > right
> > > > > > > > > > >> > >>> > > > path with this approach?
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > To achieve this, I modified the
> > > hal_esp32c6.mk
> > > > > file
> > > > > > > by
> > > > > > > > > > adding
> > > > > > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > > > > > >> > >>> > > > However, I am facing some issues: within
> > > > > > > sleep_modes.c,
> > > > > > > > > some
> > > > > > > > > > >> > >>> #include
> > > > > > > > > > >> > >>> > > > statements reference files that are not
> > > > available
> > > > > in
> > > > > > > the
> > > > > > > > > > >> > 3rd-party
> > > > > > > > > > >> > >>> > > > directory but are only present in the IDF.
> > For
> > > > > > > example:
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > > > > > >> > >>> > > > -
> > > components/esp_driver_gpio/include/rtc_io.h
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > I need those includes because
> sleep_modes.c
> > > uses
> > > > > > > > function
> > > > > > > > > > from
> > > > > > > > > > >> > >>> there.
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > Could you please advise if it's possible
> to
> > > > > > > incorporate
> > > > > > > > > > these
> > > > > > > > > > >> IDF
> > > > > > > > > > >> > >>> > folders
> > > > > > > > > > >> > >>> > > > into the 3rd-party directory, or if that
> > > > approach
> > > > > is
> > > > > > > not
> > > > > > > > > > >> > >>> recommended?
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > Best regards,
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21,
> Tiago
> > > > > Medicci
> > > > > > > > > Serrano
> > > > > > > > > > <
> > > > > > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > > Hi,
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > Just another note to guide your
> > development:
> > > > we
> > > > > > > don't
> > > > > > > > > > >> develop
> > > > > > > > > > >> > >>> > anything
> > > > > > > > > > >> > >>> > > on
> > > > > > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we
> > use
> > > > from
> > > > > > it
> > > > > > > is
> > > > > > > > > > >> derived
> > > > > > > > > > >> > >>> from
> > > > > > > > > > >> > >>> > the
> > > > > > > > > > >> > >>> > > > > path
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>>
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > > > > > >> > >>> > > > except
> > > > > > > > > > >> > >>> > > > > for some of the sources files that use
> the
> > > hal
> > > > > > > > functions
> > > > > > > > > > at
> > > > > > > > > > >> > >>> > > > > `components/hal` to implement some
> > function
> > > we
> > > > > may
> > > > > > > > use).
> > > > > > > > > > You
> > > > > > > > > > >> > can
> > > > > > > > > > >> > >>> > take a
> > > > > > > > > > >> > >>> > > > > look at the branch `
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> >
> > > > > > > > >
> > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > > > <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > > > <
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > > > <
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > > > >> <
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > >
> > > > > > > > > > >> > <
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > >
> > > > > > > > > > >> > >>> <
> > > > > > > > > > >>
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > > > > > >> > >>> > <
> > > > > > > > > > >> >
> > > > > > > > >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > > > > > >> > >>> > > <
> > > > > > > > > > >> > >>>
> > > > > > > > > > >>
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > > > > > >> > >>> > > > <
> > > > > > > > > > >> > >>>
> > > > > > > > > > >>
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > > > > > >> > >>> > > > > <
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >>
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > > >> > >
> > > > > > > > > > >> > >>> > > > and
> > > > > > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > > > > > >> > >>> > > > > with
> > > faaa46ebfb37fba4250de831efbbf2862958c344
> > > > to
> > > > > > > check
> > > > > > > > > the
> > > > > > > > > > >> kind
> > > > > > > > > > >> > >>> of
> > > > > > > > > > >> > >>> > > > changes
> > > > > > > > > > >> > >>> > > > > we do in hal. Essentially, we create a
> > > wrapper
> > > > > > layer
> > > > > > > > to
> > > > > > > > > > >> make it
> > > > > > > > > > >> > >>> > > > independent
> > > > > > > > > > >> > >>> > > > > of the host OS.
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > *Drivers must always be implemented on
> > > NuttX!*
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > That being said, you can either 1) try
> to
> > > > adapt
> > > > > > the
> > > > > > > > > > >> > >>> implementation of
> > > > > > > > > > >> > >>> > > > other
> > > > > > > > > > >> > >>> > > > > devices to use the HAL functions or 2)
> get
> > > > some
> > > > > > > > > > inspiration
> > > > > > > > > > >> on
> > > > > > > > > > >> > >>> how
> > > > > > > > > > >> > >>> > IDF
> > > > > > > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd
> > option
> > > > > > before
> > > > > > > > > simply
> > > > > > > > > > >> > >>> trying to
> > > > > > > > > > >> > >>> > > > adapt
> > > > > > > > > > >> > >>> > > > > an existing implementation (from
> ESP32-C3
> > > > legacy
> > > > > > or
> > > > > > > > from
> > > > > > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > Best regards,
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35,
> > Felipe
> > > > > Moura
> > > > > > > > > > Oliveira
> > > > > > > > > > >> <
> > > > > > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > >> > >>> > > > > > Thank you for clarification, I will
> > follow
> > > > > your
> > > > > > > > > > >> instructions.
> > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01,
> > > Tiago
> > > > > > > Medicci
> > > > > > > > > > >> Serrano <
> > > > > > > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > > Just complementing: use your forked
> > > > version
> > > > > of
> > > > > > > the
> > > > > > > > > HAL
> > > > > > > > > > >> > >>> during the
> > > > > > > > > > >> > >>> > > > > > > development. As soon as you have a
> > > working
> > > > > > > > version,
> > > > > > > > > > you
> > > > > > > > > > >> can
> > > > > > > > > > >> > >>> > submit
> > > > > > > > > > >> > >>> > > on
> > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > >> > >>> > > > > > > official repository.
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > > Best regards,
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às
> 12:58,
> > > > Tiago
> > > > > > > > Medicci
> > > > > > > > > > >> > Serrano <
> > > > > > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > Thanks for asking! You should
> follow
> > > the
> > > > > > path
> > > > > > > > > using
> > > > > > > > > > >> the
> > > > > > > > > > >> > >>> > functions
> > > > > > > > > > >> > >>> > > > on
> > > > > > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the
> > > > > > repository
> > > > > > > > and
> > > > > > > > > > use
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >>
> > > > > >
> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="
> > git@github.com:
> > > > > > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > > > > > >> > >>> > > > > > env
> > > > > > > > > > >> > >>> > > > > > > > vars (globally or before the make
> > > > command)
> > > > > > to
> > > > > > > > use
> > > > > > > > > > your
> > > > > > > > > > >> > >>> version
> > > > > > > > > > >> > >>> > of
> > > > > > > > > > >> > >>> > > > the
> > > > > > > > > > >> > >>> > > > > > > HAL.
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > I just wanted to share some
> > thoughts:
> > > > > using
> > > > > > > the
> > > > > > > > > HAL
> > > > > > > > > > >> > >>> enables us
> > > > > > > > > > >> > >>> > to
> > > > > > > > > > >> > >>> > > > > make
> > > > > > > > > > >> > >>> > > > > > > the
> > > > > > > > > > >> > >>> > > > > > > > feature available for all the
> > > Espressif
> > > > > > > devices
> > > > > > > > > > >> (please
> > > > > > > > > > >> > >>> don't
> > > > > > > > > > >> > >>> > > > bother
> > > > > > > > > > >> > >>> > > > > > with
> > > > > > > > > > >> > >>> > > > > > > > that now, as soon as you submit
> it,
> > we
> > > > can
> > > > > > > test
> > > > > > > > > for
> > > > > > > > > > >> the
> > > > > > > > > > >> > >>> other
> > > > > > > > > > >> > >>> > > > devices
> > > > > > > > > > >> > >>> > > > > > and
> > > > > > > > > > >> > >>> > > > > > > > eventually make any adjustments).
> > > > Although
> > > > > > > it's
> > > > > > > > > > >> possible
> > > > > > > > > > >> > to
> > > > > > > > > > >> > >>> > > > > reimplement
> > > > > > > > > > >> > >>> > > > > > > > these functions on NuttX, we don't
> > > > > recommend
> > > > > > > > that
> > > > > > > > > > >> because
> > > > > > > > > > >> > >>> of
> > > > > > > > > > >> > >>> > the
> > > > > > > > > > >> > >>> > > > > first
> > > > > > > > > > >> > >>> > > > > > > > statement (the ability to use for
> > the
> > > > > other
> > > > > > > > > > devices):
> > > > > > > > > > >> in
> > > > > > > > > > >> > >>> that
> > > > > > > > > > >> > >>> > > case
> > > > > > > > > > >> > >>> > > > we
> > > > > > > > > > >> > >>> > > > > > > > wouldn't be able to support the
> > > feature.
> > > > > You
> > > > > > > can
> > > > > > > > > > take
> > > > > > > > > > >> a
> > > > > > > > > > >> > >>> look on
> > > > > > > > > > >> > >>> > > IDF
> > > > > > > > > > >> > >>> > > > > for
> > > > > > > > > > >> > >>> > > > > > > > some inspiration on how it's
> > > > implemented.
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > Please let me know if you have any
> > > > > > questions.
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às
> > 12:38,
> > > > > Felipe
> > > > > > > > Moura
> > > > > > > > > > >> > >>> Oliveira <
> > > > > > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >> Our project has reached a point
> > where
> > > > we
> > > > > > need
> > > > > > > > the
> > > > > > > > > > >> Power
> > > > > > > > > > >> > >>> > Manager
> > > > > > > > > > >> > >>> > > > > > > >> functionality, which is not yet
> > > > available
> > > > > > in
> > > > > > > > the
> > > > > > > > > > >> > ESP32C6.
> > > > > > > > > > >> > >>> I am
> > > > > > > > > > >> > >>> > > > > > studying
> > > > > > > > > > >> > >>> > > > > > > to
> > > > > > > > > > >> > >>> > > > > > > >> start the implementation, but I
> am
> > > > > confused
> > > > > > > > about
> > > > > > > > > > the
> > > > > > > > > > >> > >>> correct
> > > > > > > > > > >> > >>> > > way
> > > > > > > > > > >> > >>> > > > to
> > > > > > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >> There is a Power Manager
> > > implementation
> > > > > for
> > > > > > > the
> > > > > > > > > > >> ESP32C3,
> > > > > > > > > > >> > >>> but
> > > > > > > > > > >> > >>> > it
> > > > > > > > > > >> > >>> > > > > seems
> > > > > > > > > > >> > >>> > > > > > to
> > > > > > > > > > >> > >>> > > > > > > >> follow the legacy methodology. In
> > > fact,
> > > > > the
> > > > > > > > file
> > > > > > > > > > >> > >>> > esp32c3_idle.c
> > > > > > > > > > >> > >>> > > is
> > > > > > > > > > >> > >>> > > > > > > located
> > > > > > > > > > >> > >>> > > > > > > >> in the path
> > > > > arch/risc-v/src/esp32c3-legacy.
> > > > > > > In
> > > > > > > > > this
> > > > > > > > > > >> > >>> > methodology,
> > > > > > > > > > >> > >>> > > > > > > functions
> > > > > > > > > > >> > >>> > > > > > > >> are re-implemented from the
> > Espressif
> > > > > > driver.
> > > > > > > > For
> > > > > > > > > > >> > >>> example, the
> > > > > > > > > > >> > >>> > > > > > function
> > > > > > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(),
> which
> > is
> > > > > > > currently
> > > > > > > > > > >> > available
> > > > > > > > > > >> > >>> in
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >> I tried using the implementations
> > > from
> > > > > > > > > > >> esp-hal-3rdparty
> > > > > > > > > > >> > to
> > > > > > > > > > >> > >>> > > develop
> > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in
> > > NuttX,
> > > > > but
> > > > > > > the
> > > > > > > > > > files
> > > > > > > > > > >> > >>> still
> > > > > > > > > > >> > >>> > have
> > > > > > > > > > >> > >>> > > > > many
> > > > > > > > > > >> > >>> > > > > > > >> dependencies on items that are
> not
> > > > > present
> > > > > > in
> > > > > > > > > > NuttX.
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >> My question is: Should I try to
> > make
> > > > the
> > > > > > > Power
> > > > > > > > > > >> Manager
> > > > > > > > > > >> > >>> work
> > > > > > > > > > >> > >>> > > using
> > > > > > > > > > >> > >>> > > > > the
> > > > > > > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty,
> even
> > > if
> > > > it
> > > > > > > > > requires
> > > > > > > > > > >> > making
> > > > > > > > > > >> > >>> > > changes
> > > > > > > > > > >> > >>> > > > to
> > > > > > > > > > >> > >>> > > > > > the
> > > > > > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I
> > > > re-implement
> > > > > > the
> > > > > > > > > > >> functions
> > > > > > > > > > >> > >>> within
> > > > > > > > > > >> > >>> > > > NuttX,
> > > > > > > > > > >> > >>> > > > > > > even
> > > > > > > > > > >> > >>> > > > > > > >> if, in this case, there are
> > functions
> > > > > with
> > > > > > > the
> > > > > > > > > same
> > > > > > > > > > >> > scope
> > > > > > > > > > >> > >>> and
> > > > > > > > > > >> > >>> > > > > > > >> implementation in different
> files,
> > > > where
> > > > > > one
> > > > > > > is
> > > > > > > > > > >> > compiled,
> > > > > > > > > > >> > >>> and
> > > > > > > > > > >> > >>> > > the
> > > > > > > > > > >> > >>> > > > > > other
> > > > > > > > > > >> > >>> > > > > > > is
> > > > > > > > > > >> > >>> > > > > > > >> not?
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >> --
> > > > > > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas
> > > Gerais*
> > > > > > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > > > > > >> > >>> >
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > >> > >>> > > > > > > >> <
> > > > > > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > --
> > > > > > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886
> > > > <+55+(19)+981403886>
> > > > > > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > > > > > >> > >>> > > > > > > > <
> > > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > > --
> > > > > > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > > >> > >>> > > > > > > m: +55 (19) 981403886
> > > <+55+(19)+981403886>
> > > > > > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > > > > > >> > >>> > > > > > > Follow me:
> > > > > > > > > > >> > >>> > > > > > > <
> > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > >
> > > > > > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > >> > >>> > > > > > --
> > > > > > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > >> > >>> > > > > > Linkedin <
> > > > > > > > > > >> >
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > > > > > <
> > > > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >> > >>> > > > > >
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > --
> > > > > > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > > > > > >> > >>> > > > > m: +55 (19) 981403886
> <+55+(19)+981403886>
> > > > > > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > > > > > >> > >>> > > > > Follow me:
> > > > > > > > > > >> > >>> > > > > <
> > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > >
> > > > > > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > > > > > >> > >>> > > > >
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > > > --
> > > > > > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > >> > >>> > > > Linkedin <
> > > > > > > > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > >> > >>> > > > <
> > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >> > >>> > > >
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > --
> > > > > > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > > > > > >> > >>> > > Follow me:
> > > > > > > > > > >> > >>> > > <
> > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > >
> > > > > > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > > > > > >> > >>> > >
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>> > --
> > > > > > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > > > > > >> > >>> > Linkedin <
> > > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > >> > >>> > <
> https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >> > >>> >
> > > > > > > > > > >> > >>>
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >> --
> > > > > > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > > > > > >> > >> Linkedin <
> > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > >
> > > > > > > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >> > >>
> > > > > > > > > > >> > >
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > --
> > > > > > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > >> > > Linkedin <
> > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >> > >
> > > > > > > > > > >> >
> > > > > > > > > > >> >
> > > > > > > > > > >> > --
> > > > > > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > > > > > >> > Linkedin <
> > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > > Linkedin <
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > >
> > > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > >
> > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >
> > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *Felipe Moura de Oliveira*
> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > > > > #include <stdio.h>
> > > > > > > #include <stdint.h>
> > > > > > > #include <time.h>
> > > > > > > #include <unistd.h>
> > > > > > > #include <pthread.h>
> > > > > > > #include <stdlib.h>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > * 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);
> > > > > > > }
> > > > > > >
> > > > > > > return NULL;
> > > > > > > }
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > * Public Functions
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > > * main
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > > >
> > > > > > > int main(int argc, FAR char *argv[])
> > > > > > > {
> > > > > > > pthread_t threads[NUM_THREADS];
> > > > > > > struct thread_info tinfo[NUM_THREADS];
> > > > > > > int ret;
> > > > > > >
> > > > > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> > > > > > >
> > > > > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > > > > {
> > > > > > > tinfo[i].thread_id = i + 1;
> > > > > > > tinfo[i].sleep_time = sleep_times[i];
> > > > > > >
> > > > > > > ret = pthread_create(&threads[i], NULL, thread_func,
> &tinfo[i]);
> > > > > > > if (ret != 0)
> > > > > > > {
> > > > > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > > > > exit(EXIT_FAILURE);
> > > > > > > }
> > > > > > > }
> > > > > > > int app_ret = 0;
> > > > > > > if (app_ret == -1) {
> > > > > > > printf("Error executing command\n");
> > > > > > > } else {
> > > > > > > printf("Application finished with return code: %d\n", app_ret);
> > > > > > > }
> > > > > > >
> > > > > > > while (1)
> > > > > > > {
> > > > > > > printf("Hello, World!! [Main Thread]\n");
> > > > > > > sleep(10);
> > > > > > > }
> > > > > > >
> > > > > > > return 0;
> > > > > > > }
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > You will see output below:
> > > > > > > nsh> hello
> > > > > > > Aplicação finalizou com código de retorno: 0
> > > > > > > Hello, World!! [Main Thread]
> > > > > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0
> > segundos
> > > > > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido:
> 0
> > > > > segundos
> > > > > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0
> > segundos
> > > > > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0
> > segundos
> > > > > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0
> > segundos
> > > > > > > *pmu_*Hello, World!! [Main Thread]
> > > > > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11
> > > segundos
> > > > > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16
> > > segundos
> > > > > > >
> > > > > > > I was able to power consumption below 1 mA when mcu is in idle
> > > mode,
> > > > so
> > > > > > it
> > > > > > > is in light sleep.
> > > > > > >
> > > > > > > Later, making a distclean, running wifi config and adding
> > > > > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will
> see
> > > > that
> > > > > > the
> > > > > > > mcu goes to sleep and not return.
> > > > > > >
> > > > > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > >
> > > > > > > > Hi Felipe, good to hear about your progress here!
> > > > > > > >
> > > > > > > > These functions are ROM-defined functions. By checking the
> TRM,
> > > you
> > > > > can
> > > > > > > see
> > > > > > > > a read-only flash partition that holds some functions (widely
> > > used
> > > > > > > > functions, like malloc and internal functions).
> > > > > > > >
> > > > > > > > ets_get_cpu_frequency
> > > > > > > > <
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > > > > >
> > > > > > > > is
> > > > > > > > one of these internal functions. They are defined directly at
> > the
> > > > > > linker
> > > > > > > > script.
> > > > > > > >
> > > > > > > > If I understood correctly, these functions are crashing when
> > it's
> > > > > being
> > > > > > > > called, right? If so, can you:
> > > > > > > >
> > > > > > > > 1. Share the crash dump
> > > > > > > > 2. Use GDB and try to check where/why it fails: it may
> > trying
> > > to
> > > > > > > access
> > > > > > > > some prohibited memory region or even trying to call an
> > > > > unregistered
> > > > > > > > callback.
> > > > > > > >
> > > > > > > > Thanks!
> > > > > > > >
> > > > > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > >
> > > > > > > > > Hello everyone,
> > > > > > > > >
> > > > > > > > > Tiago, I am trying to work with light sleep for now, after
> it
> > > > work
> > > > > > will
> > > > > > > > go
> > > > > > > > > ahead with deep sleep. To run in light sleep I don't need
> to
> > > > change
> > > > > > > > linker
> > > > > > > > > so I was able to build and flash without "image" issues.
> > > > > > > > > Now I am facing other kind of issue:
> > > > > > > > > Some functions refers to "ets" function and I don't know
> how
> > > > handle
> > > > > > > this,
> > > > > > > > > for instance:
> > > > > > > > >
> > > > > > > > > /**
> > > > > > > > > * @brief Get the real CPU ticks per us
> > > > > > > > > *
> > > > > > > > > * @return CPU ticks per us
> > > > > > > > > */
> > > > > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > > > > >
> > > > > > > > > This function is necessary in the *sleep_modes.c* file.
> > During
> > > > > > execute
> > > > > > > > code
> > > > > > > > > I am facing crash when this function is called, its happen
> > > > because
> > > > > > its
> > > > > > > > > implementation is a reference to other function:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > > > > > > > >
> > > > > > > > > I cannot find *ets_get_cpu_frequency*, so how should I
> handle
> > > it?
> > > > > > > > >
> > > > > > > > > PS: I have another situation like this, when I try to call
> > > > > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > > > > >
> > > > > > > > > Regards.
> > > > > > > > >
> > > > > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura
> Oliveira <
> > > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > >
> > > > > > > > > > Hello Tiago.
> > > > > > > > > >
> > > > > > > > > > Please look de draft here:
> > > > > > > https://github.com/apache/nuttx/pull/14548
> > > > > > > > > >
> > > > > > > > > > This branch will refer to the updated 3rd-party in my
> repo.
> > > > > > > > > >
> > > > > > > > > > You only need to enable PM in menuconfig and it will be
> > > enough
> > > > to
> > > > > > see
> > > > > > > > > > changes.
> > > > > > > > > >
> > > > > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci
> > Serrano <
> > > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >
> > > > > > > > > >> Hi Felipe,
> > > > > > > > > >>
> > > > > > > > > >> Can you share your PR as a draft on GH to make it easier
> > to
> > > > > check
> > > > > > > the
> > > > > > > > > >> files
> > > > > > > > > >> (and the build process)?
> > > > > > > > > >>
> > > > > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura
> > Oliveira
> > > <
> > > > > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > > > > >>
> > > > > > > > > >> > Hello Tiago,
> > > > > > > > > >> >
> > > > > > > > > >> > I "finished" the port, but after it my esp32c6 dev kit
> > is
> > > > > > > resetting.
> > > > > > > > > >> Maybe
> > > > > > > > > >> > the issue is related my changes in
> > > > > > > > > >> >
> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> > > > Can
> > > > > > you
> > > > > > > > give
> > > > > > > > > >> some
> > > > > > > > > >> > tips about how to go ahead?
> > > > > > > > > >> >
> > > > > > > > > >> > Below you can see nuttx report:
> > > > > > > > > >> > Build:Sep 19 2022
> > > > > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f
> (SPI_FAST_FLASH_BOOT)
> > > > > > > > > >> > Saved PC:0x40018bea
> > > > > > > > > >> > SPIWP:0xee
> > > > > > > > > >> > mode:DIO, clock div:2
> > > > > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > > > > >> > load:0x50000000,len:0x20
> > > > > > > > > >> > load:0x5000001e,len:0x24
> > > > > > > > > >> > Invalid image block, can't boot.
> > > > > > > > > >> > ets_main.c 331
> > > > > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > > > > >> >
> > > > > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura
> > > Oliveira
> > > > <
> > > > > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >> >
> > > > > > > > > >> > > Hello everyone,
> > > > > > > > > >> > >
> > > > > > > > > >> > > I was able to solve linker issues, editing the
> linker
> > by
> > > > > > > myself. I
> > > > > > > > > >> need
> > > > > > > > > >> > to
> > > > > > > > > >> > > finish more than one build issue before testing it,
> > so I
> > > > > will
> > > > > > > see
> > > > > > > > > if I
> > > > > > > > > >> > made
> > > > > > > > > >> > > the right changes in linker.
> > > > > > > > > >> > >
> > > > > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura
> > > > Oliveira
> > > > > <
> > > > > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >> > >
> > > > > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> I have made progress with the build issue I was
> > > > > encountering
> > > > > > > and
> > > > > > > > am
> > > > > > > > > >> now
> > > > > > > > > >> > >> "stuck" at what I believe is one of the final
> > stages. I
> > > > am
> > > > > > > > > >> experiencing
> > > > > > > > > >> > the
> > > > > > > > > >> > >> following compilation error:
> > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined
> reference
> > to
> > > > > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4):
> > > > > undefined
> > > > > > > > > >> reference
> > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8):
> > > > > undefined
> > > > > > > > > >> reference
> > > > > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc):
> > > > > undefined
> > > > > > > > > >> reference
> > > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > > >> > >>
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference
> to
> > > > > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e):
> > > > undefined
> > > > > > > > > reference
> > > > > > > > > >> to
> > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226):
> > > > undefined
> > > > > > > > > reference
> > > > > > > > > >> to
> > > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> Focusing on the item _rtc_text_start, I see that it
> > is
> > > > > > defined
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > >> > >> file:
> > > > > > > > > >> > >>
> > > > > > > > > >>
> > > > > > > >
> > > > >
> > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > >> > >> sections.ld.in
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> However, I am unsure how to add this file to the
> > > complete
> > > > > > > linking
> > > > > > > > > >> > >> process. I added this file to hal_esp32c6.mk, but
> I
> > > > > received
> > > > > > > the
> > > > > > > > > >> > >> following error:
> > > > > > > > > >> > >> LD: nuttx
> > > > > > > > > >> > >>
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > > > > >> > >>
> > > > src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > > >> > >> sections.ld.in.tmp:113 cannot move location counter
> > > > > backwards
> > > > > > > > (from
> > > > > > > > > >> > >> 40809800 to 40800000)
> > > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > > >> > >>
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> Does anyone have any tips or suggestions that could
> > > help
> > > > me
> > > > > > > move
> > > > > > > > > >> forward
> > > > > > > > > >> > >> with this process?
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> Thank you in advance for your help.
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> *Best regards,*
> > > > > > > > > >> > >>
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci
> > > > > Serrano <
> > > > > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >> > >>
> > > > > > > > > >> > >>> Hi Felipe,
> > > > > > > > > >> > >>>
> > > > > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver,
> > so a
> > > > > > > > substitute
> > > > > > > > > >> for
> > > > > > > > > >> > >>> this
> > > > > > > > > >> > >>> function should be part
> > > > > > > > > >> > >>> of
> > > > > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > > > > That
> > > > > > > > > >> being
> > > > > > > > > >> > >>> said, you can either implement it (and define it
> as
> > a
> > > > > macro,
> > > > > > > on
> > > > > > > > > >> HAL) or
> > > > > > > > > >> > >>> you
> > > > > > > > > >> > >>> can either ignore these functions related to GPIO
> > > wakeup
> > > > > > from
> > > > > > > > > sleep
> > > > > > > > > >> for
> > > > > > > > > >> > >>> now
> > > > > > > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`).
> It's
> > > up
> > > > to
> > > > > > > you:
> > > > > > > > if
> > > > > > > > > >> the
> > > > > > > > > >> > >>> GPIO
> > > > > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps,
> removing
> > > > this
> > > > > > > > feature
> > > > > > > > > >> for
> > > > > > > > > >> > >>> now.
> > > > > > > > > >> > >>>
> > > > > > > > > >> > >>> Best regards,
> > > > > > > > > >> > >>>
> > > > > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura
> > > > > Oliveira
> > > > > > <
> > > > > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > > > > >> > >>>
> > > > > > > > > >> > >>> > Hello Tiago,
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > I would like to discuss further the necessity of
> > the
> > > > > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is
> > only
> > > > > > > available
> > > > > > > > > in
> > > > > > > > > >> the
> > > > > > > > > >> > >>> IDF.
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > In sleep_modes.c, there is the following code
> > > snippet:
> > > > > > > > > >> > >>> > esp_err_t
> esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > > > > io_mask,
> > > > > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > > > > >> > >>> > {
> > > > > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > > > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > >> > >>> > }
> > > > > > > > > >> > >>> > // Translate bit map of GPIO numbers into the
> bit
> > > map
> > > > of
> > > > > > RTC
> > > > > > > > IO
> > > > > > > > > >> > numbers
> > > > > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>=
> > 1) {
> > > > > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > > > > >> > >>> > continue;
> > > > > > > > > >> > >>> > }
> > > > > > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > > >> > >>> > }
> > > > > > > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > > > > > > >> > >>> > }
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > I believe this code is essential for
> compilation.
> > > The
> > > > > > > function
> > > > > > > > > >> > >>> > rtc_io_number_get is located at the following
> path
> > > in
> > > > > the
> > > > > > > IDF:
> > > > > > > > > >> > >>> >
> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > However, the esp_driver_gpio folder is not
> present
> > > in
> > > > > the
> > > > > > > > > >> 3rd-party
> > > > > > > > > >> > >>> > directory. In this case, what is the recommended
> > > > > procedure
> > > > > > > to
> > > > > > > > > >> > proceed?
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > Thank you again for your support.
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago
> > Medicci
> > > > > > Serrano
> > > > > > > <
> > > > > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > > Hi Felipe,
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the component
> > > > `esp_pm`
> > > > > > of
> > > > > > > > > >> ESP-IDF,
> > > > > > > > > >> > >>> which
> > > > > > > > > >> > >>> > is
> > > > > > > > > >> > >>> > > a driver directly. Same for
> > > > > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > > > > >> > >>> (here, a
> > > > > > > > > >> > >>> > > detail: I wasn't able to find this path on
> IDF,
> > so
> > > > > make
> > > > > > > sure
> > > > > > > > > you
> > > > > > > > > >> > are
> > > > > > > > > >> > >>> > > checking under the `release/v5.1` branch,
> which
> > > the
> > > > > HAL
> > > > > > > was
> > > > > > > > > >> based).
> > > > > > > > > >> > >>> The
> > > > > > > > > >> > >>> > HAL
> > > > > > > > > >> > >>> > > repository doesn't contain ESP-IDF drivers,
> > which
> > > > are
> > > > > > > always
> > > > > > > > > >> > >>> implemented
> > > > > > > > > >> > >>> > on
> > > > > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL
> (at
> > > > > > > > > >> > >>> > >
> > > > > > > > >
> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > The files under
> > > > > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to
> > > > > implement
> > > > > > > the
> > > > > > > > > >> > driver.
> > > > > > > > > >> > >>> This
> > > > > > > > > >> > >>> > > is, mostly, a wrapping layer under the
> function
> > of
> > > > > > > `esp_rom`
> > > > > > > > > and
> > > > > > > > > >> > >>> `hal`
> > > > > > > > > >> > >>> > > components. However, they still may refer to
> > > ESP-IDF
> > > > > > > > drivers.
> > > > > > > > > >> That
> > > > > > > > > >> > >>> being
> > > > > > > > > >> > >>> > > said, you can check if removing such
> > dependencies
> > > is
> > > > > > > > possible.
> > > > > > > > > >> We
> > > > > > > > > >> > >>> usually
> > > > > > > > > >> > >>> > > do that with conditional macros. A good
> starting
> > > > point
> > > > > > is
> > > > > > > to
> > > > > > > > > >> check
> > > > > > > > > >> > >>> for
> > > > > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and
> headers:
> > > we
> > > > > use
> > > > > > > them
> > > > > > > > > to
> > > > > > > > > >> > >>> > remove/add
> > > > > > > > > >> > >>> > > headers and functions that aren't available on
> > > > > > > NuttX/needed
> > > > > > > > by
> > > > > > > > > >> > NuttX.
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > Best regards,
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe
> > Moura
> > > > > > > Oliveira
> > > > > > > > <
> > > > > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > > Hello all,
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > Tiago,
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > I have a question regarding the porting
> > process.
> > > > > > > > > >> Specifically, I
> > > > > > > > > >> > >>> need
> > > > > > > > > >> > >>> > to
> > > > > > > > > >> > >>> > > > add the sleep_modes.c file to the
> compilation
> > > > > process.
> > > > > > > Am
> > > > > > > > I
> > > > > > > > > on
> > > > > > > > > >> > the
> > > > > > > > > >> > >>> > right
> > > > > > > > > >> > >>> > > > path with this approach?
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > To achieve this, I modified the
> > hal_esp32c6.mk
> > > > file
> > > > > > by
> > > > > > > > > adding
> > > > > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > > > > >> > >>> > > > However, I am facing some issues: within
> > > > > > sleep_modes.c,
> > > > > > > > some
> > > > > > > > > >> > >>> #include
> > > > > > > > > >> > >>> > > > statements reference files that are not
> > > available
> > > > in
> > > > > > the
> > > > > > > > > >> > 3rd-party
> > > > > > > > > >> > >>> > > > directory but are only present in the IDF.
> For
> > > > > > example:
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > > > > >> > >>> > > > -
> > components/esp_driver_gpio/include/rtc_io.h
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > I need those includes because sleep_modes.c
> > uses
> > > > > > > function
> > > > > > > > > from
> > > > > > > > > >> > >>> there.
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > Could you please advise if it's possible to
> > > > > > incorporate
> > > > > > > > > these
> > > > > > > > > >> IDF
> > > > > > > > > >> > >>> > folders
> > > > > > > > > >> > >>> > > > into the 3rd-party directory, or if that
> > > approach
> > > > is
> > > > > > not
> > > > > > > > > >> > >>> recommended?
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > Best regards,
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago
> > > > Medicci
> > > > > > > > Serrano
> > > > > > > > > <
> > > > > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > > Hi,
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > Just another note to guide your
> development:
> > > we
> > > > > > don't
> > > > > > > > > >> develop
> > > > > > > > > >> > >>> > anything
> > > > > > > > > >> > >>> > > on
> > > > > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we
> use
> > > from
> > > > > it
> > > > > > is
> > > > > > > > > >> derived
> > > > > > > > > >> > >>> from
> > > > > > > > > >> > >>> > the
> > > > > > > > > >> > >>> > > > > path
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>>
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > > > > >> > >>> > > > except
> > > > > > > > > >> > >>> > > > > for some of the sources files that use the
> > hal
> > > > > > > functions
> > > > > > > > > at
> > > > > > > > > >> > >>> > > > > `components/hal` to implement some
> function
> > we
> > > > may
> > > > > > > use).
> > > > > > > > > You
> > > > > > > > > >> > can
> > > > > > > > > >> > >>> > take a
> > > > > > > > > >> > >>> > > > > look at the branch `
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> >
> > > > > > > > > >> >
> > > > > > > >
> > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > > > <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > > > <
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > > >> <
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > >
> > > > > > > > > >> > <
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > >
> > > > > > > > > >> > >>> <
> > > > > > > > > >>
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > > >> > >>> > <
> > > > > > > > > >> >
> > > > > > > >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > > > > >> > >>> > > <
> > > > > > > > > >> > >>>
> > > > > > > > > >>
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > > >> > >>> > > > <
> > > > > > > > > >> > >>>
> > > > > > > > > >>
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > > >> > >>> > > > > <
> > > > > > > > > >> > >>> >
> > > > > > > > > >>
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > > >> > >
> > > > > > > > > >> > >>> > > > and
> > > > > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > > > > >> > >>> > > > > with
> > faaa46ebfb37fba4250de831efbbf2862958c344
> > > to
> > > > > > check
> > > > > > > > the
> > > > > > > > > >> kind
> > > > > > > > > >> > >>> of
> > > > > > > > > >> > >>> > > > changes
> > > > > > > > > >> > >>> > > > > we do in hal. Essentially, we create a
> > wrapper
> > > > > layer
> > > > > > > to
> > > > > > > > > >> make it
> > > > > > > > > >> > >>> > > > independent
> > > > > > > > > >> > >>> > > > > of the host OS.
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > *Drivers must always be implemented on
> > NuttX!*
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > That being said, you can either 1) try to
> > > adapt
> > > > > the
> > > > > > > > > >> > >>> implementation of
> > > > > > > > > >> > >>> > > > other
> > > > > > > > > >> > >>> > > > > devices to use the HAL functions or 2) get
> > > some
> > > > > > > > > inspiration
> > > > > > > > > >> on
> > > > > > > > > >> > >>> how
> > > > > > > > > >> > >>> > IDF
> > > > > > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd
> option
> > > > > before
> > > > > > > > simply
> > > > > > > > > >> > >>> trying to
> > > > > > > > > >> > >>> > > > adapt
> > > > > > > > > >> > >>> > > > > an existing implementation (from ESP32-C3
> > > legacy
> > > > > or
> > > > > > > from
> > > > > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > Best regards,
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35,
> Felipe
> > > > Moura
> > > > > > > > > Oliveira
> > > > > > > > > >> <
> > > > > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > > > > >> > >>> > > > > >
> > > > > > > > > >> > >>> > > > > > Thank you for clarification, I will
> follow
> > > > your
> > > > > > > > > >> instructions.
> > > > > > > > > >> > >>> > > > > >
> > > > > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01,
> > Tiago
> > > > > > Medicci
> > > > > > > > > >> Serrano <
> > > > > > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >> > >>> > > > > >
> > > > > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > > Just complementing: use your forked
> > > version
> > > > of
> > > > > > the
> > > > > > > > HAL
> > > > > > > > > >> > >>> during the
> > > > > > > > > >> > >>> > > > > > > development. As soon as you have a
> > working
> > > > > > > version,
> > > > > > > > > you
> > > > > > > > > >> can
> > > > > > > > > >> > >>> > submit
> > > > > > > > > >> > >>> > > on
> > > > > > > > > >> > >>> > > > > the
> > > > > > > > > >> > >>> > > > > > > official repository.
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > > Best regards,
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58,
> > > Tiago
> > > > > > > Medicci
> > > > > > > > > >> > Serrano <
> > > > > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > Thanks for asking! You should follow
> > the
> > > > > path
> > > > > > > > using
> > > > > > > > > >> the
> > > > > > > > > >> > >>> > functions
> > > > > > > > > >> > >>> > > > on
> > > > > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the
> > > > > repository
> > > > > > > and
> > > > > > > > > use
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > >
> > > > > > > > > >>
> > > > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="
> git@github.com:
> > > > > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > > > > >> > >>> > > > > > env
> > > > > > > > > >> > >>> > > > > > > > vars (globally or before the make
> > > command)
> > > > > to
> > > > > > > use
> > > > > > > > > your
> > > > > > > > > >> > >>> version
> > > > > > > > > >> > >>> > of
> > > > > > > > > >> > >>> > > > the
> > > > > > > > > >> > >>> > > > > > > HAL.
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > I just wanted to share some
> thoughts:
> > > > using
> > > > > > the
> > > > > > > > HAL
> > > > > > > > > >> > >>> enables us
> > > > > > > > > >> > >>> > to
> > > > > > > > > >> > >>> > > > > make
> > > > > > > > > >> > >>> > > > > > > the
> > > > > > > > > >> > >>> > > > > > > > feature available for all the
> > Espressif
> > > > > > devices
> > > > > > > > > >> (please
> > > > > > > > > >> > >>> don't
> > > > > > > > > >> > >>> > > > bother
> > > > > > > > > >> > >>> > > > > > with
> > > > > > > > > >> > >>> > > > > > > > that now, as soon as you submit it,
> we
> > > can
> > > > > > test
> > > > > > > > for
> > > > > > > > > >> the
> > > > > > > > > >> > >>> other
> > > > > > > > > >> > >>> > > > devices
> > > > > > > > > >> > >>> > > > > > and
> > > > > > > > > >> > >>> > > > > > > > eventually make any adjustments).
> > > Although
> > > > > > it's
> > > > > > > > > >> possible
> > > > > > > > > >> > to
> > > > > > > > > >> > >>> > > > > reimplement
> > > > > > > > > >> > >>> > > > > > > > these functions on NuttX, we don't
> > > > recommend
> > > > > > > that
> > > > > > > > > >> because
> > > > > > > > > >> > >>> of
> > > > > > > > > >> > >>> > the
> > > > > > > > > >> > >>> > > > > first
> > > > > > > > > >> > >>> > > > > > > > statement (the ability to use for
> the
> > > > other
> > > > > > > > > devices):
> > > > > > > > > >> in
> > > > > > > > > >> > >>> that
> > > > > > > > > >> > >>> > > case
> > > > > > > > > >> > >>> > > > we
> > > > > > > > > >> > >>> > > > > > > > wouldn't be able to support the
> > feature.
> > > > You
> > > > > > can
> > > > > > > > > take
> > > > > > > > > >> a
> > > > > > > > > >> > >>> look on
> > > > > > > > > >> > >>> > > IDF
> > > > > > > > > >> > >>> > > > > for
> > > > > > > > > >> > >>> > > > > > > > some inspiration on how it's
> > > implemented.
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > Please let me know if you have any
> > > > > questions.
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às
> 12:38,
> > > > Felipe
> > > > > > > Moura
> > > > > > > > > >> > >>> Oliveira <
> > > > > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >> Our project has reached a point
> where
> > > we
> > > > > need
> > > > > > > the
> > > > > > > > > >> Power
> > > > > > > > > >> > >>> > Manager
> > > > > > > > > >> > >>> > > > > > > >> functionality, which is not yet
> > > available
> > > > > in
> > > > > > > the
> > > > > > > > > >> > ESP32C6.
> > > > > > > > > >> > >>> I am
> > > > > > > > > >> > >>> > > > > > studying
> > > > > > > > > >> > >>> > > > > > > to
> > > > > > > > > >> > >>> > > > > > > >> start the implementation, but I am
> > > > confused
> > > > > > > about
> > > > > > > > > the
> > > > > > > > > >> > >>> correct
> > > > > > > > > >> > >>> > > way
> > > > > > > > > >> > >>> > > > to
> > > > > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >> There is a Power Manager
> > implementation
> > > > for
> > > > > > the
> > > > > > > > > >> ESP32C3,
> > > > > > > > > >> > >>> but
> > > > > > > > > >> > >>> > it
> > > > > > > > > >> > >>> > > > > seems
> > > > > > > > > >> > >>> > > > > > to
> > > > > > > > > >> > >>> > > > > > > >> follow the legacy methodology. In
> > fact,
> > > > the
> > > > > > > file
> > > > > > > > > >> > >>> > esp32c3_idle.c
> > > > > > > > > >> > >>> > > is
> > > > > > > > > >> > >>> > > > > > > located
> > > > > > > > > >> > >>> > > > > > > >> in the path
> > > > arch/risc-v/src/esp32c3-legacy.
> > > > > > In
> > > > > > > > this
> > > > > > > > > >> > >>> > methodology,
> > > > > > > > > >> > >>> > > > > > > functions
> > > > > > > > > >> > >>> > > > > > > >> are re-implemented from the
> Espressif
> > > > > driver.
> > > > > > > For
> > > > > > > > > >> > >>> example, the
> > > > > > > > > >> > >>> > > > > > function
> > > > > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which
> is
> > > > > > currently
> > > > > > > > > >> > available
> > > > > > > > > >> > >>> in
> > > > > > > > > >> > >>> > > > > > > >>
> > > > esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >> I tried using the implementations
> > from
> > > > > > > > > >> esp-hal-3rdparty
> > > > > > > > > >> > to
> > > > > > > > > >> > >>> > > develop
> > > > > > > > > >> > >>> > > > > the
> > > > > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in
> > NuttX,
> > > > but
> > > > > > the
> > > > > > > > > files
> > > > > > > > > >> > >>> still
> > > > > > > > > >> > >>> > have
> > > > > > > > > >> > >>> > > > > many
> > > > > > > > > >> > >>> > > > > > > >> dependencies on items that are not
> > > > present
> > > > > in
> > > > > > > > > NuttX.
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >> My question is: Should I try to
> make
> > > the
> > > > > > Power
> > > > > > > > > >> Manager
> > > > > > > > > >> > >>> work
> > > > > > > > > >> > >>> > > using
> > > > > > > > > >> > >>> > > > > the
> > > > > > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even
> > if
> > > it
> > > > > > > > requires
> > > > > > > > > >> > making
> > > > > > > > > >> > >>> > > changes
> > > > > > > > > >> > >>> > > > to
> > > > > > > > > >> > >>> > > > > > the
> > > > > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I
> > > re-implement
> > > > > the
> > > > > > > > > >> functions
> > > > > > > > > >> > >>> within
> > > > > > > > > >> > >>> > > > NuttX,
> > > > > > > > > >> > >>> > > > > > > even
> > > > > > > > > >> > >>> > > > > > > >> if, in this case, there are
> functions
> > > > with
> > > > > > the
> > > > > > > > same
> > > > > > > > > >> > scope
> > > > > > > > > >> > >>> and
> > > > > > > > > >> > >>> > > > > > > >> implementation in different files,
> > > where
> > > > > one
> > > > > > is
> > > > > > > > > >> > compiled,
> > > > > > > > > >> > >>> and
> > > > > > > > > >> > >>> > > the
> > > > > > > > > >> > >>> > > > > > other
> > > > > > > > > >> > >>> > > > > > > is
> > > > > > > > > >> > >>> > > > > > > >> not?
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >> --
> > > > > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas
> > Gerais*
> > > > > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > > > > >> > >>> >
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > >> > >>> > > > > > > >> <
> > > > > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > --
> > > > > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886
> > > <+55+(19)+981403886>
> > > > > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > > > > >> > >>> > > > > > > > <
> > > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > > >
> > > > > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > > > > >> > >>> > > > > > > >
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > > --
> > > > > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > > > > >> > >>> > > > > > > m: +55 (19) 981403886
> > <+55+(19)+981403886>
> > > > > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > > > > >> > >>> > > > > > > Follow me:
> > > > > > > > > >> > >>> > > > > > > <
> > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > >
> > > > > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > > > > >> > >>> > > > > > >
> > > > > > > > > >> > >>> > > > > >
> > > > > > > > > >> > >>> > > > > >
> > > > > > > > > >> > >>> > > > > > --
> > > > > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > >> > >>> > > > > > Linkedin <
> > > > > > > > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > > > > > <
> > > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >> > >>> > > > > >
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > --
> > > > > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > > > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > > > > >> > >>> > > > > Follow me:
> > > > > > > > > >> > >>> > > > > <
> > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > >
> > > > > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > > > > >> > >>> > > > >
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > > > --
> > > > > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > >> > >>> > > > Linkedin <
> > > > > > > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > >> > >>> > > > <
> > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >> > >>> > > >
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > --
> > > > > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > > > > >> > >>> > > Follow me:
> > > > > > > > > >> > >>> > > <
> > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > >
> > > > > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > > > > >> > >>> > >
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>> > --
> > > > > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > > > > >> > >>> > Linkedin <
> > > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >> > >>> >
> > > > > > > > > >> > >>>
> > > > > > > > > >> > >>
> > > > > > > > > >> > >>
> > > > > > > > > >> > >> --
> > > > > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > > > > >> > >> Linkedin <
> > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > >
> > > > > > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >> > >>
> > > > > > > > > >> > >
> > > > > > > > > >> > >
> > > > > > > > > >> > > --
> > > > > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > > > > >> > > Linkedin <
> > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >> > >
> > > > > > > > > >> >
> > > > > > > > > >> >
> > > > > > > > > >> > --
> > > > > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > > > > >> > Linkedin <
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > > Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > >
> > > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > >
> > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > *Felipe Moura de Oliveira*
> > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >
> > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Felipe Moura de Oliveira*
> > > > > *Universidade Federal de Minas Gerais*
> > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
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.medicci@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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > > > #include <stdio.h>
> > > > > > #include <stdint.h>
> > > > > > #include <time.h>
> > > > > > #include <unistd.h>
> > > > > > #include <pthread.h>
> > > > > > #include <stdlib.h>
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > * 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);
> > > > > > }
> > > > > >
> > > > > > return NULL;
> > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > * Public Functions
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > > * main
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > > >
> > > > > > int main(int argc, FAR char *argv[])
> > > > > > {
> > > > > > pthread_t threads[NUM_THREADS];
> > > > > > struct thread_info tinfo[NUM_THREADS];
> > > > > > int ret;
> > > > > >
> > > > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> > > > > >
> > > > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > > > {
> > > > > > tinfo[i].thread_id = i + 1;
> > > > > > tinfo[i].sleep_time = sleep_times[i];
> > > > > >
> > > > > > ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
> > > > > > if (ret != 0)
> > > > > > {
> > > > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > > > exit(EXIT_FAILURE);
> > > > > > }
> > > > > > }
> > > > > > int app_ret = 0;
> > > > > > if (app_ret == -1) {
> > > > > > printf("Error executing command\n");
> > > > > > } else {
> > > > > > printf("Application finished with return code: %d\n", app_ret);
> > > > > > }
> > > > > >
> > > > > > while (1)
> > > > > > {
> > > > > > printf("Hello, World!! [Main Thread]\n");
> > > > > > sleep(10);
> > > > > > }
> > > > > >
> > > > > > return 0;
> > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > > > You will see output below:
> > > > > > nsh> hello
> > > > > > Aplicação finalizou com código de retorno: 0
> > > > > > Hello, World!! [Main Thread]
> > > > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0
> segundos
> > > > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0
> > > > segundos
> > > > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0
> segundos
> > > > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0
> segundos
> > > > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0
> segundos
> > > > > > *pmu_*Hello, World!! [Main Thread]
> > > > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11
> > segundos
> > > > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16
> > segundos
> > > > > >
> > > > > > I was able to power consumption below 1 mA when mcu is in idle
> > mode,
> > > so
> > > > > it
> > > > > > is in light sleep.
> > > > > >
> > > > > > Later, making a distclean, running wifi config and adding
> > > > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see
> > > that
> > > > > the
> > > > > > mcu goes to sleep and not return.
> > > > > >
> > > > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > >
> > > > > > > Hi Felipe, good to hear about your progress here!
> > > > > > >
> > > > > > > These functions are ROM-defined functions. By checking the TRM,
> > you
> > > > can
> > > > > > see
> > > > > > > a read-only flash partition that holds some functions (widely
> > used
> > > > > > > functions, like malloc and internal functions).
> > > > > > >
> > > > > > > ets_get_cpu_frequency
> > > > > > > <
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > > > >
> > > > > > > is
> > > > > > > one of these internal functions. They are defined directly at
> the
> > > > > linker
> > > > > > > script.
> > > > > > >
> > > > > > > If I understood correctly, these functions are crashing when
> it's
> > > > being
> > > > > > > called, right? If so, can you:
> > > > > > >
> > > > > > > 1. Share the crash dump
> > > > > > > 2. Use GDB and try to check where/why it fails: it may
> trying
> > to
> > > > > > access
> > > > > > > some prohibited memory region or even trying to call an
> > > > unregistered
> > > > > > > callback.
> > > > > > >
> > > > > > > Thanks!
> > > > > > >
> > > > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > >
> > > > > > > > Hello everyone,
> > > > > > > >
> > > > > > > > Tiago, I am trying to work with light sleep for now, after it
> > > work
> > > > > will
> > > > > > > go
> > > > > > > > ahead with deep sleep. To run in light sleep I don't need to
> > > change
> > > > > > > linker
> > > > > > > > so I was able to build and flash without "image" issues.
> > > > > > > > Now I am facing other kind of issue:
> > > > > > > > Some functions refers to "ets" function and I don't know how
> > > handle
> > > > > > this,
> > > > > > > > for instance:
> > > > > > > >
> > > > > > > > /**
> > > > > > > > * @brief Get the real CPU ticks per us
> > > > > > > > *
> > > > > > > > * @return CPU ticks per us
> > > > > > > > */
> > > > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > > > >
> > > > > > > > This function is necessary in the *sleep_modes.c* file.
> During
> > > > > execute
> > > > > > > code
> > > > > > > > I am facing crash when this function is called, its happen
> > > because
> > > > > its
> > > > > > > > implementation is a reference to other function:
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > > > > > > >
> > > > > > > > I cannot find *ets_get_cpu_frequency*, so how should I handle
> > it?
> > > > > > > >
> > > > > > > > PS: I have another situation like this, when I try to call
> > > > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > > > >
> > > > > > > > Regards.
> > > > > > > >
> > > > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > >
> > > > > > > > > Hello Tiago.
> > > > > > > > >
> > > > > > > > > Please look de draft here:
> > > > > > https://github.com/apache/nuttx/pull/14548
> > > > > > > > >
> > > > > > > > > This branch will refer to the updated 3rd-party in my repo.
> > > > > > > > >
> > > > > > > > > You only need to enable PM in menuconfig and it will be
> > enough
> > > to
> > > > > see
> > > > > > > > > changes.
> > > > > > > > >
> > > > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci
> Serrano <
> > > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > >
> > > > > > > > >> Hi Felipe,
> > > > > > > > >>
> > > > > > > > >> Can you share your PR as a draft on GH to make it easier
> to
> > > > check
> > > > > > the
> > > > > > > > >> files
> > > > > > > > >> (and the build process)?
> > > > > > > > >>
> > > > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura
> Oliveira
> > <
> > > > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > > > >>
> > > > > > > > >> > Hello Tiago,
> > > > > > > > >> >
> > > > > > > > >> > I "finished" the port, but after it my esp32c6 dev kit
> is
> > > > > > resetting.
> > > > > > > > >> Maybe
> > > > > > > > >> > the issue is related my changes in
> > > > > > > > >> >
> boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> > > Can
> > > > > you
> > > > > > > give
> > > > > > > > >> some
> > > > > > > > >> > tips about how to go ahead?
> > > > > > > > >> >
> > > > > > > > >> > Below you can see nuttx report:
> > > > > > > > >> > Build:Sep 19 2022
> > > > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > > > > > > > >> > Saved PC:0x40018bea
> > > > > > > > >> > SPIWP:0xee
> > > > > > > > >> > mode:DIO, clock div:2
> > > > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > > > >> > load:0x50000000,len:0x20
> > > > > > > > >> > load:0x5000001e,len:0x24
> > > > > > > > >> > Invalid image block, can't boot.
> > > > > > > > >> > ets_main.c 331
> > > > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > > > >> >
> > > > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura
> > Oliveira
> > > <
> > > > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > > > >> >
> > > > > > > > >> > > Hello everyone,
> > > > > > > > >> > >
> > > > > > > > >> > > I was able to solve linker issues, editing the linker
> by
> > > > > > myself. I
> > > > > > > > >> need
> > > > > > > > >> > to
> > > > > > > > >> > > finish more than one build issue before testing it,
> so I
> > > > will
> > > > > > see
> > > > > > > > if I
> > > > > > > > >> > made
> > > > > > > > >> > > the right changes in linker.
> > > > > > > > >> > >
> > > > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura
> > > Oliveira
> > > > <
> > > > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > >> > >
> > > > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > > > >> > >>
> > > > > > > > >> > >> I have made progress with the build issue I was
> > > > encountering
> > > > > > and
> > > > > > > am
> > > > > > > > >> now
> > > > > > > > >> > >> "stuck" at what I believe is one of the final
> stages. I
> > > am
> > > > > > > > >> experiencing
> > > > > > > > >> > the
> > > > > > > > >> > >> following compilation error:
> > > > > > > > >> > >> LD: nuttx
> > > > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference
> to
> > > > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4):
> > > > undefined
> > > > > > > > >> reference
> > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8):
> > > > undefined
> > > > > > > > >> reference
> > > > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc):
> > > > undefined
> > > > > > > > >> reference
> > > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > > >> > >>
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > > > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e):
> > > undefined
> > > > > > > > reference
> > > > > > > > >> to
> > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226):
> > > undefined
> > > > > > > > reference
> > > > > > > > >> to
> > > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > >> > >>
> > > > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > > > >> > >>
> > > > > > > > >> > >> Focusing on the item _rtc_text_start, I see that it
> is
> > > > > defined
> > > > > > in
> > > > > > > > the
> > > > > > > > >> > >> file:
> > > > > > > > >> > >>
> > > > > > > > >>
> > > > > > >
> > > >
> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > >> > >> sections.ld.in
> > > > > > > > >> > >>
> > > > > > > > >> > >> However, I am unsure how to add this file to the
> > complete
> > > > > > linking
> > > > > > > > >> > >> process. I added this file to hal_esp32c6.mk, but I
> > > > received
> > > > > > the
> > > > > > > > >> > >> following error:
> > > > > > > > >> > >> LD: nuttx
> > > > > > > > >> > >>
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > >
> > > > > >
> > > >
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > > > >> > >>
> > > src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > > >> > >> sections.ld.in.tmp:113 cannot move location counter
> > > > backwards
> > > > > > > (from
> > > > > > > > >> > >> 40809800 to 40800000)
> > > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > > >> > >>
> > > > > > > > >> > >>
> > > > > > > > >> > >> Does anyone have any tips or suggestions that could
> > help
> > > me
> > > > > > move
> > > > > > > > >> forward
> > > > > > > > >> > >> with this process?
> > > > > > > > >> > >>
> > > > > > > > >> > >> Thank you in advance for your help.
> > > > > > > > >> > >>
> > > > > > > > >> > >> *Best regards,*
> > > > > > > > >> > >>
> > > > > > > > >> > >>
> > > > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci
> > > > Serrano <
> > > > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > > > >> > >>
> > > > > > > > >> > >>> Hi Felipe,
> > > > > > > > >> > >>>
> > > > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver,
> so a
> > > > > > > substitute
> > > > > > > > >> for
> > > > > > > > >> > >>> this
> > > > > > > > >> > >>> function should be part
> > > > > > > > >> > >>> of
> > > > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > > > That
> > > > > > > > >> being
> > > > > > > > >> > >>> said, you can either implement it (and define it as
> a
> > > > macro,
> > > > > > on
> > > > > > > > >> HAL) or
> > > > > > > > >> > >>> you
> > > > > > > > >> > >>> can either ignore these functions related to GPIO
> > wakeup
> > > > > from
> > > > > > > > sleep
> > > > > > > > >> for
> > > > > > > > >> > >>> now
> > > > > > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's
> > up
> > > to
> > > > > > you:
> > > > > > > if
> > > > > > > > >> the
> > > > > > > > >> > >>> GPIO
> > > > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing
> > > this
> > > > > > > feature
> > > > > > > > >> for
> > > > > > > > >> > >>> now.
> > > > > > > > >> > >>>
> > > > > > > > >> > >>> Best regards,
> > > > > > > > >> > >>>
> > > > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura
> > > > Oliveira
> > > > > <
> > > > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > > > >> > >>>
> > > > > > > > >> > >>> > Hello Tiago,
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > I would like to discuss further the necessity of
> the
> > > > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is
> only
> > > > > > available
> > > > > > > > in
> > > > > > > > >> the
> > > > > > > > >> > >>> IDF.
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > In sleep_modes.c, there is the following code
> > snippet:
> > > > > > > > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > > > io_mask,
> > > > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > > > >> > >>> > {
> > > > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > >> > >>> > }
> > > > > > > > >> > >>> > // Translate bit map of GPIO numbers into the bit
> > map
> > > of
> > > > > RTC
> > > > > > > IO
> > > > > > > > >> > numbers
> > > > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>=
> 1) {
> > > > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > > > >> > >>> > continue;
> > > > > > > > >> > >>> > }
> > > > > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > > >> > >>> > }
> > > > > > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > > > > > >> > >>> > }
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > I believe this code is essential for compilation.
> > The
> > > > > > function
> > > > > > > > >> > >>> > rtc_io_number_get is located at the following path
> > in
> > > > the
> > > > > > IDF:
> > > > > > > > >> > >>> >
> components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > However, the esp_driver_gpio folder is not present
> > in
> > > > the
> > > > > > > > >> 3rd-party
> > > > > > > > >> > >>> > directory. In this case, what is the recommended
> > > > procedure
> > > > > > to
> > > > > > > > >> > proceed?
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > Thank you again for your support.
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago
> Medicci
> > > > > Serrano
> > > > > > <
> > > > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > > Hi Felipe,
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the component
> > > `esp_pm`
> > > > > of
> > > > > > > > >> ESP-IDF,
> > > > > > > > >> > >>> which
> > > > > > > > >> > >>> > is
> > > > > > > > >> > >>> > > a driver directly. Same for
> > > > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > > > >> > >>> (here, a
> > > > > > > > >> > >>> > > detail: I wasn't able to find this path on IDF,
> so
> > > > make
> > > > > > sure
> > > > > > > > you
> > > > > > > > >> > are
> > > > > > > > >> > >>> > > checking under the `release/v5.1` branch, which
> > the
> > > > HAL
> > > > > > was
> > > > > > > > >> based).
> > > > > > > > >> > >>> The
> > > > > > > > >> > >>> > HAL
> > > > > > > > >> > >>> > > repository doesn't contain ESP-IDF drivers,
> which
> > > are
> > > > > > always
> > > > > > > > >> > >>> implemented
> > > > > > > > >> > >>> > on
> > > > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > > > > > > >> > >>> > >
> > > > > > > >
> > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > The files under
> > > > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to
> > > > implement
> > > > > > the
> > > > > > > > >> > driver.
> > > > > > > > >> > >>> This
> > > > > > > > >> > >>> > > is, mostly, a wrapping layer under the function
> of
> > > > > > `esp_rom`
> > > > > > > > and
> > > > > > > > >> > >>> `hal`
> > > > > > > > >> > >>> > > components. However, they still may refer to
> > ESP-IDF
> > > > > > > drivers.
> > > > > > > > >> That
> > > > > > > > >> > >>> being
> > > > > > > > >> > >>> > > said, you can check if removing such
> dependencies
> > is
> > > > > > > possible.
> > > > > > > > >> We
> > > > > > > > >> > >>> usually
> > > > > > > > >> > >>> > > do that with conditional macros. A good starting
> > > point
> > > > > is
> > > > > > to
> > > > > > > > >> check
> > > > > > > > >> > >>> for
> > > > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and headers:
> > we
> > > > use
> > > > > > them
> > > > > > > > to
> > > > > > > > >> > >>> > remove/add
> > > > > > > > >> > >>> > > headers and functions that aren't available on
> > > > > > NuttX/needed
> > > > > > > by
> > > > > > > > >> > NuttX.
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > Best regards,
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe
> Moura
> > > > > > Oliveira
> > > > > > > <
> > > > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > > Hello all,
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > Tiago,
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > I have a question regarding the porting
> process.
> > > > > > > > >> Specifically, I
> > > > > > > > >> > >>> need
> > > > > > > > >> > >>> > to
> > > > > > > > >> > >>> > > > add the sleep_modes.c file to the compilation
> > > > process.
> > > > > > Am
> > > > > > > I
> > > > > > > > on
> > > > > > > > >> > the
> > > > > > > > >> > >>> > right
> > > > > > > > >> > >>> > > > path with this approach?
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > To achieve this, I modified the
> hal_esp32c6.mk
> > > file
> > > > > by
> > > > > > > > adding
> > > > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > > > >> > >>> > > > However, I am facing some issues: within
> > > > > sleep_modes.c,
> > > > > > > some
> > > > > > > > >> > >>> #include
> > > > > > > > >> > >>> > > > statements reference files that are not
> > available
> > > in
> > > > > the
> > > > > > > > >> > 3rd-party
> > > > > > > > >> > >>> > > > directory but are only present in the IDF. For
> > > > > example:
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > > > >> > >>> > > > -
> components/esp_driver_gpio/include/rtc_io.h
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > I need those includes because sleep_modes.c
> uses
> > > > > > function
> > > > > > > > from
> > > > > > > > >> > >>> there.
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > Could you please advise if it's possible to
> > > > > incorporate
> > > > > > > > these
> > > > > > > > >> IDF
> > > > > > > > >> > >>> > folders
> > > > > > > > >> > >>> > > > into the 3rd-party directory, or if that
> > approach
> > > is
> > > > > not
> > > > > > > > >> > >>> recommended?
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > Best regards,
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago
> > > Medicci
> > > > > > > Serrano
> > > > > > > > <
> > > > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > > Hi,
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > Just another note to guide your development:
> > we
> > > > > don't
> > > > > > > > >> develop
> > > > > > > > >> > >>> > anything
> > > > > > > > >> > >>> > > on
> > > > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use
> > from
> > > > it
> > > > > is
> > > > > > > > >> derived
> > > > > > > > >> > >>> from
> > > > > > > > >> > >>> > the
> > > > > > > > >> > >>> > > > > path
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>>
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > > > >> > >>> > > > except
> > > > > > > > >> > >>> > > > > for some of the sources files that use the
> hal
> > > > > > functions
> > > > > > > > at
> > > > > > > > >> > >>> > > > > `components/hal` to implement some function
> we
> > > may
> > > > > > use).
> > > > > > > > You
> > > > > > > > >> > can
> > > > > > > > >> > >>> > take a
> > > > > > > > >> > >>> > > > > look at the branch `
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> >
> > > > > > > > >> >
> > > > > > >
> > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > > > <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > > >> <
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >
> > > > > > > > >> > <
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > >
> > > > > > > > >> > >>> <
> > > > > > > > >>
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > >> > >>> > <
> > > > > > > > >> >
> > > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > > > > >> > >>> > > <
> > > > > > > > >> > >>>
> > > > > > > > >>
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > >> > >>> > > > <
> > > > > > > > >> > >>>
> > > > > > > > >>
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > > >> > >>> > > > > <
> > > > > > > > >> > >>> >
> > > > > > > > >>
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > > >> > >
> > > > > > > > >> > >>> > > > and
> > > > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > > > >> > >>> > > > > with
> faaa46ebfb37fba4250de831efbbf2862958c344
> > to
> > > > > check
> > > > > > > the
> > > > > > > > >> kind
> > > > > > > > >> > >>> of
> > > > > > > > >> > >>> > > > changes
> > > > > > > > >> > >>> > > > > we do in hal. Essentially, we create a
> wrapper
> > > > layer
> > > > > > to
> > > > > > > > >> make it
> > > > > > > > >> > >>> > > > independent
> > > > > > > > >> > >>> > > > > of the host OS.
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > *Drivers must always be implemented on
> NuttX!*
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > That being said, you can either 1) try to
> > adapt
> > > > the
> > > > > > > > >> > >>> implementation of
> > > > > > > > >> > >>> > > > other
> > > > > > > > >> > >>> > > > > devices to use the HAL functions or 2) get
> > some
> > > > > > > > inspiration
> > > > > > > > >> on
> > > > > > > > >> > >>> how
> > > > > > > > >> > >>> > IDF
> > > > > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd option
> > > > before
> > > > > > > simply
> > > > > > > > >> > >>> trying to
> > > > > > > > >> > >>> > > > adapt
> > > > > > > > >> > >>> > > > > an existing implementation (from ESP32-C3
> > legacy
> > > > or
> > > > > > from
> > > > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > Best regards,
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe
> > > Moura
> > > > > > > > Oliveira
> > > > > > > > >> <
> > > > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > > > >> > >>> > > > > >
> > > > > > > > >> > >>> > > > > > Thank you for clarification, I will follow
> > > your
> > > > > > > > >> instructions.
> > > > > > > > >> > >>> > > > > >
> > > > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01,
> Tiago
> > > > > Medicci
> > > > > > > > >> Serrano <
> > > > > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > >> > >>> > > > > >
> > > > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > > Just complementing: use your forked
> > version
> > > of
> > > > > the
> > > > > > > HAL
> > > > > > > > >> > >>> during the
> > > > > > > > >> > >>> > > > > > > development. As soon as you have a
> working
> > > > > > version,
> > > > > > > > you
> > > > > > > > >> can
> > > > > > > > >> > >>> > submit
> > > > > > > > >> > >>> > > on
> > > > > > > > >> > >>> > > > > the
> > > > > > > > >> > >>> > > > > > > official repository.
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > > Best regards,
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58,
> > Tiago
> > > > > > Medicci
> > > > > > > > >> > Serrano <
> > > > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > Thanks for asking! You should follow
> the
> > > > path
> > > > > > > using
> > > > > > > > >> the
> > > > > > > > >> > >>> > functions
> > > > > > > > >> > >>> > > > on
> > > > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the
> > > > repository
> > > > > > and
> > > > > > > > use
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > >
> > > > > > > > >>
> > > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > > > >> > >>> > > > > > env
> > > > > > > > >> > >>> > > > > > > > vars (globally or before the make
> > command)
> > > > to
> > > > > > use
> > > > > > > > your
> > > > > > > > >> > >>> version
> > > > > > > > >> > >>> > of
> > > > > > > > >> > >>> > > > the
> > > > > > > > >> > >>> > > > > > > HAL.
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > I just wanted to share some thoughts:
> > > using
> > > > > the
> > > > > > > HAL
> > > > > > > > >> > >>> enables us
> > > > > > > > >> > >>> > to
> > > > > > > > >> > >>> > > > > make
> > > > > > > > >> > >>> > > > > > > the
> > > > > > > > >> > >>> > > > > > > > feature available for all the
> Espressif
> > > > > devices
> > > > > > > > >> (please
> > > > > > > > >> > >>> don't
> > > > > > > > >> > >>> > > > bother
> > > > > > > > >> > >>> > > > > > with
> > > > > > > > >> > >>> > > > > > > > that now, as soon as you submit it, we
> > can
> > > > > test
> > > > > > > for
> > > > > > > > >> the
> > > > > > > > >> > >>> other
> > > > > > > > >> > >>> > > > devices
> > > > > > > > >> > >>> > > > > > and
> > > > > > > > >> > >>> > > > > > > > eventually make any adjustments).
> > Although
> > > > > it's
> > > > > > > > >> possible
> > > > > > > > >> > to
> > > > > > > > >> > >>> > > > > reimplement
> > > > > > > > >> > >>> > > > > > > > these functions on NuttX, we don't
> > > recommend
> > > > > > that
> > > > > > > > >> because
> > > > > > > > >> > >>> of
> > > > > > > > >> > >>> > the
> > > > > > > > >> > >>> > > > > first
> > > > > > > > >> > >>> > > > > > > > statement (the ability to use for the
> > > other
> > > > > > > > devices):
> > > > > > > > >> in
> > > > > > > > >> > >>> that
> > > > > > > > >> > >>> > > case
> > > > > > > > >> > >>> > > > we
> > > > > > > > >> > >>> > > > > > > > wouldn't be able to support the
> feature.
> > > You
> > > > > can
> > > > > > > > take
> > > > > > > > >> a
> > > > > > > > >> > >>> look on
> > > > > > > > >> > >>> > > IDF
> > > > > > > > >> > >>> > > > > for
> > > > > > > > >> > >>> > > > > > > > some inspiration on how it's
> > implemented.
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > Please let me know if you have any
> > > > questions.
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38,
> > > Felipe
> > > > > > Moura
> > > > > > > > >> > >>> Oliveira <
> > > > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >> Our project has reached a point where
> > we
> > > > need
> > > > > > the
> > > > > > > > >> Power
> > > > > > > > >> > >>> > Manager
> > > > > > > > >> > >>> > > > > > > >> functionality, which is not yet
> > available
> > > > in
> > > > > > the
> > > > > > > > >> > ESP32C6.
> > > > > > > > >> > >>> I am
> > > > > > > > >> > >>> > > > > > studying
> > > > > > > > >> > >>> > > > > > > to
> > > > > > > > >> > >>> > > > > > > >> start the implementation, but I am
> > > confused
> > > > > > about
> > > > > > > > the
> > > > > > > > >> > >>> correct
> > > > > > > > >> > >>> > > way
> > > > > > > > >> > >>> > > > to
> > > > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >> There is a Power Manager
> implementation
> > > for
> > > > > the
> > > > > > > > >> ESP32C3,
> > > > > > > > >> > >>> but
> > > > > > > > >> > >>> > it
> > > > > > > > >> > >>> > > > > seems
> > > > > > > > >> > >>> > > > > > to
> > > > > > > > >> > >>> > > > > > > >> follow the legacy methodology. In
> fact,
> > > the
> > > > > > file
> > > > > > > > >> > >>> > esp32c3_idle.c
> > > > > > > > >> > >>> > > is
> > > > > > > > >> > >>> > > > > > > located
> > > > > > > > >> > >>> > > > > > > >> in the path
> > > arch/risc-v/src/esp32c3-legacy.
> > > > > In
> > > > > > > this
> > > > > > > > >> > >>> > methodology,
> > > > > > > > >> > >>> > > > > > > functions
> > > > > > > > >> > >>> > > > > > > >> are re-implemented from the Espressif
> > > > driver.
> > > > > > For
> > > > > > > > >> > >>> example, the
> > > > > > > > >> > >>> > > > > > function
> > > > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is
> > > > > currently
> > > > > > > > >> > available
> > > > > > > > >> > >>> in
> > > > > > > > >> > >>> > > > > > > >>
> > > esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >> I tried using the implementations
> from
> > > > > > > > >> esp-hal-3rdparty
> > > > > > > > >> > to
> > > > > > > > >> > >>> > > develop
> > > > > > > > >> > >>> > > > > the
> > > > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in
> NuttX,
> > > but
> > > > > the
> > > > > > > > files
> > > > > > > > >> > >>> still
> > > > > > > > >> > >>> > have
> > > > > > > > >> > >>> > > > > many
> > > > > > > > >> > >>> > > > > > > >> dependencies on items that are not
> > > present
> > > > in
> > > > > > > > NuttX.
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >> My question is: Should I try to make
> > the
> > > > > Power
> > > > > > > > >> Manager
> > > > > > > > >> > >>> work
> > > > > > > > >> > >>> > > using
> > > > > > > > >> > >>> > > > > the
> > > > > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even
> if
> > it
> > > > > > > requires
> > > > > > > > >> > making
> > > > > > > > >> > >>> > > changes
> > > > > > > > >> > >>> > > > to
> > > > > > > > >> > >>> > > > > > the
> > > > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I
> > re-implement
> > > > the
> > > > > > > > >> functions
> > > > > > > > >> > >>> within
> > > > > > > > >> > >>> > > > NuttX,
> > > > > > > > >> > >>> > > > > > > even
> > > > > > > > >> > >>> > > > > > > >> if, in this case, there are functions
> > > with
> > > > > the
> > > > > > > same
> > > > > > > > >> > scope
> > > > > > > > >> > >>> and
> > > > > > > > >> > >>> > > > > > > >> implementation in different files,
> > where
> > > > one
> > > > > is
> > > > > > > > >> > compiled,
> > > > > > > > >> > >>> and
> > > > > > > > >> > >>> > > the
> > > > > > > > >> > >>> > > > > > other
> > > > > > > > >> > >>> > > > > > > is
> > > > > > > > >> > >>> > > > > > > >> not?
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >> --
> > > > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas
> Gerais*
> > > > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > > > >> > >>> >
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > >> > >>> > > > > > > >> <
> > > > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > > > >
> > > > > > > > >> > >>> > > > > > > >>
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > --
> > > > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886
> > <+55+(19)+981403886>
> > > > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > > > >> > >>> > > > > > > > <
> > > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > > >
> > > > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > > > >> > >>> > > > > > > >
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > > --
> > > > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > > > >> > >>> > > > > > > m: +55 (19) 981403886
> <+55+(19)+981403886>
> > > > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > > > >> > >>> > > > > > > Follow me:
> > > > > > > > >> > >>> > > > > > > <
> > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > >
> > > > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > > > >> > >>> > > > > > >
> > > > > > > > >> > >>> > > > > >
> > > > > > > > >> > >>> > > > > >
> > > > > > > > >> > >>> > > > > > --
> > > > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > >> > >>> > > > > > Linkedin <
> > > > > > > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > > > > > <
> > > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >> > >>> > > > > >
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > --
> > > > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > > > >> > >>> > > > > Follow me:
> > > > > > > > >> > >>> > > > > <
> > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > >
> > > > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > > > >> > >>> > > > >
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > > > --
> > > > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > > > >> > >>> > > > Linkedin <
> > > > > > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > >> > >>> > > > <
> https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >> > >>> > > >
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > --
> > > > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > > > >> > >>> > > Follow me:
> > > > > > > > >> > >>> > > <
> > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > >
> > > > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > > > >> > >>> > >
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>> > --
> > > > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > > > >> > >>> > Linkedin <
> > > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >> > >>> >
> > > > > > > > >> > >>>
> > > > > > > > >> > >>
> > > > > > > > >> > >>
> > > > > > > > >> > >> --
> > > > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > > > >> > >> Linkedin <
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > >
> > > > > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >> > >>
> > > > > > > > >> > >
> > > > > > > > >> > >
> > > > > > > > >> > > --
> > > > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > > > >> > > Linkedin <
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >> > >
> > > > > > > > >> >
> > > > > > > > >> >
> > > > > > > > >> > --
> > > > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > > > >> > Linkedin <
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > >
> > > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >
> > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *Felipe Moura de Oliveira*
> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
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.fmo@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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > > #include <stdio.h>
> > > > > #include <stdint.h>
> > > > > #include <time.h>
> > > > > #include <unistd.h>
> > > > > #include <pthread.h>
> > > > > #include <stdlib.h>
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > * 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);
> > > > > }
> > > > >
> > > > > return NULL;
> > > > > }
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > * Public Functions
> > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > > * main
> > > > >
> > > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > > >
> > > > > int main(int argc, FAR char *argv[])
> > > > > {
> > > > > pthread_t threads[NUM_THREADS];
> > > > > struct thread_info tinfo[NUM_THREADS];
> > > > > int ret;
> > > > >
> > > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> > > > >
> > > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > > {
> > > > > tinfo[i].thread_id = i + 1;
> > > > > tinfo[i].sleep_time = sleep_times[i];
> > > > >
> > > > > ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
> > > > > if (ret != 0)
> > > > > {
> > > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > > exit(EXIT_FAILURE);
> > > > > }
> > > > > }
> > > > > int app_ret = 0;
> > > > > if (app_ret == -1) {
> > > > > printf("Error executing command\n");
> > > > > } else {
> > > > > printf("Application finished with return code: %d\n", app_ret);
> > > > > }
> > > > >
> > > > > while (1)
> > > > > {
> > > > > printf("Hello, World!! [Main Thread]\n");
> > > > > sleep(10);
> > > > > }
> > > > >
> > > > > return 0;
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > You will see output below:
> > > > > nsh> hello
> > > > > Aplicação finalizou com código de retorno: 0
> > > > > Hello, World!! [Main Thread]
> > > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0
> > > segundos
> > > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > > *pmu_*Hello, World!! [Main Thread]
> > > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11
> segundos
> > > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16
> segundos
> > > > >
> > > > > I was able to power consumption below 1 mA when mcu is in idle
> mode,
> > so
> > > > it
> > > > > is in light sleep.
> > > > >
> > > > > Later, making a distclean, running wifi config and adding
> > > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see
> > that
> > > > the
> > > > > mcu goes to sleep and not return.
> > > > >
> > > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > > > > tiago.medicci@gmail.com> escreveu:
> > > > >
> > > > > > Hi Felipe, good to hear about your progress here!
> > > > > >
> > > > > > These functions are ROM-defined functions. By checking the TRM,
> you
> > > can
> > > > > see
> > > > > > a read-only flash partition that holds some functions (widely
> used
> > > > > > functions, like malloc and internal functions).
> > > > > >
> > > > > > ets_get_cpu_frequency
> > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > > >
> > > > > > is
> > > > > > one of these internal functions. They are defined directly at the
> > > > linker
> > > > > > script.
> > > > > >
> > > > > > If I understood correctly, these functions are crashing when it's
> > > being
> > > > > > called, right? If so, can you:
> > > > > >
> > > > > > 1. Share the crash dump
> > > > > > 2. Use GDB and try to check where/why it fails: it may trying
> to
> > > > > access
> > > > > > some prohibited memory region or even trying to call an
> > > unregistered
> > > > > > callback.
> > > > > >
> > > > > > Thanks!
> > > > > >
> > > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > > > > > moura.fmo@gmail.com> escreveu:
> > > > > >
> > > > > > > Hello everyone,
> > > > > > >
> > > > > > > Tiago, I am trying to work with light sleep for now, after it
> > work
> > > > will
> > > > > > go
> > > > > > > ahead with deep sleep. To run in light sleep I don't need to
> > change
> > > > > > linker
> > > > > > > so I was able to build and flash without "image" issues.
> > > > > > > Now I am facing other kind of issue:
> > > > > > > Some functions refers to "ets" function and I don't know how
> > handle
> > > > > this,
> > > > > > > for instance:
> > > > > > >
> > > > > > > /**
> > > > > > > * @brief Get the real CPU ticks per us
> > > > > > > *
> > > > > > > * @return CPU ticks per us
> > > > > > > */
> > > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > > >
> > > > > > > This function is necessary in the *sleep_modes.c* file. During
> > > > execute
> > > > > > code
> > > > > > > I am facing crash when this function is called, its happen
> > because
> > > > its
> > > > > > > implementation is a reference to other function:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > > > > > >
> > > > > > > I cannot find *ets_get_cpu_frequency*, so how should I handle
> it?
> > > > > > >
> > > > > > > PS: I have another situation like this, when I try to call
> > > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > > >
> > > > > > > Regards.
> > > > > > >
> > > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > >
> > > > > > > > Hello Tiago.
> > > > > > > >
> > > > > > > > Please look de draft here:
> > > > > https://github.com/apache/nuttx/pull/14548
> > > > > > > >
> > > > > > > > This branch will refer to the updated 3rd-party in my repo.
> > > > > > > >
> > > > > > > > You only need to enable PM in menuconfig and it will be
> enough
> > to
> > > > see
> > > > > > > > changes.
> > > > > > > >
> > > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > >
> > > > > > > >> Hi Felipe,
> > > > > > > >>
> > > > > > > >> Can you share your PR as a draft on GH to make it easier to
> > > check
> > > > > the
> > > > > > > >> files
> > > > > > > >> (and the build process)?
> > > > > > > >>
> > > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira
> <
> > > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > > >>
> > > > > > > >> > Hello Tiago,
> > > > > > > >> >
> > > > > > > >> > I "finished" the port, but after it my esp32c6 dev kit is
> > > > > resetting.
> > > > > > > >> Maybe
> > > > > > > >> > the issue is related my changes in
> > > > > > > >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> > Can
> > > > you
> > > > > > give
> > > > > > > >> some
> > > > > > > >> > tips about how to go ahead?
> > > > > > > >> >
> > > > > > > >> > Below you can see nuttx report:
> > > > > > > >> > Build:Sep 19 2022
> > > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > > > > > > >> > Saved PC:0x40018bea
> > > > > > > >> > SPIWP:0xee
> > > > > > > >> > mode:DIO, clock div:2
> > > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > > >> > load:0x50000000,len:0x20
> > > > > > > >> > load:0x5000001e,len:0x24
> > > > > > > >> > Invalid image block, can't boot.
> > > > > > > >> > ets_main.c 331
> > > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > > >> >
> > > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura
> Oliveira
> > <
> > > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > > >> >
> > > > > > > >> > > Hello everyone,
> > > > > > > >> > >
> > > > > > > >> > > I was able to solve linker issues, editing the linker by
> > > > > myself. I
> > > > > > > >> need
> > > > > > > >> > to
> > > > > > > >> > > finish more than one build issue before testing it, so I
> > > will
> > > > > see
> > > > > > > if I
> > > > > > > >> > made
> > > > > > > >> > > the right changes in linker.
> > > > > > > >> > >
> > > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura
> > Oliveira
> > > <
> > > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > > >> > >
> > > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > > >> > >>
> > > > > > > >> > >> I have made progress with the build issue I was
> > > encountering
> > > > > and
> > > > > > am
> > > > > > > >> now
> > > > > > > >> > >> "stuck" at what I believe is one of the final stages. I
> > am
> > > > > > > >> experiencing
> > > > > > > >> > the
> > > > > > > >> > >> following compilation error:
> > > > > > > >> > >> LD: nuttx
> > > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4):
> > > undefined
> > > > > > > >> reference
> > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8):
> > > undefined
> > > > > > > >> reference
> > > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc):
> > > undefined
> > > > > > > >> reference
> > > > > > > >> > >> to `_rtc_text_start'
> > > > > > > >> > >> riscv-none-elf-ld:
> > > > > > > >> > >>
> > > > > > > >> >
> > > > > > > >>
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e):
> > undefined
> > > > > > > reference
> > > > > > > >> to
> > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226):
> > undefined
> > > > > > > reference
> > > > > > > >> to
> > > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > >> > >>
> > > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > > >> > >>
> > > > > > > >> > >> Focusing on the item _rtc_text_start, I see that it is
> > > > defined
> > > > > in
> > > > > > > the
> > > > > > > >> > >> file:
> > > > > > > >> > >>
> > > > > > > >>
> > > > > >
> > > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > >> > >> sections.ld.in
> > > > > > > >> > >>
> > > > > > > >> > >> However, I am unsure how to add this file to the
> complete
> > > > > linking
> > > > > > > >> > >> process. I added this file to hal_esp32c6.mk, but I
> > > received
> > > > > the
> > > > > > > >> > >> following error:
> > > > > > > >> > >> LD: nuttx
> > > > > > > >> > >>
> > > > > > > >> >
> > > > > > > >>
> > > > > > >
> > > > >
> > >
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > > >> > >>
> > src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > > >> > >> sections.ld.in.tmp:113 cannot move location counter
> > > backwards
> > > > > > (from
> > > > > > > >> > >> 40809800 to 40800000)
> > > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > > >> > >>
> > > > > > > >> > >>
> > > > > > > >> > >> Does anyone have any tips or suggestions that could
> help
> > me
> > > > > move
> > > > > > > >> forward
> > > > > > > >> > >> with this process?
> > > > > > > >> > >>
> > > > > > > >> > >> Thank you in advance for your help.
> > > > > > > >> > >>
> > > > > > > >> > >> *Best regards,*
> > > > > > > >> > >>
> > > > > > > >> > >>
> > > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci
> > > Serrano <
> > > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > > >> > >>
> > > > > > > >> > >>> Hi Felipe,
> > > > > > > >> > >>>
> > > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a
> > > > > > substitute
> > > > > > > >> for
> > > > > > > >> > >>> this
> > > > > > > >> > >>> function should be part
> > > > > > > >> > >>> of
> > > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > > That
> > > > > > > >> being
> > > > > > > >> > >>> said, you can either implement it (and define it as a
> > > macro,
> > > > > on
> > > > > > > >> HAL) or
> > > > > > > >> > >>> you
> > > > > > > >> > >>> can either ignore these functions related to GPIO
> wakeup
> > > > from
> > > > > > > sleep
> > > > > > > >> for
> > > > > > > >> > >>> now
> > > > > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's
> up
> > to
> > > > > you:
> > > > > > if
> > > > > > > >> the
> > > > > > > >> > >>> GPIO
> > > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing
> > this
> > > > > > feature
> > > > > > > >> for
> > > > > > > >> > >>> now.
> > > > > > > >> > >>>
> > > > > > > >> > >>> Best regards,
> > > > > > > >> > >>>
> > > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura
> > > Oliveira
> > > > <
> > > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > > >> > >>>
> > > > > > > >> > >>> > Hello Tiago,
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > I would like to discuss further the necessity of the
> > > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only
> > > > > available
> > > > > > > in
> > > > > > > >> the
> > > > > > > >> > >>> IDF.
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > In sleep_modes.c, there is the following code
> snippet:
> > > > > > > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > > io_mask,
> > > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > > >> > >>> > {
> > > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > >> > >>> > }
> > > > > > > >> > >>> > // Translate bit map of GPIO numbers into the bit
> map
> > of
> > > > RTC
> > > > > > IO
> > > > > > > >> > numbers
> > > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > > >> > >>> > continue;
> > > > > > > >> > >>> > }
> > > > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > > >> > >>> > }
> > > > > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > > > > >> > >>> > }
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > I believe this code is essential for compilation.
> The
> > > > > function
> > > > > > > >> > >>> > rtc_io_number_get is located at the following path
> in
> > > the
> > > > > IDF:
> > > > > > > >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > However, the esp_driver_gpio folder is not present
> in
> > > the
> > > > > > > >> 3rd-party
> > > > > > > >> > >>> > directory. In this case, what is the recommended
> > > procedure
> > > > > to
> > > > > > > >> > proceed?
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > Thank you again for your support.
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci
> > > > Serrano
> > > > > <
> > > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > > Hi Felipe,
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the component
> > `esp_pm`
> > > > of
> > > > > > > >> ESP-IDF,
> > > > > > > >> > >>> which
> > > > > > > >> > >>> > is
> > > > > > > >> > >>> > > a driver directly. Same for
> > > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > > >> > >>> (here, a
> > > > > > > >> > >>> > > detail: I wasn't able to find this path on IDF, so
> > > make
> > > > > sure
> > > > > > > you
> > > > > > > >> > are
> > > > > > > >> > >>> > > checking under the `release/v5.1` branch, which
> the
> > > HAL
> > > > > was
> > > > > > > >> based).
> > > > > > > >> > >>> The
> > > > > > > >> > >>> > HAL
> > > > > > > >> > >>> > > repository doesn't contain ESP-IDF drivers, which
> > are
> > > > > always
> > > > > > > >> > >>> implemented
> > > > > > > >> > >>> > on
> > > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > > > > > >> > >>> > >
> > > > > > >
> `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > The files under
> > > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to
> > > implement
> > > > > the
> > > > > > > >> > driver.
> > > > > > > >> > >>> This
> > > > > > > >> > >>> > > is, mostly, a wrapping layer under the function of
> > > > > `esp_rom`
> > > > > > > and
> > > > > > > >> > >>> `hal`
> > > > > > > >> > >>> > > components. However, they still may refer to
> ESP-IDF
> > > > > > drivers.
> > > > > > > >> That
> > > > > > > >> > >>> being
> > > > > > > >> > >>> > > said, you can check if removing such dependencies
> is
> > > > > > possible.
> > > > > > > >> We
> > > > > > > >> > >>> usually
> > > > > > > >> > >>> > > do that with conditional macros. A good starting
> > point
> > > > is
> > > > > to
> > > > > > > >> check
> > > > > > > >> > >>> for
> > > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and headers:
> we
> > > use
> > > > > them
> > > > > > > to
> > > > > > > >> > >>> > remove/add
> > > > > > > >> > >>> > > headers and functions that aren't available on
> > > > > NuttX/needed
> > > > > > by
> > > > > > > >> > NuttX.
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > Best regards,
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura
> > > > > Oliveira
> > > > > > <
> > > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > > Hello all,
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > Tiago,
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > I have a question regarding the porting process.
> > > > > > > >> Specifically, I
> > > > > > > >> > >>> need
> > > > > > > >> > >>> > to
> > > > > > > >> > >>> > > > add the sleep_modes.c file to the compilation
> > > process.
> > > > > Am
> > > > > > I
> > > > > > > on
> > > > > > > >> > the
> > > > > > > >> > >>> > right
> > > > > > > >> > >>> > > > path with this approach?
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk
> > file
> > > > by
> > > > > > > adding
> > > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > > >> > >>> > > > However, I am facing some issues: within
> > > > sleep_modes.c,
> > > > > > some
> > > > > > > >> > >>> #include
> > > > > > > >> > >>> > > > statements reference files that are not
> available
> > in
> > > > the
> > > > > > > >> > 3rd-party
> > > > > > > >> > >>> > > > directory but are only present in the IDF. For
> > > > example:
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > > >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > I need those includes because sleep_modes.c uses
> > > > > function
> > > > > > > from
> > > > > > > >> > >>> there.
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > Could you please advise if it's possible to
> > > > incorporate
> > > > > > > these
> > > > > > > >> IDF
> > > > > > > >> > >>> > folders
> > > > > > > >> > >>> > > > into the 3rd-party directory, or if that
> approach
> > is
> > > > not
> > > > > > > >> > >>> recommended?
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > Best regards,
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago
> > Medicci
> > > > > > Serrano
> > > > > > > <
> > > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > > Hi,
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > Just another note to guide your development:
> we
> > > > don't
> > > > > > > >> develop
> > > > > > > >> > >>> > anything
> > > > > > > >> > >>> > > on
> > > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use
> from
> > > it
> > > > is
> > > > > > > >> derived
> > > > > > > >> > >>> from
> > > > > > > >> > >>> > the
> > > > > > > >> > >>> > > > > path
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> >
> > > > > > > >> > >>>
> > > > > > > >> >
> > > > > > > >>
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > > >> > >>> > > > except
> > > > > > > >> > >>> > > > > for some of the sources files that use the hal
> > > > > functions
> > > > > > > at
> > > > > > > >> > >>> > > > > `components/hal` to implement some function we
> > may
> > > > > use).
> > > > > > > You
> > > > > > > >> > can
> > > > > > > >> > >>> > take a
> > > > > > > >> > >>> > > > > look at the branch `
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> >
> > > > > > > >> >
> > > > > >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > > >> <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > > >> > <
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >
> > > > > > > >> > >>> <
> > > > > > > >>
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > >> > >>> > <
> > > > > > > >> >
> > > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > > > > >> > >>> > > <
> > > > > > > >> > >>>
> > > > > > > >>
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > >> > >>> > > > <
> > > > > > > >> > >>>
> > > > > > > >>
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > > >> > >>> > > > > <
> > > > > > > >> > >>> >
> > > > > > > >>
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > > >> > >
> > > > > > > >> > >>> > > > and
> > > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > > >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344
> to
> > > > check
> > > > > > the
> > > > > > > >> kind
> > > > > > > >> > >>> of
> > > > > > > >> > >>> > > > changes
> > > > > > > >> > >>> > > > > we do in hal. Essentially, we create a wrapper
> > > layer
> > > > > to
> > > > > > > >> make it
> > > > > > > >> > >>> > > > independent
> > > > > > > >> > >>> > > > > of the host OS.
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > That being said, you can either 1) try to
> adapt
> > > the
> > > > > > > >> > >>> implementation of
> > > > > > > >> > >>> > > > other
> > > > > > > >> > >>> > > > > devices to use the HAL functions or 2) get
> some
> > > > > > > inspiration
> > > > > > > >> on
> > > > > > > >> > >>> how
> > > > > > > >> > >>> > IDF
> > > > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd option
> > > before
> > > > > > simply
> > > > > > > >> > >>> trying to
> > > > > > > >> > >>> > > > adapt
> > > > > > > >> > >>> > > > > an existing implementation (from ESP32-C3
> legacy
> > > or
> > > > > from
> > > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > Best regards,
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe
> > Moura
> > > > > > > Oliveira
> > > > > > > >> <
> > > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > > >> > >>> > > > > >
> > > > > > > >> > >>> > > > > > Thank you for clarification, I will follow
> > your
> > > > > > > >> instructions.
> > > > > > > >> > >>> > > > > >
> > > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago
> > > > Medicci
> > > > > > > >> Serrano <
> > > > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > >> > >>> > > > > >
> > > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > > Just complementing: use your forked
> version
> > of
> > > > the
> > > > > > HAL
> > > > > > > >> > >>> during the
> > > > > > > >> > >>> > > > > > > development. As soon as you have a working
> > > > > version,
> > > > > > > you
> > > > > > > >> can
> > > > > > > >> > >>> > submit
> > > > > > > >> > >>> > > on
> > > > > > > >> > >>> > > > > the
> > > > > > > >> > >>> > > > > > > official repository.
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > > Best regards,
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58,
> Tiago
> > > > > Medicci
> > > > > > > >> > Serrano <
> > > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > Thanks for asking! You should follow the
> > > path
> > > > > > using
> > > > > > > >> the
> > > > > > > >> > >>> > functions
> > > > > > > >> > >>> > > > on
> > > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the
> > > repository
> > > > > and
> > > > > > > use
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > >
> > > > > > > >>
> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > > >> > >>> > > > > > env
> > > > > > > >> > >>> > > > > > > > vars (globally or before the make
> command)
> > > to
> > > > > use
> > > > > > > your
> > > > > > > >> > >>> version
> > > > > > > >> > >>> > of
> > > > > > > >> > >>> > > > the
> > > > > > > >> > >>> > > > > > > HAL.
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > I just wanted to share some thoughts:
> > using
> > > > the
> > > > > > HAL
> > > > > > > >> > >>> enables us
> > > > > > > >> > >>> > to
> > > > > > > >> > >>> > > > > make
> > > > > > > >> > >>> > > > > > > the
> > > > > > > >> > >>> > > > > > > > feature available for all the Espressif
> > > > devices
> > > > > > > >> (please
> > > > > > > >> > >>> don't
> > > > > > > >> > >>> > > > bother
> > > > > > > >> > >>> > > > > > with
> > > > > > > >> > >>> > > > > > > > that now, as soon as you submit it, we
> can
> > > > test
> > > > > > for
> > > > > > > >> the
> > > > > > > >> > >>> other
> > > > > > > >> > >>> > > > devices
> > > > > > > >> > >>> > > > > > and
> > > > > > > >> > >>> > > > > > > > eventually make any adjustments).
> Although
> > > > it's
> > > > > > > >> possible
> > > > > > > >> > to
> > > > > > > >> > >>> > > > > reimplement
> > > > > > > >> > >>> > > > > > > > these functions on NuttX, we don't
> > recommend
> > > > > that
> > > > > > > >> because
> > > > > > > >> > >>> of
> > > > > > > >> > >>> > the
> > > > > > > >> > >>> > > > > first
> > > > > > > >> > >>> > > > > > > > statement (the ability to use for the
> > other
> > > > > > > devices):
> > > > > > > >> in
> > > > > > > >> > >>> that
> > > > > > > >> > >>> > > case
> > > > > > > >> > >>> > > > we
> > > > > > > >> > >>> > > > > > > > wouldn't be able to support the feature.
> > You
> > > > can
> > > > > > > take
> > > > > > > >> a
> > > > > > > >> > >>> look on
> > > > > > > >> > >>> > > IDF
> > > > > > > >> > >>> > > > > for
> > > > > > > >> > >>> > > > > > > > some inspiration on how it's
> implemented.
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > Please let me know if you have any
> > > questions.
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38,
> > Felipe
> > > > > Moura
> > > > > > > >> > >>> Oliveira <
> > > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >> Our project has reached a point where
> we
> > > need
> > > > > the
> > > > > > > >> Power
> > > > > > > >> > >>> > Manager
> > > > > > > >> > >>> > > > > > > >> functionality, which is not yet
> available
> > > in
> > > > > the
> > > > > > > >> > ESP32C6.
> > > > > > > >> > >>> I am
> > > > > > > >> > >>> > > > > > studying
> > > > > > > >> > >>> > > > > > > to
> > > > > > > >> > >>> > > > > > > >> start the implementation, but I am
> > confused
> > > > > about
> > > > > > > the
> > > > > > > >> > >>> correct
> > > > > > > >> > >>> > > way
> > > > > > > >> > >>> > > > to
> > > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >> There is a Power Manager implementation
> > for
> > > > the
> > > > > > > >> ESP32C3,
> > > > > > > >> > >>> but
> > > > > > > >> > >>> > it
> > > > > > > >> > >>> > > > > seems
> > > > > > > >> > >>> > > > > > to
> > > > > > > >> > >>> > > > > > > >> follow the legacy methodology. In fact,
> > the
> > > > > file
> > > > > > > >> > >>> > esp32c3_idle.c
> > > > > > > >> > >>> > > is
> > > > > > > >> > >>> > > > > > > located
> > > > > > > >> > >>> > > > > > > >> in the path
> > arch/risc-v/src/esp32c3-legacy.
> > > > In
> > > > > > this
> > > > > > > >> > >>> > methodology,
> > > > > > > >> > >>> > > > > > > functions
> > > > > > > >> > >>> > > > > > > >> are re-implemented from the Espressif
> > > driver.
> > > > > For
> > > > > > > >> > >>> example, the
> > > > > > > >> > >>> > > > > > function
> > > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is
> > > > currently
> > > > > > > >> > available
> > > > > > > >> > >>> in
> > > > > > > >> > >>> > > > > > > >>
> > esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >> I tried using the implementations from
> > > > > > > >> esp-hal-3rdparty
> > > > > > > >> > to
> > > > > > > >> > >>> > > develop
> > > > > > > >> > >>> > > > > the
> > > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX,
> > but
> > > > the
> > > > > > > files
> > > > > > > >> > >>> still
> > > > > > > >> > >>> > have
> > > > > > > >> > >>> > > > > many
> > > > > > > >> > >>> > > > > > > >> dependencies on items that are not
> > present
> > > in
> > > > > > > NuttX.
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >> My question is: Should I try to make
> the
> > > > Power
> > > > > > > >> Manager
> > > > > > > >> > >>> work
> > > > > > > >> > >>> > > using
> > > > > > > >> > >>> > > > > the
> > > > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if
> it
> > > > > > requires
> > > > > > > >> > making
> > > > > > > >> > >>> > > changes
> > > > > > > >> > >>> > > > to
> > > > > > > >> > >>> > > > > > the
> > > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I
> re-implement
> > > the
> > > > > > > >> functions
> > > > > > > >> > >>> within
> > > > > > > >> > >>> > > > NuttX,
> > > > > > > >> > >>> > > > > > > even
> > > > > > > >> > >>> > > > > > > >> if, in this case, there are functions
> > with
> > > > the
> > > > > > same
> > > > > > > >> > scope
> > > > > > > >> > >>> and
> > > > > > > >> > >>> > > > > > > >> implementation in different files,
> where
> > > one
> > > > is
> > > > > > > >> > compiled,
> > > > > > > >> > >>> and
> > > > > > > >> > >>> > > the
> > > > > > > >> > >>> > > > > > other
> > > > > > > >> > >>> > > > > > > is
> > > > > > > >> > >>> > > > > > > >> not?
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >> --
> > > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > > >> > >>> >
> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > >> > >>> > > > > > > >> <
> > > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > > >
> > > > > > > >> > >>> > > > > > > >>
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > --
> > > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886
> <+55+(19)+981403886>
> > > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > > >> > >>> > > > > > > > <
> > > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > > >
> > > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > > >> > >>> > > > > > > >
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > > --
> > > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > > >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > > >> > >>> > > > > > > Follow me:
> > > > > > > >> > >>> > > > > > > <
> > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > >
> > > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > > >> > >>> > > > > > >
> > > > > > > >> > >>> > > > > >
> > > > > > > >> > >>> > > > > >
> > > > > > > >> > >>> > > > > > --
> > > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > >> > >>> > > > > > Linkedin <
> > > > > > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > > > > > <
> > https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >> > >>> > > > > >
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > --
> > > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > > >> > >>> > > > > Follow me:
> > > > > > > >> > >>> > > > > <
> > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > >
> > > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > > >> > >>> > > > >
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > > > --
> > > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > > >> > >>> > > > Linkedin <
> > > > > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >> > >>> > > >
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > --
> > > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > > >> > >>> > > Follow me:
> > > > > > > >> > >>> > > <
> https://www.linkedin.com/in/tiago-serrano-924458b6
> > >
> > > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > > >> > >>> > >
> > > > > > > >> > >>> >
> > > > > > > >> > >>> >
> > > > > > > >> > >>> > --
> > > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > > >> > >>> > Linkedin <
> > > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >> > >>> >
> > > > > > > >> > >>>
> > > > > > > >> > >>
> > > > > > > >> > >>
> > > > > > > >> > >> --
> > > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > > >> > >> Linkedin <
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > >
> > > > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >> > >>
> > > > > > > >> > >
> > > > > > > >> > >
> > > > > > > >> > > --
> > > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > > >> > > Linkedin <
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >> > >
> > > > > > > >> >
> > > > > > > >> >
> > > > > > > >> > --
> > > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > > >> > Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > *Felipe Moura de Oliveira*
> > > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >
> > > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > *Felipe Moura de Oliveira*
> > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >
> > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Felipe Moura de Oliveira*
> > > > > *Universidade Federal de Minas Gerais*
> > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
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.medicci@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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > > #include <stdio.h>
> > > > #include <stdint.h>
> > > > #include <time.h>
> > > > #include <unistd.h>
> > > > #include <pthread.h>
> > > > #include <stdlib.h>
> > > >
> > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > * 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);
> > > > }
> > > >
> > > > return NULL;
> > > > }
> > > >
> > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > * Public Functions
> > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > >
> > > >
> > > >
> > >
> >
> /****************************************************************************
> > > > * main
> > > >
> > > >
> > >
> >
> ****************************************************************************/
> > > >
> > > > int main(int argc, FAR char *argv[])
> > > > {
> > > > pthread_t threads[NUM_THREADS];
> > > > struct thread_info tinfo[NUM_THREADS];
> > > > int ret;
> > > >
> > > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> > > >
> > > > for (int i = 0; i < NUM_THREADS; i++)
> > > > {
> > > > tinfo[i].thread_id = i + 1;
> > > > tinfo[i].sleep_time = sleep_times[i];
> > > >
> > > > ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
> > > > if (ret != 0)
> > > > {
> > > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > > exit(EXIT_FAILURE);
> > > > }
> > > > }
> > > > int app_ret = 0;
> > > > if (app_ret == -1) {
> > > > printf("Error executing command\n");
> > > > } else {
> > > > printf("Application finished with return code: %d\n", app_ret);
> > > > }
> > > >
> > > > while (1)
> > > > {
> > > > printf("Hello, World!! [Main Thread]\n");
> > > > sleep(10);
> > > > }
> > > >
> > > > return 0;
> > > > }
> > > >
> > > >
> > > >
> > > > You will see output below:
> > > > nsh> hello
> > > > Aplicação finalizou com código de retorno: 0
> > > > Hello, World!! [Main Thread]
> > > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0
> > segundos
> > > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0 segundos
> > > > *pmu_*Hello, World!! [Main Thread]
> > > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11 segundos
> > > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16 segundos
> > > >
> > > > I was able to power consumption below 1 mA when mcu is in idle mode,
> so
> > > it
> > > > is in light sleep.
> > > >
> > > > Later, making a distclean, running wifi config and adding
> > > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see
> that
> > > the
> > > > mcu goes to sleep and not return.
> > > >
> > > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > > > tiago.medicci@gmail.com> escreveu:
> > > >
> > > > > Hi Felipe, good to hear about your progress here!
> > > > >
> > > > > These functions are ROM-defined functions. By checking the TRM, you
> > can
> > > > see
> > > > > a read-only flash partition that holds some functions (widely used
> > > > > functions, like malloc and internal functions).
> > > > >
> > > > > ets_get_cpu_frequency
> > > > > <
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > > >
> > > > > is
> > > > > one of these internal functions. They are defined directly at the
> > > linker
> > > > > script.
> > > > >
> > > > > If I understood correctly, these functions are crashing when it's
> > being
> > > > > called, right? If so, can you:
> > > > >
> > > > > 1. Share the crash dump
> > > > > 2. Use GDB and try to check where/why it fails: it may trying to
> > > > access
> > > > > some prohibited memory region or even trying to call an
> > unregistered
> > > > > callback.
> > > > >
> > > > > Thanks!
> > > > >
> > > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > > > > moura.fmo@gmail.com> escreveu:
> > > > >
> > > > > > Hello everyone,
> > > > > >
> > > > > > Tiago, I am trying to work with light sleep for now, after it
> work
> > > will
> > > > > go
> > > > > > ahead with deep sleep. To run in light sleep I don't need to
> change
> > > > > linker
> > > > > > so I was able to build and flash without "image" issues.
> > > > > > Now I am facing other kind of issue:
> > > > > > Some functions refers to "ets" function and I don't know how
> handle
> > > > this,
> > > > > > for instance:
> > > > > >
> > > > > > /**
> > > > > > * @brief Get the real CPU ticks per us
> > > > > > *
> > > > > > * @return CPU ticks per us
> > > > > > */
> > > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > > >
> > > > > > This function is necessary in the *sleep_modes.c* file. During
> > > execute
> > > > > code
> > > > > > I am facing crash when this function is called, its happen
> because
> > > its
> > > > > > implementation is a reference to other function:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > > > > >
> > > > > > I cannot find *ets_get_cpu_frequency*, so how should I handle it?
> > > > > >
> > > > > > PS: I have another situation like this, when I try to call
> > > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > > >
> > > > > > Regards.
> > > > > >
> > > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > > > > > moura.fmo@gmail.com> escreveu:
> > > > > >
> > > > > > > Hello Tiago.
> > > > > > >
> > > > > > > Please look de draft here:
> > > > https://github.com/apache/nuttx/pull/14548
> > > > > > >
> > > > > > > This branch will refer to the updated 3rd-party in my repo.
> > > > > > >
> > > > > > > You only need to enable PM in menuconfig and it will be enough
> to
> > > see
> > > > > > > changes.
> > > > > > >
> > > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > >
> > > > > > >> Hi Felipe,
> > > > > > >>
> > > > > > >> Can you share your PR as a draft on GH to make it easier to
> > check
> > > > the
> > > > > > >> files
> > > > > > >> (and the build process)?
> > > > > > >>
> > > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> > > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > > >>
> > > > > > >> > Hello Tiago,
> > > > > > >> >
> > > > > > >> > I "finished" the port, but after it my esp32c6 dev kit is
> > > > resetting.
> > > > > > >> Maybe
> > > > > > >> > the issue is related my changes in
> > > > > > >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld.
> Can
> > > you
> > > > > give
> > > > > > >> some
> > > > > > >> > tips about how to go ahead?
> > > > > > >> >
> > > > > > >> > Below you can see nuttx report:
> > > > > > >> > Build:Sep 19 2022
> > > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > > > > > >> > Saved PC:0x40018bea
> > > > > > >> > SPIWP:0xee
> > > > > > >> > mode:DIO, clock div:2
> > > > > > >> > load:0x40800000,len:0x61e0
> > > > > > >> > load:0x408061e0,len:0xc34
> > > > > > >> > load:0x50000000,len:0x20
> > > > > > >> > load:0x5000001e,len:0x24
> > > > > > >> > Invalid image block, can't boot.
> > > > > > >> > ets_main.c 331
> > > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > > >> >
> > > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira
> <
> > > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > > >> >
> > > > > > >> > > Hello everyone,
> > > > > > >> > >
> > > > > > >> > > I was able to solve linker issues, editing the linker by
> > > > myself. I
> > > > > > >> need
> > > > > > >> > to
> > > > > > >> > > finish more than one build issue before testing it, so I
> > will
> > > > see
> > > > > > if I
> > > > > > >> > made
> > > > > > >> > > the right changes in linker.
> > > > > > >> > >
> > > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura
> Oliveira
> > <
> > > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > > >> > >
> > > > > > >> > >> *Hello everyone, Tiago,*
> > > > > > >> > >>
> > > > > > >> > >> I have made progress with the build issue I was
> > encountering
> > > > and
> > > > > am
> > > > > > >> now
> > > > > > >> > >> "stuck" at what I believe is one of the final stages. I
> am
> > > > > > >> experiencing
> > > > > > >> > the
> > > > > > >> > >> following compilation error:
> > > > > > >> > >> LD: nuttx
> > > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > > >> > >> riscv-none-elf-ld:
> > > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > > > > > >> > >> `_rtc_force_fast_end'
> > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4):
> > undefined
> > > > > > >> reference
> > > > > > >> > >> to `_rtc_text_start'
> > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8):
> > undefined
> > > > > > >> reference
> > > > > > >> > >> to `_rtc_force_fast_end'
> > > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc):
> > undefined
> > > > > > >> reference
> > > > > > >> > >> to `_rtc_text_start'
> > > > > > >> > >> riscv-none-elf-ld:
> > > > > > >> > >>
> > > > > > >> >
> > > > > > >>
> > > > > >
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > > > > > >> > >> `rv_core_critical_regs_save'
> > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e):
> undefined
> > > > > > reference
> > > > > > >> to
> > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226):
> undefined
> > > > > > reference
> > > > > > >> to
> > > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > >> > >>
> > > > > > >> > >> I would greatly appreciate your assistance.
> > > > > > >> > >>
> > > > > > >> > >> Focusing on the item _rtc_text_start, I see that it is
> > > defined
> > > > in
> > > > > > the
> > > > > > >> > >> file:
> > > > > > >> > >>
> > > > > > >>
> > > > >
> > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > >> > >> sections.ld.in
> > > > > > >> > >>
> > > > > > >> > >> However, I am unsure how to add this file to the complete
> > > > linking
> > > > > > >> > >> process. I added this file to hal_esp32c6.mk, but I
> > received
> > > > the
> > > > > > >> > >> following error:
> > > > > > >> > >> LD: nuttx
> > > > > > >> > >>
> > > > > > >> >
> > > > > > >>
> > > > > >
> > > >
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > > >> > >>
> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > > >> > >> sections.ld.in.tmp:113 cannot move location counter
> > backwards
> > > > > (from
> > > > > > >> > >> 40809800 to 40800000)
> > > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > > >> > >>
> > > > > > >> > >>
> > > > > > >> > >> Does anyone have any tips or suggestions that could help
> me
> > > > move
> > > > > > >> forward
> > > > > > >> > >> with this process?
> > > > > > >> > >>
> > > > > > >> > >> Thank you in advance for your help.
> > > > > > >> > >>
> > > > > > >> > >> *Best regards,*
> > > > > > >> > >>
> > > > > > >> > >>
> > > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci
> > Serrano <
> > > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > > >> > >>
> > > > > > >> > >>> Hi Felipe,
> > > > > > >> > >>>
> > > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a
> > > > > substitute
> > > > > > >> for
> > > > > > >> > >>> this
> > > > > > >> > >>> function should be part
> > > > > > >> > >>> of
> > `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > > That
> > > > > > >> being
> > > > > > >> > >>> said, you can either implement it (and define it as a
> > macro,
> > > > on
> > > > > > >> HAL) or
> > > > > > >> > >>> you
> > > > > > >> > >>> can either ignore these functions related to GPIO wakeup
> > > from
> > > > > > sleep
> > > > > > >> for
> > > > > > >> > >>> now
> > > > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up
> to
> > > > you:
> > > > > if
> > > > > > >> the
> > > > > > >> > >>> GPIO
> > > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing
> this
> > > > > feature
> > > > > > >> for
> > > > > > >> > >>> now.
> > > > > > >> > >>>
> > > > > > >> > >>> Best regards,
> > > > > > >> > >>>
> > > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura
> > Oliveira
> > > <
> > > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > > >> > >>>
> > > > > > >> > >>> > Hello Tiago,
> > > > > > >> > >>> >
> > > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > > >> > >>> >
> > > > > > >> > >>> > I would like to discuss further the necessity of the
> > > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only
> > > > available
> > > > > > in
> > > > > > >> the
> > > > > > >> > >>> IDF.
> > > > > > >> > >>> >
> > > > > > >> > >>> > In sleep_modes.c, there is the following code snippet:
> > > > > > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t
> > > io_mask,
> > > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > > >> > >>> > {
> > > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > >> > >>> > }
> > > > > > >> > >>> > // Translate bit map of GPIO numbers into the bit map
> of
> > > RTC
> > > > > IO
> > > > > > >> > numbers
> > > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > > >> > >>> > continue;
> > > > > > >> > >>> > }
> > > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > > >> > >>> > }
> > > > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > > > >> > >>> > }
> > > > > > >> > >>> >
> > > > > > >> > >>> > I believe this code is essential for compilation. The
> > > > function
> > > > > > >> > >>> > rtc_io_number_get is located at the following path in
> > the
> > > > IDF:
> > > > > > >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > > >> > >>> >
> > > > > > >> > >>> > However, the esp_driver_gpio folder is not present in
> > the
> > > > > > >> 3rd-party
> > > > > > >> > >>> > directory. In this case, what is the recommended
> > procedure
> > > > to
> > > > > > >> > proceed?
> > > > > > >> > >>> >
> > > > > > >> > >>> > Thank you again for your support.
> > > > > > >> > >>> >
> > > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci
> > > Serrano
> > > > <
> > > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > > >> > >>> >
> > > > > > >> > >>> > > Hi Felipe,
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > `esp_private/pm_impl.h` is from the component
> `esp_pm`
> > > of
> > > > > > >> ESP-IDF,
> > > > > > >> > >>> which
> > > > > > >> > >>> > is
> > > > > > >> > >>> > > a driver directly. Same for
> > > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > > >> > >>> (here, a
> > > > > > >> > >>> > > detail: I wasn't able to find this path on IDF, so
> > make
> > > > sure
> > > > > > you
> > > > > > >> > are
> > > > > > >> > >>> > > checking under the `release/v5.1` branch, which the
> > HAL
> > > > was
> > > > > > >> based).
> > > > > > >> > >>> The
> > > > > > >> > >>> > HAL
> > > > > > >> > >>> > > repository doesn't contain ESP-IDF drivers, which
> are
> > > > always
> > > > > > >> > >>> implemented
> > > > > > >> > >>> > on
> > > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > > > > >> > >>> > >
> > > > > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > The files under
> > > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to
> > implement
> > > > the
> > > > > > >> > driver.
> > > > > > >> > >>> This
> > > > > > >> > >>> > > is, mostly, a wrapping layer under the function of
> > > > `esp_rom`
> > > > > > and
> > > > > > >> > >>> `hal`
> > > > > > >> > >>> > > components. However, they still may refer to ESP-IDF
> > > > > drivers.
> > > > > > >> That
> > > > > > >> > >>> being
> > > > > > >> > >>> > > said, you can check if removing such dependencies is
> > > > > possible.
> > > > > > >> We
> > > > > > >> > >>> usually
> > > > > > >> > >>> > > do that with conditional macros. A good starting
> point
> > > is
> > > > to
> > > > > > >> check
> > > > > > >> > >>> for
> > > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and headers: we
> > use
> > > > them
> > > > > > to
> > > > > > >> > >>> > remove/add
> > > > > > >> > >>> > > headers and functions that aren't available on
> > > > NuttX/needed
> > > > > by
> > > > > > >> > NuttX.
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > Best regards,
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura
> > > > Oliveira
> > > > > <
> > > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > > Hello all,
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > Tiago,
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > I have a question regarding the porting process.
> > > > > > >> Specifically, I
> > > > > > >> > >>> need
> > > > > > >> > >>> > to
> > > > > > >> > >>> > > > add the sleep_modes.c file to the compilation
> > process.
> > > > Am
> > > > > I
> > > > > > on
> > > > > > >> > the
> > > > > > >> > >>> > right
> > > > > > >> > >>> > > > path with this approach?
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk
> file
> > > by
> > > > > > adding
> > > > > > >> > >>> > > > sleep_modes.c.
> > > > > > >> > >>> > > > However, I am facing some issues: within
> > > sleep_modes.c,
> > > > > some
> > > > > > >> > >>> #include
> > > > > > >> > >>> > > > statements reference files that are not available
> in
> > > the
> > > > > > >> > 3rd-party
> > > > > > >> > >>> > > > directory but are only present in the IDF. For
> > > example:
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > > >> > >>> > > > - esp_cpu.h
> > > > > > >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > I need those includes because sleep_modes.c uses
> > > > function
> > > > > > from
> > > > > > >> > >>> there.
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > Could you please advise if it's possible to
> > > incorporate
> > > > > > these
> > > > > > >> IDF
> > > > > > >> > >>> > folders
> > > > > > >> > >>> > > > into the 3rd-party directory, or if that approach
> is
> > > not
> > > > > > >> > >>> recommended?
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > Thank you for your assistance.
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > Best regards,
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago
> Medicci
> > > > > Serrano
> > > > > > <
> > > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > > Hi,
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > Just another note to guide your development: we
> > > don't
> > > > > > >> develop
> > > > > > >> > >>> > anything
> > > > > > >> > >>> > > on
> > > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from
> > it
> > > is
> > > > > > >> derived
> > > > > > >> > >>> from
> > > > > > >> > >>> > the
> > > > > > >> > >>> > > > > path
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > >
> > > > > > >> > >>> >
> > > > > > >> > >>>
> > > > > > >> >
> > > > > > >>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > > >> > >>> > > > > (essentially, header files from
> > > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > > >> > >>> > > > except
> > > > > > >> > >>> > > > > for some of the sources files that use the hal
> > > > functions
> > > > > > at
> > > > > > >> > >>> > > > > `components/hal` to implement some function we
> may
> > > > use).
> > > > > > You
> > > > > > >> > can
> > > > > > >> > >>> > take a
> > > > > > >> > >>> > > > > look at the branch `
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> >
> > > > > > >> >
> > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > > >> <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > > >> > <
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >
> > > > > > >> > >>> <
> > > > > > >>
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > >> > >>> > <
> > > > > > >> >
> > > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > > > > >> > >>> > > <
> > > > > > >> > >>>
> > > > > > >>
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > >> > >>> > > > <
> > > > > > >> > >>>
> > > > > > >>
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > > >> > >>> > > > > <
> > > > > > >> > >>> >
> > > > > > >>
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > > >> > >
> > > > > > >> > >>> > > > and
> > > > > > >> > >>> > > > > especially the commits beginning
> > > > > > >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to
> > > check
> > > > > the
> > > > > > >> kind
> > > > > > >> > >>> of
> > > > > > >> > >>> > > > changes
> > > > > > >> > >>> > > > > we do in hal. Essentially, we create a wrapper
> > layer
> > > > to
> > > > > > >> make it
> > > > > > >> > >>> > > > independent
> > > > > > >> > >>> > > > > of the host OS.
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > That being said, you can either 1) try to adapt
> > the
> > > > > > >> > >>> implementation of
> > > > > > >> > >>> > > > other
> > > > > > >> > >>> > > > > devices to use the HAL functions or 2) get some
> > > > > > inspiration
> > > > > > >> on
> > > > > > >> > >>> how
> > > > > > >> > >>> > IDF
> > > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd option
> > before
> > > > > simply
> > > > > > >> > >>> trying to
> > > > > > >> > >>> > > > adapt
> > > > > > >> > >>> > > > > an existing implementation (from ESP32-C3 legacy
> > or
> > > > from
> > > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > Best regards,
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe
> Moura
> > > > > > Oliveira
> > > > > > >> <
> > > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > > Hello Tiago.
> > > > > > >> > >>> > > > > >
> > > > > > >> > >>> > > > > > Thank you for clarification, I will follow
> your
> > > > > > >> instructions.
> > > > > > >> > >>> > > > > >
> > > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago
> > > Medicci
> > > > > > >> Serrano <
> > > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > >> > >>> > > > > >
> > > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > > Just complementing: use your forked version
> of
> > > the
> > > > > HAL
> > > > > > >> > >>> during the
> > > > > > >> > >>> > > > > > > development. As soon as you have a working
> > > > version,
> > > > > > you
> > > > > > >> can
> > > > > > >> > >>> > submit
> > > > > > >> > >>> > > on
> > > > > > >> > >>> > > > > the
> > > > > > >> > >>> > > > > > > official repository.
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > > Best regards,
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago
> > > > Medicci
> > > > > > >> > Serrano <
> > > > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > Thanks for asking! You should follow the
> > path
> > > > > using
> > > > > > >> the
> > > > > > >> > >>> > functions
> > > > > > >> > >>> > > > on
> > > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the
> > repository
> > > > and
> > > > > > use
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > >
> > > > > > >>
> > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > >> > >>> > > > > > env
> > > > > > >> > >>> > > > > > > > vars (globally or before the make command)
> > to
> > > > use
> > > > > > your
> > > > > > >> > >>> version
> > > > > > >> > >>> > of
> > > > > > >> > >>> > > > the
> > > > > > >> > >>> > > > > > > HAL.
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > I just wanted to share some thoughts:
> using
> > > the
> > > > > HAL
> > > > > > >> > >>> enables us
> > > > > > >> > >>> > to
> > > > > > >> > >>> > > > > make
> > > > > > >> > >>> > > > > > > the
> > > > > > >> > >>> > > > > > > > feature available for all the Espressif
> > > devices
> > > > > > >> (please
> > > > > > >> > >>> don't
> > > > > > >> > >>> > > > bother
> > > > > > >> > >>> > > > > > with
> > > > > > >> > >>> > > > > > > > that now, as soon as you submit it, we can
> > > test
> > > > > for
> > > > > > >> the
> > > > > > >> > >>> other
> > > > > > >> > >>> > > > devices
> > > > > > >> > >>> > > > > > and
> > > > > > >> > >>> > > > > > > > eventually make any adjustments). Although
> > > it's
> > > > > > >> possible
> > > > > > >> > to
> > > > > > >> > >>> > > > > reimplement
> > > > > > >> > >>> > > > > > > > these functions on NuttX, we don't
> recommend
> > > > that
> > > > > > >> because
> > > > > > >> > >>> of
> > > > > > >> > >>> > the
> > > > > > >> > >>> > > > > first
> > > > > > >> > >>> > > > > > > > statement (the ability to use for the
> other
> > > > > > devices):
> > > > > > >> in
> > > > > > >> > >>> that
> > > > > > >> > >>> > > case
> > > > > > >> > >>> > > > we
> > > > > > >> > >>> > > > > > > > wouldn't be able to support the feature.
> You
> > > can
> > > > > > take
> > > > > > >> a
> > > > > > >> > >>> look on
> > > > > > >> > >>> > > IDF
> > > > > > >> > >>> > > > > for
> > > > > > >> > >>> > > > > > > > some inspiration on how it's implemented.
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > Please let me know if you have any
> > questions.
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > Best regards,
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38,
> Felipe
> > > > Moura
> > > > > > >> > >>> Oliveira <
> > > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >> Our project has reached a point where we
> > need
> > > > the
> > > > > > >> Power
> > > > > > >> > >>> > Manager
> > > > > > >> > >>> > > > > > > >> functionality, which is not yet available
> > in
> > > > the
> > > > > > >> > ESP32C6.
> > > > > > >> > >>> I am
> > > > > > >> > >>> > > > > > studying
> > > > > > >> > >>> > > > > > > to
> > > > > > >> > >>> > > > > > > >> start the implementation, but I am
> confused
> > > > about
> > > > > > the
> > > > > > >> > >>> correct
> > > > > > >> > >>> > > way
> > > > > > >> > >>> > > > to
> > > > > > >> > >>> > > > > > > >> approach this.
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >> There is a Power Manager implementation
> for
> > > the
> > > > > > >> ESP32C3,
> > > > > > >> > >>> but
> > > > > > >> > >>> > it
> > > > > > >> > >>> > > > > seems
> > > > > > >> > >>> > > > > > to
> > > > > > >> > >>> > > > > > > >> follow the legacy methodology. In fact,
> the
> > > > file
> > > > > > >> > >>> > esp32c3_idle.c
> > > > > > >> > >>> > > is
> > > > > > >> > >>> > > > > > > located
> > > > > > >> > >>> > > > > > > >> in the path
> arch/risc-v/src/esp32c3-legacy.
> > > In
> > > > > this
> > > > > > >> > >>> > methodology,
> > > > > > >> > >>> > > > > > > functions
> > > > > > >> > >>> > > > > > > >> are re-implemented from the Espressif
> > driver.
> > > > For
> > > > > > >> > >>> example, the
> > > > > > >> > >>> > > > > > function
> > > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is
> > > currently
> > > > > > >> > available
> > > > > > >> > >>> in
> > > > > > >> > >>> > > > > > > >>
> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >> I tried using the implementations from
> > > > > > >> esp-hal-3rdparty
> > > > > > >> > to
> > > > > > >> > >>> > > develop
> > > > > > >> > >>> > > > > the
> > > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX,
> but
> > > the
> > > > > > files
> > > > > > >> > >>> still
> > > > > > >> > >>> > have
> > > > > > >> > >>> > > > > many
> > > > > > >> > >>> > > > > > > >> dependencies on items that are not
> present
> > in
> > > > > > NuttX.
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >> My question is: Should I try to make the
> > > Power
> > > > > > >> Manager
> > > > > > >> > >>> work
> > > > > > >> > >>> > > using
> > > > > > >> > >>> > > > > the
> > > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it
> > > > > requires
> > > > > > >> > making
> > > > > > >> > >>> > > changes
> > > > > > >> > >>> > > > to
> > > > > > >> > >>> > > > > > the
> > > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I re-implement
> > the
> > > > > > >> functions
> > > > > > >> > >>> within
> > > > > > >> > >>> > > > NuttX,
> > > > > > >> > >>> > > > > > > even
> > > > > > >> > >>> > > > > > > >> if, in this case, there are functions
> with
> > > the
> > > > > same
> > > > > > >> > scope
> > > > > > >> > >>> and
> > > > > > >> > >>> > > > > > > >> implementation in different files, where
> > one
> > > is
> > > > > > >> > compiled,
> > > > > > >> > >>> and
> > > > > > >> > >>> > > the
> > > > > > >> > >>> > > > > > other
> > > > > > >> > >>> > > > > > > is
> > > > > > >> > >>> > > > > > > >> not?
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >> --
> > > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > > >> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > >> > >>> > > > > > > >> <
> > > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > > >
> > > > > > >> > >>> > > > > > > >>
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > --
> > > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > > >> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > > >> > >>> > > > > > > > Follow me:
> > > > > > >> > >>> > > > > > > > <
> > > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > > >
> > > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > > >> > >>> > > > > > > >
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > > --
> > > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > > >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > > >> > >>> > > > > > > Follow me:
> > > > > > >> > >>> > > > > > > <
> > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > >
> > > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > > >> > >>> > > > > > >
> > > > > > >> > >>> > > > > >
> > > > > > >> > >>> > > > > >
> > > > > > >> > >>> > > > > > --
> > > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > >> > >>> > > > > > Linkedin <
> > > > > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > > >> > >>> >
> > > > > > >> > >>> > > > > > <
> https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >> > >>> > > > > >
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > --
> > > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > > >> > >>> > > > > Follow me:
> > > > > > >> > >>> > > > > <
> > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > >
> > > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > > >> > >>> > > > >
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > > > --
> > > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > > >> > >>> > > > Linkedin <
> > > > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >> > >>> > > >
> > > > > > >> > >>> > >
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > --
> > > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > > >> > >>> > >
> > > > > > >> > >>> > > Embedded Software Engineer
> > > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > > >> > >>> > > a: Campinas, Brazil
> > > > > > >> > >>> > > Follow me:
> > > > > > >> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6
> >
> > > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > > >> > >>> > >
> > > > > > >> > >>> >
> > > > > > >> > >>> >
> > > > > > >> > >>> > --
> > > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > > >> > >>> > Linkedin <
> > > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >> > >>> >
> > > > > > >> > >>>
> > > > > > >> > >>
> > > > > > >> > >>
> > > > > > >> > >> --
> > > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > > >> > >> Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > >
> > > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >> > >>
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > --
> > > > > > >> > > *Felipe Moura de Oliveira*
> > > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > > >> > > Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >> > >
> > > > > > >> >
> > > > > > >> >
> > > > > > >> > --
> > > > > > >> > *Felipe Moura de Oliveira*
> > > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > > >> > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > *Felipe Moura de Oliveira*
> > > > > > > *Universidade Federal de Minas Gerais*
> > > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >
> > > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *Felipe Moura de Oliveira*
> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
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.fmo@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.medicci@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.fmo@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 <nuttx/config.h>
> > > #include <stdio.h>
> > > #include <stdint.h>
> > > #include <time.h>
> > > #include <unistd.h>
> > > #include <pthread.h>
> > > #include <stdlib.h>
> > >
> > >
> > >
> >
> /****************************************************************************
> > > * 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);
> > > }
> > >
> > > return NULL;
> > > }
> > >
> > >
> > >
> >
> /****************************************************************************
> > > * Public Functions
> > >
> > >
> >
> ****************************************************************************/
> > >
> > >
> > >
> >
> /****************************************************************************
> > > * main
> > >
> > >
> >
> ****************************************************************************/
> > >
> > > int main(int argc, FAR char *argv[])
> > > {
> > > pthread_t threads[NUM_THREADS];
> > > struct thread_info tinfo[NUM_THREADS];
> > > int ret;
> > >
> > > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> > >
> > > for (int i = 0; i < NUM_THREADS; i++)
> > > {
> > > tinfo[i].thread_id = i + 1;
> > > tinfo[i].sleep_time = sleep_times[i];
> > >
> > > ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
> > > if (ret != 0)
> > > {
> > > printf("Error creating thread %d: %d\n", i + 1, ret);
> > > exit(EXIT_FAILURE);
> > > }
> > > }
> > > int app_ret = 0;
> > > if (app_ret == -1) {
> > > printf("Error executing command\n");
> > > } else {
> > > printf("Application finished with return code: %d\n", app_ret);
> > > }
> > >
> > > while (1)
> > > {
> > > printf("Hello, World!! [Main Thread]\n");
> > > sleep(10);
> > > }
> > >
> > > return 0;
> > > }
> > >
> > >
> > >
> > > You will see output below:
> > > nsh> hello
> > > Aplicação finalizou com código de retorno: 0
> > > Hello, World!! [Main Thread]
> > > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0 segundos
> > > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0
> segundos
> > > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0 segundos
> > > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0 segundos
> > > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0 segundos
> > > *pmu_*Hello, World!! [Main Thread]
> > > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11 segundos
> > > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16 segundos
> > >
> > > I was able to power consumption below 1 mA when mcu is in idle mode, so
> > it
> > > is in light sleep.
> > >
> > > Later, making a distclean, running wifi config and adding
> > > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see that
> > the
> > > mcu goes to sleep and not return.
> > >
> > > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > > tiago.medicci@gmail.com> escreveu:
> > >
> > > > Hi Felipe, good to hear about your progress here!
> > > >
> > > > These functions are ROM-defined functions. By checking the TRM, you
> can
> > > see
> > > > a read-only flash partition that holds some functions (widely used
> > > > functions, like malloc and internal functions).
> > > >
> > > > ets_get_cpu_frequency
> > > > <
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > > >
> > > > is
> > > > one of these internal functions. They are defined directly at the
> > linker
> > > > script.
> > > >
> > > > If I understood correctly, these functions are crashing when it's
> being
> > > > called, right? If so, can you:
> > > >
> > > > 1. Share the crash dump
> > > > 2. Use GDB and try to check where/why it fails: it may trying to
> > > access
> > > > some prohibited memory region or even trying to call an
> unregistered
> > > > callback.
> > > >
> > > > Thanks!
> > > >
> > > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > > > moura.fmo@gmail.com> escreveu:
> > > >
> > > > > Hello everyone,
> > > > >
> > > > > Tiago, I am trying to work with light sleep for now, after it work
> > will
> > > > go
> > > > > ahead with deep sleep. To run in light sleep I don't need to change
> > > > linker
> > > > > so I was able to build and flash without "image" issues.
> > > > > Now I am facing other kind of issue:
> > > > > Some functions refers to "ets" function and I don't know how handle
> > > this,
> > > > > for instance:
> > > > >
> > > > > /**
> > > > > * @brief Get the real CPU ticks per us
> > > > > *
> > > > > * @return CPU ticks per us
> > > > > */
> > > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > > >
> > > > > This function is necessary in the *sleep_modes.c* file. During
> > execute
> > > > code
> > > > > I am facing crash when this function is called, its happen because
> > its
> > > > > implementation is a reference to other function:
> > > > >
> > > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > > > >
> > > > > I cannot find *ets_get_cpu_frequency*, so how should I handle it?
> > > > >
> > > > > PS: I have another situation like this, when I try to call
> > > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > > >
> > > > > Regards.
> > > > >
> > > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > > > > moura.fmo@gmail.com> escreveu:
> > > > >
> > > > > > Hello Tiago.
> > > > > >
> > > > > > Please look de draft here:
> > > https://github.com/apache/nuttx/pull/14548
> > > > > >
> > > > > > This branch will refer to the updated 3rd-party in my repo.
> > > > > >
> > > > > > You only need to enable PM in menuconfig and it will be enough to
> > see
> > > > > > changes.
> > > > > >
> > > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > >
> > > > > >> Hi Felipe,
> > > > > >>
> > > > > >> Can you share your PR as a draft on GH to make it easier to
> check
> > > the
> > > > > >> files
> > > > > >> (and the build process)?
> > > > > >>
> > > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> > > > > >> moura.fmo@gmail.com> escreveu:
> > > > > >>
> > > > > >> > Hello Tiago,
> > > > > >> >
> > > > > >> > I "finished" the port, but after it my esp32c6 dev kit is
> > > resetting.
> > > > > >> Maybe
> > > > > >> > the issue is related my changes in
> > > > > >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can
> > you
> > > > give
> > > > > >> some
> > > > > >> > tips about how to go ahead?
> > > > > >> >
> > > > > >> > Below you can see nuttx report:
> > > > > >> > Build:Sep 19 2022
> > > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > > > > >> > Saved PC:0x40018bea
> > > > > >> > SPIWP:0xee
> > > > > >> > mode:DIO, clock div:2
> > > > > >> > load:0x40800000,len:0x61e0
> > > > > >> > load:0x408061e0,len:0xc34
> > > > > >> > load:0x50000000,len:0x20
> > > > > >> > load:0x5000001e,len:0x24
> > > > > >> > Invalid image block, can't boot.
> > > > > >> > ets_main.c 331
> > > > > >> > ESP-ROM:esp32c6-20220919
> > > > > >> >
> > > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> > > > > >> > moura.fmo@gmail.com> escreveu:
> > > > > >> >
> > > > > >> > > Hello everyone,
> > > > > >> > >
> > > > > >> > > I was able to solve linker issues, editing the linker by
> > > myself. I
> > > > > >> need
> > > > > >> > to
> > > > > >> > > finish more than one build issue before testing it, so I
> will
> > > see
> > > > > if I
> > > > > >> > made
> > > > > >> > > the right changes in linker.
> > > > > >> > >
> > > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira
> <
> > > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > > >> > >
> > > > > >> > >> *Hello everyone, Tiago,*
> > > > > >> > >>
> > > > > >> > >> I have made progress with the build issue I was
> encountering
> > > and
> > > > am
> > > > > >> now
> > > > > >> > >> "stuck" at what I believe is one of the final stages. I am
> > > > > >> experiencing
> > > > > >> > the
> > > > > >> > >> following compilation error:
> > > > > >> > >> LD: nuttx
> > > > > >> > >> riscv-none-elf-ld: warning:
> > > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > > >> > >> has a LOAD segment with RWX permissions
> > > > > >> > >> riscv-none-elf-ld:
> > > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > > > > >> > >> `_rtc_force_fast_end'
> > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4):
> undefined
> > > > > >> reference
> > > > > >> > >> to `_rtc_text_start'
> > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8):
> undefined
> > > > > >> reference
> > > > > >> > >> to `_rtc_force_fast_end'
> > > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc):
> undefined
> > > > > >> reference
> > > > > >> > >> to `_rtc_text_start'
> > > > > >> > >> riscv-none-elf-ld:
> > > > > >> > >>
> > > > > >> >
> > > > > >>
> > > > >
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > > > > >> > >> `rv_core_critical_regs_save'
> > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined
> > > > > reference
> > > > > >> to
> > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined
> > > > > reference
> > > > > >> to
> > > > > >> > >> `rv_core_critical_regs_restore'
> > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > >> > >>
> > > > > >> > >> I would greatly appreciate your assistance.
> > > > > >> > >>
> > > > > >> > >> Focusing on the item _rtc_text_start, I see that it is
> > defined
> > > in
> > > > > the
> > > > > >> > >> file:
> > > > > >> > >>
> > > > > >>
> > > >
> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > >> > >> sections.ld.in
> > > > > >> > >>
> > > > > >> > >> However, I am unsure how to add this file to the complete
> > > linking
> > > > > >> > >> process. I added this file to hal_esp32c6.mk, but I
> received
> > > the
> > > > > >> > >> following error:
> > > > > >> > >> LD: nuttx
> > > > > >> > >>
> > > > > >> >
> > > > > >>
> > > > >
> > >
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > > >> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > > >> > >> sections.ld.in.tmp:113 cannot move location counter
> backwards
> > > > (from
> > > > > >> > >> 40809800 to 40800000)
> > > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > > >> > >>
> > > > > >> > >>
> > > > > >> > >> Does anyone have any tips or suggestions that could help me
> > > move
> > > > > >> forward
> > > > > >> > >> with this process?
> > > > > >> > >>
> > > > > >> > >> Thank you in advance for your help.
> > > > > >> > >>
> > > > > >> > >> *Best regards,*
> > > > > >> > >>
> > > > > >> > >>
> > > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci
> Serrano <
> > > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > > >> > >>
> > > > > >> > >>> Hi Felipe,
> > > > > >> > >>>
> > > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a
> > > > substitute
> > > > > >> for
> > > > > >> > >>> this
> > > > > >> > >>> function should be part
> > > > > >> > >>> of
> `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > > That
> > > > > >> being
> > > > > >> > >>> said, you can either implement it (and define it as a
> macro,
> > > on
> > > > > >> HAL) or
> > > > > >> > >>> you
> > > > > >> > >>> can either ignore these functions related to GPIO wakeup
> > from
> > > > > sleep
> > > > > >> for
> > > > > >> > >>> now
> > > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to
> > > you:
> > > > if
> > > > > >> the
> > > > > >> > >>> GPIO
> > > > > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing this
> > > > feature
> > > > > >> for
> > > > > >> > >>> now.
> > > > > >> > >>>
> > > > > >> > >>> Best regards,
> > > > > >> > >>>
> > > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura
> Oliveira
> > <
> > > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > > >> > >>>
> > > > > >> > >>> > Hello Tiago,
> > > > > >> > >>> >
> > > > > >> > >>> > Thank you for your assistance earlier.
> > > > > >> > >>> >
> > > > > >> > >>> > I would like to discuss further the necessity of the
> > > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only
> > > available
> > > > > in
> > > > > >> the
> > > > > >> > >>> IDF.
> > > > > >> > >>> >
> > > > > >> > >>> > In sleep_modes.c, there is the following code snippet:
> > > > > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t
> > io_mask,
> > > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > > >> > >>> > {
> > > > > >> > >>> > if (io_mask == 0 && level_mode >
> > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > >> > >>> > }
> > > > > >> > >>> > // Translate bit map of GPIO numbers into the bit map of
> > RTC
> > > > IO
> > > > > >> > numbers
> > > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > > >> > >>> > continue;
> > > > > >> > >>> > }
> > > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > > >> > >>> > }
> > > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > > >> > >>> > }
> > > > > >> > >>> >
> > > > > >> > >>> > I believe this code is essential for compilation. The
> > > function
> > > > > >> > >>> > rtc_io_number_get is located at the following path in
> the
> > > IDF:
> > > > > >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > > >> > >>> >
> > > > > >> > >>> > However, the esp_driver_gpio folder is not present in
> the
> > > > > >> 3rd-party
> > > > > >> > >>> > directory. In this case, what is the recommended
> procedure
> > > to
> > > > > >> > proceed?
> > > > > >> > >>> >
> > > > > >> > >>> > Thank you again for your support.
> > > > > >> > >>> >
> > > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci
> > Serrano
> > > <
> > > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > > >> > >>> >
> > > > > >> > >>> > > Hi Felipe,
> > > > > >> > >>> > >
> > > > > >> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm`
> > of
> > > > > >> ESP-IDF,
> > > > > >> > >>> which
> > > > > >> > >>> > is
> > > > > >> > >>> > > a driver directly. Same for
> > > > `esp_driver_gpio/include/rtc_io.h`
> > > > > >> > >>> (here, a
> > > > > >> > >>> > > detail: I wasn't able to find this path on IDF, so
> make
> > > sure
> > > > > you
> > > > > >> > are
> > > > > >> > >>> > > checking under the `release/v5.1` branch, which the
> HAL
> > > was
> > > > > >> based).
> > > > > >> > >>> The
> > > > > >> > >>> > HAL
> > > > > >> > >>> > > repository doesn't contain ESP-IDF drivers, which are
> > > always
> > > > > >> > >>> implemented
> > > > > >> > >>> > on
> > > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > > > >> > >>> > >
> > > > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > > >> > >>> > >
> > > > > >> > >>> > > The files under
> > > `esp-hal-3rdparty/components/esp_hw_support`
> > > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to
> implement
> > > the
> > > > > >> > driver.
> > > > > >> > >>> This
> > > > > >> > >>> > > is, mostly, a wrapping layer under the function of
> > > `esp_rom`
> > > > > and
> > > > > >> > >>> `hal`
> > > > > >> > >>> > > components. However, they still may refer to ESP-IDF
> > > > drivers.
> > > > > >> That
> > > > > >> > >>> being
> > > > > >> > >>> > > said, you can check if removing such dependencies is
> > > > possible.
> > > > > >> We
> > > > > >> > >>> usually
> > > > > >> > >>> > > do that with conditional macros. A good starting point
> > is
> > > to
> > > > > >> check
> > > > > >> > >>> for
> > > > > >> > >>> > > `#ifdef __NuttX__` on these sources and headers: we
> use
> > > them
> > > > > to
> > > > > >> > >>> > remove/add
> > > > > >> > >>> > > headers and functions that aren't available on
> > > NuttX/needed
> > > > by
> > > > > >> > NuttX.
> > > > > >> > >>> > >
> > > > > >> > >>> > > Best regards,
> > > > > >> > >>> > >
> > > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura
> > > Oliveira
> > > > <
> > > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > > >> > >>> > >
> > > > > >> > >>> > > > Hello all,
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > Tiago,
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > I have a question regarding the porting process.
> > > > > >> Specifically, I
> > > > > >> > >>> need
> > > > > >> > >>> > to
> > > > > >> > >>> > > > add the sleep_modes.c file to the compilation
> process.
> > > Am
> > > > I
> > > > > on
> > > > > >> > the
> > > > > >> > >>> > right
> > > > > >> > >>> > > > path with this approach?
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file
> > by
> > > > > adding
> > > > > >> > >>> > > > sleep_modes.c.
> > > > > >> > >>> > > > However, I am facing some issues: within
> > sleep_modes.c,
> > > > some
> > > > > >> > >>> #include
> > > > > >> > >>> > > > statements reference files that are not available in
> > the
> > > > > >> > 3rd-party
> > > > > >> > >>> > > > directory but are only present in the IDF. For
> > example:
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > > >> > >>> > > > - esp_cpu.h
> > > > > >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > I need those includes because sleep_modes.c uses
> > > function
> > > > > from
> > > > > >> > >>> there.
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > Could you please advise if it's possible to
> > incorporate
> > > > > these
> > > > > >> IDF
> > > > > >> > >>> > folders
> > > > > >> > >>> > > > into the 3rd-party directory, or if that approach is
> > not
> > > > > >> > >>> recommended?
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > Thank you for your assistance.
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > Best regards,
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci
> > > > Serrano
> > > > > <
> > > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > > Hi,
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > Just another note to guide your development: we
> > don't
> > > > > >> develop
> > > > > >> > >>> > anything
> > > > > >> > >>> > > on
> > > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from
> it
> > is
> > > > > >> derived
> > > > > >> > >>> from
> > > > > >> > >>> > the
> > > > > >> > >>> > > > > path
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > >
> > > > > >> > >>> > >
> > > > > >> > >>> >
> > > > > >> > >>>
> > > > > >> >
> > > > > >>
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > >> > >>> > > > > (essentially, header files from
> > > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > > >> > >>> > > > except
> > > > > >> > >>> > > > > for some of the sources files that use the hal
> > > functions
> > > > > at
> > > > > >> > >>> > > > > `components/hal` to implement some function we may
> > > use).
> > > > > You
> > > > > >> > can
> > > > > >> > >>> > take a
> > > > > >> > >>> > > > > look at the branch `
> > > > > >> > >>> > > > >
> > > > > >> > >>> >
> > > > > >> >
> > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > >> <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > > >> > <
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >
> > > > > >> > >>> <
> > > > > >>
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > >> > >>> > <
> > > > > >> >
> > > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > > > > >> > >>> > > <
> > > > > >> > >>>
> > > > > >>
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > >> > >>> > > > <
> > > > > >> > >>>
> > > > > >>
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > >> > >>> > > > > <
> > > > > >> > >>> >
> > > > > >>
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > > >> > >
> > > > > >> > >>> > > > and
> > > > > >> > >>> > > > > especially the commits beginning
> > > > > >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to
> > check
> > > > the
> > > > > >> kind
> > > > > >> > >>> of
> > > > > >> > >>> > > > changes
> > > > > >> > >>> > > > > we do in hal. Essentially, we create a wrapper
> layer
> > > to
> > > > > >> make it
> > > > > >> > >>> > > > independent
> > > > > >> > >>> > > > > of the host OS.
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > That being said, you can either 1) try to adapt
> the
> > > > > >> > >>> implementation of
> > > > > >> > >>> > > > other
> > > > > >> > >>> > > > > devices to use the HAL functions or 2) get some
> > > > > inspiration
> > > > > >> on
> > > > > >> > >>> how
> > > > > >> > >>> > IDF
> > > > > >> > >>> > > > > implements PM. I'd stick with the 2nd option
> before
> > > > simply
> > > > > >> > >>> trying to
> > > > > >> > >>> > > > adapt
> > > > > >> > >>> > > > > an existing implementation (from ESP32-C3 legacy
> or
> > > from
> > > > > >> > >>> > > ESP32/ESP32-S3).
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > Best regards,
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura
> > > > > Oliveira
> > > > > >> <
> > > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > > Hello Tiago.
> > > > > >> > >>> > > > > >
> > > > > >> > >>> > > > > > Thank you for clarification, I will follow your
> > > > > >> instructions.
> > > > > >> > >>> > > > > >
> > > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago
> > Medicci
> > > > > >> Serrano <
> > > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > >> > >>> > > > > >
> > > > > >> > >>> > > > > > > Hi Felipe,
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > > Just complementing: use your forked version of
> > the
> > > > HAL
> > > > > >> > >>> during the
> > > > > >> > >>> > > > > > > development. As soon as you have a working
> > > version,
> > > > > you
> > > > > >> can
> > > > > >> > >>> > submit
> > > > > >> > >>> > > on
> > > > > >> > >>> > > > > the
> > > > > >> > >>> > > > > > > official repository.
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > > Best regards,
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago
> > > Medicci
> > > > > >> > Serrano <
> > > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > > > Hi Felipe,
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > Thanks for asking! You should follow the
> path
> > > > using
> > > > > >> the
> > > > > >> > >>> > functions
> > > > > >> > >>> > > > on
> > > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the
> repository
> > > and
> > > > > use
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > >
> > > > > >>
> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > >> > >>> > > > > > env
> > > > > >> > >>> > > > > > > > vars (globally or before the make command)
> to
> > > use
> > > > > your
> > > > > >> > >>> version
> > > > > >> > >>> > of
> > > > > >> > >>> > > > the
> > > > > >> > >>> > > > > > > HAL.
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > I just wanted to share some thoughts: using
> > the
> > > > HAL
> > > > > >> > >>> enables us
> > > > > >> > >>> > to
> > > > > >> > >>> > > > > make
> > > > > >> > >>> > > > > > > the
> > > > > >> > >>> > > > > > > > feature available for all the Espressif
> > devices
> > > > > >> (please
> > > > > >> > >>> don't
> > > > > >> > >>> > > > bother
> > > > > >> > >>> > > > > > with
> > > > > >> > >>> > > > > > > > that now, as soon as you submit it, we can
> > test
> > > > for
> > > > > >> the
> > > > > >> > >>> other
> > > > > >> > >>> > > > devices
> > > > > >> > >>> > > > > > and
> > > > > >> > >>> > > > > > > > eventually make any adjustments). Although
> > it's
> > > > > >> possible
> > > > > >> > to
> > > > > >> > >>> > > > > reimplement
> > > > > >> > >>> > > > > > > > these functions on NuttX, we don't recommend
> > > that
> > > > > >> because
> > > > > >> > >>> of
> > > > > >> > >>> > the
> > > > > >> > >>> > > > > first
> > > > > >> > >>> > > > > > > > statement (the ability to use for the other
> > > > > devices):
> > > > > >> in
> > > > > >> > >>> that
> > > > > >> > >>> > > case
> > > > > >> > >>> > > > we
> > > > > >> > >>> > > > > > > > wouldn't be able to support the feature. You
> > can
> > > > > take
> > > > > >> a
> > > > > >> > >>> look on
> > > > > >> > >>> > > IDF
> > > > > >> > >>> > > > > for
> > > > > >> > >>> > > > > > > > some inspiration on how it's implemented.
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > Please let me know if you have any
> questions.
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > Best regards,
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe
> > > Moura
> > > > > >> > >>> Oliveira <
> > > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > >> Hello everyone,
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >> Our project has reached a point where we
> need
> > > the
> > > > > >> Power
> > > > > >> > >>> > Manager
> > > > > >> > >>> > > > > > > >> functionality, which is not yet available
> in
> > > the
> > > > > >> > ESP32C6.
> > > > > >> > >>> I am
> > > > > >> > >>> > > > > > studying
> > > > > >> > >>> > > > > > > to
> > > > > >> > >>> > > > > > > >> start the implementation, but I am confused
> > > about
> > > > > the
> > > > > >> > >>> correct
> > > > > >> > >>> > > way
> > > > > >> > >>> > > > to
> > > > > >> > >>> > > > > > > >> approach this.
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >> There is a Power Manager implementation for
> > the
> > > > > >> ESP32C3,
> > > > > >> > >>> but
> > > > > >> > >>> > it
> > > > > >> > >>> > > > > seems
> > > > > >> > >>> > > > > > to
> > > > > >> > >>> > > > > > > >> follow the legacy methodology. In fact, the
> > > file
> > > > > >> > >>> > esp32c3_idle.c
> > > > > >> > >>> > > is
> > > > > >> > >>> > > > > > > located
> > > > > >> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy.
> > In
> > > > this
> > > > > >> > >>> > methodology,
> > > > > >> > >>> > > > > > > functions
> > > > > >> > >>> > > > > > > >> are re-implemented from the Espressif
> driver.
> > > For
> > > > > >> > >>> example, the
> > > > > >> > >>> > > > > > function
> > > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is
> > currently
> > > > > >> > available
> > > > > >> > >>> in
> > > > > >> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >> I tried using the implementations from
> > > > > >> esp-hal-3rdparty
> > > > > >> > to
> > > > > >> > >>> > > develop
> > > > > >> > >>> > > > > the
> > > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but
> > the
> > > > > files
> > > > > >> > >>> still
> > > > > >> > >>> > have
> > > > > >> > >>> > > > > many
> > > > > >> > >>> > > > > > > >> dependencies on items that are not present
> in
> > > > > NuttX.
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >> My question is: Should I try to make the
> > Power
> > > > > >> Manager
> > > > > >> > >>> work
> > > > > >> > >>> > > using
> > > > > >> > >>> > > > > the
> > > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it
> > > > requires
> > > > > >> > making
> > > > > >> > >>> > > changes
> > > > > >> > >>> > > > to
> > > > > >> > >>> > > > > > the
> > > > > >> > >>> > > > > > > >> 3rd-party code? Or should I re-implement
> the
> > > > > >> functions
> > > > > >> > >>> within
> > > > > >> > >>> > > > NuttX,
> > > > > >> > >>> > > > > > > even
> > > > > >> > >>> > > > > > > >> if, in this case, there are functions with
> > the
> > > > same
> > > > > >> > scope
> > > > > >> > >>> and
> > > > > >> > >>> > > > > > > >> implementation in different files, where
> one
> > is
> > > > > >> > compiled,
> > > > > >> > >>> and
> > > > > >> > >>> > > the
> > > > > >> > >>> > > > > > other
> > > > > >> > >>> > > > > > > is
> > > > > >> > >>> > > > > > > >> not?
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >> --
> > > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > > > > >> > >>> > > > > > > >> Linkedin <
> > > > > >> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > >> > >>> > > > > > > >> <
> > https://twitter.com/FelipeMOliveir?lang=pt-br
> > > >
> > > > > >> > >>> > > > > > > >>
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > --
> > > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > > >> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > > >> > >>> > > > > > > > Follow me:
> > > > > >> > >>> > > > > > > > <
> > > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > > >
> > > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > > >> > >>> > > > > > > >
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > > --
> > > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > > >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > > >> > >>> > > > > > > Follow me:
> > > > > >> > >>> > > > > > > <
> > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > >
> > > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > > >> > >>> > > > > > >
> > > > > >> > >>> > > > > >
> > > > > >> > >>> > > > > >
> > > > > >> > >>> > > > > > --
> > > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > > >> > >>> > > > > > Linkedin <
> > > > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > > >> > >>> >
> > > > > >> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >> > >>> > > > > >
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > --
> > > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > > > Embedded Software Engineer
> > > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > > >> > >>> > > > > a: Campinas, Brazil
> > > > > >> > >>> > > > > Follow me:
> > > > > >> > >>> > > > > <
> https://www.linkedin.com/in/tiago-serrano-924458b6
> > >
> > > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > > >> > >>> > > > >
> > > > > >> > >>> > > >
> > > > > >> > >>> > > >
> > > > > >> > >>> > > > --
> > > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > > >> > >>> > > > Linkedin <
> > > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >> > >>> > > >
> > > > > >> > >>> > >
> > > > > >> > >>> > >
> > > > > >> > >>> > > --
> > > > > >> > >>> > > Tiago Medicci Serrano
> > > > > >> > >>> > >
> > > > > >> > >>> > > Embedded Software Engineer
> > > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > > >> > >>> > > a: Campinas, Brazil
> > > > > >> > >>> > > Follow me:
> > > > > >> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > >> > >>> > > <https://github.com/tmedicci>
> > > > > >> > >>> > >
> > > > > >> > >>> >
> > > > > >> > >>> >
> > > > > >> > >>> > --
> > > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > > >> > >>> > Linkedin <
> > > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >> > >>> >
> > > > > >> > >>>
> > > > > >> > >>
> > > > > >> > >>
> > > > > >> > >> --
> > > > > >> > >> *Felipe Moura de Oliveira*
> > > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > > >> > >> Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > >
> > > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >> > >>
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > --
> > > > > >> > > *Felipe Moura de Oliveira*
> > > > > >> > > *Universidade Federal de Minas Gerais*
> > > > > >> > > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >> > >
> > > > > >> >
> > > > > >> >
> > > > > >> > --
> > > > > >> > *Felipe Moura de Oliveira*
> > > > > >> > *Universidade Federal de Minas Gerais*
> > > > > >> > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *Felipe Moura de Oliveira*
> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Felipe Moura de Oliveira*
> > > > > *Universidade Federal de Minas Gerais*
> > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
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.medicci@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.fmo@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 <nuttx/config.h>
> > #include <stdio.h>
> > #include <stdint.h>
> > #include <time.h>
> > #include <unistd.h>
> > #include <pthread.h>
> > #include <stdlib.h>
> >
> >
> >
> /****************************************************************************
> > * 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);
> > }
> >
> > return NULL;
> > }
> >
> >
> >
> /****************************************************************************
> > * Public Functions
> >
> >
> ****************************************************************************/
> >
> >
> >
> /****************************************************************************
> > * main
> >
> >
> ****************************************************************************/
> >
> > int main(int argc, FAR char *argv[])
> > {
> > pthread_t threads[NUM_THREADS];
> > struct thread_info tinfo[NUM_THREADS];
> > int ret;
> >
> > unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
> >
> > for (int i = 0; i < NUM_THREADS; i++)
> > {
> > tinfo[i].thread_id = i + 1;
> > tinfo[i].sleep_time = sleep_times[i];
> >
> > ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
> > if (ret != 0)
> > {
> > printf("Error creating thread %d: %d\n", i + 1, ret);
> > exit(EXIT_FAILURE);
> > }
> > }
> > int app_ret = 0;
> > if (app_ret == -1) {
> > printf("Error executing command\n");
> > } else {
> > printf("Application finished with return code: %d\n", app_ret);
> > }
> >
> > while (1)
> > {
> > printf("Hello, World!! [Main Thread]\n");
> > sleep(10);
> > }
> >
> > return 0;
> > }
> >
> >
> >
> > You will see output below:
> > nsh> hello
> > Aplicação finalizou com código de retorno: 0
> > Hello, World!! [Main Thread]
> > Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0 segundos
> > Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0 segundos
> > Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0 segundos
> > Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0 segundos
> > Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0 segundos
> > *pmu_*Hello, World!! [Main Thread]
> > Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11 segundos
> > Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16 segundos
> >
> > I was able to power consumption below 1 mA when mcu is in idle mode, so
> it
> > is in light sleep.
> >
> > Later, making a distclean, running wifi config and adding
> > CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see that
> the
> > mcu goes to sleep and not return.
> >
> > Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> > tiago.medicci@gmail.com> escreveu:
> >
> > > Hi Felipe, good to hear about your progress here!
> > >
> > > These functions are ROM-defined functions. By checking the TRM, you can
> > see
> > > a read-only flash partition that holds some functions (widely used
> > > functions, like malloc and internal functions).
> > >
> > > ets_get_cpu_frequency
> > > <
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > > >
> > > is
> > > one of these internal functions. They are defined directly at the
> linker
> > > script.
> > >
> > > If I understood correctly, these functions are crashing when it's being
> > > called, right? If so, can you:
> > >
> > > 1. Share the crash dump
> > > 2. Use GDB and try to check where/why it fails: it may trying to
> > access
> > > some prohibited memory region or even trying to call an unregistered
> > > callback.
> > >
> > > Thanks!
> > >
> > > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > > moura.fmo@gmail.com> escreveu:
> > >
> > > > Hello everyone,
> > > >
> > > > Tiago, I am trying to work with light sleep for now, after it work
> will
> > > go
> > > > ahead with deep sleep. To run in light sleep I don't need to change
> > > linker
> > > > so I was able to build and flash without "image" issues.
> > > > Now I am facing other kind of issue:
> > > > Some functions refers to "ets" function and I don't know how handle
> > this,
> > > > for instance:
> > > >
> > > > /**
> > > > * @brief Get the real CPU ticks per us
> > > > *
> > > > * @return CPU ticks per us
> > > > */
> > > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > > >
> > > > This function is necessary in the *sleep_modes.c* file. During
> execute
> > > code
> > > > I am facing crash when this function is called, its happen because
> its
> > > > implementation is a reference to other function:
> > > >
> > > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > > >
> > > > I cannot find *ets_get_cpu_frequency*, so how should I handle it?
> > > >
> > > > PS: I have another situation like this, when I try to call
> > > > *esp_rom_set_cpu_ticks_per_us* function.
> > > >
> > > > Regards.
> > > >
> > > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > > > moura.fmo@gmail.com> escreveu:
> > > >
> > > > > Hello Tiago.
> > > > >
> > > > > Please look de draft here:
> > https://github.com/apache/nuttx/pull/14548
> > > > >
> > > > > This branch will refer to the updated 3rd-party in my repo.
> > > > >
> > > > > You only need to enable PM in menuconfig and it will be enough to
> see
> > > > > changes.
> > > > >
> > > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > > > > tiago.medicci@gmail.com> escreveu:
> > > > >
> > > > >> Hi Felipe,
> > > > >>
> > > > >> Can you share your PR as a draft on GH to make it easier to check
> > the
> > > > >> files
> > > > >> (and the build process)?
> > > > >>
> > > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> > > > >> moura.fmo@gmail.com> escreveu:
> > > > >>
> > > > >> > Hello Tiago,
> > > > >> >
> > > > >> > I "finished" the port, but after it my esp32c6 dev kit is
> > resetting.
> > > > >> Maybe
> > > > >> > the issue is related my changes in
> > > > >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can
> you
> > > give
> > > > >> some
> > > > >> > tips about how to go ahead?
> > > > >> >
> > > > >> > Below you can see nuttx report:
> > > > >> > Build:Sep 19 2022
> > > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > > > >> > Saved PC:0x40018bea
> > > > >> > SPIWP:0xee
> > > > >> > mode:DIO, clock div:2
> > > > >> > load:0x40800000,len:0x61e0
> > > > >> > load:0x408061e0,len:0xc34
> > > > >> > load:0x50000000,len:0x20
> > > > >> > load:0x5000001e,len:0x24
> > > > >> > Invalid image block, can't boot.
> > > > >> > ets_main.c 331
> > > > >> > ESP-ROM:esp32c6-20220919
> > > > >> >
> > > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> > > > >> > moura.fmo@gmail.com> escreveu:
> > > > >> >
> > > > >> > > Hello everyone,
> > > > >> > >
> > > > >> > > I was able to solve linker issues, editing the linker by
> > myself. I
> > > > >> need
> > > > >> > to
> > > > >> > > finish more than one build issue before testing it, so I will
> > see
> > > > if I
> > > > >> > made
> > > > >> > > the right changes in linker.
> > > > >> > >
> > > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> > > > >> > > moura.fmo@gmail.com> escreveu:
> > > > >> > >
> > > > >> > >> *Hello everyone, Tiago,*
> > > > >> > >>
> > > > >> > >> I have made progress with the build issue I was encountering
> > and
> > > am
> > > > >> now
> > > > >> > >> "stuck" at what I believe is one of the final stages. I am
> > > > >> experiencing
> > > > >> > the
> > > > >> > >> following compilation error:
> > > > >> > >> LD: nuttx
> > > > >> > >> riscv-none-elf-ld: warning:
> > > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > > >> > >> has a LOAD segment with RWX permissions
> > > > >> > >> riscv-none-elf-ld:
> > > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > > >> > >> libarch.a(sleep_modes.o): in function
> > > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > > > >> > >> `_rtc_force_fast_end'
> > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined
> > > > >> reference
> > > > >> > >> to `_rtc_text_start'
> > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined
> > > > >> reference
> > > > >> > >> to `_rtc_force_fast_end'
> > > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined
> > > > >> reference
> > > > >> > >> to `_rtc_text_start'
> > > > >> > >> riscv-none-elf-ld:
> > > > >> > >>
> > > > >> >
> > > > >>
> > > >
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > > >> > >> in function `esp_sleep_cpu_retention':
> > > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > > > >> > >> `rv_core_critical_regs_save'
> > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined
> > > > reference
> > > > >> to
> > > > >> > >> `rv_core_critical_regs_restore'
> > > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined
> > > > reference
> > > > >> to
> > > > >> > >> `rv_core_critical_regs_restore'
> > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > >> > >>
> > > > >> > >> I would greatly appreciate your assistance.
> > > > >> > >>
> > > > >> > >> Focusing on the item _rtc_text_start, I see that it is
> defined
> > in
> > > > the
> > > > >> > >> file:
> > > > >> > >>
> > > > >>
> > > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > >> > >> sections.ld.in
> > > > >> > >>
> > > > >> > >> However, I am unsure how to add this file to the complete
> > linking
> > > > >> > >> process. I added this file to hal_esp32c6.mk, but I received
> > the
> > > > >> > >> following error:
> > > > >> > >> LD: nuttx
> > > > >> > >>
> > > > >> >
> > > > >>
> > > >
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > > >> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > > >> > >> sections.ld.in.tmp:113 cannot move location counter backwards
> > > (from
> > > > >> > >> 40809800 to 40800000)
> > > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > > >> > >>
> > > > >> > >>
> > > > >> > >> Does anyone have any tips or suggestions that could help me
> > move
> > > > >> forward
> > > > >> > >> with this process?
> > > > >> > >>
> > > > >> > >> Thank you in advance for your help.
> > > > >> > >>
> > > > >> > >> *Best regards,*
> > > > >> > >>
> > > > >> > >>
> > > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> > > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > > >> > >>
> > > > >> > >>> Hi Felipe,
> > > > >> > >>>
> > > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a
> > > substitute
> > > > >> for
> > > > >> > >>> this
> > > > >> > >>> function should be part
> > > > >> > >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> > That
> > > > >> being
> > > > >> > >>> said, you can either implement it (and define it as a macro,
> > on
> > > > >> HAL) or
> > > > >> > >>> you
> > > > >> > >>> can either ignore these functions related to GPIO wakeup
> from
> > > > sleep
> > > > >> for
> > > > >> > >>> now
> > > > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to
> > you:
> > > if
> > > > >> the
> > > > >> > >>> GPIO
> > > > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing this
> > > feature
> > > > >> for
> > > > >> > >>> now.
> > > > >> > >>>
> > > > >> > >>> Best regards,
> > > > >> > >>>
> > > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira
> <
> > > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > > >> > >>>
> > > > >> > >>> > Hello Tiago,
> > > > >> > >>> >
> > > > >> > >>> > Thank you for your assistance earlier.
> > > > >> > >>> >
> > > > >> > >>> > I would like to discuss further the necessity of the
> > > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only
> > available
> > > > in
> > > > >> the
> > > > >> > >>> IDF.
> > > > >> > >>> >
> > > > >> > >>> > In sleep_modes.c, there is the following code snippet:
> > > > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t
> io_mask,
> > > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > > >> > >>> > {
> > > > >> > >>> > if (io_mask == 0 && level_mode >
> ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > >> > >>> > }
> > > > >> > >>> > // Translate bit map of GPIO numbers into the bit map of
> RTC
> > > IO
> > > > >> > numbers
> > > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > > > >> > >>> > if ((io_mask & 1) == 0) {
> > > > >> > >>> > continue;
> > > > >> > >>> > }
> > > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > > >> > >>> > }
> > > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > > >> > >>> > }
> > > > >> > >>> >
> > > > >> > >>> > I believe this code is essential for compilation. The
> > function
> > > > >> > >>> > rtc_io_number_get is located at the following path in the
> > IDF:
> > > > >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > > >> > >>> >
> > > > >> > >>> > However, the esp_driver_gpio folder is not present in the
> > > > >> 3rd-party
> > > > >> > >>> > directory. In this case, what is the recommended procedure
> > to
> > > > >> > proceed?
> > > > >> > >>> >
> > > > >> > >>> > Thank you again for your support.
> > > > >> > >>> >
> > > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci
> Serrano
> > <
> > > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > > >> > >>> >
> > > > >> > >>> > > Hi Felipe,
> > > > >> > >>> > >
> > > > >> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm`
> of
> > > > >> ESP-IDF,
> > > > >> > >>> which
> > > > >> > >>> > is
> > > > >> > >>> > > a driver directly. Same for
> > > `esp_driver_gpio/include/rtc_io.h`
> > > > >> > >>> (here, a
> > > > >> > >>> > > detail: I wasn't able to find this path on IDF, so make
> > sure
> > > > you
> > > > >> > are
> > > > >> > >>> > > checking under the `release/v5.1` branch, which the HAL
> > was
> > > > >> based).
> > > > >> > >>> The
> > > > >> > >>> > HAL
> > > > >> > >>> > > repository doesn't contain ESP-IDF drivers, which are
> > always
> > > > >> > >>> implemented
> > > > >> > >>> > on
> > > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > > >> > >>> > >
> > > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > > >> > >>> > >
> > > > >> > >>> > > The files under
> > `esp-hal-3rdparty/components/esp_hw_support`
> > > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to implement
> > the
> > > > >> > driver.
> > > > >> > >>> This
> > > > >> > >>> > > is, mostly, a wrapping layer under the function of
> > `esp_rom`
> > > > and
> > > > >> > >>> `hal`
> > > > >> > >>> > > components. However, they still may refer to ESP-IDF
> > > drivers.
> > > > >> That
> > > > >> > >>> being
> > > > >> > >>> > > said, you can check if removing such dependencies is
> > > possible.
> > > > >> We
> > > > >> > >>> usually
> > > > >> > >>> > > do that with conditional macros. A good starting point
> is
> > to
> > > > >> check
> > > > >> > >>> for
> > > > >> > >>> > > `#ifdef __NuttX__` on these sources and headers: we use
> > them
> > > > to
> > > > >> > >>> > remove/add
> > > > >> > >>> > > headers and functions that aren't available on
> > NuttX/needed
> > > by
> > > > >> > NuttX.
> > > > >> > >>> > >
> > > > >> > >>> > > Best regards,
> > > > >> > >>> > >
> > > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura
> > Oliveira
> > > <
> > > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > > >> > >>> > >
> > > > >> > >>> > > > Hello all,
> > > > >> > >>> > > >
> > > > >> > >>> > > > Tiago,
> > > > >> > >>> > > >
> > > > >> > >>> > > > I have a question regarding the porting process.
> > > > >> Specifically, I
> > > > >> > >>> need
> > > > >> > >>> > to
> > > > >> > >>> > > > add the sleep_modes.c file to the compilation process.
> > Am
> > > I
> > > > on
> > > > >> > the
> > > > >> > >>> > right
> > > > >> > >>> > > > path with this approach?
> > > > >> > >>> > > >
> > > > >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file
> by
> > > > adding
> > > > >> > >>> > > > sleep_modes.c.
> > > > >> > >>> > > > However, I am facing some issues: within
> sleep_modes.c,
> > > some
> > > > >> > >>> #include
> > > > >> > >>> > > > statements reference files that are not available in
> the
> > > > >> > 3rd-party
> > > > >> > >>> > > > directory but are only present in the IDF. For
> example:
> > > > >> > >>> > > >
> > > > >> > >>> > > > - esp_private/pm_impl.h
> > > > >> > >>> > > > - esp_cpu.h
> > > > >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > > > >> > >>> > > >
> > > > >> > >>> > > > I need those includes because sleep_modes.c uses
> > function
> > > > from
> > > > >> > >>> there.
> > > > >> > >>> > > >
> > > > >> > >>> > > > Could you please advise if it's possible to
> incorporate
> > > > these
> > > > >> IDF
> > > > >> > >>> > folders
> > > > >> > >>> > > > into the 3rd-party directory, or if that approach is
> not
> > > > >> > >>> recommended?
> > > > >> > >>> > > >
> > > > >> > >>> > > > Thank you for your assistance.
> > > > >> > >>> > > >
> > > > >> > >>> > > > Best regards,
> > > > >> > >>> > > >
> > > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci
> > > Serrano
> > > > <
> > > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > > >> > >>> > > >
> > > > >> > >>> > > > > Hi,
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > Just another note to guide your development: we
> don't
> > > > >> develop
> > > > >> > >>> > anything
> > > > >> > >>> > > on
> > > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from it
> is
> > > > >> derived
> > > > >> > >>> from
> > > > >> > >>> > the
> > > > >> > >>> > > > > path
> > > > >> > >>> > > > >
> > > > >> > >>> > > > >
> > > > >> > >>> > > >
> > > > >> > >>> > >
> > > > >> > >>> >
> > > > >> > >>>
> > > > >> >
> > > > >>
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > >> > >>> > > > > (essentially, header files from
> > > > >> > >>> `components/hal/<chip>/include/hal`,
> > > > >> > >>> > > > except
> > > > >> > >>> > > > > for some of the sources files that use the hal
> > functions
> > > > at
> > > > >> > >>> > > > > `components/hal` to implement some function we may
> > use).
> > > > You
> > > > >> > can
> > > > >> > >>> > take a
> > > > >> > >>> > > > > look at the branch `
> > > > >> > >>> > > > >
> > > > >> > >>> >
> > > > >> >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > >> <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > > >> > <
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >
> > > > >> > >>> <
> > > > >>
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > >> > >>> > <
> > > > >> >
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > >> > >>> > > <
> > > > >> > >>>
> > > > >>
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > >> > >>> > > > <
> > > > >> > >>>
> > > > >>
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > >> > >>> > > > > <
> > > > >> > >>> >
> > > > >>
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > > >> > >
> > > > >> > >>> > > > and
> > > > >> > >>> > > > > especially the commits beginning
> > > > >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to
> check
> > > the
> > > > >> kind
> > > > >> > >>> of
> > > > >> > >>> > > > changes
> > > > >> > >>> > > > > we do in hal. Essentially, we create a wrapper layer
> > to
> > > > >> make it
> > > > >> > >>> > > > independent
> > > > >> > >>> > > > > of the host OS.
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > That being said, you can either 1) try to adapt the
> > > > >> > >>> implementation of
> > > > >> > >>> > > > other
> > > > >> > >>> > > > > devices to use the HAL functions or 2) get some
> > > > inspiration
> > > > >> on
> > > > >> > >>> how
> > > > >> > >>> > IDF
> > > > >> > >>> > > > > implements PM. I'd stick with the 2nd option before
> > > simply
> > > > >> > >>> trying to
> > > > >> > >>> > > > adapt
> > > > >> > >>> > > > > an existing implementation (from ESP32-C3 legacy or
> > from
> > > > >> > >>> > > ESP32/ESP32-S3).
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > Best regards,
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura
> > > > Oliveira
> > > > >> <
> > > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > > Hello Tiago.
> > > > >> > >>> > > > > >
> > > > >> > >>> > > > > > Thank you for clarification, I will follow your
> > > > >> instructions.
> > > > >> > >>> > > > > >
> > > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago
> Medicci
> > > > >> Serrano <
> > > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > >> > >>> > > > > >
> > > > >> > >>> > > > > > > Hi Felipe,
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > > Just complementing: use your forked version of
> the
> > > HAL
> > > > >> > >>> during the
> > > > >> > >>> > > > > > > development. As soon as you have a working
> > version,
> > > > you
> > > > >> can
> > > > >> > >>> > submit
> > > > >> > >>> > > on
> > > > >> > >>> > > > > the
> > > > >> > >>> > > > > > > official repository.
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > > Best regards,
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago
> > Medicci
> > > > >> > Serrano <
> > > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > > > Hi Felipe,
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > Thanks for asking! You should follow the path
> > > using
> > > > >> the
> > > > >> > >>> > functions
> > > > >> > >>> > > > on
> > > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the repository
> > and
> > > > use
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > >
> > > > >> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > >> > >>> > > > > > env
> > > > >> > >>> > > > > > > > vars (globally or before the make command) to
> > use
> > > > your
> > > > >> > >>> version
> > > > >> > >>> > of
> > > > >> > >>> > > > the
> > > > >> > >>> > > > > > > HAL.
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > I just wanted to share some thoughts: using
> the
> > > HAL
> > > > >> > >>> enables us
> > > > >> > >>> > to
> > > > >> > >>> > > > > make
> > > > >> > >>> > > > > > > the
> > > > >> > >>> > > > > > > > feature available for all the Espressif
> devices
> > > > >> (please
> > > > >> > >>> don't
> > > > >> > >>> > > > bother
> > > > >> > >>> > > > > > with
> > > > >> > >>> > > > > > > > that now, as soon as you submit it, we can
> test
> > > for
> > > > >> the
> > > > >> > >>> other
> > > > >> > >>> > > > devices
> > > > >> > >>> > > > > > and
> > > > >> > >>> > > > > > > > eventually make any adjustments). Although
> it's
> > > > >> possible
> > > > >> > to
> > > > >> > >>> > > > > reimplement
> > > > >> > >>> > > > > > > > these functions on NuttX, we don't recommend
> > that
> > > > >> because
> > > > >> > >>> of
> > > > >> > >>> > the
> > > > >> > >>> > > > > first
> > > > >> > >>> > > > > > > > statement (the ability to use for the other
> > > > devices):
> > > > >> in
> > > > >> > >>> that
> > > > >> > >>> > > case
> > > > >> > >>> > > > we
> > > > >> > >>> > > > > > > > wouldn't be able to support the feature. You
> can
> > > > take
> > > > >> a
> > > > >> > >>> look on
> > > > >> > >>> > > IDF
> > > > >> > >>> > > > > for
> > > > >> > >>> > > > > > > > some inspiration on how it's implemented.
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > Please let me know if you have any questions.
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > Best regards,
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe
> > Moura
> > > > >> > >>> Oliveira <
> > > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > >> Hello everyone,
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >> Our project has reached a point where we need
> > the
> > > > >> Power
> > > > >> > >>> > Manager
> > > > >> > >>> > > > > > > >> functionality, which is not yet available in
> > the
> > > > >> > ESP32C6.
> > > > >> > >>> I am
> > > > >> > >>> > > > > > studying
> > > > >> > >>> > > > > > > to
> > > > >> > >>> > > > > > > >> start the implementation, but I am confused
> > about
> > > > the
> > > > >> > >>> correct
> > > > >> > >>> > > way
> > > > >> > >>> > > > to
> > > > >> > >>> > > > > > > >> approach this.
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >> There is a Power Manager implementation for
> the
> > > > >> ESP32C3,
> > > > >> > >>> but
> > > > >> > >>> > it
> > > > >> > >>> > > > > seems
> > > > >> > >>> > > > > > to
> > > > >> > >>> > > > > > > >> follow the legacy methodology. In fact, the
> > file
> > > > >> > >>> > esp32c3_idle.c
> > > > >> > >>> > > is
> > > > >> > >>> > > > > > > located
> > > > >> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy.
> In
> > > this
> > > > >> > >>> > methodology,
> > > > >> > >>> > > > > > > functions
> > > > >> > >>> > > > > > > >> are re-implemented from the Espressif driver.
> > For
> > > > >> > >>> example, the
> > > > >> > >>> > > > > > function
> > > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is
> currently
> > > > >> > available
> > > > >> > >>> in
> > > > >> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >> I tried using the implementations from
> > > > >> esp-hal-3rdparty
> > > > >> > to
> > > > >> > >>> > > develop
> > > > >> > >>> > > > > the
> > > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but
> the
> > > > files
> > > > >> > >>> still
> > > > >> > >>> > have
> > > > >> > >>> > > > > many
> > > > >> > >>> > > > > > > >> dependencies on items that are not present in
> > > > NuttX.
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >> My question is: Should I try to make the
> Power
> > > > >> Manager
> > > > >> > >>> work
> > > > >> > >>> > > using
> > > > >> > >>> > > > > the
> > > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it
> > > requires
> > > > >> > making
> > > > >> > >>> > > changes
> > > > >> > >>> > > > to
> > > > >> > >>> > > > > > the
> > > > >> > >>> > > > > > > >> 3rd-party code? Or should I re-implement the
> > > > >> functions
> > > > >> > >>> within
> > > > >> > >>> > > > NuttX,
> > > > >> > >>> > > > > > > even
> > > > >> > >>> > > > > > > >> if, in this case, there are functions with
> the
> > > same
> > > > >> > scope
> > > > >> > >>> and
> > > > >> > >>> > > > > > > >> implementation in different files, where one
> is
> > > > >> > compiled,
> > > > >> > >>> and
> > > > >> > >>> > > the
> > > > >> > >>> > > > > > other
> > > > >> > >>> > > > > > > is
> > > > >> > >>> > > > > > > >> not?
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >> --
> > > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > > >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > > > >> > >>> > > > > > > >> Linkedin <
> > > > >> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > >> > >>> > > > > > > >> <
> https://twitter.com/FelipeMOliveir?lang=pt-br
> > >
> > > > >> > >>> > > > > > > >>
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > --
> > > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > > > Embedded Software Engineer
> > > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > > >> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > > >> > >>> > > > > > > > Follow me:
> > > > >> > >>> > > > > > > > <
> > > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > > >
> > > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > > >> > >>> > > > > > > >
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > > --
> > > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > > > Embedded Software Engineer
> > > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > > >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > > >> > >>> > > > > > > a: Campinas, Brazil
> > > > >> > >>> > > > > > > Follow me:
> > > > >> > >>> > > > > > > <
> > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > >
> > > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > > >> > >>> > > > > > >
> > > > >> > >>> > > > > >
> > > > >> > >>> > > > > >
> > > > >> > >>> > > > > > --
> > > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > > >> > >>> > > > > > Linkedin <
> > > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > > >> > >>> >
> > > > >> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >> > >>> > > > > >
> > > > >> > >>> > > > >
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > --
> > > > >> > >>> > > > > Tiago Medicci Serrano
> > > > >> > >>> > > > >
> > > > >> > >>> > > > > Embedded Software Engineer
> > > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > > >> > >>> > > > > a: Campinas, Brazil
> > > > >> > >>> > > > > Follow me:
> > > > >> > >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6
> >
> > > > >> > >>> > > > > <https://github.com/tmedicci>
> > > > >> > >>> > > > >
> > > > >> > >>> > > >
> > > > >> > >>> > > >
> > > > >> > >>> > > > --
> > > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > > >> > >>> > > > Linkedin <
> > > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >> > >>> > > >
> > > > >> > >>> > >
> > > > >> > >>> > >
> > > > >> > >>> > > --
> > > > >> > >>> > > Tiago Medicci Serrano
> > > > >> > >>> > >
> > > > >> > >>> > > Embedded Software Engineer
> > > > >> > >>> > > MSc Electronics/Microelectronics
> > > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > >> > >>> > > e: tiago.medicci@gmail.com
> > > > >> > >>> > > a: Campinas, Brazil
> > > > >> > >>> > > Follow me:
> > > > >> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > >> > >>> > > <https://github.com/tmedicci>
> > > > >> > >>> > >
> > > > >> > >>> >
> > > > >> > >>> >
> > > > >> > >>> > --
> > > > >> > >>> > *Felipe Moura de Oliveira*
> > > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > > >> > >>> > Linkedin <
> > > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >> > >>> >
> > > > >> > >>>
> > > > >> > >>
> > > > >> > >>
> > > > >> > >> --
> > > > >> > >> *Felipe Moura de Oliveira*
> > > > >> > >> *Universidade Federal de Minas Gerais*
> > > > >> > >> Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >
> > > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >> > >>
> > > > >> > >
> > > > >> > >
> > > > >> > > --
> > > > >> > > *Felipe Moura de Oliveira*
> > > > >> > > *Universidade Federal de Minas Gerais*
> > > > >> > > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >> > >
> > > > >> >
> > > > >> >
> > > > >> > --
> > > > >> > *Felipe Moura de Oliveira*
> > > > >> > *Universidade Federal de Minas Gerais*
> > > > >> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > *Felipe Moura de Oliveira*
> > > > > *Universidade Federal de Minas Gerais*
> > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
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.fmo@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 <nuttx/config.h>
> #include <stdio.h>
> #include <stdint.h>
> #include <time.h>
> #include <unistd.h>
> #include <pthread.h>
> #include <stdlib.h>
>
>
> /****************************************************************************
> * 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);
> }
>
> return NULL;
> }
>
>
> /****************************************************************************
> * Public Functions
>
> ****************************************************************************/
>
>
> /****************************************************************************
> * main
>
> ****************************************************************************/
>
> int main(int argc, FAR char *argv[])
> {
> pthread_t threads[NUM_THREADS];
> struct thread_info tinfo[NUM_THREADS];
> int ret;
>
> unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
>
> for (int i = 0; i < NUM_THREADS; i++)
> {
> tinfo[i].thread_id = i + 1;
> tinfo[i].sleep_time = sleep_times[i];
>
> ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
> if (ret != 0)
> {
> printf("Error creating thread %d: %d\n", i + 1, ret);
> exit(EXIT_FAILURE);
> }
> }
> int app_ret = 0;
> if (app_ret == -1) {
> printf("Error executing command\n");
> } else {
> printf("Application finished with return code: %d\n", app_ret);
> }
>
> while (1)
> {
> printf("Hello, World!! [Main Thread]\n");
> sleep(10);
> }
>
> return 0;
> }
>
>
>
> You will see output below:
> nsh> hello
> Aplicação finalizou com código de retorno: 0
> Hello, World!! [Main Thread]
> Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0 segundos
> Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0 segundos
> Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0 segundos
> Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0 segundos
> Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0 segundos
> *pmu_*Hello, World!! [Main Thread]
> Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11 segundos
> Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16 segundos
>
> I was able to power consumption below 1 mA when mcu is in idle mode, so it
> is in light sleep.
>
> Later, making a distclean, running wifi config and adding
> CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see that the
> mcu goes to sleep and not return.
>
> Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
> > Hi Felipe, good to hear about your progress here!
> >
> > These functions are ROM-defined functions. By checking the TRM, you can
> see
> > a read-only flash partition that holds some functions (widely used
> > functions, like malloc and internal functions).
> >
> > ets_get_cpu_frequency
> > <
> >
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> > >
> > is
> > one of these internal functions. They are defined directly at the linker
> > script.
> >
> > If I understood correctly, these functions are crashing when it's being
> > called, right? If so, can you:
> >
> > 1. Share the crash dump
> > 2. Use GDB and try to check where/why it fails: it may trying to
> access
> > some prohibited memory region or even trying to call an unregistered
> > callback.
> >
> > Thanks!
> >
> > Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> > > Hello everyone,
> > >
> > > Tiago, I am trying to work with light sleep for now, after it work will
> > go
> > > ahead with deep sleep. To run in light sleep I don't need to change
> > linker
> > > so I was able to build and flash without "image" issues.
> > > Now I am facing other kind of issue:
> > > Some functions refers to "ets" function and I don't know how handle
> this,
> > > for instance:
> > >
> > > /**
> > > * @brief Get the real CPU ticks per us
> > > *
> > > * @return CPU ticks per us
> > > */
> > > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> > >
> > > This function is necessary in the *sleep_modes.c* file. During execute
> > code
> > > I am facing crash when this function is called, its happen because its
> > > implementation is a reference to other function:
> > >
> > >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> > >
> > > I cannot find *ets_get_cpu_frequency*, so how should I handle it?
> > >
> > > PS: I have another situation like this, when I try to call
> > > *esp_rom_set_cpu_ticks_per_us* function.
> > >
> > > Regards.
> > >
> > > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > > moura.fmo@gmail.com> escreveu:
> > >
> > > > Hello Tiago.
> > > >
> > > > Please look de draft here:
> https://github.com/apache/nuttx/pull/14548
> > > >
> > > > This branch will refer to the updated 3rd-party in my repo.
> > > >
> > > > You only need to enable PM in menuconfig and it will be enough to see
> > > > changes.
> > > >
> > > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > > > tiago.medicci@gmail.com> escreveu:
> > > >
> > > >> Hi Felipe,
> > > >>
> > > >> Can you share your PR as a draft on GH to make it easier to check
> the
> > > >> files
> > > >> (and the build process)?
> > > >>
> > > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> > > >> moura.fmo@gmail.com> escreveu:
> > > >>
> > > >> > Hello Tiago,
> > > >> >
> > > >> > I "finished" the port, but after it my esp32c6 dev kit is
> resetting.
> > > >> Maybe
> > > >> > the issue is related my changes in
> > > >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you
> > give
> > > >> some
> > > >> > tips about how to go ahead?
> > > >> >
> > > >> > Below you can see nuttx report:
> > > >> > Build:Sep 19 2022
> > > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > > >> > Saved PC:0x40018bea
> > > >> > SPIWP:0xee
> > > >> > mode:DIO, clock div:2
> > > >> > load:0x40800000,len:0x61e0
> > > >> > load:0x408061e0,len:0xc34
> > > >> > load:0x50000000,len:0x20
> > > >> > load:0x5000001e,len:0x24
> > > >> > Invalid image block, can't boot.
> > > >> > ets_main.c 331
> > > >> > ESP-ROM:esp32c6-20220919
> > > >> >
> > > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> > > >> > moura.fmo@gmail.com> escreveu:
> > > >> >
> > > >> > > Hello everyone,
> > > >> > >
> > > >> > > I was able to solve linker issues, editing the linker by
> myself. I
> > > >> need
> > > >> > to
> > > >> > > finish more than one build issue before testing it, so I will
> see
> > > if I
> > > >> > made
> > > >> > > the right changes in linker.
> > > >> > >
> > > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> > > >> > > moura.fmo@gmail.com> escreveu:
> > > >> > >
> > > >> > >> *Hello everyone, Tiago,*
> > > >> > >>
> > > >> > >> I have made progress with the build issue I was encountering
> and
> > am
> > > >> now
> > > >> > >> "stuck" at what I believe is one of the final stages. I am
> > > >> experiencing
> > > >> > the
> > > >> > >> following compilation error:
> > > >> > >> LD: nuttx
> > > >> > >> riscv-none-elf-ld: warning:
> > > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > > >> > >> has a LOAD segment with RWX permissions
> > > >> > >> riscv-none-elf-ld:
> > > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > > >> > >> libarch.a(sleep_modes.o): in function
> > > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > > >> > >> `_rtc_force_fast_end'
> > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined
> > > >> reference
> > > >> > >> to `_rtc_text_start'
> > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined
> > > >> reference
> > > >> > >> to `_rtc_force_fast_end'
> > > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined
> > > >> reference
> > > >> > >> to `_rtc_text_start'
> > > >> > >> riscv-none-elf-ld:
> > > >> > >>
> > > >> >
> > > >>
> > >
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > > >> > >> in function `esp_sleep_cpu_retention':
> > > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > > >> > >> `rv_core_critical_regs_save'
> > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined
> > > reference
> > > >> to
> > > >> > >> `rv_core_critical_regs_restore'
> > > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined
> > > reference
> > > >> to
> > > >> > >> `rv_core_critical_regs_restore'
> > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > >> > >>
> > > >> > >> I would greatly appreciate your assistance.
> > > >> > >>
> > > >> > >> Focusing on the item _rtc_text_start, I see that it is defined
> in
> > > the
> > > >> > >> file:
> > > >> > >>
> > > >>
> > arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > >> > >> sections.ld.in
> > > >> > >>
> > > >> > >> However, I am unsure how to add this file to the complete
> linking
> > > >> > >> process. I added this file to hal_esp32c6.mk, but I received
> the
> > > >> > >> following error:
> > > >> > >> LD: nuttx
> > > >> > >>
> > > >> >
> > > >>
> > >
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > > >> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > > >> > >> sections.ld.in.tmp:113 cannot move location counter backwards
> > (from
> > > >> > >> 40809800 to 40800000)
> > > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > > >> > >>
> > > >> > >>
> > > >> > >> Does anyone have any tips or suggestions that could help me
> move
> > > >> forward
> > > >> > >> with this process?
> > > >> > >>
> > > >> > >> Thank you in advance for your help.
> > > >> > >>
> > > >> > >> *Best regards,*
> > > >> > >>
> > > >> > >>
> > > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> > > >> > >> tiago.medicci@gmail.com> escreveu:
> > > >> > >>
> > > >> > >>> Hi Felipe,
> > > >> > >>>
> > > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a
> > substitute
> > > >> for
> > > >> > >>> this
> > > >> > >>> function should be part
> > > >> > >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`.
> That
> > > >> being
> > > >> > >>> said, you can either implement it (and define it as a macro,
> on
> > > >> HAL) or
> > > >> > >>> you
> > > >> > >>> can either ignore these functions related to GPIO wakeup from
> > > sleep
> > > >> for
> > > >> > >>> now
> > > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to
> you:
> > if
> > > >> the
> > > >> > >>> GPIO
> > > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing this
> > feature
> > > >> for
> > > >> > >>> now.
> > > >> > >>>
> > > >> > >>> Best regards,
> > > >> > >>>
> > > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
> > > >> > >>> moura.fmo@gmail.com> escreveu:
> > > >> > >>>
> > > >> > >>> > Hello Tiago,
> > > >> > >>> >
> > > >> > >>> > Thank you for your assistance earlier.
> > > >> > >>> >
> > > >> > >>> > I would like to discuss further the necessity of the
> > > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only
> available
> > > in
> > > >> the
> > > >> > >>> IDF.
> > > >> > >>> >
> > > >> > >>> > In sleep_modes.c, there is the following code snippet:
> > > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> > > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > > >> > >>> > {
> > > >> > >>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > >> > >>> > }
> > > >> > >>> > // Translate bit map of GPIO numbers into the bit map of RTC
> > IO
> > > >> > numbers
> > > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > > >> > >>> > if ((io_mask & 1) == 0) {
> > > >> > >>> > continue;
> > > >> > >>> > }
> > > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > > >> > >>> > return ESP_ERR_INVALID_ARG;
> > > >> > >>> > }
> > > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > > >> > >>> > }
> > > >> > >>> >
> > > >> > >>> > I believe this code is essential for compilation. The
> function
> > > >> > >>> > rtc_io_number_get is located at the following path in the
> IDF:
> > > >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > > >> > >>> >
> > > >> > >>> > However, the esp_driver_gpio folder is not present in the
> > > >> 3rd-party
> > > >> > >>> > directory. In this case, what is the recommended procedure
> to
> > > >> > proceed?
> > > >> > >>> >
> > > >> > >>> > Thank you again for your support.
> > > >> > >>> >
> > > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano
> <
> > > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > > >> > >>> >
> > > >> > >>> > > Hi Felipe,
> > > >> > >>> > >
> > > >> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of
> > > >> ESP-IDF,
> > > >> > >>> which
> > > >> > >>> > is
> > > >> > >>> > > a driver directly. Same for
> > `esp_driver_gpio/include/rtc_io.h`
> > > >> > >>> (here, a
> > > >> > >>> > > detail: I wasn't able to find this path on IDF, so make
> sure
> > > you
> > > >> > are
> > > >> > >>> > > checking under the `release/v5.1` branch, which the HAL
> was
> > > >> based).
> > > >> > >>> The
> > > >> > >>> > HAL
> > > >> > >>> > > repository doesn't contain ESP-IDF drivers, which are
> always
> > > >> > >>> implemented
> > > >> > >>> > on
> > > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > >> > >>> > >
> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > > >> > >>> > >
> > > >> > >>> > > The files under
> `esp-hal-3rdparty/components/esp_hw_support`
> > > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to implement
> the
> > > >> > driver.
> > > >> > >>> This
> > > >> > >>> > > is, mostly, a wrapping layer under the function of
> `esp_rom`
> > > and
> > > >> > >>> `hal`
> > > >> > >>> > > components. However, they still may refer to ESP-IDF
> > drivers.
> > > >> That
> > > >> > >>> being
> > > >> > >>> > > said, you can check if removing such dependencies is
> > possible.
> > > >> We
> > > >> > >>> usually
> > > >> > >>> > > do that with conditional macros. A good starting point is
> to
> > > >> check
> > > >> > >>> for
> > > >> > >>> > > `#ifdef __NuttX__` on these sources and headers: we use
> them
> > > to
> > > >> > >>> > remove/add
> > > >> > >>> > > headers and functions that aren't available on
> NuttX/needed
> > by
> > > >> > NuttX.
> > > >> > >>> > >
> > > >> > >>> > > Best regards,
> > > >> > >>> > >
> > > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura
> Oliveira
> > <
> > > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > > >> > >>> > >
> > > >> > >>> > > > Hello all,
> > > >> > >>> > > >
> > > >> > >>> > > > Tiago,
> > > >> > >>> > > >
> > > >> > >>> > > > I have a question regarding the porting process.
> > > >> Specifically, I
> > > >> > >>> need
> > > >> > >>> > to
> > > >> > >>> > > > add the sleep_modes.c file to the compilation process.
> Am
> > I
> > > on
> > > >> > the
> > > >> > >>> > right
> > > >> > >>> > > > path with this approach?
> > > >> > >>> > > >
> > > >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file by
> > > adding
> > > >> > >>> > > > sleep_modes.c.
> > > >> > >>> > > > However, I am facing some issues: within sleep_modes.c,
> > some
> > > >> > >>> #include
> > > >> > >>> > > > statements reference files that are not available in the
> > > >> > 3rd-party
> > > >> > >>> > > > directory but are only present in the IDF. For example:
> > > >> > >>> > > >
> > > >> > >>> > > > - esp_private/pm_impl.h
> > > >> > >>> > > > - esp_cpu.h
> > > >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > > >> > >>> > > >
> > > >> > >>> > > > I need those includes because sleep_modes.c uses
> function
> > > from
> > > >> > >>> there.
> > > >> > >>> > > >
> > > >> > >>> > > > Could you please advise if it's possible to incorporate
> > > these
> > > >> IDF
> > > >> > >>> > folders
> > > >> > >>> > > > into the 3rd-party directory, or if that approach is not
> > > >> > >>> recommended?
> > > >> > >>> > > >
> > > >> > >>> > > > Thank you for your assistance.
> > > >> > >>> > > >
> > > >> > >>> > > > Best regards,
> > > >> > >>> > > >
> > > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci
> > Serrano
> > > <
> > > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > > >> > >>> > > >
> > > >> > >>> > > > > Hi,
> > > >> > >>> > > > >
> > > >> > >>> > > > > Just another note to guide your development: we don't
> > > >> develop
> > > >> > >>> > anything
> > > >> > >>> > > on
> > > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from it is
> > > >> derived
> > > >> > >>> from
> > > >> > >>> > the
> > > >> > >>> > > > > path
> > > >> > >>> > > > >
> > > >> > >>> > > > >
> > > >> > >>> > > >
> > > >> > >>> > >
> > > >> > >>> >
> > > >> > >>>
> > > >> >
> > > >>
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > >> > >>> > > > > (essentially, header files from
> > > >> > >>> `components/hal/<chip>/include/hal`,
> > > >> > >>> > > > except
> > > >> > >>> > > > > for some of the sources files that use the hal
> functions
> > > at
> > > >> > >>> > > > > `components/hal` to implement some function we may
> use).
> > > You
> > > >> > can
> > > >> > >>> > take a
> > > >> > >>> > > > > look at the branch `
> > > >> > >>> > > > >
> > > >> > >>> >
> > > >> >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > >> <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > > >> > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >
> > > >> > >>> <
> > > >>
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > >> > >>> > <
> > > >> >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > >> > >>> > > <
> > > >> > >>>
> > > >>
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > >> > >>> > > > <
> > > >> > >>>
> > > >>
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > >> > >>> > > > > <
> > > >> > >>> >
> > > >>
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > > >> > >
> > > >> > >>> > > > and
> > > >> > >>> > > > > especially the commits beginning
> > > >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check
> > the
> > > >> kind
> > > >> > >>> of
> > > >> > >>> > > > changes
> > > >> > >>> > > > > we do in hal. Essentially, we create a wrapper layer
> to
> > > >> make it
> > > >> > >>> > > > independent
> > > >> > >>> > > > > of the host OS.
> > > >> > >>> > > > >
> > > >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > > >> > >>> > > > >
> > > >> > >>> > > > > That being said, you can either 1) try to adapt the
> > > >> > >>> implementation of
> > > >> > >>> > > > other
> > > >> > >>> > > > > devices to use the HAL functions or 2) get some
> > > inspiration
> > > >> on
> > > >> > >>> how
> > > >> > >>> > IDF
> > > >> > >>> > > > > implements PM. I'd stick with the 2nd option before
> > simply
> > > >> > >>> trying to
> > > >> > >>> > > > adapt
> > > >> > >>> > > > > an existing implementation (from ESP32-C3 legacy or
> from
> > > >> > >>> > > ESP32/ESP32-S3).
> > > >> > >>> > > > >
> > > >> > >>> > > > > Best regards,
> > > >> > >>> > > > >
> > > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura
> > > Oliveira
> > > >> <
> > > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > > >> > >>> > > > >
> > > >> > >>> > > > > > Hello Tiago.
> > > >> > >>> > > > > >
> > > >> > >>> > > > > > Thank you for clarification, I will follow your
> > > >> instructions.
> > > >> > >>> > > > > >
> > > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci
> > > >> Serrano <
> > > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > > >> > >>> > > > > >
> > > >> > >>> > > > > > > Hi Felipe,
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > > Just complementing: use your forked version of the
> > HAL
> > > >> > >>> during the
> > > >> > >>> > > > > > > development. As soon as you have a working
> version,
> > > you
> > > >> can
> > > >> > >>> > submit
> > > >> > >>> > > on
> > > >> > >>> > > > > the
> > > >> > >>> > > > > > > official repository.
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > > Best regards,
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago
> Medicci
> > > >> > Serrano <
> > > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > > > Hi Felipe,
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > Thanks for asking! You should follow the path
> > using
> > > >> the
> > > >> > >>> > functions
> > > >> > >>> > > > on
> > > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the repository
> and
> > > use
> > > >> > >>> > > > > > > >
> > > >> > >>> > >
> > > >> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > > >> > >>> > > > > > env
> > > >> > >>> > > > > > > > vars (globally or before the make command) to
> use
> > > your
> > > >> > >>> version
> > > >> > >>> > of
> > > >> > >>> > > > the
> > > >> > >>> > > > > > > HAL.
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > I just wanted to share some thoughts: using the
> > HAL
> > > >> > >>> enables us
> > > >> > >>> > to
> > > >> > >>> > > > > make
> > > >> > >>> > > > > > > the
> > > >> > >>> > > > > > > > feature available for all the Espressif devices
> > > >> (please
> > > >> > >>> don't
> > > >> > >>> > > > bother
> > > >> > >>> > > > > > with
> > > >> > >>> > > > > > > > that now, as soon as you submit it, we can test
> > for
> > > >> the
> > > >> > >>> other
> > > >> > >>> > > > devices
> > > >> > >>> > > > > > and
> > > >> > >>> > > > > > > > eventually make any adjustments). Although it's
> > > >> possible
> > > >> > to
> > > >> > >>> > > > > reimplement
> > > >> > >>> > > > > > > > these functions on NuttX, we don't recommend
> that
> > > >> because
> > > >> > >>> of
> > > >> > >>> > the
> > > >> > >>> > > > > first
> > > >> > >>> > > > > > > > statement (the ability to use for the other
> > > devices):
> > > >> in
> > > >> > >>> that
> > > >> > >>> > > case
> > > >> > >>> > > > we
> > > >> > >>> > > > > > > > wouldn't be able to support the feature. You can
> > > take
> > > >> a
> > > >> > >>> look on
> > > >> > >>> > > IDF
> > > >> > >>> > > > > for
> > > >> > >>> > > > > > > > some inspiration on how it's implemented.
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > Please let me know if you have any questions.
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > Best regards,
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe
> Moura
> > > >> > >>> Oliveira <
> > > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > >> Hello everyone,
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >> Our project has reached a point where we need
> the
> > > >> Power
> > > >> > >>> > Manager
> > > >> > >>> > > > > > > >> functionality, which is not yet available in
> the
> > > >> > ESP32C6.
> > > >> > >>> I am
> > > >> > >>> > > > > > studying
> > > >> > >>> > > > > > > to
> > > >> > >>> > > > > > > >> start the implementation, but I am confused
> about
> > > the
> > > >> > >>> correct
> > > >> > >>> > > way
> > > >> > >>> > > > to
> > > >> > >>> > > > > > > >> approach this.
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >> There is a Power Manager implementation for the
> > > >> ESP32C3,
> > > >> > >>> but
> > > >> > >>> > it
> > > >> > >>> > > > > seems
> > > >> > >>> > > > > > to
> > > >> > >>> > > > > > > >> follow the legacy methodology. In fact, the
> file
> > > >> > >>> > esp32c3_idle.c
> > > >> > >>> > > is
> > > >> > >>> > > > > > > located
> > > >> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In
> > this
> > > >> > >>> > methodology,
> > > >> > >>> > > > > > > functions
> > > >> > >>> > > > > > > >> are re-implemented from the Espressif driver.
> For
> > > >> > >>> example, the
> > > >> > >>> > > > > > function
> > > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is currently
> > > >> > available
> > > >> > >>> in
> > > >> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >> I tried using the implementations from
> > > >> esp-hal-3rdparty
> > > >> > to
> > > >> > >>> > > develop
> > > >> > >>> > > > > the
> > > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the
> > > files
> > > >> > >>> still
> > > >> > >>> > have
> > > >> > >>> > > > > many
> > > >> > >>> > > > > > > >> dependencies on items that are not present in
> > > NuttX.
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >> My question is: Should I try to make the Power
> > > >> Manager
> > > >> > >>> work
> > > >> > >>> > > using
> > > >> > >>> > > > > the
> > > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it
> > requires
> > > >> > making
> > > >> > >>> > > changes
> > > >> > >>> > > > to
> > > >> > >>> > > > > > the
> > > >> > >>> > > > > > > >> 3rd-party code? Or should I re-implement the
> > > >> functions
> > > >> > >>> within
> > > >> > >>> > > > NuttX,
> > > >> > >>> > > > > > > even
> > > >> > >>> > > > > > > >> if, in this case, there are functions with the
> > same
> > > >> > scope
> > > >> > >>> and
> > > >> > >>> > > > > > > >> implementation in different files, where one is
> > > >> > compiled,
> > > >> > >>> and
> > > >> > >>> > > the
> > > >> > >>> > > > > > other
> > > >> > >>> > > > > > > is
> > > >> > >>> > > > > > > >> not?
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >> --
> > > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > > >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > > >> > >>> > > > > > > >> Linkedin <
> > > >> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > >> > >>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br
> >
> > > >> > >>> > > > > > > >>
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > --
> > > >> > >>> > > > > > > > Tiago Medicci Serrano
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > > > Embedded Software Engineer
> > > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > > >> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > > >> > >>> > > > > > > > a: Campinas, Brazil
> > > >> > >>> > > > > > > > Follow me:
> > > >> > >>> > > > > > > > <
> > https://www.linkedin.com/in/tiago-serrano-924458b6
> > > >
> > > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > > >> > >>> > > > > > > >
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > > --
> > > >> > >>> > > > > > > Tiago Medicci Serrano
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > > > Embedded Software Engineer
> > > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > > >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > > >> > >>> > > > > > > a: Campinas, Brazil
> > > >> > >>> > > > > > > Follow me:
> > > >> > >>> > > > > > > <
> https://www.linkedin.com/in/tiago-serrano-924458b6
> > >
> > > >> > >>> > > > > > > <https://github.com/tmedicci>
> > > >> > >>> > > > > > >
> > > >> > >>> > > > > >
> > > >> > >>> > > > > >
> > > >> > >>> > > > > > --
> > > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > > >> > >>> > > > > > Linkedin <
> > > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > > >> > >>> >
> > > >> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >> > >>> > > > > >
> > > >> > >>> > > > >
> > > >> > >>> > > > >
> > > >> > >>> > > > > --
> > > >> > >>> > > > > Tiago Medicci Serrano
> > > >> > >>> > > > >
> > > >> > >>> > > > > Embedded Software Engineer
> > > >> > >>> > > > > MSc Electronics/Microelectronics
> > > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > >> > >>> > > > > e: tiago.medicci@gmail.com
> > > >> > >>> > > > > a: Campinas, Brazil
> > > >> > >>> > > > > Follow me:
> > > >> > >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > >> > >>> > > > > <https://github.com/tmedicci>
> > > >> > >>> > > > >
> > > >> > >>> > > >
> > > >> > >>> > > >
> > > >> > >>> > > > --
> > > >> > >>> > > > *Felipe Moura de Oliveira*
> > > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > > >> > >>> > > > Linkedin <
> > > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >> > >>> > > >
> > > >> > >>> > >
> > > >> > >>> > >
> > > >> > >>> > > --
> > > >> > >>> > > Tiago Medicci Serrano
> > > >> > >>> > >
> > > >> > >>> > > Embedded Software Engineer
> > > >> > >>> > > MSc Electronics/Microelectronics
> > > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > >> > >>> > > e: tiago.medicci@gmail.com
> > > >> > >>> > > a: Campinas, Brazil
> > > >> > >>> > > Follow me:
> > > >> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > >> > >>> > > <https://github.com/tmedicci>
> > > >> > >>> > >
> > > >> > >>> >
> > > >> > >>> >
> > > >> > >>> > --
> > > >> > >>> > *Felipe Moura de Oliveira*
> > > >> > >>> > *Universidade Federal de Minas Gerais*
> > > >> > >>> > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >> > >>> >
> > > >> > >>>
> > > >> > >>
> > > >> > >>
> > > >> > >> --
> > > >> > >> *Felipe Moura de Oliveira*
> > > >> > >> *Universidade Federal de Minas Gerais*
> > > >> > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >
> > > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >> > >>
> > > >> > >
> > > >> > >
> > > >> > > --
> > > >> > > *Felipe Moura de Oliveira*
> > > >> > > *Universidade Federal de Minas Gerais*
> > > >> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >> > >
> > > >> >
> > > >> >
> > > >> > --
> > > >> > *Felipe Moura de Oliveira*
> > > >> > *Universidade Federal de Minas Gerais*
> > > >> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >> >
> > > >>
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
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 <nuttx/config.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
/****************************************************************************
* 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);
}
return NULL;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* main
****************************************************************************/
int main(int argc, FAR char *argv[])
{
pthread_t threads[NUM_THREADS];
struct thread_info tinfo[NUM_THREADS];
int ret;
unsigned int sleep_times[NUM_THREADS] = {15, 11, 30, 70, 25};
for (int i = 0; i < NUM_THREADS; i++)
{
tinfo[i].thread_id = i + 1;
tinfo[i].sleep_time = sleep_times[i];
ret = pthread_create(&threads[i], NULL, thread_func, &tinfo[i]);
if (ret != 0)
{
printf("Error creating thread %d: %d\n", i + 1, ret);
exit(EXIT_FAILURE);
}
}
int app_ret = 0;
if (app_ret == -1) {
printf("Error executing command\n");
} else {
printf("Application finished with return code: %d\n", app_ret);
}
while (1)
{
printf("Hello, World!! [Main Thread]\n");
sleep(10);
}
return 0;
}
You will see output below:
nsh> hello
Aplicação finalizou com código de retorno: 0
Hello, World!! [Main Thread]
Hello, World!! [Thread 1] Iteração: 1 | Tempo decorrido: 0 segundos
Hello, World!! [Thread 2] It*pmu_*eração: 1 | Tempo decorrido: 0 segundos
Hello, World!! [Thread 3] Iteração: 1 | Tempo decorrido: 0 segundos
Hello, World!! [Thread 4] Iteração: 1 | Tempo decorrido: 0 segundos
Hello, World!! [Thread 5] Iteração: 1 | Tempo decorrido: 0 segundos
*pmu_*Hello, World!! [Main Thread]
Hello, World!! [Thread 2] Iteração: 2 | Tempo decorrido: 11 segundos
Hello, World!! [Thread 1] Iteração: 2 | Tempo decorrido: 16 segundos
I was able to power consumption below 1 mA when mcu is in idle mode, so it
is in light sleep.
Later, making a distclean, running wifi config and adding
CONFIG_ESP_AUTO_SLEEP=y and CONFIG_EXAMPLES_HELLO=y, you will see that the
mcu goes to sleep and not return.
Em seg., 4 de nov. de 2024 às 08:48, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi Felipe, good to hear about your progress here!
>
> These functions are ROM-defined functions. By checking the TRM, you can see
> a read-only flash partition that holds some functions (widely used
> functions, like malloc and internal functions).
>
> ets_get_cpu_frequency
> <
> https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32
> >
> is
> one of these internal functions. They are defined directly at the linker
> script.
>
> If I understood correctly, these functions are crashing when it's being
> called, right? If so, can you:
>
> 1. Share the crash dump
> 2. Use GDB and try to check where/why it fails: it may trying to access
> some prohibited memory region or even trying to call an unregistered
> callback.
>
> Thanks!
>
> Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello everyone,
> >
> > Tiago, I am trying to work with light sleep for now, after it work will
> go
> > ahead with deep sleep. To run in light sleep I don't need to change
> linker
> > so I was able to build and flash without "image" issues.
> > Now I am facing other kind of issue:
> > Some functions refers to "ets" function and I don't know how handle this,
> > for instance:
> >
> > /**
> > * @brief Get the real CPU ticks per us
> > *
> > * @return CPU ticks per us
> > */
> > uint32_t esp_rom_get_cpu_ticks_per_us(void);
> >
> > This function is necessary in the *sleep_modes.c* file. During execute
> code
> > I am facing crash when this function is called, its happen because its
> > implementation is a reference to other function:
> >
> >
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> > ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
> >
> > I cannot find *ets_get_cpu_frequency*, so how should I handle it?
> >
> > PS: I have another situation like this, when I try to call
> > *esp_rom_set_cpu_ticks_per_us* function.
> >
> > Regards.
> >
> > Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> > > Hello Tiago.
> > >
> > > Please look de draft here: https://github.com/apache/nuttx/pull/14548
> > >
> > > This branch will refer to the updated 3rd-party in my repo.
> > >
> > > You only need to enable PM in menuconfig and it will be enough to see
> > > changes.
> > >
> > > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > > tiago.medicci@gmail.com> escreveu:
> > >
> > >> Hi Felipe,
> > >>
> > >> Can you share your PR as a draft on GH to make it easier to check the
> > >> files
> > >> (and the build process)?
> > >>
> > >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> > >> moura.fmo@gmail.com> escreveu:
> > >>
> > >> > Hello Tiago,
> > >> >
> > >> > I "finished" the port, but after it my esp32c6 dev kit is resetting.
> > >> Maybe
> > >> > the issue is related my changes in
> > >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you
> give
> > >> some
> > >> > tips about how to go ahead?
> > >> >
> > >> > Below you can see nuttx report:
> > >> > Build:Sep 19 2022
> > >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > >> > Saved PC:0x40018bea
> > >> > SPIWP:0xee
> > >> > mode:DIO, clock div:2
> > >> > load:0x40800000,len:0x61e0
> > >> > load:0x408061e0,len:0xc34
> > >> > load:0x50000000,len:0x20
> > >> > load:0x5000001e,len:0x24
> > >> > Invalid image block, can't boot.
> > >> > ets_main.c 331
> > >> > ESP-ROM:esp32c6-20220919
> > >> >
> > >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> > >> > moura.fmo@gmail.com> escreveu:
> > >> >
> > >> > > Hello everyone,
> > >> > >
> > >> > > I was able to solve linker issues, editing the linker by myself. I
> > >> need
> > >> > to
> > >> > > finish more than one build issue before testing it, so I will see
> > if I
> > >> > made
> > >> > > the right changes in linker.
> > >> > >
> > >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> > >> > > moura.fmo@gmail.com> escreveu:
> > >> > >
> > >> > >> *Hello everyone, Tiago,*
> > >> > >>
> > >> > >> I have made progress with the build issue I was encountering and
> am
> > >> now
> > >> > >> "stuck" at what I believe is one of the final stages. I am
> > >> experiencing
> > >> > the
> > >> > >> following compilation error:
> > >> > >> LD: nuttx
> > >> > >> riscv-none-elf-ld: warning:
> > >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > >> > >> has a LOAD segment with RWX permissions
> > >> > >> riscv-none-elf-ld:
> > >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > >> > >> libarch.a(sleep_modes.o): in function
> > >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > >> > >> `_rtc_force_fast_end'
> > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined
> > >> reference
> > >> > >> to `_rtc_text_start'
> > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined
> > >> reference
> > >> > >> to `_rtc_force_fast_end'
> > >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined
> > >> reference
> > >> > >> to `_rtc_text_start'
> > >> > >> riscv-none-elf-ld:
> > >> > >>
> > >> >
> > >>
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > >> > >> in function `esp_sleep_cpu_retention':
> > >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > >> > >> `rv_core_critical_regs_save'
> > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined
> > reference
> > >> to
> > >> > >> `rv_core_critical_regs_restore'
> > >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined
> > reference
> > >> to
> > >> > >> `rv_core_critical_regs_restore'
> > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > >> > >>
> > >> > >> I would greatly appreciate your assistance.
> > >> > >>
> > >> > >> Focusing on the item _rtc_text_start, I see that it is defined in
> > the
> > >> > >> file:
> > >> > >>
> > >>
> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > >> > >> sections.ld.in
> > >> > >>
> > >> > >> However, I am unsure how to add this file to the complete linking
> > >> > >> process. I added this file to hal_esp32c6.mk, but I received the
> > >> > >> following error:
> > >> > >> LD: nuttx
> > >> > >>
> > >> >
> > >>
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > >> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > >> > >> sections.ld.in.tmp:113 cannot move location counter backwards
> (from
> > >> > >> 40809800 to 40800000)
> > >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > >> > >>
> > >> > >>
> > >> > >> Does anyone have any tips or suggestions that could help me move
> > >> forward
> > >> > >> with this process?
> > >> > >>
> > >> > >> Thank you in advance for your help.
> > >> > >>
> > >> > >> *Best regards,*
> > >> > >>
> > >> > >>
> > >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> > >> > >> tiago.medicci@gmail.com> escreveu:
> > >> > >>
> > >> > >>> Hi Felipe,
> > >> > >>>
> > >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a
> substitute
> > >> for
> > >> > >>> this
> > >> > >>> function should be part
> > >> > >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That
> > >> being
> > >> > >>> said, you can either implement it (and define it as a macro, on
> > >> HAL) or
> > >> > >>> you
> > >> > >>> can either ignore these functions related to GPIO wakeup from
> > sleep
> > >> for
> > >> > >>> now
> > >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to you:
> if
> > >> the
> > >> > >>> GPIO
> > >> > >>> wakeup isn't mandatory, it'd go baby steps, removing this
> feature
> > >> for
> > >> > >>> now.
> > >> > >>>
> > >> > >>> Best regards,
> > >> > >>>
> > >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
> > >> > >>> moura.fmo@gmail.com> escreveu:
> > >> > >>>
> > >> > >>> > Hello Tiago,
> > >> > >>> >
> > >> > >>> > Thank you for your assistance earlier.
> > >> > >>> >
> > >> > >>> > I would like to discuss further the necessity of the
> > >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only available
> > in
> > >> the
> > >> > >>> IDF.
> > >> > >>> >
> > >> > >>> > In sleep_modes.c, there is the following code snippet:
> > >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> > >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > >> > >>> > {
> > >> > >>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > >> > >>> > return ESP_ERR_INVALID_ARG;
> > >> > >>> > }
> > >> > >>> > // Translate bit map of GPIO numbers into the bit map of RTC
> IO
> > >> > numbers
> > >> > >>> > uint32_t rtc_gpio_mask = 0;
> > >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > >> > >>> > if ((io_mask & 1) == 0) {
> > >> > >>> > continue;
> > >> > >>> > }
> > >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > >> > >>> > return ESP_ERR_INVALID_ARG;
> > >> > >>> > }
> > >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > >> > >>> > }
> > >> > >>> >
> > >> > >>> > I believe this code is essential for compilation. The function
> > >> > >>> > rtc_io_number_get is located at the following path in the IDF:
> > >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > >> > >>> >
> > >> > >>> > However, the esp_driver_gpio folder is not present in the
> > >> 3rd-party
> > >> > >>> > directory. In this case, what is the recommended procedure to
> > >> > proceed?
> > >> > >>> >
> > >> > >>> > Thank you again for your support.
> > >> > >>> >
> > >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
> > >> > >>> > tiago.medicci@gmail.com> escreveu:
> > >> > >>> >
> > >> > >>> > > Hi Felipe,
> > >> > >>> > >
> > >> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of
> > >> ESP-IDF,
> > >> > >>> which
> > >> > >>> > is
> > >> > >>> > > a driver directly. Same for
> `esp_driver_gpio/include/rtc_io.h`
> > >> > >>> (here, a
> > >> > >>> > > detail: I wasn't able to find this path on IDF, so make sure
> > you
> > >> > are
> > >> > >>> > > checking under the `release/v5.1` branch, which the HAL was
> > >> based).
> > >> > >>> The
> > >> > >>> > HAL
> > >> > >>> > > repository doesn't contain ESP-IDF drivers, which are always
> > >> > >>> implemented
> > >> > >>> > on
> > >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > >> > >>> > >
> > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > >> > >>> > >
> > >> > >>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
> > >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to implement the
> > >> > driver.
> > >> > >>> This
> > >> > >>> > > is, mostly, a wrapping layer under the function of `esp_rom`
> > and
> > >> > >>> `hal`
> > >> > >>> > > components. However, they still may refer to ESP-IDF
> drivers.
> > >> That
> > >> > >>> being
> > >> > >>> > > said, you can check if removing such dependencies is
> possible.
> > >> We
> > >> > >>> usually
> > >> > >>> > > do that with conditional macros. A good starting point is to
> > >> check
> > >> > >>> for
> > >> > >>> > > `#ifdef __NuttX__` on these sources and headers: we use them
> > to
> > >> > >>> > remove/add
> > >> > >>> > > headers and functions that aren't available on NuttX/needed
> by
> > >> > NuttX.
> > >> > >>> > >
> > >> > >>> > > Best regards,
> > >> > >>> > >
> > >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira
> <
> > >> > >>> > > moura.fmo@gmail.com> escreveu:
> > >> > >>> > >
> > >> > >>> > > > Hello all,
> > >> > >>> > > >
> > >> > >>> > > > Tiago,
> > >> > >>> > > >
> > >> > >>> > > > I have a question regarding the porting process.
> > >> Specifically, I
> > >> > >>> need
> > >> > >>> > to
> > >> > >>> > > > add the sleep_modes.c file to the compilation process. Am
> I
> > on
> > >> > the
> > >> > >>> > right
> > >> > >>> > > > path with this approach?
> > >> > >>> > > >
> > >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file by
> > adding
> > >> > >>> > > > sleep_modes.c.
> > >> > >>> > > > However, I am facing some issues: within sleep_modes.c,
> some
> > >> > >>> #include
> > >> > >>> > > > statements reference files that are not available in the
> > >> > 3rd-party
> > >> > >>> > > > directory but are only present in the IDF. For example:
> > >> > >>> > > >
> > >> > >>> > > > - esp_private/pm_impl.h
> > >> > >>> > > > - esp_cpu.h
> > >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > >> > >>> > > >
> > >> > >>> > > > I need those includes because sleep_modes.c uses function
> > from
> > >> > >>> there.
> > >> > >>> > > >
> > >> > >>> > > > Could you please advise if it's possible to incorporate
> > these
> > >> IDF
> > >> > >>> > folders
> > >> > >>> > > > into the 3rd-party directory, or if that approach is not
> > >> > >>> recommended?
> > >> > >>> > > >
> > >> > >>> > > > Thank you for your assistance.
> > >> > >>> > > >
> > >> > >>> > > > Best regards,
> > >> > >>> > > >
> > >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci
> Serrano
> > <
> > >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > >> > >>> > > >
> > >> > >>> > > > > Hi,
> > >> > >>> > > > >
> > >> > >>> > > > > Just another note to guide your development: we don't
> > >> develop
> > >> > >>> > anything
> > >> > >>> > > on
> > >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from it is
> > >> derived
> > >> > >>> from
> > >> > >>> > the
> > >> > >>> > > > > path
> > >> > >>> > > > >
> > >> > >>> > > > >
> > >> > >>> > > >
> > >> > >>> > >
> > >> > >>> >
> > >> > >>>
> > >> >
> > >>
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > >> > >>> > > > > (essentially, header files from
> > >> > >>> `components/hal/<chip>/include/hal`,
> > >> > >>> > > > except
> > >> > >>> > > > > for some of the sources files that use the hal functions
> > at
> > >> > >>> > > > > `components/hal` to implement some function we may use).
> > You
> > >> > can
> > >> > >>> > take a
> > >> > >>> > > > > look at the branch `
> > >> > >>> > > > >
> > >> > >>> >
> > >> >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > >> > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > >> > >>> <
> > >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >> > >>> > <
> > >> >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >> > >>> > > <
> > >> > >>>
> > >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >> > >>> > > > <
> > >> > >>>
> > >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >> > >>> > > > > <
> > >> > >>> >
> > >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >> > >
> > >> > >>> > > > and
> > >> > >>> > > > > especially the commits beginning
> > >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check
> the
> > >> kind
> > >> > >>> of
> > >> > >>> > > > changes
> > >> > >>> > > > > we do in hal. Essentially, we create a wrapper layer to
> > >> make it
> > >> > >>> > > > independent
> > >> > >>> > > > > of the host OS.
> > >> > >>> > > > >
> > >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > >> > >>> > > > >
> > >> > >>> > > > > That being said, you can either 1) try to adapt the
> > >> > >>> implementation of
> > >> > >>> > > > other
> > >> > >>> > > > > devices to use the HAL functions or 2) get some
> > inspiration
> > >> on
> > >> > >>> how
> > >> > >>> > IDF
> > >> > >>> > > > > implements PM. I'd stick with the 2nd option before
> simply
> > >> > >>> trying to
> > >> > >>> > > > adapt
> > >> > >>> > > > > an existing implementation (from ESP32-C3 legacy or from
> > >> > >>> > > ESP32/ESP32-S3).
> > >> > >>> > > > >
> > >> > >>> > > > > Best regards,
> > >> > >>> > > > >
> > >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura
> > Oliveira
> > >> <
> > >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > >> > >>> > > > >
> > >> > >>> > > > > > Hello Tiago.
> > >> > >>> > > > > >
> > >> > >>> > > > > > Thank you for clarification, I will follow your
> > >> instructions.
> > >> > >>> > > > > >
> > >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci
> > >> Serrano <
> > >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > >> > >>> > > > > >
> > >> > >>> > > > > > > Hi Felipe,
> > >> > >>> > > > > > >
> > >> > >>> > > > > > > Just complementing: use your forked version of the
> HAL
> > >> > >>> during the
> > >> > >>> > > > > > > development. As soon as you have a working version,
> > you
> > >> can
> > >> > >>> > submit
> > >> > >>> > > on
> > >> > >>> > > > > the
> > >> > >>> > > > > > > official repository.
> > >> > >>> > > > > > >
> > >> > >>> > > > > > > Best regards,
> > >> > >>> > > > > > >
> > >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci
> > >> > Serrano <
> > >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > >> > >>> > > > > > >
> > >> > >>> > > > > > > > Hi Felipe,
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > Thanks for asking! You should follow the path
> using
> > >> the
> > >> > >>> > functions
> > >> > >>> > > > on
> > >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the repository and
> > use
> > >> > >>> > > > > > > >
> > >> > >>> > >
> > >> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > >> > >>> > > > > > env
> > >> > >>> > > > > > > > vars (globally or before the make command) to use
> > your
> > >> > >>> version
> > >> > >>> > of
> > >> > >>> > > > the
> > >> > >>> > > > > > > HAL.
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > I just wanted to share some thoughts: using the
> HAL
> > >> > >>> enables us
> > >> > >>> > to
> > >> > >>> > > > > make
> > >> > >>> > > > > > > the
> > >> > >>> > > > > > > > feature available for all the Espressif devices
> > >> (please
> > >> > >>> don't
> > >> > >>> > > > bother
> > >> > >>> > > > > > with
> > >> > >>> > > > > > > > that now, as soon as you submit it, we can test
> for
> > >> the
> > >> > >>> other
> > >> > >>> > > > devices
> > >> > >>> > > > > > and
> > >> > >>> > > > > > > > eventually make any adjustments). Although it's
> > >> possible
> > >> > to
> > >> > >>> > > > > reimplement
> > >> > >>> > > > > > > > these functions on NuttX, we don't recommend that
> > >> because
> > >> > >>> of
> > >> > >>> > the
> > >> > >>> > > > > first
> > >> > >>> > > > > > > > statement (the ability to use for the other
> > devices):
> > >> in
> > >> > >>> that
> > >> > >>> > > case
> > >> > >>> > > > we
> > >> > >>> > > > > > > > wouldn't be able to support the feature. You can
> > take
> > >> a
> > >> > >>> look on
> > >> > >>> > > IDF
> > >> > >>> > > > > for
> > >> > >>> > > > > > > > some inspiration on how it's implemented.
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > Please let me know if you have any questions.
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > Best regards,
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura
> > >> > >>> Oliveira <
> > >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > >> Hello everyone,
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >> Our project has reached a point where we need the
> > >> Power
> > >> > >>> > Manager
> > >> > >>> > > > > > > >> functionality, which is not yet available in the
> > >> > ESP32C6.
> > >> > >>> I am
> > >> > >>> > > > > > studying
> > >> > >>> > > > > > > to
> > >> > >>> > > > > > > >> start the implementation, but I am confused about
> > the
> > >> > >>> correct
> > >> > >>> > > way
> > >> > >>> > > > to
> > >> > >>> > > > > > > >> approach this.
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >> There is a Power Manager implementation for the
> > >> ESP32C3,
> > >> > >>> but
> > >> > >>> > it
> > >> > >>> > > > > seems
> > >> > >>> > > > > > to
> > >> > >>> > > > > > > >> follow the legacy methodology. In fact, the file
> > >> > >>> > esp32c3_idle.c
> > >> > >>> > > is
> > >> > >>> > > > > > > located
> > >> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In
> this
> > >> > >>> > methodology,
> > >> > >>> > > > > > > functions
> > >> > >>> > > > > > > >> are re-implemented from the Espressif driver. For
> > >> > >>> example, the
> > >> > >>> > > > > > function
> > >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is currently
> > >> > available
> > >> > >>> in
> > >> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >> I tried using the implementations from
> > >> esp-hal-3rdparty
> > >> > to
> > >> > >>> > > develop
> > >> > >>> > > > > the
> > >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the
> > files
> > >> > >>> still
> > >> > >>> > have
> > >> > >>> > > > > many
> > >> > >>> > > > > > > >> dependencies on items that are not present in
> > NuttX.
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >> My question is: Should I try to make the Power
> > >> Manager
> > >> > >>> work
> > >> > >>> > > using
> > >> > >>> > > > > the
> > >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it
> requires
> > >> > making
> > >> > >>> > > changes
> > >> > >>> > > > to
> > >> > >>> > > > > > the
> > >> > >>> > > > > > > >> 3rd-party code? Or should I re-implement the
> > >> functions
> > >> > >>> within
> > >> > >>> > > > NuttX,
> > >> > >>> > > > > > > even
> > >> > >>> > > > > > > >> if, in this case, there are functions with the
> same
> > >> > scope
> > >> > >>> and
> > >> > >>> > > > > > > >> implementation in different files, where one is
> > >> > compiled,
> > >> > >>> and
> > >> > >>> > > the
> > >> > >>> > > > > > other
> > >> > >>> > > > > > > is
> > >> > >>> > > > > > > >> not?
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >> --
> > >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > >> > >>> > > > > > > >> Linkedin <
> > >> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> > >>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> > >>> > > > > > > >>
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > --
> > >> > >>> > > > > > > > Tiago Medicci Serrano
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > > > Embedded Software Engineer
> > >> > >>> > > > > > > > MSc Electronics/Microelectronics
> > >> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > >> > >>> > > > > > > > a: Campinas, Brazil
> > >> > >>> > > > > > > > Follow me:
> > >> > >>> > > > > > > > <
> https://www.linkedin.com/in/tiago-serrano-924458b6
> > >
> > >> > >>> > > > > > > > <https://github.com/tmedicci>
> > >> > >>> > > > > > > >
> > >> > >>> > > > > > >
> > >> > >>> > > > > > >
> > >> > >>> > > > > > > --
> > >> > >>> > > > > > > Tiago Medicci Serrano
> > >> > >>> > > > > > >
> > >> > >>> > > > > > > Embedded Software Engineer
> > >> > >>> > > > > > > MSc Electronics/Microelectronics
> > >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >> > >>> > > > > > > e: tiago.medicci@gmail.com
> > >> > >>> > > > > > > a: Campinas, Brazil
> > >> > >>> > > > > > > Follow me:
> > >> > >>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6
> >
> > >> > >>> > > > > > > <https://github.com/tmedicci>
> > >> > >>> > > > > > >
> > >> > >>> > > > > >
> > >> > >>> > > > > >
> > >> > >>> > > > > > --
> > >> > >>> > > > > > *Felipe Moura de Oliveira*
> > >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > >> > >>> > > > > > Linkedin <
> > >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >> > >>> >
> > >> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> > >>> > > > > >
> > >> > >>> > > > >
> > >> > >>> > > > >
> > >> > >>> > > > > --
> > >> > >>> > > > > Tiago Medicci Serrano
> > >> > >>> > > > >
> > >> > >>> > > > > Embedded Software Engineer
> > >> > >>> > > > > MSc Electronics/Microelectronics
> > >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >> > >>> > > > > e: tiago.medicci@gmail.com
> > >> > >>> > > > > a: Campinas, Brazil
> > >> > >>> > > > > Follow me:
> > >> > >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > >> > >>> > > > > <https://github.com/tmedicci>
> > >> > >>> > > > >
> > >> > >>> > > >
> > >> > >>> > > >
> > >> > >>> > > > --
> > >> > >>> > > > *Felipe Moura de Oliveira*
> > >> > >>> > > > *Universidade Federal de Minas Gerais*
> > >> > >>> > > > Linkedin <
> > >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> > >>> > > >
> > >> > >>> > >
> > >> > >>> > >
> > >> > >>> > > --
> > >> > >>> > > Tiago Medicci Serrano
> > >> > >>> > >
> > >> > >>> > > Embedded Software Engineer
> > >> > >>> > > MSc Electronics/Microelectronics
> > >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >> > >>> > > e: tiago.medicci@gmail.com
> > >> > >>> > > a: Campinas, Brazil
> > >> > >>> > > Follow me:
> > >> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > >> > >>> > > <https://github.com/tmedicci>
> > >> > >>> > >
> > >> > >>> >
> > >> > >>> >
> > >> > >>> > --
> > >> > >>> > *Felipe Moura de Oliveira*
> > >> > >>> > *Universidade Federal de Minas Gerais*
> > >> > >>> > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> > >>> >
> > >> > >>>
> > >> > >>
> > >> > >>
> > >> > >> --
> > >> > >> *Felipe Moura de Oliveira*
> > >> > >> *Universidade Federal de Minas Gerais*
> > >> > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> > >>
> > >> > >
> > >> > >
> > >> > > --
> > >> > > *Felipe Moura de Oliveira*
> > >> > > *Universidade Federal de Minas Gerais*
> > >> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> > >
> > >> >
> > >> >
> > >> > --
> > >> > *Felipe Moura de Oliveira*
> > >> > *Universidade Federal de Minas Gerais*
> > >> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >> >
> > >>
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi Felipe, good to hear about your progress here!
These functions are ROM-defined functions. By checking the TRM, you can see
a read-only flash partition that holds some functions (widely used
functions, like malloc and internal functions).
ets_get_cpu_frequency
<https://github.com/espressif/esp-hal-3rdparty/blob/1a1545b6ffb54029259ba8691d9ee200bfda2471/components/esp_rom/esp32c6/ld/esp32c6.rom.ld#L32>
is
one of these internal functions. They are defined directly at the linker
script.
If I understood correctly, these functions are crashing when it's being
called, right? If so, can you:
1. Share the crash dump
2. Use GDB and try to check where/why it fails: it may trying to access
some prohibited memory region or even trying to call an unregistered
callback.
Thanks!
Em sex., 1 de nov. de 2024 às 13:41, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello everyone,
>
> Tiago, I am trying to work with light sleep for now, after it work will go
> ahead with deep sleep. To run in light sleep I don't need to change linker
> so I was able to build and flash without "image" issues.
> Now I am facing other kind of issue:
> Some functions refers to "ets" function and I don't know how handle this,
> for instance:
>
> /**
> * @brief Get the real CPU ticks per us
> *
> * @return CPU ticks per us
> */
> uint32_t esp_rom_get_cpu_ticks_per_us(void);
>
> This function is necessary in the *sleep_modes.c* file. During execute code
> I am facing crash when this function is called, its happen because its
> implementation is a reference to other function:
>
> arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
> ( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
>
> I cannot find *ets_get_cpu_frequency*, so how should I handle it?
>
> PS: I have another situation like this, when I try to call
> *esp_rom_set_cpu_ticks_per_us* function.
>
> Regards.
>
> Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello Tiago.
> >
> > Please look de draft here: https://github.com/apache/nuttx/pull/14548
> >
> > This branch will refer to the updated 3rd-party in my repo.
> >
> > You only need to enable PM in menuconfig and it will be enough to see
> > changes.
> >
> > Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> > tiago.medicci@gmail.com> escreveu:
> >
> >> Hi Felipe,
> >>
> >> Can you share your PR as a draft on GH to make it easier to check the
> >> files
> >> (and the build process)?
> >>
> >> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> >> moura.fmo@gmail.com> escreveu:
> >>
> >> > Hello Tiago,
> >> >
> >> > I "finished" the port, but after it my esp32c6 dev kit is resetting.
> >> Maybe
> >> > the issue is related my changes in
> >> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you give
> >> some
> >> > tips about how to go ahead?
> >> >
> >> > Below you can see nuttx report:
> >> > Build:Sep 19 2022
> >> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> >> > Saved PC:0x40018bea
> >> > SPIWP:0xee
> >> > mode:DIO, clock div:2
> >> > load:0x40800000,len:0x61e0
> >> > load:0x408061e0,len:0xc34
> >> > load:0x50000000,len:0x20
> >> > load:0x5000001e,len:0x24
> >> > Invalid image block, can't boot.
> >> > ets_main.c 331
> >> > ESP-ROM:esp32c6-20220919
> >> >
> >> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> >> > moura.fmo@gmail.com> escreveu:
> >> >
> >> > > Hello everyone,
> >> > >
> >> > > I was able to solve linker issues, editing the linker by myself. I
> >> need
> >> > to
> >> > > finish more than one build issue before testing it, so I will see
> if I
> >> > made
> >> > > the right changes in linker.
> >> > >
> >> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> >> > > moura.fmo@gmail.com> escreveu:
> >> > >
> >> > >> *Hello everyone, Tiago,*
> >> > >>
> >> > >> I have made progress with the build issue I was encountering and am
> >> now
> >> > >> "stuck" at what I believe is one of the final stages. I am
> >> experiencing
> >> > the
> >> > >> following compilation error:
> >> > >> LD: nuttx
> >> > >> riscv-none-elf-ld: warning:
> >> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> >> > >> has a LOAD segment with RWX permissions
> >> > >> riscv-none-elf-ld:
> >> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> >> > >> libarch.a(sleep_modes.o): in function
> >> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> >> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> >> > >> `_rtc_force_fast_end'
> >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined
> >> reference
> >> > >> to `_rtc_text_start'
> >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined
> >> reference
> >> > >> to `_rtc_force_fast_end'
> >> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined
> >> reference
> >> > >> to `_rtc_text_start'
> >> > >> riscv-none-elf-ld:
> >> > >>
> >> >
> >>
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> >> > >> in function `esp_sleep_cpu_retention':
> >> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> >> > >> `rv_core_critical_regs_save'
> >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined
> reference
> >> to
> >> > >> `rv_core_critical_regs_restore'
> >> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined
> reference
> >> to
> >> > >> `rv_core_critical_regs_restore'
> >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> >> > >>
> >> > >> I would greatly appreciate your assistance.
> >> > >>
> >> > >> Focusing on the item _rtc_text_start, I see that it is defined in
> the
> >> > >> file:
> >> > >>
> >> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> >> > >> sections.ld.in
> >> > >>
> >> > >> However, I am unsure how to add this file to the complete linking
> >> > >> process. I added this file to hal_esp32c6.mk, but I received the
> >> > >> following error:
> >> > >> LD: nuttx
> >> > >>
> >> >
> >>
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> >> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> >> > >> sections.ld.in.tmp:113 cannot move location counter backwards (from
> >> > >> 40809800 to 40800000)
> >> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> >> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> >> > >>
> >> > >>
> >> > >> Does anyone have any tips or suggestions that could help me move
> >> forward
> >> > >> with this process?
> >> > >>
> >> > >> Thank you in advance for your help.
> >> > >>
> >> > >> *Best regards,*
> >> > >>
> >> > >>
> >> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> >> > >> tiago.medicci@gmail.com> escreveu:
> >> > >>
> >> > >>> Hi Felipe,
> >> > >>>
> >> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute
> >> for
> >> > >>> this
> >> > >>> function should be part
> >> > >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That
> >> being
> >> > >>> said, you can either implement it (and define it as a macro, on
> >> HAL) or
> >> > >>> you
> >> > >>> can either ignore these functions related to GPIO wakeup from
> sleep
> >> for
> >> > >>> now
> >> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if
> >> the
> >> > >>> GPIO
> >> > >>> wakeup isn't mandatory, it'd go baby steps, removing this feature
> >> for
> >> > >>> now.
> >> > >>>
> >> > >>> Best regards,
> >> > >>>
> >> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
> >> > >>> moura.fmo@gmail.com> escreveu:
> >> > >>>
> >> > >>> > Hello Tiago,
> >> > >>> >
> >> > >>> > Thank you for your assistance earlier.
> >> > >>> >
> >> > >>> > I would like to discuss further the necessity of the
> >> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only available
> in
> >> the
> >> > >>> IDF.
> >> > >>> >
> >> > >>> > In sleep_modes.c, there is the following code snippet:
> >> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> >> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> >> > >>> > {
> >> > >>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> >> > >>> > return ESP_ERR_INVALID_ARG;
> >> > >>> > }
> >> > >>> > // Translate bit map of GPIO numbers into the bit map of RTC IO
> >> > numbers
> >> > >>> > uint32_t rtc_gpio_mask = 0;
> >> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> >> > >>> > if ((io_mask & 1) == 0) {
> >> > >>> > continue;
> >> > >>> > }
> >> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> >> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> >> > >>> > return ESP_ERR_INVALID_ARG;
> >> > >>> > }
> >> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> >> > >>> > }
> >> > >>> >
> >> > >>> > I believe this code is essential for compilation. The function
> >> > >>> > rtc_io_number_get is located at the following path in the IDF:
> >> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> >> > >>> >
> >> > >>> > However, the esp_driver_gpio folder is not present in the
> >> 3rd-party
> >> > >>> > directory. In this case, what is the recommended procedure to
> >> > proceed?
> >> > >>> >
> >> > >>> > Thank you again for your support.
> >> > >>> >
> >> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
> >> > >>> > tiago.medicci@gmail.com> escreveu:
> >> > >>> >
> >> > >>> > > Hi Felipe,
> >> > >>> > >
> >> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of
> >> ESP-IDF,
> >> > >>> which
> >> > >>> > is
> >> > >>> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h`
> >> > >>> (here, a
> >> > >>> > > detail: I wasn't able to find this path on IDF, so make sure
> you
> >> > are
> >> > >>> > > checking under the `release/v5.1` branch, which the HAL was
> >> based).
> >> > >>> The
> >> > >>> > HAL
> >> > >>> > > repository doesn't contain ESP-IDF drivers, which are always
> >> > >>> implemented
> >> > >>> > on
> >> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> >> > >>> > >
> `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> >> > >>> > >
> >> > >>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
> >> > >>> > > (`sleep_modes.c`, for instance) MAY be used to implement the
> >> > driver.
> >> > >>> This
> >> > >>> > > is, mostly, a wrapping layer under the function of `esp_rom`
> and
> >> > >>> `hal`
> >> > >>> > > components. However, they still may refer to ESP-IDF drivers.
> >> That
> >> > >>> being
> >> > >>> > > said, you can check if removing such dependencies is possible.
> >> We
> >> > >>> usually
> >> > >>> > > do that with conditional macros. A good starting point is to
> >> check
> >> > >>> for
> >> > >>> > > `#ifdef __NuttX__` on these sources and headers: we use them
> to
> >> > >>> > remove/add
> >> > >>> > > headers and functions that aren't available on NuttX/needed by
> >> > NuttX.
> >> > >>> > >
> >> > >>> > > Best regards,
> >> > >>> > >
> >> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
> >> > >>> > > moura.fmo@gmail.com> escreveu:
> >> > >>> > >
> >> > >>> > > > Hello all,
> >> > >>> > > >
> >> > >>> > > > Tiago,
> >> > >>> > > >
> >> > >>> > > > I have a question regarding the porting process.
> >> Specifically, I
> >> > >>> need
> >> > >>> > to
> >> > >>> > > > add the sleep_modes.c file to the compilation process. Am I
> on
> >> > the
> >> > >>> > right
> >> > >>> > > > path with this approach?
> >> > >>> > > >
> >> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file by
> adding
> >> > >>> > > > sleep_modes.c.
> >> > >>> > > > However, I am facing some issues: within sleep_modes.c, some
> >> > >>> #include
> >> > >>> > > > statements reference files that are not available in the
> >> > 3rd-party
> >> > >>> > > > directory but are only present in the IDF. For example:
> >> > >>> > > >
> >> > >>> > > > - esp_private/pm_impl.h
> >> > >>> > > > - esp_cpu.h
> >> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> >> > >>> > > >
> >> > >>> > > > I need those includes because sleep_modes.c uses function
> from
> >> > >>> there.
> >> > >>> > > >
> >> > >>> > > > Could you please advise if it's possible to incorporate
> these
> >> IDF
> >> > >>> > folders
> >> > >>> > > > into the 3rd-party directory, or if that approach is not
> >> > >>> recommended?
> >> > >>> > > >
> >> > >>> > > > Thank you for your assistance.
> >> > >>> > > >
> >> > >>> > > > Best regards,
> >> > >>> > > >
> >> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano
> <
> >> > >>> > > > tiago.medicci@gmail.com> escreveu:
> >> > >>> > > >
> >> > >>> > > > > Hi,
> >> > >>> > > > >
> >> > >>> > > > > Just another note to guide your development: we don't
> >> develop
> >> > >>> > anything
> >> > >>> > > on
> >> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from it is
> >> derived
> >> > >>> from
> >> > >>> > the
> >> > >>> > > > > path
> >> > >>> > > > >
> >> > >>> > > > >
> >> > >>> > > >
> >> > >>> > >
> >> > >>> >
> >> > >>>
> >> >
> >>
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> >> > >>> > > > > (essentially, header files from
> >> > >>> `components/hal/<chip>/include/hal`,
> >> > >>> > > > except
> >> > >>> > > > > for some of the sources files that use the hal functions
> at
> >> > >>> > > > > `components/hal` to implement some function we may use).
> You
> >> > can
> >> > >>> > take a
> >> > >>> > > > > look at the branch `
> >> > >>> > > > >
> >> > >>> >
> >> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> >> > >>> <
> >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >> > >>> > <
> >> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >> > >>> > > <
> >> > >>>
> >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >> > >>> > > > <
> >> > >>>
> >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >> > >>> > > > > <
> >> > >>> >
> >> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >> > >
> >> > >>> > > > and
> >> > >>> > > > > especially the commits beginning
> >> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the
> >> kind
> >> > >>> of
> >> > >>> > > > changes
> >> > >>> > > > > we do in hal. Essentially, we create a wrapper layer to
> >> make it
> >> > >>> > > > independent
> >> > >>> > > > > of the host OS.
> >> > >>> > > > >
> >> > >>> > > > > *Drivers must always be implemented on NuttX!*
> >> > >>> > > > >
> >> > >>> > > > > That being said, you can either 1) try to adapt the
> >> > >>> implementation of
> >> > >>> > > > other
> >> > >>> > > > > devices to use the HAL functions or 2) get some
> inspiration
> >> on
> >> > >>> how
> >> > >>> > IDF
> >> > >>> > > > > implements PM. I'd stick with the 2nd option before simply
> >> > >>> trying to
> >> > >>> > > > adapt
> >> > >>> > > > > an existing implementation (from ESP32-C3 legacy or from
> >> > >>> > > ESP32/ESP32-S3).
> >> > >>> > > > >
> >> > >>> > > > > Best regards,
> >> > >>> > > > >
> >> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura
> Oliveira
> >> <
> >> > >>> > > > > moura.fmo@gmail.com> escreveu:
> >> > >>> > > > >
> >> > >>> > > > > > Hello Tiago.
> >> > >>> > > > > >
> >> > >>> > > > > > Thank you for clarification, I will follow your
> >> instructions.
> >> > >>> > > > > >
> >> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci
> >> Serrano <
> >> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> >> > >>> > > > > >
> >> > >>> > > > > > > Hi Felipe,
> >> > >>> > > > > > >
> >> > >>> > > > > > > Just complementing: use your forked version of the HAL
> >> > >>> during the
> >> > >>> > > > > > > development. As soon as you have a working version,
> you
> >> can
> >> > >>> > submit
> >> > >>> > > on
> >> > >>> > > > > the
> >> > >>> > > > > > > official repository.
> >> > >>> > > > > > >
> >> > >>> > > > > > > Best regards,
> >> > >>> > > > > > >
> >> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci
> >> > Serrano <
> >> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> >> > >>> > > > > > >
> >> > >>> > > > > > > > Hi Felipe,
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > Thanks for asking! You should follow the path using
> >> the
> >> > >>> > functions
> >> > >>> > > > on
> >> > >>> > > > > > > > esp-hal-3rdparty. You can fork the repository and
> use
> >> > >>> > > > > > > >
> >> > >>> > >
> >> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> >> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> >> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> >> > >>> > > > > > env
> >> > >>> > > > > > > > vars (globally or before the make command) to use
> your
> >> > >>> version
> >> > >>> > of
> >> > >>> > > > the
> >> > >>> > > > > > > HAL.
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > I just wanted to share some thoughts: using the HAL
> >> > >>> enables us
> >> > >>> > to
> >> > >>> > > > > make
> >> > >>> > > > > > > the
> >> > >>> > > > > > > > feature available for all the Espressif devices
> >> (please
> >> > >>> don't
> >> > >>> > > > bother
> >> > >>> > > > > > with
> >> > >>> > > > > > > > that now, as soon as you submit it, we can test for
> >> the
> >> > >>> other
> >> > >>> > > > devices
> >> > >>> > > > > > and
> >> > >>> > > > > > > > eventually make any adjustments). Although it's
> >> possible
> >> > to
> >> > >>> > > > > reimplement
> >> > >>> > > > > > > > these functions on NuttX, we don't recommend that
> >> because
> >> > >>> of
> >> > >>> > the
> >> > >>> > > > > first
> >> > >>> > > > > > > > statement (the ability to use for the other
> devices):
> >> in
> >> > >>> that
> >> > >>> > > case
> >> > >>> > > > we
> >> > >>> > > > > > > > wouldn't be able to support the feature. You can
> take
> >> a
> >> > >>> look on
> >> > >>> > > IDF
> >> > >>> > > > > for
> >> > >>> > > > > > > > some inspiration on how it's implemented.
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > Please let me know if you have any questions.
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > Best regards,
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura
> >> > >>> Oliveira <
> >> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> >> > >>> > > > > > > >
> >> > >>> > > > > > > >> Hello everyone,
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >> Our project has reached a point where we need the
> >> Power
> >> > >>> > Manager
> >> > >>> > > > > > > >> functionality, which is not yet available in the
> >> > ESP32C6.
> >> > >>> I am
> >> > >>> > > > > > studying
> >> > >>> > > > > > > to
> >> > >>> > > > > > > >> start the implementation, but I am confused about
> the
> >> > >>> correct
> >> > >>> > > way
> >> > >>> > > > to
> >> > >>> > > > > > > >> approach this.
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >> There is a Power Manager implementation for the
> >> ESP32C3,
> >> > >>> but
> >> > >>> > it
> >> > >>> > > > > seems
> >> > >>> > > > > > to
> >> > >>> > > > > > > >> follow the legacy methodology. In fact, the file
> >> > >>> > esp32c3_idle.c
> >> > >>> > > is
> >> > >>> > > > > > > located
> >> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
> >> > >>> > methodology,
> >> > >>> > > > > > > functions
> >> > >>> > > > > > > >> are re-implemented from the Espressif driver. For
> >> > >>> example, the
> >> > >>> > > > > > function
> >> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is currently
> >> > available
> >> > >>> in
> >> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >> I tried using the implementations from
> >> esp-hal-3rdparty
> >> > to
> >> > >>> > > develop
> >> > >>> > > > > the
> >> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the
> files
> >> > >>> still
> >> > >>> > have
> >> > >>> > > > > many
> >> > >>> > > > > > > >> dependencies on items that are not present in
> NuttX.
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >> My question is: Should I try to make the Power
> >> Manager
> >> > >>> work
> >> > >>> > > using
> >> > >>> > > > > the
> >> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it requires
> >> > making
> >> > >>> > > changes
> >> > >>> > > > to
> >> > >>> > > > > > the
> >> > >>> > > > > > > >> 3rd-party code? Or should I re-implement the
> >> functions
> >> > >>> within
> >> > >>> > > > NuttX,
> >> > >>> > > > > > > even
> >> > >>> > > > > > > >> if, in this case, there are functions with the same
> >> > scope
> >> > >>> and
> >> > >>> > > > > > > >> implementation in different files, where one is
> >> > compiled,
> >> > >>> and
> >> > >>> > > the
> >> > >>> > > > > > other
> >> > >>> > > > > > > is
> >> > >>> > > > > > > >> not?
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >> --
> >> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> >> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> >> > >>> > > > > > > >> Linkedin <
> >> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> > >>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> > >>> > > > > > > >>
> >> > >>> > > > > > > >
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > --
> >> > >>> > > > > > > > Tiago Medicci Serrano
> >> > >>> > > > > > > >
> >> > >>> > > > > > > > Embedded Software Engineer
> >> > >>> > > > > > > > MSc Electronics/Microelectronics
> >> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >> > >>> > > > > > > > e: tiago.medicci@gmail.com
> >> > >>> > > > > > > > a: Campinas, Brazil
> >> > >>> > > > > > > > Follow me:
> >> > >>> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6
> >
> >> > >>> > > > > > > > <https://github.com/tmedicci>
> >> > >>> > > > > > > >
> >> > >>> > > > > > >
> >> > >>> > > > > > >
> >> > >>> > > > > > > --
> >> > >>> > > > > > > Tiago Medicci Serrano
> >> > >>> > > > > > >
> >> > >>> > > > > > > Embedded Software Engineer
> >> > >>> > > > > > > MSc Electronics/Microelectronics
> >> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >> > >>> > > > > > > e: tiago.medicci@gmail.com
> >> > >>> > > > > > > a: Campinas, Brazil
> >> > >>> > > > > > > Follow me:
> >> > >>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >> > >>> > > > > > > <https://github.com/tmedicci>
> >> > >>> > > > > > >
> >> > >>> > > > > >
> >> > >>> > > > > >
> >> > >>> > > > > > --
> >> > >>> > > > > > *Felipe Moura de Oliveira*
> >> > >>> > > > > > *Universidade Federal de Minas Gerais*
> >> > >>> > > > > > Linkedin <
> >> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >> > >>> >
> >> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> > >>> > > > > >
> >> > >>> > > > >
> >> > >>> > > > >
> >> > >>> > > > > --
> >> > >>> > > > > Tiago Medicci Serrano
> >> > >>> > > > >
> >> > >>> > > > > Embedded Software Engineer
> >> > >>> > > > > MSc Electronics/Microelectronics
> >> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >> > >>> > > > > e: tiago.medicci@gmail.com
> >> > >>> > > > > a: Campinas, Brazil
> >> > >>> > > > > Follow me:
> >> > >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >> > >>> > > > > <https://github.com/tmedicci>
> >> > >>> > > > >
> >> > >>> > > >
> >> > >>> > > >
> >> > >>> > > > --
> >> > >>> > > > *Felipe Moura de Oliveira*
> >> > >>> > > > *Universidade Federal de Minas Gerais*
> >> > >>> > > > Linkedin <
> >> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> > >>> > > >
> >> > >>> > >
> >> > >>> > >
> >> > >>> > > --
> >> > >>> > > Tiago Medicci Serrano
> >> > >>> > >
> >> > >>> > > Embedded Software Engineer
> >> > >>> > > MSc Electronics/Microelectronics
> >> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >> > >>> > > e: tiago.medicci@gmail.com
> >> > >>> > > a: Campinas, Brazil
> >> > >>> > > Follow me:
> >> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >> > >>> > > <https://github.com/tmedicci>
> >> > >>> > >
> >> > >>> >
> >> > >>> >
> >> > >>> > --
> >> > >>> > *Felipe Moura de Oliveira*
> >> > >>> > *Universidade Federal de Minas Gerais*
> >> > >>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> > >>> >
> >> > >>>
> >> > >>
> >> > >>
> >> > >> --
> >> > >> *Felipe Moura de Oliveira*
> >> > >> *Universidade Federal de Minas Gerais*
> >> > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> > >>
> >> > >
> >> > >
> >> > > --
> >> > > *Felipe Moura de Oliveira*
> >> > > *Universidade Federal de Minas Gerais*
> >> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> > >
> >> >
> >> >
> >> > --
> >> > *Felipe Moura de Oliveira*
> >> > *Universidade Federal de Minas Gerais*
> >> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >> >
> >>
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello everyone,
Tiago, I am trying to work with light sleep for now, after it work will go
ahead with deep sleep. To run in light sleep I don't need to change linker
so I was able to build and flash without "image" issues.
Now I am facing other kind of issue:
Some functions refers to "ets" function and I don't know how handle this,
for instance:
/**
* @brief Get the real CPU ticks per us
*
* @return CPU ticks per us
*/
uint32_t esp_rom_get_cpu_ticks_per_us(void);
This function is necessary in the *sleep_modes.c* file. During execute code
I am facing crash when this function is called, its happen because its
implementation is a reference to other function:
arch/risc-v/src/esp32c6/esp-hal-3rdparty/components/esp_rom/esp32c6/ld/esp32c6.rom.api.ld:46:PROVIDE
( *esp_rom_get_cpu_ticks_per_us* = ets_get_cpu_frequency );
I cannot find *ets_get_cpu_frequency*, so how should I handle it?
PS: I have another situation like this, when I try to call
*esp_rom_set_cpu_ticks_per_us* function.
Regards.
Em ter., 29 de out. de 2024 às 13:24, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello Tiago.
>
> Please look de draft here: https://github.com/apache/nuttx/pull/14548
>
> This branch will refer to the updated 3rd-party in my repo.
>
> You only need to enable PM in menuconfig and it will be enough to see
> changes.
>
> Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
>> Hi Felipe,
>>
>> Can you share your PR as a draft on GH to make it easier to check the
>> files
>> (and the build process)?
>>
>> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
>> moura.fmo@gmail.com> escreveu:
>>
>> > Hello Tiago,
>> >
>> > I "finished" the port, but after it my esp32c6 dev kit is resetting.
>> Maybe
>> > the issue is related my changes in
>> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you give
>> some
>> > tips about how to go ahead?
>> >
>> > Below you can see nuttx report:
>> > Build:Sep 19 2022
>> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
>> > Saved PC:0x40018bea
>> > SPIWP:0xee
>> > mode:DIO, clock div:2
>> > load:0x40800000,len:0x61e0
>> > load:0x408061e0,len:0xc34
>> > load:0x50000000,len:0x20
>> > load:0x5000001e,len:0x24
>> > Invalid image block, can't boot.
>> > ets_main.c 331
>> > ESP-ROM:esp32c6-20220919
>> >
>> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
>> > moura.fmo@gmail.com> escreveu:
>> >
>> > > Hello everyone,
>> > >
>> > > I was able to solve linker issues, editing the linker by myself. I
>> need
>> > to
>> > > finish more than one build issue before testing it, so I will see if I
>> > made
>> > > the right changes in linker.
>> > >
>> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
>> > > moura.fmo@gmail.com> escreveu:
>> > >
>> > >> *Hello everyone, Tiago,*
>> > >>
>> > >> I have made progress with the build issue I was encountering and am
>> now
>> > >> "stuck" at what I believe is one of the final stages. I am
>> experiencing
>> > the
>> > >> following compilation error:
>> > >> LD: nuttx
>> > >> riscv-none-elf-ld: warning:
>> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
>> > >> has a LOAD segment with RWX permissions
>> > >> riscv-none-elf-ld:
>> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
>> > >> libarch.a(sleep_modes.o): in function
>> > >> `esp_set_deep_sleep_wake_stub_default_entry':
>> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
>> > >> `_rtc_force_fast_end'
>> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined
>> reference
>> > >> to `_rtc_text_start'
>> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined
>> reference
>> > >> to `_rtc_force_fast_end'
>> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined
>> reference
>> > >> to `_rtc_text_start'
>> > >> riscv-none-elf-ld:
>> > >>
>> >
>> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
>> > >> in function `esp_sleep_cpu_retention':
>> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
>> > >> `rv_core_critical_regs_save'
>> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined reference
>> to
>> > >> `rv_core_critical_regs_restore'
>> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined reference
>> to
>> > >> `rv_core_critical_regs_restore'
>> > >> make[1]: *** [Makefile:189: nuttx] Error 1
>> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
>> > >>
>> > >> I would greatly appreciate your assistance.
>> > >>
>> > >> Focusing on the item _rtc_text_start, I see that it is defined in the
>> > >> file:
>> > >>
>> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
>> > >> sections.ld.in
>> > >>
>> > >> However, I am unsure how to add this file to the complete linking
>> > >> process. I added this file to hal_esp32c6.mk, but I received the
>> > >> following error:
>> > >> LD: nuttx
>> > >>
>> >
>> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
>> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
>> > >> sections.ld.in.tmp:113 cannot move location counter backwards (from
>> > >> 40809800 to 40800000)
>> > >> make[1]: *** [Makefile:189: nuttx] Error 1
>> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
>> > >>
>> > >>
>> > >> Does anyone have any tips or suggestions that could help me move
>> forward
>> > >> with this process?
>> > >>
>> > >> Thank you in advance for your help.
>> > >>
>> > >> *Best regards,*
>> > >>
>> > >>
>> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
>> > >> tiago.medicci@gmail.com> escreveu:
>> > >>
>> > >>> Hi Felipe,
>> > >>>
>> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute
>> for
>> > >>> this
>> > >>> function should be part
>> > >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That
>> being
>> > >>> said, you can either implement it (and define it as a macro, on
>> HAL) or
>> > >>> you
>> > >>> can either ignore these functions related to GPIO wakeup from sleep
>> for
>> > >>> now
>> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if
>> the
>> > >>> GPIO
>> > >>> wakeup isn't mandatory, it'd go baby steps, removing this feature
>> for
>> > >>> now.
>> > >>>
>> > >>> Best regards,
>> > >>>
>> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
>> > >>> moura.fmo@gmail.com> escreveu:
>> > >>>
>> > >>> > Hello Tiago,
>> > >>> >
>> > >>> > Thank you for your assistance earlier.
>> > >>> >
>> > >>> > I would like to discuss further the necessity of the
>> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only available in
>> the
>> > >>> IDF.
>> > >>> >
>> > >>> > In sleep_modes.c, there is the following code snippet:
>> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
>> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
>> > >>> > {
>> > >>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
>> > >>> > return ESP_ERR_INVALID_ARG;
>> > >>> > }
>> > >>> > // Translate bit map of GPIO numbers into the bit map of RTC IO
>> > numbers
>> > >>> > uint32_t rtc_gpio_mask = 0;
>> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
>> > >>> > if ((io_mask & 1) == 0) {
>> > >>> > continue;
>> > >>> > }
>> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
>> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
>> > >>> > return ESP_ERR_INVALID_ARG;
>> > >>> > }
>> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
>> > >>> > }
>> > >>> >
>> > >>> > I believe this code is essential for compilation. The function
>> > >>> > rtc_io_number_get is located at the following path in the IDF:
>> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
>> > >>> >
>> > >>> > However, the esp_driver_gpio folder is not present in the
>> 3rd-party
>> > >>> > directory. In this case, what is the recommended procedure to
>> > proceed?
>> > >>> >
>> > >>> > Thank you again for your support.
>> > >>> >
>> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
>> > >>> > tiago.medicci@gmail.com> escreveu:
>> > >>> >
>> > >>> > > Hi Felipe,
>> > >>> > >
>> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of
>> ESP-IDF,
>> > >>> which
>> > >>> > is
>> > >>> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h`
>> > >>> (here, a
>> > >>> > > detail: I wasn't able to find this path on IDF, so make sure you
>> > are
>> > >>> > > checking under the `release/v5.1` branch, which the HAL was
>> based).
>> > >>> The
>> > >>> > HAL
>> > >>> > > repository doesn't contain ESP-IDF drivers, which are always
>> > >>> implemented
>> > >>> > on
>> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
>> > >>> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
>> > >>> > >
>> > >>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
>> > >>> > > (`sleep_modes.c`, for instance) MAY be used to implement the
>> > driver.
>> > >>> This
>> > >>> > > is, mostly, a wrapping layer under the function of `esp_rom` and
>> > >>> `hal`
>> > >>> > > components. However, they still may refer to ESP-IDF drivers.
>> That
>> > >>> being
>> > >>> > > said, you can check if removing such dependencies is possible.
>> We
>> > >>> usually
>> > >>> > > do that with conditional macros. A good starting point is to
>> check
>> > >>> for
>> > >>> > > `#ifdef __NuttX__` on these sources and headers: we use them to
>> > >>> > remove/add
>> > >>> > > headers and functions that aren't available on NuttX/needed by
>> > NuttX.
>> > >>> > >
>> > >>> > > Best regards,
>> > >>> > >
>> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
>> > >>> > > moura.fmo@gmail.com> escreveu:
>> > >>> > >
>> > >>> > > > Hello all,
>> > >>> > > >
>> > >>> > > > Tiago,
>> > >>> > > >
>> > >>> > > > I have a question regarding the porting process.
>> Specifically, I
>> > >>> need
>> > >>> > to
>> > >>> > > > add the sleep_modes.c file to the compilation process. Am I on
>> > the
>> > >>> > right
>> > >>> > > > path with this approach?
>> > >>> > > >
>> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file by adding
>> > >>> > > > sleep_modes.c.
>> > >>> > > > However, I am facing some issues: within sleep_modes.c, some
>> > >>> #include
>> > >>> > > > statements reference files that are not available in the
>> > 3rd-party
>> > >>> > > > directory but are only present in the IDF. For example:
>> > >>> > > >
>> > >>> > > > - esp_private/pm_impl.h
>> > >>> > > > - esp_cpu.h
>> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
>> > >>> > > >
>> > >>> > > > I need those includes because sleep_modes.c uses function from
>> > >>> there.
>> > >>> > > >
>> > >>> > > > Could you please advise if it's possible to incorporate these
>> IDF
>> > >>> > folders
>> > >>> > > > into the 3rd-party directory, or if that approach is not
>> > >>> recommended?
>> > >>> > > >
>> > >>> > > > Thank you for your assistance.
>> > >>> > > >
>> > >>> > > > Best regards,
>> > >>> > > >
>> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
>> > >>> > > > tiago.medicci@gmail.com> escreveu:
>> > >>> > > >
>> > >>> > > > > Hi,
>> > >>> > > > >
>> > >>> > > > > Just another note to guide your development: we don't
>> develop
>> > >>> > anything
>> > >>> > > on
>> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from it is
>> derived
>> > >>> from
>> > >>> > the
>> > >>> > > > > path
>> > >>> > > > >
>> > >>> > > > >
>> > >>> > > >
>> > >>> > >
>> > >>> >
>> > >>>
>> >
>> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
>> > >>> > > > > (essentially, header files from
>> > >>> `components/hal/<chip>/include/hal`,
>> > >>> > > > except
>> > >>> > > > > for some of the sources files that use the hal functions at
>> > >>> > > > > `components/hal` to implement some function we may use). You
>> > can
>> > >>> > take a
>> > >>> > > > > look at the branch `
>> > >>> > > > >
>> > >>> >
>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
>> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > >>> <
>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > >>> > <
>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > >>> > > <
>> > >>>
>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > >>> > > > <
>> > >>>
>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > >>> > > > > <
>> > >>> >
>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
>> > >
>> > >>> > > > and
>> > >>> > > > > especially the commits beginning
>> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the
>> kind
>> > >>> of
>> > >>> > > > changes
>> > >>> > > > > we do in hal. Essentially, we create a wrapper layer to
>> make it
>> > >>> > > > independent
>> > >>> > > > > of the host OS.
>> > >>> > > > >
>> > >>> > > > > *Drivers must always be implemented on NuttX!*
>> > >>> > > > >
>> > >>> > > > > That being said, you can either 1) try to adapt the
>> > >>> implementation of
>> > >>> > > > other
>> > >>> > > > > devices to use the HAL functions or 2) get some inspiration
>> on
>> > >>> how
>> > >>> > IDF
>> > >>> > > > > implements PM. I'd stick with the 2nd option before simply
>> > >>> trying to
>> > >>> > > > adapt
>> > >>> > > > > an existing implementation (from ESP32-C3 legacy or from
>> > >>> > > ESP32/ESP32-S3).
>> > >>> > > > >
>> > >>> > > > > Best regards,
>> > >>> > > > >
>> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira
>> <
>> > >>> > > > > moura.fmo@gmail.com> escreveu:
>> > >>> > > > >
>> > >>> > > > > > Hello Tiago.
>> > >>> > > > > >
>> > >>> > > > > > Thank you for clarification, I will follow your
>> instructions.
>> > >>> > > > > >
>> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci
>> Serrano <
>> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
>> > >>> > > > > >
>> > >>> > > > > > > Hi Felipe,
>> > >>> > > > > > >
>> > >>> > > > > > > Just complementing: use your forked version of the HAL
>> > >>> during the
>> > >>> > > > > > > development. As soon as you have a working version, you
>> can
>> > >>> > submit
>> > >>> > > on
>> > >>> > > > > the
>> > >>> > > > > > > official repository.
>> > >>> > > > > > >
>> > >>> > > > > > > Best regards,
>> > >>> > > > > > >
>> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci
>> > Serrano <
>> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
>> > >>> > > > > > >
>> > >>> > > > > > > > Hi Felipe,
>> > >>> > > > > > > >
>> > >>> > > > > > > > Thanks for asking! You should follow the path using
>> the
>> > >>> > functions
>> > >>> > > > on
>> > >>> > > > > > > > esp-hal-3rdparty. You can fork the repository and use
>> > >>> > > > > > > >
>> > >>> > >
>> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
>> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
>> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
>> > >>> > > > > > env
>> > >>> > > > > > > > vars (globally or before the make command) to use your
>> > >>> version
>> > >>> > of
>> > >>> > > > the
>> > >>> > > > > > > HAL.
>> > >>> > > > > > > >
>> > >>> > > > > > > > I just wanted to share some thoughts: using the HAL
>> > >>> enables us
>> > >>> > to
>> > >>> > > > > make
>> > >>> > > > > > > the
>> > >>> > > > > > > > feature available for all the Espressif devices
>> (please
>> > >>> don't
>> > >>> > > > bother
>> > >>> > > > > > with
>> > >>> > > > > > > > that now, as soon as you submit it, we can test for
>> the
>> > >>> other
>> > >>> > > > devices
>> > >>> > > > > > and
>> > >>> > > > > > > > eventually make any adjustments). Although it's
>> possible
>> > to
>> > >>> > > > > reimplement
>> > >>> > > > > > > > these functions on NuttX, we don't recommend that
>> because
>> > >>> of
>> > >>> > the
>> > >>> > > > > first
>> > >>> > > > > > > > statement (the ability to use for the other devices):
>> in
>> > >>> that
>> > >>> > > case
>> > >>> > > > we
>> > >>> > > > > > > > wouldn't be able to support the feature. You can take
>> a
>> > >>> look on
>> > >>> > > IDF
>> > >>> > > > > for
>> > >>> > > > > > > > some inspiration on how it's implemented.
>> > >>> > > > > > > >
>> > >>> > > > > > > > Please let me know if you have any questions.
>> > >>> > > > > > > >
>> > >>> > > > > > > > Best regards,
>> > >>> > > > > > > >
>> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura
>> > >>> Oliveira <
>> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
>> > >>> > > > > > > >
>> > >>> > > > > > > >> Hello everyone,
>> > >>> > > > > > > >>
>> > >>> > > > > > > >> Our project has reached a point where we need the
>> Power
>> > >>> > Manager
>> > >>> > > > > > > >> functionality, which is not yet available in the
>> > ESP32C6.
>> > >>> I am
>> > >>> > > > > > studying
>> > >>> > > > > > > to
>> > >>> > > > > > > >> start the implementation, but I am confused about the
>> > >>> correct
>> > >>> > > way
>> > >>> > > > to
>> > >>> > > > > > > >> approach this.
>> > >>> > > > > > > >>
>> > >>> > > > > > > >> There is a Power Manager implementation for the
>> ESP32C3,
>> > >>> but
>> > >>> > it
>> > >>> > > > > seems
>> > >>> > > > > > to
>> > >>> > > > > > > >> follow the legacy methodology. In fact, the file
>> > >>> > esp32c3_idle.c
>> > >>> > > is
>> > >>> > > > > > > located
>> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
>> > >>> > methodology,
>> > >>> > > > > > > functions
>> > >>> > > > > > > >> are re-implemented from the Espressif driver. For
>> > >>> example, the
>> > >>> > > > > > function
>> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is currently
>> > available
>> > >>> in
>> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
>> > >>> > > > > > > >>
>> > >>> > > > > > > >> I tried using the implementations from
>> esp-hal-3rdparty
>> > to
>> > >>> > > develop
>> > >>> > > > > the
>> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files
>> > >>> still
>> > >>> > have
>> > >>> > > > > many
>> > >>> > > > > > > >> dependencies on items that are not present in NuttX.
>> > >>> > > > > > > >>
>> > >>> > > > > > > >> My question is: Should I try to make the Power
>> Manager
>> > >>> work
>> > >>> > > using
>> > >>> > > > > the
>> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it requires
>> > making
>> > >>> > > changes
>> > >>> > > > to
>> > >>> > > > > > the
>> > >>> > > > > > > >> 3rd-party code? Or should I re-implement the
>> functions
>> > >>> within
>> > >>> > > > NuttX,
>> > >>> > > > > > > even
>> > >>> > > > > > > >> if, in this case, there are functions with the same
>> > scope
>> > >>> and
>> > >>> > > > > > > >> implementation in different files, where one is
>> > compiled,
>> > >>> and
>> > >>> > > the
>> > >>> > > > > > other
>> > >>> > > > > > > is
>> > >>> > > > > > > >> not?
>> > >>> > > > > > > >>
>> > >>> > > > > > > >>
>> > >>> > > > > > > >> --
>> > >>> > > > > > > >> *Felipe Moura de Oliveira*
>> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
>> > >>> > > > > > > >> Linkedin <
>> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > >>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > >>> > > > > > > >>
>> > >>> > > > > > > >
>> > >>> > > > > > > >
>> > >>> > > > > > > > --
>> > >>> > > > > > > > Tiago Medicci Serrano
>> > >>> > > > > > > >
>> > >>> > > > > > > > Embedded Software Engineer
>> > >>> > > > > > > > MSc Electronics/Microelectronics
>> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > >>> > > > > > > > e: tiago.medicci@gmail.com
>> > >>> > > > > > > > a: Campinas, Brazil
>> > >>> > > > > > > > Follow me:
>> > >>> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > >>> > > > > > > > <https://github.com/tmedicci>
>> > >>> > > > > > > >
>> > >>> > > > > > >
>> > >>> > > > > > >
>> > >>> > > > > > > --
>> > >>> > > > > > > Tiago Medicci Serrano
>> > >>> > > > > > >
>> > >>> > > > > > > Embedded Software Engineer
>> > >>> > > > > > > MSc Electronics/Microelectronics
>> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > >>> > > > > > > e: tiago.medicci@gmail.com
>> > >>> > > > > > > a: Campinas, Brazil
>> > >>> > > > > > > Follow me:
>> > >>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > >>> > > > > > > <https://github.com/tmedicci>
>> > >>> > > > > > >
>> > >>> > > > > >
>> > >>> > > > > >
>> > >>> > > > > > --
>> > >>> > > > > > *Felipe Moura de Oliveira*
>> > >>> > > > > > *Universidade Federal de Minas Gerais*
>> > >>> > > > > > Linkedin <
>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
>> > >>> >
>> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > >>> > > > > >
>> > >>> > > > >
>> > >>> > > > >
>> > >>> > > > > --
>> > >>> > > > > Tiago Medicci Serrano
>> > >>> > > > >
>> > >>> > > > > Embedded Software Engineer
>> > >>> > > > > MSc Electronics/Microelectronics
>> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > >>> > > > > e: tiago.medicci@gmail.com
>> > >>> > > > > a: Campinas, Brazil
>> > >>> > > > > Follow me:
>> > >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > >>> > > > > <https://github.com/tmedicci>
>> > >>> > > > >
>> > >>> > > >
>> > >>> > > >
>> > >>> > > > --
>> > >>> > > > *Felipe Moura de Oliveira*
>> > >>> > > > *Universidade Federal de Minas Gerais*
>> > >>> > > > Linkedin <
>> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > >>> > > >
>> > >>> > >
>> > >>> > >
>> > >>> > > --
>> > >>> > > Tiago Medicci Serrano
>> > >>> > >
>> > >>> > > Embedded Software Engineer
>> > >>> > > MSc Electronics/Microelectronics
>> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > >>> > > e: tiago.medicci@gmail.com
>> > >>> > > a: Campinas, Brazil
>> > >>> > > Follow me:
>> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > >>> > > <https://github.com/tmedicci>
>> > >>> > >
>> > >>> >
>> > >>> >
>> > >>> > --
>> > >>> > *Felipe Moura de Oliveira*
>> > >>> > *Universidade Federal de Minas Gerais*
>> > >>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > >>> >
>> > >>>
>> > >>
>> > >>
>> > >> --
>> > >> *Felipe Moura de Oliveira*
>> > >> *Universidade Federal de Minas Gerais*
>> > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > >>
>> > >
>> > >
>> > > --
>> > > *Felipe Moura de Oliveira*
>> > > *Universidade Federal de Minas Gerais*
>> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > >
>> >
>> >
>> > --
>> > *Felipe Moura de Oliveira*
>> > *Universidade Federal de Minas Gerais*
>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> >
>>
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello Tiago.
Please look de draft here: https://github.com/apache/nuttx/pull/14548
This branch will refer to the updated 3rd-party in my repo.
You only need to enable PM in menuconfig and it will be enough to see
changes.
Em ter., 29 de out. de 2024 às 13:10, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi Felipe,
>
> Can you share your PR as a draft on GH to make it easier to check the files
> (and the build process)?
>
> Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello Tiago,
> >
> > I "finished" the port, but after it my esp32c6 dev kit is resetting.
> Maybe
> > the issue is related my changes in
> > boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you give
> some
> > tips about how to go ahead?
> >
> > Below you can see nuttx report:
> > Build:Sep 19 2022
> > rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> > Saved PC:0x40018bea
> > SPIWP:0xee
> > mode:DIO, clock div:2
> > load:0x40800000,len:0x61e0
> > load:0x408061e0,len:0xc34
> > load:0x50000000,len:0x20
> > load:0x5000001e,len:0x24
> > Invalid image block, can't boot.
> > ets_main.c 331
> > ESP-ROM:esp32c6-20220919
> >
> > Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> > > Hello everyone,
> > >
> > > I was able to solve linker issues, editing the linker by myself. I need
> > to
> > > finish more than one build issue before testing it, so I will see if I
> > made
> > > the right changes in linker.
> > >
> > > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> > > moura.fmo@gmail.com> escreveu:
> > >
> > >> *Hello everyone, Tiago,*
> > >>
> > >> I have made progress with the build issue I was encountering and am
> now
> > >> "stuck" at what I believe is one of the final stages. I am
> experiencing
> > the
> > >> following compilation error:
> > >> LD: nuttx
> > >> riscv-none-elf-ld: warning:
> > /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> > >> has a LOAD segment with RWX permissions
> > >> riscv-none-elf-ld: /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> > >> libarch.a(sleep_modes.o): in function
> > >> `esp_set_deep_sleep_wake_stub_default_entry':
> > >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> > >> `_rtc_force_fast_end'
> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined
> reference
> > >> to `_rtc_text_start'
> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined
> reference
> > >> to `_rtc_force_fast_end'
> > >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined
> reference
> > >> to `_rtc_text_start'
> > >> riscv-none-elf-ld:
> > >>
> >
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> > >> in function `esp_sleep_cpu_retention':
> > >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> > >> `rv_core_critical_regs_save'
> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined reference
> to
> > >> `rv_core_critical_regs_restore'
> > >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined reference
> to
> > >> `rv_core_critical_regs_restore'
> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > >>
> > >> I would greatly appreciate your assistance.
> > >>
> > >> Focusing on the item _rtc_text_start, I see that it is defined in the
> > >> file:
> > >>
> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > >> sections.ld.in
> > >>
> > >> However, I am unsure how to add this file to the complete linking
> > >> process. I added this file to hal_esp32c6.mk, but I received the
> > >> following error:
> > >> LD: nuttx
> > >>
> > riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> > >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> > >> sections.ld.in.tmp:113 cannot move location counter backwards (from
> > >> 40809800 to 40800000)
> > >> make[1]: *** [Makefile:189: nuttx] Error 1
> > >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> > >>
> > >>
> > >> Does anyone have any tips or suggestions that could help me move
> forward
> > >> with this process?
> > >>
> > >> Thank you in advance for your help.
> > >>
> > >> *Best regards,*
> > >>
> > >>
> > >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> > >> tiago.medicci@gmail.com> escreveu:
> > >>
> > >>> Hi Felipe,
> > >>>
> > >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute for
> > >>> this
> > >>> function should be part
> > >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That
> being
> > >>> said, you can either implement it (and define it as a macro, on HAL)
> or
> > >>> you
> > >>> can either ignore these functions related to GPIO wakeup from sleep
> for
> > >>> now
> > >>> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if
> the
> > >>> GPIO
> > >>> wakeup isn't mandatory, it'd go baby steps, removing this feature for
> > >>> now.
> > >>>
> > >>> Best regards,
> > >>>
> > >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
> > >>> moura.fmo@gmail.com> escreveu:
> > >>>
> > >>> > Hello Tiago,
> > >>> >
> > >>> > Thank you for your assistance earlier.
> > >>> >
> > >>> > I would like to discuss further the necessity of the
> > >>> > esp_driver_gpio/include/rtc_io.h file, which is only available in
> the
> > >>> IDF.
> > >>> >
> > >>> > In sleep_modes.c, there is the following code snippet:
> > >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> > >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > >>> > {
> > >>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > >>> > return ESP_ERR_INVALID_ARG;
> > >>> > }
> > >>> > // Translate bit map of GPIO numbers into the bit map of RTC IO
> > numbers
> > >>> > uint32_t rtc_gpio_mask = 0;
> > >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > >>> > if ((io_mask & 1) == 0) {
> > >>> > continue;
> > >>> > }
> > >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > >>> > return ESP_ERR_INVALID_ARG;
> > >>> > }
> > >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > >>> > }
> > >>> >
> > >>> > I believe this code is essential for compilation. The function
> > >>> > rtc_io_number_get is located at the following path in the IDF:
> > >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> > >>> >
> > >>> > However, the esp_driver_gpio folder is not present in the 3rd-party
> > >>> > directory. In this case, what is the recommended procedure to
> > proceed?
> > >>> >
> > >>> > Thank you again for your support.
> > >>> >
> > >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
> > >>> > tiago.medicci@gmail.com> escreveu:
> > >>> >
> > >>> > > Hi Felipe,
> > >>> > >
> > >>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of
> ESP-IDF,
> > >>> which
> > >>> > is
> > >>> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h`
> > >>> (here, a
> > >>> > > detail: I wasn't able to find this path on IDF, so make sure you
> > are
> > >>> > > checking under the `release/v5.1` branch, which the HAL was
> based).
> > >>> The
> > >>> > HAL
> > >>> > > repository doesn't contain ESP-IDF drivers, which are always
> > >>> implemented
> > >>> > on
> > >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > >>> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > >>> > >
> > >>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
> > >>> > > (`sleep_modes.c`, for instance) MAY be used to implement the
> > driver.
> > >>> This
> > >>> > > is, mostly, a wrapping layer under the function of `esp_rom` and
> > >>> `hal`
> > >>> > > components. However, they still may refer to ESP-IDF drivers.
> That
> > >>> being
> > >>> > > said, you can check if removing such dependencies is possible. We
> > >>> usually
> > >>> > > do that with conditional macros. A good starting point is to
> check
> > >>> for
> > >>> > > `#ifdef __NuttX__` on these sources and headers: we use them to
> > >>> > remove/add
> > >>> > > headers and functions that aren't available on NuttX/needed by
> > NuttX.
> > >>> > >
> > >>> > > Best regards,
> > >>> > >
> > >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
> > >>> > > moura.fmo@gmail.com> escreveu:
> > >>> > >
> > >>> > > > Hello all,
> > >>> > > >
> > >>> > > > Tiago,
> > >>> > > >
> > >>> > > > I have a question regarding the porting process. Specifically,
> I
> > >>> need
> > >>> > to
> > >>> > > > add the sleep_modes.c file to the compilation process. Am I on
> > the
> > >>> > right
> > >>> > > > path with this approach?
> > >>> > > >
> > >>> > > > To achieve this, I modified the hal_esp32c6.mk file by adding
> > >>> > > > sleep_modes.c.
> > >>> > > > However, I am facing some issues: within sleep_modes.c, some
> > >>> #include
> > >>> > > > statements reference files that are not available in the
> > 3rd-party
> > >>> > > > directory but are only present in the IDF. For example:
> > >>> > > >
> > >>> > > > - esp_private/pm_impl.h
> > >>> > > > - esp_cpu.h
> > >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> > >>> > > >
> > >>> > > > I need those includes because sleep_modes.c uses function from
> > >>> there.
> > >>> > > >
> > >>> > > > Could you please advise if it's possible to incorporate these
> IDF
> > >>> > folders
> > >>> > > > into the 3rd-party directory, or if that approach is not
> > >>> recommended?
> > >>> > > >
> > >>> > > > Thank you for your assistance.
> > >>> > > >
> > >>> > > > Best regards,
> > >>> > > >
> > >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
> > >>> > > > tiago.medicci@gmail.com> escreveu:
> > >>> > > >
> > >>> > > > > Hi,
> > >>> > > > >
> > >>> > > > > Just another note to guide your development: we don't develop
> > >>> > anything
> > >>> > > on
> > >>> > > > > `esp-hal-3rdparty`: most of the code we use from it is
> derived
> > >>> from
> > >>> > the
> > >>> > > > > path
> > >>> > > > >
> > >>> > > > >
> > >>> > > >
> > >>> > >
> > >>> >
> > >>>
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > >>> > > > > (essentially, header files from
> > >>> `components/hal/<chip>/include/hal`,
> > >>> > > > except
> > >>> > > > > for some of the sources files that use the hal functions at
> > >>> > > > > `components/hal` to implement some function we may use). You
> > can
> > >>> > take a
> > >>> > > > > look at the branch `
> > >>> > > > >
> > >>> >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >>> <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >>> > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > >>> > > <
> > >>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > >>> > > > <
> > >>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> > >>> > > > > <
> > >>> >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> > >
> > >>> > > > and
> > >>> > > > > especially the commits beginning
> > >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the
> kind
> > >>> of
> > >>> > > > changes
> > >>> > > > > we do in hal. Essentially, we create a wrapper layer to make
> it
> > >>> > > > independent
> > >>> > > > > of the host OS.
> > >>> > > > >
> > >>> > > > > *Drivers must always be implemented on NuttX!*
> > >>> > > > >
> > >>> > > > > That being said, you can either 1) try to adapt the
> > >>> implementation of
> > >>> > > > other
> > >>> > > > > devices to use the HAL functions or 2) get some inspiration
> on
> > >>> how
> > >>> > IDF
> > >>> > > > > implements PM. I'd stick with the 2nd option before simply
> > >>> trying to
> > >>> > > > adapt
> > >>> > > > > an existing implementation (from ESP32-C3 legacy or from
> > >>> > > ESP32/ESP32-S3).
> > >>> > > > >
> > >>> > > > > Best regards,
> > >>> > > > >
> > >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> > >>> > > > > moura.fmo@gmail.com> escreveu:
> > >>> > > > >
> > >>> > > > > > Hello Tiago.
> > >>> > > > > >
> > >>> > > > > > Thank you for clarification, I will follow your
> instructions.
> > >>> > > > > >
> > >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci
> Serrano <
> > >>> > > > > > tiago.medicci@gmail.com> escreveu:
> > >>> > > > > >
> > >>> > > > > > > Hi Felipe,
> > >>> > > > > > >
> > >>> > > > > > > Just complementing: use your forked version of the HAL
> > >>> during the
> > >>> > > > > > > development. As soon as you have a working version, you
> can
> > >>> > submit
> > >>> > > on
> > >>> > > > > the
> > >>> > > > > > > official repository.
> > >>> > > > > > >
> > >>> > > > > > > Best regards,
> > >>> > > > > > >
> > >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci
> > Serrano <
> > >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> > >>> > > > > > >
> > >>> > > > > > > > Hi Felipe,
> > >>> > > > > > > >
> > >>> > > > > > > > Thanks for asking! You should follow the path using the
> > >>> > functions
> > >>> > > > on
> > >>> > > > > > > > esp-hal-3rdparty. You can fork the repository and use
> > >>> > > > > > > >
> > >>> > >
> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > >>> > > > tmedicci/esp-hal-3rdparty.git"`
> > >>> > > > > > env
> > >>> > > > > > > > vars (globally or before the make command) to use your
> > >>> version
> > >>> > of
> > >>> > > > the
> > >>> > > > > > > HAL.
> > >>> > > > > > > >
> > >>> > > > > > > > I just wanted to share some thoughts: using the HAL
> > >>> enables us
> > >>> > to
> > >>> > > > > make
> > >>> > > > > > > the
> > >>> > > > > > > > feature available for all the Espressif devices (please
> > >>> don't
> > >>> > > > bother
> > >>> > > > > > with
> > >>> > > > > > > > that now, as soon as you submit it, we can test for the
> > >>> other
> > >>> > > > devices
> > >>> > > > > > and
> > >>> > > > > > > > eventually make any adjustments). Although it's
> possible
> > to
> > >>> > > > > reimplement
> > >>> > > > > > > > these functions on NuttX, we don't recommend that
> because
> > >>> of
> > >>> > the
> > >>> > > > > first
> > >>> > > > > > > > statement (the ability to use for the other devices):
> in
> > >>> that
> > >>> > > case
> > >>> > > > we
> > >>> > > > > > > > wouldn't be able to support the feature. You can take a
> > >>> look on
> > >>> > > IDF
> > >>> > > > > for
> > >>> > > > > > > > some inspiration on how it's implemented.
> > >>> > > > > > > >
> > >>> > > > > > > > Please let me know if you have any questions.
> > >>> > > > > > > >
> > >>> > > > > > > > Best regards,
> > >>> > > > > > > >
> > >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura
> > >>> Oliveira <
> > >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> > >>> > > > > > > >
> > >>> > > > > > > >> Hello everyone,
> > >>> > > > > > > >>
> > >>> > > > > > > >> Our project has reached a point where we need the
> Power
> > >>> > Manager
> > >>> > > > > > > >> functionality, which is not yet available in the
> > ESP32C6.
> > >>> I am
> > >>> > > > > > studying
> > >>> > > > > > > to
> > >>> > > > > > > >> start the implementation, but I am confused about the
> > >>> correct
> > >>> > > way
> > >>> > > > to
> > >>> > > > > > > >> approach this.
> > >>> > > > > > > >>
> > >>> > > > > > > >> There is a Power Manager implementation for the
> ESP32C3,
> > >>> but
> > >>> > it
> > >>> > > > > seems
> > >>> > > > > > to
> > >>> > > > > > > >> follow the legacy methodology. In fact, the file
> > >>> > esp32c3_idle.c
> > >>> > > is
> > >>> > > > > > > located
> > >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
> > >>> > methodology,
> > >>> > > > > > > functions
> > >>> > > > > > > >> are re-implemented from the Espressif driver. For
> > >>> example, the
> > >>> > > > > > function
> > >>> > > > > > > >> esp32c3_light_sleep_start(), which is currently
> > available
> > >>> in
> > >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > >>> > > > > > > >>
> > >>> > > > > > > >> I tried using the implementations from
> esp-hal-3rdparty
> > to
> > >>> > > develop
> > >>> > > > > the
> > >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files
> > >>> still
> > >>> > have
> > >>> > > > > many
> > >>> > > > > > > >> dependencies on items that are not present in NuttX.
> > >>> > > > > > > >>
> > >>> > > > > > > >> My question is: Should I try to make the Power Manager
> > >>> work
> > >>> > > using
> > >>> > > > > the
> > >>> > > > > > > >> functions in esp-hal-3rdparty, even if it requires
> > making
> > >>> > > changes
> > >>> > > > to
> > >>> > > > > > the
> > >>> > > > > > > >> 3rd-party code? Or should I re-implement the functions
> > >>> within
> > >>> > > > NuttX,
> > >>> > > > > > > even
> > >>> > > > > > > >> if, in this case, there are functions with the same
> > scope
> > >>> and
> > >>> > > > > > > >> implementation in different files, where one is
> > compiled,
> > >>> and
> > >>> > > the
> > >>> > > > > > other
> > >>> > > > > > > is
> > >>> > > > > > > >> not?
> > >>> > > > > > > >>
> > >>> > > > > > > >>
> > >>> > > > > > > >> --
> > >>> > > > > > > >> *Felipe Moura de Oliveira*
> > >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> > >>> > > > > > > >> Linkedin <
> > >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >>> > > > > > > >>
> > >>> > > > > > > >
> > >>> > > > > > > >
> > >>> > > > > > > > --
> > >>> > > > > > > > Tiago Medicci Serrano
> > >>> > > > > > > >
> > >>> > > > > > > > Embedded Software Engineer
> > >>> > > > > > > > MSc Electronics/Microelectronics
> > >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >>> > > > > > > > e: tiago.medicci@gmail.com
> > >>> > > > > > > > a: Campinas, Brazil
> > >>> > > > > > > > Follow me:
> > >>> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > >>> > > > > > > > <https://github.com/tmedicci>
> > >>> > > > > > > >
> > >>> > > > > > >
> > >>> > > > > > >
> > >>> > > > > > > --
> > >>> > > > > > > Tiago Medicci Serrano
> > >>> > > > > > >
> > >>> > > > > > > Embedded Software Engineer
> > >>> > > > > > > MSc Electronics/Microelectronics
> > >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >>> > > > > > > e: tiago.medicci@gmail.com
> > >>> > > > > > > a: Campinas, Brazil
> > >>> > > > > > > Follow me:
> > >>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > >>> > > > > > > <https://github.com/tmedicci>
> > >>> > > > > > >
> > >>> > > > > >
> > >>> > > > > >
> > >>> > > > > > --
> > >>> > > > > > *Felipe Moura de Oliveira*
> > >>> > > > > > *Universidade Federal de Minas Gerais*
> > >>> > > > > > Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0
> > >>> >
> > >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >>> > > > > >
> > >>> > > > >
> > >>> > > > >
> > >>> > > > > --
> > >>> > > > > Tiago Medicci Serrano
> > >>> > > > >
> > >>> > > > > Embedded Software Engineer
> > >>> > > > > MSc Electronics/Microelectronics
> > >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >>> > > > > e: tiago.medicci@gmail.com
> > >>> > > > > a: Campinas, Brazil
> > >>> > > > > Follow me:
> > >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > >>> > > > > <https://github.com/tmedicci>
> > >>> > > > >
> > >>> > > >
> > >>> > > >
> > >>> > > > --
> > >>> > > > *Felipe Moura de Oliveira*
> > >>> > > > *Universidade Federal de Minas Gerais*
> > >>> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >
> > >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >>> > > >
> > >>> > >
> > >>> > >
> > >>> > > --
> > >>> > > Tiago Medicci Serrano
> > >>> > >
> > >>> > > Embedded Software Engineer
> > >>> > > MSc Electronics/Microelectronics
> > >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > >>> > > e: tiago.medicci@gmail.com
> > >>> > > a: Campinas, Brazil
> > >>> > > Follow me:
> > >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > >>> > > <https://github.com/tmedicci>
> > >>> > >
> > >>> >
> > >>> >
> > >>> > --
> > >>> > *Felipe Moura de Oliveira*
> > >>> > *Universidade Federal de Minas Gerais*
> > >>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >>> >
> > >>>
> > >>
> > >>
> > >> --
> > >> *Felipe Moura de Oliveira*
> > >> *Universidade Federal de Minas Gerais*
> > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >>
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi Felipe,
Can you share your PR as a draft on GH to make it easier to check the files
(and the build process)?
Em ter., 29 de out. de 2024 às 12:41, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello Tiago,
>
> I "finished" the port, but after it my esp32c6 dev kit is resetting. Maybe
> the issue is related my changes in
> boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you give some
> tips about how to go ahead?
>
> Below you can see nuttx report:
> Build:Sep 19 2022
> rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
> Saved PC:0x40018bea
> SPIWP:0xee
> mode:DIO, clock div:2
> load:0x40800000,len:0x61e0
> load:0x408061e0,len:0xc34
> load:0x50000000,len:0x20
> load:0x5000001e,len:0x24
> Invalid image block, can't boot.
> ets_main.c 331
> ESP-ROM:esp32c6-20220919
>
> Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello everyone,
> >
> > I was able to solve linker issues, editing the linker by myself. I need
> to
> > finish more than one build issue before testing it, so I will see if I
> made
> > the right changes in linker.
> >
> > Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> >> *Hello everyone, Tiago,*
> >>
> >> I have made progress with the build issue I was encountering and am now
> >> "stuck" at what I believe is one of the final stages. I am experiencing
> the
> >> following compilation error:
> >> LD: nuttx
> >> riscv-none-elf-ld: warning:
> /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> >> has a LOAD segment with RWX permissions
> >> riscv-none-elf-ld: /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> >> libarch.a(sleep_modes.o): in function
> >> `esp_set_deep_sleep_wake_stub_default_entry':
> >> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> >> `_rtc_force_fast_end'
> >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined reference
> >> to `_rtc_text_start'
> >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined reference
> >> to `_rtc_force_fast_end'
> >> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined reference
> >> to `_rtc_text_start'
> >> riscv-none-elf-ld:
> >>
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> >> in function `esp_sleep_cpu_retention':
> >> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> >> `rv_core_critical_regs_save'
> >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined reference to
> >> `rv_core_critical_regs_restore'
> >> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined reference to
> >> `rv_core_critical_regs_restore'
> >> make[1]: *** [Makefile:189: nuttx] Error 1
> >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> >>
> >> I would greatly appreciate your assistance.
> >>
> >> Focusing on the item _rtc_text_start, I see that it is defined in the
> >> file:
> >> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> >> sections.ld.in
> >>
> >> However, I am unsure how to add this file to the complete linking
> >> process. I added this file to hal_esp32c6.mk, but I received the
> >> following error:
> >> LD: nuttx
> >>
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> >> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> >> sections.ld.in.tmp:113 cannot move location counter backwards (from
> >> 40809800 to 40800000)
> >> make[1]: *** [Makefile:189: nuttx] Error 1
> >> make: *** [tools/Unix.mk:551: nuttx] Error 2
> >>
> >>
> >> Does anyone have any tips or suggestions that could help me move forward
> >> with this process?
> >>
> >> Thank you in advance for your help.
> >>
> >> *Best regards,*
> >>
> >>
> >> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> >> tiago.medicci@gmail.com> escreveu:
> >>
> >>> Hi Felipe,
> >>>
> >>> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute for
> >>> this
> >>> function should be part
> >>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That being
> >>> said, you can either implement it (and define it as a macro, on HAL) or
> >>> you
> >>> can either ignore these functions related to GPIO wakeup from sleep for
> >>> now
> >>> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if the
> >>> GPIO
> >>> wakeup isn't mandatory, it'd go baby steps, removing this feature for
> >>> now.
> >>>
> >>> Best regards,
> >>>
> >>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
> >>> moura.fmo@gmail.com> escreveu:
> >>>
> >>> > Hello Tiago,
> >>> >
> >>> > Thank you for your assistance earlier.
> >>> >
> >>> > I would like to discuss further the necessity of the
> >>> > esp_driver_gpio/include/rtc_io.h file, which is only available in the
> >>> IDF.
> >>> >
> >>> > In sleep_modes.c, there is the following code snippet:
> >>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> >>> > esp_sleep_ext1_wakeup_mode_t level_mode)
> >>> > {
> >>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> >>> > return ESP_ERR_INVALID_ARG;
> >>> > }
> >>> > // Translate bit map of GPIO numbers into the bit map of RTC IO
> numbers
> >>> > uint32_t rtc_gpio_mask = 0;
> >>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> >>> > if ((io_mask & 1) == 0) {
> >>> > continue;
> >>> > }
> >>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> >>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> >>> > return ESP_ERR_INVALID_ARG;
> >>> > }
> >>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> >>> > }
> >>> >
> >>> > I believe this code is essential for compilation. The function
> >>> > rtc_io_number_get is located at the following path in the IDF:
> >>> > components/esp_driver_gpio/include/driver/rtc_io.h.
> >>> >
> >>> > However, the esp_driver_gpio folder is not present in the 3rd-party
> >>> > directory. In this case, what is the recommended procedure to
> proceed?
> >>> >
> >>> > Thank you again for your support.
> >>> >
> >>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
> >>> > tiago.medicci@gmail.com> escreveu:
> >>> >
> >>> > > Hi Felipe,
> >>> > >
> >>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF,
> >>> which
> >>> > is
> >>> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h`
> >>> (here, a
> >>> > > detail: I wasn't able to find this path on IDF, so make sure you
> are
> >>> > > checking under the `release/v5.1` branch, which the HAL was based).
> >>> The
> >>> > HAL
> >>> > > repository doesn't contain ESP-IDF drivers, which are always
> >>> implemented
> >>> > on
> >>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> >>> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> >>> > >
> >>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
> >>> > > (`sleep_modes.c`, for instance) MAY be used to implement the
> driver.
> >>> This
> >>> > > is, mostly, a wrapping layer under the function of `esp_rom` and
> >>> `hal`
> >>> > > components. However, they still may refer to ESP-IDF drivers. That
> >>> being
> >>> > > said, you can check if removing such dependencies is possible. We
> >>> usually
> >>> > > do that with conditional macros. A good starting point is to check
> >>> for
> >>> > > `#ifdef __NuttX__` on these sources and headers: we use them to
> >>> > remove/add
> >>> > > headers and functions that aren't available on NuttX/needed by
> NuttX.
> >>> > >
> >>> > > Best regards,
> >>> > >
> >>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
> >>> > > moura.fmo@gmail.com> escreveu:
> >>> > >
> >>> > > > Hello all,
> >>> > > >
> >>> > > > Tiago,
> >>> > > >
> >>> > > > I have a question regarding the porting process. Specifically, I
> >>> need
> >>> > to
> >>> > > > add the sleep_modes.c file to the compilation process. Am I on
> the
> >>> > right
> >>> > > > path with this approach?
> >>> > > >
> >>> > > > To achieve this, I modified the hal_esp32c6.mk file by adding
> >>> > > > sleep_modes.c.
> >>> > > > However, I am facing some issues: within sleep_modes.c, some
> >>> #include
> >>> > > > statements reference files that are not available in the
> 3rd-party
> >>> > > > directory but are only present in the IDF. For example:
> >>> > > >
> >>> > > > - esp_private/pm_impl.h
> >>> > > > - esp_cpu.h
> >>> > > > - components/esp_driver_gpio/include/rtc_io.h
> >>> > > >
> >>> > > > I need those includes because sleep_modes.c uses function from
> >>> there.
> >>> > > >
> >>> > > > Could you please advise if it's possible to incorporate these IDF
> >>> > folders
> >>> > > > into the 3rd-party directory, or if that approach is not
> >>> recommended?
> >>> > > >
> >>> > > > Thank you for your assistance.
> >>> > > >
> >>> > > > Best regards,
> >>> > > >
> >>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
> >>> > > > tiago.medicci@gmail.com> escreveu:
> >>> > > >
> >>> > > > > Hi,
> >>> > > > >
> >>> > > > > Just another note to guide your development: we don't develop
> >>> > anything
> >>> > > on
> >>> > > > > `esp-hal-3rdparty`: most of the code we use from it is derived
> >>> from
> >>> > the
> >>> > > > > path
> >>> > > > >
> >>> > > > >
> >>> > > >
> >>> > >
> >>> >
> >>>
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> >>> > > > > (essentially, header files from
> >>> `components/hal/<chip>/include/hal`,
> >>> > > > except
> >>> > > > > for some of the sources files that use the hal functions at
> >>> > > > > `components/hal` to implement some function we may use). You
> can
> >>> > take a
> >>> > > > > look at the branch `
> >>> > > > >
> >>> >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >>> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >>> > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >>> > > <
> >>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >>> > > > <
> >>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> >>> > > > > <
> >>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
> >
> >>> > > > and
> >>> > > > > especially the commits beginning
> >>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind
> >>> of
> >>> > > > changes
> >>> > > > > we do in hal. Essentially, we create a wrapper layer to make it
> >>> > > > independent
> >>> > > > > of the host OS.
> >>> > > > >
> >>> > > > > *Drivers must always be implemented on NuttX!*
> >>> > > > >
> >>> > > > > That being said, you can either 1) try to adapt the
> >>> implementation of
> >>> > > > other
> >>> > > > > devices to use the HAL functions or 2) get some inspiration on
> >>> how
> >>> > IDF
> >>> > > > > implements PM. I'd stick with the 2nd option before simply
> >>> trying to
> >>> > > > adapt
> >>> > > > > an existing implementation (from ESP32-C3 legacy or from
> >>> > > ESP32/ESP32-S3).
> >>> > > > >
> >>> > > > > Best regards,
> >>> > > > >
> >>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> >>> > > > > moura.fmo@gmail.com> escreveu:
> >>> > > > >
> >>> > > > > > Hello Tiago.
> >>> > > > > >
> >>> > > > > > Thank you for clarification, I will follow your instructions.
> >>> > > > > >
> >>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> >>> > > > > > tiago.medicci@gmail.com> escreveu:
> >>> > > > > >
> >>> > > > > > > Hi Felipe,
> >>> > > > > > >
> >>> > > > > > > Just complementing: use your forked version of the HAL
> >>> during the
> >>> > > > > > > development. As soon as you have a working version, you can
> >>> > submit
> >>> > > on
> >>> > > > > the
> >>> > > > > > > official repository.
> >>> > > > > > >
> >>> > > > > > > Best regards,
> >>> > > > > > >
> >>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci
> Serrano <
> >>> > > > > > > tiago.medicci@gmail.com> escreveu:
> >>> > > > > > >
> >>> > > > > > > > Hi Felipe,
> >>> > > > > > > >
> >>> > > > > > > > Thanks for asking! You should follow the path using the
> >>> > functions
> >>> > > > on
> >>> > > > > > > > esp-hal-3rdparty. You can fork the repository and use
> >>> > > > > > > >
> >>> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> >>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> >>> > > > tmedicci/esp-hal-3rdparty.git"`
> >>> > > > > > env
> >>> > > > > > > > vars (globally or before the make command) to use your
> >>> version
> >>> > of
> >>> > > > the
> >>> > > > > > > HAL.
> >>> > > > > > > >
> >>> > > > > > > > I just wanted to share some thoughts: using the HAL
> >>> enables us
> >>> > to
> >>> > > > > make
> >>> > > > > > > the
> >>> > > > > > > > feature available for all the Espressif devices (please
> >>> don't
> >>> > > > bother
> >>> > > > > > with
> >>> > > > > > > > that now, as soon as you submit it, we can test for the
> >>> other
> >>> > > > devices
> >>> > > > > > and
> >>> > > > > > > > eventually make any adjustments). Although it's possible
> to
> >>> > > > > reimplement
> >>> > > > > > > > these functions on NuttX, we don't recommend that because
> >>> of
> >>> > the
> >>> > > > > first
> >>> > > > > > > > statement (the ability to use for the other devices): in
> >>> that
> >>> > > case
> >>> > > > we
> >>> > > > > > > > wouldn't be able to support the feature. You can take a
> >>> look on
> >>> > > IDF
> >>> > > > > for
> >>> > > > > > > > some inspiration on how it's implemented.
> >>> > > > > > > >
> >>> > > > > > > > Please let me know if you have any questions.
> >>> > > > > > > >
> >>> > > > > > > > Best regards,
> >>> > > > > > > >
> >>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura
> >>> Oliveira <
> >>> > > > > > > > moura.fmo@gmail.com> escreveu:
> >>> > > > > > > >
> >>> > > > > > > >> Hello everyone,
> >>> > > > > > > >>
> >>> > > > > > > >> Our project has reached a point where we need the Power
> >>> > Manager
> >>> > > > > > > >> functionality, which is not yet available in the
> ESP32C6.
> >>> I am
> >>> > > > > > studying
> >>> > > > > > > to
> >>> > > > > > > >> start the implementation, but I am confused about the
> >>> correct
> >>> > > way
> >>> > > > to
> >>> > > > > > > >> approach this.
> >>> > > > > > > >>
> >>> > > > > > > >> There is a Power Manager implementation for the ESP32C3,
> >>> but
> >>> > it
> >>> > > > > seems
> >>> > > > > > to
> >>> > > > > > > >> follow the legacy methodology. In fact, the file
> >>> > esp32c3_idle.c
> >>> > > is
> >>> > > > > > > located
> >>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
> >>> > methodology,
> >>> > > > > > > functions
> >>> > > > > > > >> are re-implemented from the Espressif driver. For
> >>> example, the
> >>> > > > > > function
> >>> > > > > > > >> esp32c3_light_sleep_start(), which is currently
> available
> >>> in
> >>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> >>> > > > > > > >>
> >>> > > > > > > >> I tried using the implementations from esp-hal-3rdparty
> to
> >>> > > develop
> >>> > > > > the
> >>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files
> >>> still
> >>> > have
> >>> > > > > many
> >>> > > > > > > >> dependencies on items that are not present in NuttX.
> >>> > > > > > > >>
> >>> > > > > > > >> My question is: Should I try to make the Power Manager
> >>> work
> >>> > > using
> >>> > > > > the
> >>> > > > > > > >> functions in esp-hal-3rdparty, even if it requires
> making
> >>> > > changes
> >>> > > > to
> >>> > > > > > the
> >>> > > > > > > >> 3rd-party code? Or should I re-implement the functions
> >>> within
> >>> > > > NuttX,
> >>> > > > > > > even
> >>> > > > > > > >> if, in this case, there are functions with the same
> scope
> >>> and
> >>> > > > > > > >> implementation in different files, where one is
> compiled,
> >>> and
> >>> > > the
> >>> > > > > > other
> >>> > > > > > > is
> >>> > > > > > > >> not?
> >>> > > > > > > >>
> >>> > > > > > > >>
> >>> > > > > > > >> --
> >>> > > > > > > >> *Felipe Moura de Oliveira*
> >>> > > > > > > >> *Universidade Federal de Minas Gerais*
> >>> > > > > > > >> Linkedin <
> >>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >>> > > > > > > >>
> >>> > > > > > > >
> >>> > > > > > > >
> >>> > > > > > > > --
> >>> > > > > > > > Tiago Medicci Serrano
> >>> > > > > > > >
> >>> > > > > > > > Embedded Software Engineer
> >>> > > > > > > > MSc Electronics/Microelectronics
> >>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >>> > > > > > > > e: tiago.medicci@gmail.com
> >>> > > > > > > > a: Campinas, Brazil
> >>> > > > > > > > Follow me:
> >>> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >>> > > > > > > > <https://github.com/tmedicci>
> >>> > > > > > > >
> >>> > > > > > >
> >>> > > > > > >
> >>> > > > > > > --
> >>> > > > > > > Tiago Medicci Serrano
> >>> > > > > > >
> >>> > > > > > > Embedded Software Engineer
> >>> > > > > > > MSc Electronics/Microelectronics
> >>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >>> > > > > > > e: tiago.medicci@gmail.com
> >>> > > > > > > a: Campinas, Brazil
> >>> > > > > > > Follow me:
> >>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >>> > > > > > > <https://github.com/tmedicci>
> >>> > > > > > >
> >>> > > > > >
> >>> > > > > >
> >>> > > > > > --
> >>> > > > > > *Felipe Moura de Oliveira*
> >>> > > > > > *Universidade Federal de Minas Gerais*
> >>> > > > > > Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0
> >>> >
> >>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >>> > > > > >
> >>> > > > >
> >>> > > > >
> >>> > > > > --
> >>> > > > > Tiago Medicci Serrano
> >>> > > > >
> >>> > > > > Embedded Software Engineer
> >>> > > > > MSc Electronics/Microelectronics
> >>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >>> > > > > e: tiago.medicci@gmail.com
> >>> > > > > a: Campinas, Brazil
> >>> > > > > Follow me:
> >>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >>> > > > > <https://github.com/tmedicci>
> >>> > > > >
> >>> > > >
> >>> > > >
> >>> > > > --
> >>> > > > *Felipe Moura de Oliveira*
> >>> > > > *Universidade Federal de Minas Gerais*
> >>> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >>> > > >
> >>> > >
> >>> > >
> >>> > > --
> >>> > > Tiago Medicci Serrano
> >>> > >
> >>> > > Embedded Software Engineer
> >>> > > MSc Electronics/Microelectronics
> >>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> >>> > > e: tiago.medicci@gmail.com
> >>> > > a: Campinas, Brazil
> >>> > > Follow me:
> >>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> >>> > > <https://github.com/tmedicci>
> >>> > >
> >>> >
> >>> >
> >>> > --
> >>> > *Felipe Moura de Oliveira*
> >>> > *Universidade Federal de Minas Gerais*
> >>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >>> >
> >>>
> >>
> >>
> >> --
> >> *Felipe Moura de Oliveira*
> >> *Universidade Federal de Minas Gerais*
> >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >>
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello Tiago,
I "finished" the port, but after it my esp32c6 dev kit is resetting. Maybe
the issue is related my changes in
boards/risc-v/esp32c6/common/scripts/esp32c6_sections.ld. Can you give some
tips about how to go ahead?
Below you can see nuttx report:
Build:Sep 19 2022
rst:0x7 (TG0_WDT_HPSYS),boot:0x7f (SPI_FAST_FLASH_BOOT)
Saved PC:0x40018bea
SPIWP:0xee
mode:DIO, clock div:2
load:0x40800000,len:0x61e0
load:0x408061e0,len:0xc34
load:0x50000000,len:0x20
load:0x5000001e,len:0x24
Invalid image block, can't boot.
ets_main.c 331
ESP-ROM:esp32c6-20220919
Em ter., 29 de out. de 2024 às 08:46, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello everyone,
>
> I was able to solve linker issues, editing the linker by myself. I need to
> finish more than one build issue before testing it, so I will see if I made
> the right changes in linker.
>
> Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
>> *Hello everyone, Tiago,*
>>
>> I have made progress with the build issue I was encountering and am now
>> "stuck" at what I believe is one of the final stages. I am experiencing the
>> following compilation error:
>> LD: nuttx
>> riscv-none-elf-ld: warning: /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
>> has a LOAD segment with RWX permissions
>> riscv-none-elf-ld: /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
>> libarch.a(sleep_modes.o): in function
>> `esp_set_deep_sleep_wake_stub_default_entry':
>> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
>> `_rtc_force_fast_end'
>> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined reference
>> to `_rtc_text_start'
>> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined reference
>> to `_rtc_force_fast_end'
>> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined reference
>> to `_rtc_text_start'
>> riscv-none-elf-ld:
>> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
>> in function `esp_sleep_cpu_retention':
>> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
>> `rv_core_critical_regs_save'
>> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined reference to
>> `rv_core_critical_regs_restore'
>> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined reference to
>> `rv_core_critical_regs_restore'
>> make[1]: *** [Makefile:189: nuttx] Error 1
>> make: *** [tools/Unix.mk:551: nuttx] Error 2
>>
>> I would greatly appreciate your assistance.
>>
>> Focusing on the item _rtc_text_start, I see that it is defined in the
>> file:
>> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
>> sections.ld.in
>>
>> However, I am unsure how to add this file to the complete linking
>> process. I added this file to hal_esp32c6.mk, but I received the
>> following error:
>> LD: nuttx
>> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
>> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
>> sections.ld.in.tmp:113 cannot move location counter backwards (from
>> 40809800 to 40800000)
>> make[1]: *** [Makefile:189: nuttx] Error 1
>> make: *** [tools/Unix.mk:551: nuttx] Error 2
>>
>>
>> Does anyone have any tips or suggestions that could help me move forward
>> with this process?
>>
>> Thank you in advance for your help.
>>
>> *Best regards,*
>>
>>
>> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
>> tiago.medicci@gmail.com> escreveu:
>>
>>> Hi Felipe,
>>>
>>> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute for
>>> this
>>> function should be part
>>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That being
>>> said, you can either implement it (and define it as a macro, on HAL) or
>>> you
>>> can either ignore these functions related to GPIO wakeup from sleep for
>>> now
>>> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if the
>>> GPIO
>>> wakeup isn't mandatory, it'd go baby steps, removing this feature for
>>> now.
>>>
>>> Best regards,
>>>
>>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
>>> moura.fmo@gmail.com> escreveu:
>>>
>>> > Hello Tiago,
>>> >
>>> > Thank you for your assistance earlier.
>>> >
>>> > I would like to discuss further the necessity of the
>>> > esp_driver_gpio/include/rtc_io.h file, which is only available in the
>>> IDF.
>>> >
>>> > In sleep_modes.c, there is the following code snippet:
>>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
>>> > esp_sleep_ext1_wakeup_mode_t level_mode)
>>> > {
>>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
>>> > return ESP_ERR_INVALID_ARG;
>>> > }
>>> > // Translate bit map of GPIO numbers into the bit map of RTC IO numbers
>>> > uint32_t rtc_gpio_mask = 0;
>>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
>>> > if ((io_mask & 1) == 0) {
>>> > continue;
>>> > }
>>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
>>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
>>> > return ESP_ERR_INVALID_ARG;
>>> > }
>>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
>>> > }
>>> >
>>> > I believe this code is essential for compilation. The function
>>> > rtc_io_number_get is located at the following path in the IDF:
>>> > components/esp_driver_gpio/include/driver/rtc_io.h.
>>> >
>>> > However, the esp_driver_gpio folder is not present in the 3rd-party
>>> > directory. In this case, what is the recommended procedure to proceed?
>>> >
>>> > Thank you again for your support.
>>> >
>>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
>>> > tiago.medicci@gmail.com> escreveu:
>>> >
>>> > > Hi Felipe,
>>> > >
>>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF,
>>> which
>>> > is
>>> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h`
>>> (here, a
>>> > > detail: I wasn't able to find this path on IDF, so make sure you are
>>> > > checking under the `release/v5.1` branch, which the HAL was based).
>>> The
>>> > HAL
>>> > > repository doesn't contain ESP-IDF drivers, which are always
>>> implemented
>>> > on
>>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
>>> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
>>> > >
>>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
>>> > > (`sleep_modes.c`, for instance) MAY be used to implement the driver.
>>> This
>>> > > is, mostly, a wrapping layer under the function of `esp_rom` and
>>> `hal`
>>> > > components. However, they still may refer to ESP-IDF drivers. That
>>> being
>>> > > said, you can check if removing such dependencies is possible. We
>>> usually
>>> > > do that with conditional macros. A good starting point is to check
>>> for
>>> > > `#ifdef __NuttX__` on these sources and headers: we use them to
>>> > remove/add
>>> > > headers and functions that aren't available on NuttX/needed by NuttX.
>>> > >
>>> > > Best regards,
>>> > >
>>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
>>> > > moura.fmo@gmail.com> escreveu:
>>> > >
>>> > > > Hello all,
>>> > > >
>>> > > > Tiago,
>>> > > >
>>> > > > I have a question regarding the porting process. Specifically, I
>>> need
>>> > to
>>> > > > add the sleep_modes.c file to the compilation process. Am I on the
>>> > right
>>> > > > path with this approach?
>>> > > >
>>> > > > To achieve this, I modified the hal_esp32c6.mk file by adding
>>> > > > sleep_modes.c.
>>> > > > However, I am facing some issues: within sleep_modes.c, some
>>> #include
>>> > > > statements reference files that are not available in the 3rd-party
>>> > > > directory but are only present in the IDF. For example:
>>> > > >
>>> > > > - esp_private/pm_impl.h
>>> > > > - esp_cpu.h
>>> > > > - components/esp_driver_gpio/include/rtc_io.h
>>> > > >
>>> > > > I need those includes because sleep_modes.c uses function from
>>> there.
>>> > > >
>>> > > > Could you please advise if it's possible to incorporate these IDF
>>> > folders
>>> > > > into the 3rd-party directory, or if that approach is not
>>> recommended?
>>> > > >
>>> > > > Thank you for your assistance.
>>> > > >
>>> > > > Best regards,
>>> > > >
>>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
>>> > > > tiago.medicci@gmail.com> escreveu:
>>> > > >
>>> > > > > Hi,
>>> > > > >
>>> > > > > Just another note to guide your development: we don't develop
>>> > anything
>>> > > on
>>> > > > > `esp-hal-3rdparty`: most of the code we use from it is derived
>>> from
>>> > the
>>> > > > > path
>>> > > > >
>>> > > > >
>>> > > >
>>> > >
>>> >
>>> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
>>> > > > > (essentially, header files from
>>> `components/hal/<chip>/include/hal`,
>>> > > > except
>>> > > > > for some of the sources files that use the hal functions at
>>> > > > > `components/hal` to implement some function we may use). You can
>>> > take a
>>> > > > > look at the branch `
>>> > > > >
>>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
>>> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>>> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>>> > > <
>>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>>> > > > <
>>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>>> > > > > <
>>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>>> > > > and
>>> > > > > especially the commits beginning
>>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind
>>> of
>>> > > > changes
>>> > > > > we do in hal. Essentially, we create a wrapper layer to make it
>>> > > > independent
>>> > > > > of the host OS.
>>> > > > >
>>> > > > > *Drivers must always be implemented on NuttX!*
>>> > > > >
>>> > > > > That being said, you can either 1) try to adapt the
>>> implementation of
>>> > > > other
>>> > > > > devices to use the HAL functions or 2) get some inspiration on
>>> how
>>> > IDF
>>> > > > > implements PM. I'd stick with the 2nd option before simply
>>> trying to
>>> > > > adapt
>>> > > > > an existing implementation (from ESP32-C3 legacy or from
>>> > > ESP32/ESP32-S3).
>>> > > > >
>>> > > > > Best regards,
>>> > > > >
>>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
>>> > > > > moura.fmo@gmail.com> escreveu:
>>> > > > >
>>> > > > > > Hello Tiago.
>>> > > > > >
>>> > > > > > Thank you for clarification, I will follow your instructions.
>>> > > > > >
>>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
>>> > > > > > tiago.medicci@gmail.com> escreveu:
>>> > > > > >
>>> > > > > > > Hi Felipe,
>>> > > > > > >
>>> > > > > > > Just complementing: use your forked version of the HAL
>>> during the
>>> > > > > > > development. As soon as you have a working version, you can
>>> > submit
>>> > > on
>>> > > > > the
>>> > > > > > > official repository.
>>> > > > > > >
>>> > > > > > > Best regards,
>>> > > > > > >
>>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
>>> > > > > > > tiago.medicci@gmail.com> escreveu:
>>> > > > > > >
>>> > > > > > > > Hi Felipe,
>>> > > > > > > >
>>> > > > > > > > Thanks for asking! You should follow the path using the
>>> > functions
>>> > > > on
>>> > > > > > > > esp-hal-3rdparty. You can fork the repository and use
>>> > > > > > > >
>>> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
>>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
>>> > > > tmedicci/esp-hal-3rdparty.git"`
>>> > > > > > env
>>> > > > > > > > vars (globally or before the make command) to use your
>>> version
>>> > of
>>> > > > the
>>> > > > > > > HAL.
>>> > > > > > > >
>>> > > > > > > > I just wanted to share some thoughts: using the HAL
>>> enables us
>>> > to
>>> > > > > make
>>> > > > > > > the
>>> > > > > > > > feature available for all the Espressif devices (please
>>> don't
>>> > > > bother
>>> > > > > > with
>>> > > > > > > > that now, as soon as you submit it, we can test for the
>>> other
>>> > > > devices
>>> > > > > > and
>>> > > > > > > > eventually make any adjustments). Although it's possible to
>>> > > > > reimplement
>>> > > > > > > > these functions on NuttX, we don't recommend that because
>>> of
>>> > the
>>> > > > > first
>>> > > > > > > > statement (the ability to use for the other devices): in
>>> that
>>> > > case
>>> > > > we
>>> > > > > > > > wouldn't be able to support the feature. You can take a
>>> look on
>>> > > IDF
>>> > > > > for
>>> > > > > > > > some inspiration on how it's implemented.
>>> > > > > > > >
>>> > > > > > > > Please let me know if you have any questions.
>>> > > > > > > >
>>> > > > > > > > Best regards,
>>> > > > > > > >
>>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura
>>> Oliveira <
>>> > > > > > > > moura.fmo@gmail.com> escreveu:
>>> > > > > > > >
>>> > > > > > > >> Hello everyone,
>>> > > > > > > >>
>>> > > > > > > >> Our project has reached a point where we need the Power
>>> > Manager
>>> > > > > > > >> functionality, which is not yet available in the ESP32C6.
>>> I am
>>> > > > > > studying
>>> > > > > > > to
>>> > > > > > > >> start the implementation, but I am confused about the
>>> correct
>>> > > way
>>> > > > to
>>> > > > > > > >> approach this.
>>> > > > > > > >>
>>> > > > > > > >> There is a Power Manager implementation for the ESP32C3,
>>> but
>>> > it
>>> > > > > seems
>>> > > > > > to
>>> > > > > > > >> follow the legacy methodology. In fact, the file
>>> > esp32c3_idle.c
>>> > > is
>>> > > > > > > located
>>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
>>> > methodology,
>>> > > > > > > functions
>>> > > > > > > >> are re-implemented from the Espressif driver. For
>>> example, the
>>> > > > > > function
>>> > > > > > > >> esp32c3_light_sleep_start(), which is currently available
>>> in
>>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
>>> > > > > > > >>
>>> > > > > > > >> I tried using the implementations from esp-hal-3rdparty to
>>> > > develop
>>> > > > > the
>>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files
>>> still
>>> > have
>>> > > > > many
>>> > > > > > > >> dependencies on items that are not present in NuttX.
>>> > > > > > > >>
>>> > > > > > > >> My question is: Should I try to make the Power Manager
>>> work
>>> > > using
>>> > > > > the
>>> > > > > > > >> functions in esp-hal-3rdparty, even if it requires making
>>> > > changes
>>> > > > to
>>> > > > > > the
>>> > > > > > > >> 3rd-party code? Or should I re-implement the functions
>>> within
>>> > > > NuttX,
>>> > > > > > > even
>>> > > > > > > >> if, in this case, there are functions with the same scope
>>> and
>>> > > > > > > >> implementation in different files, where one is compiled,
>>> and
>>> > > the
>>> > > > > > other
>>> > > > > > > is
>>> > > > > > > >> not?
>>> > > > > > > >>
>>> > > > > > > >>
>>> > > > > > > >> --
>>> > > > > > > >> *Felipe Moura de Oliveira*
>>> > > > > > > >> *Universidade Federal de Minas Gerais*
>>> > > > > > > >> Linkedin <
>>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>>> > > > > > > >>
>>> > > > > > > >
>>> > > > > > > >
>>> > > > > > > > --
>>> > > > > > > > Tiago Medicci Serrano
>>> > > > > > > >
>>> > > > > > > > Embedded Software Engineer
>>> > > > > > > > MSc Electronics/Microelectronics
>>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>>> > > > > > > > e: tiago.medicci@gmail.com
>>> > > > > > > > a: Campinas, Brazil
>>> > > > > > > > Follow me:
>>> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>>> > > > > > > > <https://github.com/tmedicci>
>>> > > > > > > >
>>> > > > > > >
>>> > > > > > >
>>> > > > > > > --
>>> > > > > > > Tiago Medicci Serrano
>>> > > > > > >
>>> > > > > > > Embedded Software Engineer
>>> > > > > > > MSc Electronics/Microelectronics
>>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>>> > > > > > > e: tiago.medicci@gmail.com
>>> > > > > > > a: Campinas, Brazil
>>> > > > > > > Follow me:
>>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>>> > > > > > > <https://github.com/tmedicci>
>>> > > > > > >
>>> > > > > >
>>> > > > > >
>>> > > > > > --
>>> > > > > > *Felipe Moura de Oliveira*
>>> > > > > > *Universidade Federal de Minas Gerais*
>>> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0
>>> >
>>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>>> > > > > >
>>> > > > >
>>> > > > >
>>> > > > > --
>>> > > > > Tiago Medicci Serrano
>>> > > > >
>>> > > > > Embedded Software Engineer
>>> > > > > MSc Electronics/Microelectronics
>>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>>> > > > > e: tiago.medicci@gmail.com
>>> > > > > a: Campinas, Brazil
>>> > > > > Follow me:
>>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>>> > > > > <https://github.com/tmedicci>
>>> > > > >
>>> > > >
>>> > > >
>>> > > > --
>>> > > > *Felipe Moura de Oliveira*
>>> > > > *Universidade Federal de Minas Gerais*
>>> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>>> > > >
>>> > >
>>> > >
>>> > > --
>>> > > Tiago Medicci Serrano
>>> > >
>>> > > Embedded Software Engineer
>>> > > MSc Electronics/Microelectronics
>>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
>>> > > e: tiago.medicci@gmail.com
>>> > > a: Campinas, Brazil
>>> > > Follow me:
>>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>>> > > <https://github.com/tmedicci>
>>> > >
>>> >
>>> >
>>> > --
>>> > *Felipe Moura de Oliveira*
>>> > *Universidade Federal de Minas Gerais*
>>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>>> >
>>>
>>
>>
>> --
>> *Felipe Moura de Oliveira*
>> *Universidade Federal de Minas Gerais*
>> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>>
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello everyone,
I was able to solve linker issues, editing the linker by myself. I need to
finish more than one build issue before testing it, so I will see if I made
the right changes in linker.
Em seg., 28 de out. de 2024 às 16:01, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> *Hello everyone, Tiago,*
>
> I have made progress with the build issue I was encountering and am now
> "stuck" at what I believe is one of the final stages. I am experiencing the
> following compilation error:
> LD: nuttx
> riscv-none-elf-ld: warning: /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
> has a LOAD segment with RWX permissions
> riscv-none-elf-ld: /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
> libarch.a(sleep_modes.o): in function
> `esp_set_deep_sleep_wake_stub_default_entry':
> sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
> `_rtc_force_fast_end'
> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined reference
> to `_rtc_text_start'
> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined reference to
> `_rtc_force_fast_end'
> riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined reference
> to `_rtc_text_start'
> riscv-none-elf-ld:
> /home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
> in function `esp_sleep_cpu_retention':
> sleep_cpu.c:(.iram1.8+0x200): undefined reference to
> `rv_core_critical_regs_save'
> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined reference to
> `rv_core_critical_regs_restore'
> riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined reference to
> `rv_core_critical_regs_restore'
> make[1]: *** [Makefile:189: nuttx] Error 1
> make: *** [tools/Unix.mk:551: nuttx] Error 2
>
> I would greatly appreciate your assistance.
>
> Focusing on the item _rtc_text_start, I see that it is defined in the
> file:
> arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> sections.ld.in
>
> However, I am unsure how to add this file to the complete linking process.
> I added this file to hal_esp32c6.mk, but I received the following error:
> LD: nuttx
> riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/
> src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
> sections.ld.in.tmp:113 cannot move location counter backwards (from
> 40809800 to 40800000)
> make[1]: *** [Makefile:189: nuttx] Error 1
> make: *** [tools/Unix.mk:551: nuttx] Error 2
>
>
> Does anyone have any tips or suggestions that could help me move forward
> with this process?
>
> Thank you in advance for your help.
>
> *Best regards,*
>
>
> Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
>> Hi Felipe,
>>
>> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute for this
>> function should be part
>> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That being
>> said, you can either implement it (and define it as a macro, on HAL) or
>> you
>> can either ignore these functions related to GPIO wakeup from sleep for
>> now
>> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if the
>> GPIO
>> wakeup isn't mandatory, it'd go baby steps, removing this feature for now.
>>
>> Best regards,
>>
>> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
>> moura.fmo@gmail.com> escreveu:
>>
>> > Hello Tiago,
>> >
>> > Thank you for your assistance earlier.
>> >
>> > I would like to discuss further the necessity of the
>> > esp_driver_gpio/include/rtc_io.h file, which is only available in the
>> IDF.
>> >
>> > In sleep_modes.c, there is the following code snippet:
>> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
>> > esp_sleep_ext1_wakeup_mode_t level_mode)
>> > {
>> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
>> > return ESP_ERR_INVALID_ARG;
>> > }
>> > // Translate bit map of GPIO numbers into the bit map of RTC IO numbers
>> > uint32_t rtc_gpio_mask = 0;
>> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
>> > if ((io_mask & 1) == 0) {
>> > continue;
>> > }
>> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
>> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
>> > return ESP_ERR_INVALID_ARG;
>> > }
>> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
>> > }
>> >
>> > I believe this code is essential for compilation. The function
>> > rtc_io_number_get is located at the following path in the IDF:
>> > components/esp_driver_gpio/include/driver/rtc_io.h.
>> >
>> > However, the esp_driver_gpio folder is not present in the 3rd-party
>> > directory. In this case, what is the recommended procedure to proceed?
>> >
>> > Thank you again for your support.
>> >
>> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
>> > tiago.medicci@gmail.com> escreveu:
>> >
>> > > Hi Felipe,
>> > >
>> > > `esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF,
>> which
>> > is
>> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h` (here,
>> a
>> > > detail: I wasn't able to find this path on IDF, so make sure you are
>> > > checking under the `release/v5.1` branch, which the HAL was based).
>> The
>> > HAL
>> > > repository doesn't contain ESP-IDF drivers, which are always
>> implemented
>> > on
>> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
>> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
>> > >
>> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
>> > > (`sleep_modes.c`, for instance) MAY be used to implement the driver.
>> This
>> > > is, mostly, a wrapping layer under the function of `esp_rom` and `hal`
>> > > components. However, they still may refer to ESP-IDF drivers. That
>> being
>> > > said, you can check if removing such dependencies is possible. We
>> usually
>> > > do that with conditional macros. A good starting point is to check for
>> > > `#ifdef __NuttX__` on these sources and headers: we use them to
>> > remove/add
>> > > headers and functions that aren't available on NuttX/needed by NuttX.
>> > >
>> > > Best regards,
>> > >
>> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
>> > > moura.fmo@gmail.com> escreveu:
>> > >
>> > > > Hello all,
>> > > >
>> > > > Tiago,
>> > > >
>> > > > I have a question regarding the porting process. Specifically, I
>> need
>> > to
>> > > > add the sleep_modes.c file to the compilation process. Am I on the
>> > right
>> > > > path with this approach?
>> > > >
>> > > > To achieve this, I modified the hal_esp32c6.mk file by adding
>> > > > sleep_modes.c.
>> > > > However, I am facing some issues: within sleep_modes.c, some
>> #include
>> > > > statements reference files that are not available in the 3rd-party
>> > > > directory but are only present in the IDF. For example:
>> > > >
>> > > > - esp_private/pm_impl.h
>> > > > - esp_cpu.h
>> > > > - components/esp_driver_gpio/include/rtc_io.h
>> > > >
>> > > > I need those includes because sleep_modes.c uses function from
>> there.
>> > > >
>> > > > Could you please advise if it's possible to incorporate these IDF
>> > folders
>> > > > into the 3rd-party directory, or if that approach is not
>> recommended?
>> > > >
>> > > > Thank you for your assistance.
>> > > >
>> > > > Best regards,
>> > > >
>> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
>> > > > tiago.medicci@gmail.com> escreveu:
>> > > >
>> > > > > Hi,
>> > > > >
>> > > > > Just another note to guide your development: we don't develop
>> > anything
>> > > on
>> > > > > `esp-hal-3rdparty`: most of the code we use from it is derived
>> from
>> > the
>> > > > > path
>> > > > >
>> > > > >
>> > > >
>> > >
>> >
>> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
>> > > > > (essentially, header files from
>> `components/hal/<chip>/include/hal`,
>> > > > except
>> > > > > for some of the sources files that use the hal functions at
>> > > > > `components/hal` to implement some function we may use). You can
>> > take a
>> > > > > look at the branch `
>> > > > >
>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
>> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c
>> >
>> > > > <
>> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > > > > <
>> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
>> > > > and
>> > > > > especially the commits beginning
>> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of
>> > > > changes
>> > > > > we do in hal. Essentially, we create a wrapper layer to make it
>> > > > independent
>> > > > > of the host OS.
>> > > > >
>> > > > > *Drivers must always be implemented on NuttX!*
>> > > > >
>> > > > > That being said, you can either 1) try to adapt the
>> implementation of
>> > > > other
>> > > > > devices to use the HAL functions or 2) get some inspiration on how
>> > IDF
>> > > > > implements PM. I'd stick with the 2nd option before simply trying
>> to
>> > > > adapt
>> > > > > an existing implementation (from ESP32-C3 legacy or from
>> > > ESP32/ESP32-S3).
>> > > > >
>> > > > > Best regards,
>> > > > >
>> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
>> > > > > moura.fmo@gmail.com> escreveu:
>> > > > >
>> > > > > > Hello Tiago.
>> > > > > >
>> > > > > > Thank you for clarification, I will follow your instructions.
>> > > > > >
>> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
>> > > > > > tiago.medicci@gmail.com> escreveu:
>> > > > > >
>> > > > > > > Hi Felipe,
>> > > > > > >
>> > > > > > > Just complementing: use your forked version of the HAL during
>> the
>> > > > > > > development. As soon as you have a working version, you can
>> > submit
>> > > on
>> > > > > the
>> > > > > > > official repository.
>> > > > > > >
>> > > > > > > Best regards,
>> > > > > > >
>> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
>> > > > > > > tiago.medicci@gmail.com> escreveu:
>> > > > > > >
>> > > > > > > > Hi Felipe,
>> > > > > > > >
>> > > > > > > > Thanks for asking! You should follow the path using the
>> > functions
>> > > > on
>> > > > > > > > esp-hal-3rdparty. You can fork the repository and use
>> > > > > > > >
>> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
>> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
>> > > > tmedicci/esp-hal-3rdparty.git"`
>> > > > > > env
>> > > > > > > > vars (globally or before the make command) to use your
>> version
>> > of
>> > > > the
>> > > > > > > HAL.
>> > > > > > > >
>> > > > > > > > I just wanted to share some thoughts: using the HAL enables
>> us
>> > to
>> > > > > make
>> > > > > > > the
>> > > > > > > > feature available for all the Espressif devices (please
>> don't
>> > > > bother
>> > > > > > with
>> > > > > > > > that now, as soon as you submit it, we can test for the
>> other
>> > > > devices
>> > > > > > and
>> > > > > > > > eventually make any adjustments). Although it's possible to
>> > > > > reimplement
>> > > > > > > > these functions on NuttX, we don't recommend that because of
>> > the
>> > > > > first
>> > > > > > > > statement (the ability to use for the other devices): in
>> that
>> > > case
>> > > > we
>> > > > > > > > wouldn't be able to support the feature. You can take a
>> look on
>> > > IDF
>> > > > > for
>> > > > > > > > some inspiration on how it's implemented.
>> > > > > > > >
>> > > > > > > > Please let me know if you have any questions.
>> > > > > > > >
>> > > > > > > > Best regards,
>> > > > > > > >
>> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira
>> <
>> > > > > > > > moura.fmo@gmail.com> escreveu:
>> > > > > > > >
>> > > > > > > >> Hello everyone,
>> > > > > > > >>
>> > > > > > > >> Our project has reached a point where we need the Power
>> > Manager
>> > > > > > > >> functionality, which is not yet available in the ESP32C6.
>> I am
>> > > > > > studying
>> > > > > > > to
>> > > > > > > >> start the implementation, but I am confused about the
>> correct
>> > > way
>> > > > to
>> > > > > > > >> approach this.
>> > > > > > > >>
>> > > > > > > >> There is a Power Manager implementation for the ESP32C3,
>> but
>> > it
>> > > > > seems
>> > > > > > to
>> > > > > > > >> follow the legacy methodology. In fact, the file
>> > esp32c3_idle.c
>> > > is
>> > > > > > > located
>> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
>> > methodology,
>> > > > > > > functions
>> > > > > > > >> are re-implemented from the Espressif driver. For example,
>> the
>> > > > > > function
>> > > > > > > >> esp32c3_light_sleep_start(), which is currently available
>> in
>> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
>> > > > > > > >>
>> > > > > > > >> I tried using the implementations from esp-hal-3rdparty to
>> > > develop
>> > > > > the
>> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files still
>> > have
>> > > > > many
>> > > > > > > >> dependencies on items that are not present in NuttX.
>> > > > > > > >>
>> > > > > > > >> My question is: Should I try to make the Power Manager work
>> > > using
>> > > > > the
>> > > > > > > >> functions in esp-hal-3rdparty, even if it requires making
>> > > changes
>> > > > to
>> > > > > > the
>> > > > > > > >> 3rd-party code? Or should I re-implement the functions
>> within
>> > > > NuttX,
>> > > > > > > even
>> > > > > > > >> if, in this case, there are functions with the same scope
>> and
>> > > > > > > >> implementation in different files, where one is compiled,
>> and
>> > > the
>> > > > > > other
>> > > > > > > is
>> > > > > > > >> not?
>> > > > > > > >>
>> > > > > > > >>
>> > > > > > > >> --
>> > > > > > > >> *Felipe Moura de Oliveira*
>> > > > > > > >> *Universidade Federal de Minas Gerais*
>> > > > > > > >> Linkedin <
>> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > > > > > > >>
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > --
>> > > > > > > > Tiago Medicci Serrano
>> > > > > > > >
>> > > > > > > > Embedded Software Engineer
>> > > > > > > > MSc Electronics/Microelectronics
>> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > > > > > > > e: tiago.medicci@gmail.com
>> > > > > > > > a: Campinas, Brazil
>> > > > > > > > Follow me:
>> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > > > > > > > <https://github.com/tmedicci>
>> > > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > > > --
>> > > > > > > Tiago Medicci Serrano
>> > > > > > >
>> > > > > > > Embedded Software Engineer
>> > > > > > > MSc Electronics/Microelectronics
>> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > > > > > > e: tiago.medicci@gmail.com
>> > > > > > > a: Campinas, Brazil
>> > > > > > > Follow me:
>> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > > > > > > <https://github.com/tmedicci>
>> > > > > > >
>> > > > > >
>> > > > > >
>> > > > > > --
>> > > > > > *Felipe Moura de Oliveira*
>> > > > > > *Universidade Federal de Minas Gerais*
>> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > > > > >
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Tiago Medicci Serrano
>> > > > >
>> > > > > Embedded Software Engineer
>> > > > > MSc Electronics/Microelectronics
>> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > > > > e: tiago.medicci@gmail.com
>> > > > > a: Campinas, Brazil
>> > > > > Follow me:
>> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > > > > <https://github.com/tmedicci>
>> > > > >
>> > > >
>> > > >
>> > > > --
>> > > > *Felipe Moura de Oliveira*
>> > > > *Universidade Federal de Minas Gerais*
>> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> > > >
>> > >
>> > >
>> > > --
>> > > Tiago Medicci Serrano
>> > >
>> > > Embedded Software Engineer
>> > > MSc Electronics/Microelectronics
>> > > m: +55 (19) 981403886 <+55+(19)+981403886>
>> > > e: tiago.medicci@gmail.com
>> > > a: Campinas, Brazil
>> > > Follow me:
>> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
>> > > <https://github.com/tmedicci>
>> > >
>> >
>> >
>> > --
>> > *Felipe Moura de Oliveira*
>> > *Universidade Federal de Minas Gerais*
>> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
>> >
>>
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
*Hello everyone, Tiago,*
I have made progress with the build issue I was encountering and am now
"stuck" at what I believe is one of the final stages. I am experiencing the
following compilation error:
LD: nuttx
riscv-none-elf-ld: warning: /home/felipe-moura/nuttxspace/nuttx-felipe/nuttx
has a LOAD segment with RWX permissions
riscv-none-elf-ld: /home/felipe-moura/nuttxspace/nuttx-felipe/staging/
libarch.a(sleep_modes.o): in function
`esp_set_deep_sleep_wake_stub_default_entry':
sleep_modes.c:(.rtc.text.4+0x0): undefined reference to
`_rtc_force_fast_end'
riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x4): undefined reference to
`_rtc_text_start'
riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0x8): undefined reference to
`_rtc_force_fast_end'
riscv-none-elf-ld: sleep_modes.c:(.rtc.text.4+0xc): undefined reference to
`_rtc_text_start'
riscv-none-elf-ld:
/home/felipe-moura/nuttxspace/nuttx-felipe/staging/libarch.a(sleep_cpu.o):
in function `esp_sleep_cpu_retention':
sleep_cpu.c:(.iram1.8+0x200): undefined reference to
`rv_core_critical_regs_save'
riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x21e): undefined reference to
`rv_core_critical_regs_restore'
riscv-none-elf-ld: sleep_cpu.c:(.iram1.8+0x226): undefined reference to
`rv_core_critical_regs_restore'
make[1]: *** [Makefile:189: nuttx] Error 1
make: *** [tools/Unix.mk:551: nuttx] Error 2
I would greatly appreciate your assistance.
Focusing on the item _rtc_text_start, I see that it is defined in the file:
arch/risc-v/src/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/
sections.ld.in
However, I am unsure how to add this file to the complete linking process.
I added this file to hal_esp32c6.mk, but I received the following error:
LD: nuttx
riscv-none-elf-ld:/home/felipe-moura/nuttxspace/nuttx-felipe/arch/risc-v/src
/chip/esp-hal-3rdparty/components/esp_system/ld/esp32c6/sections.ld.in.tmp:
113 cannot move location counter backwards (from 40809800 to 40800000)
make[1]: *** [Makefile:189: nuttx] Error 1
make: *** [tools/Unix.mk:551: nuttx] Error 2
Does anyone have any tips or suggestions that could help me move forward
with this process?
Thank you in advance for your help.
*Best regards,*
Em sex., 25 de out. de 2024 às 12:02, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi Felipe,
>
> The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute for this
> function should be part
> of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That being
> said, you can either implement it (and define it as a macro, on HAL) or you
> can either ignore these functions related to GPIO wakeup from sleep for now
> (using, for instance, the `#ifndef __NuttX__`). It's up to you: if the GPIO
> wakeup isn't mandatory, it'd go baby steps, removing this feature for now.
>
> Best regards,
>
> Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello Tiago,
> >
> > Thank you for your assistance earlier.
> >
> > I would like to discuss further the necessity of the
> > esp_driver_gpio/include/rtc_io.h file, which is only available in the
> IDF.
> >
> > In sleep_modes.c, there is the following code snippet:
> > esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> > esp_sleep_ext1_wakeup_mode_t level_mode)
> > {
> > if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> > return ESP_ERR_INVALID_ARG;
> > }
> > // Translate bit map of GPIO numbers into the bit map of RTC IO numbers
> > uint32_t rtc_gpio_mask = 0;
> > for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> > if ((io_mask & 1) == 0) {
> > continue;
> > }
> > if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> > ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> > return ESP_ERR_INVALID_ARG;
> > }
> > rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> > }
> >
> > I believe this code is essential for compilation. The function
> > rtc_io_number_get is located at the following path in the IDF:
> > components/esp_driver_gpio/include/driver/rtc_io.h.
> >
> > However, the esp_driver_gpio folder is not present in the 3rd-party
> > directory. In this case, what is the recommended procedure to proceed?
> >
> > Thank you again for your support.
> >
> > Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
> > tiago.medicci@gmail.com> escreveu:
> >
> > > Hi Felipe,
> > >
> > > `esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF,
> which
> > is
> > > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h` (here, a
> > > detail: I wasn't able to find this path on IDF, so make sure you are
> > > checking under the `release/v5.1` branch, which the HAL was based). The
> > HAL
> > > repository doesn't contain ESP-IDF drivers, which are always
> implemented
> > on
> > > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> > >
> > > The files under `esp-hal-3rdparty/components/esp_hw_support`
> > > (`sleep_modes.c`, for instance) MAY be used to implement the driver.
> This
> > > is, mostly, a wrapping layer under the function of `esp_rom` and `hal`
> > > components. However, they still may refer to ESP-IDF drivers. That
> being
> > > said, you can check if removing such dependencies is possible. We
> usually
> > > do that with conditional macros. A good starting point is to check for
> > > `#ifdef __NuttX__` on these sources and headers: we use them to
> > remove/add
> > > headers and functions that aren't available on NuttX/needed by NuttX.
> > >
> > > Best regards,
> > >
> > > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
> > > moura.fmo@gmail.com> escreveu:
> > >
> > > > Hello all,
> > > >
> > > > Tiago,
> > > >
> > > > I have a question regarding the porting process. Specifically, I need
> > to
> > > > add the sleep_modes.c file to the compilation process. Am I on the
> > right
> > > > path with this approach?
> > > >
> > > > To achieve this, I modified the hal_esp32c6.mk file by adding
> > > > sleep_modes.c.
> > > > However, I am facing some issues: within sleep_modes.c, some #include
> > > > statements reference files that are not available in the 3rd-party
> > > > directory but are only present in the IDF. For example:
> > > >
> > > > - esp_private/pm_impl.h
> > > > - esp_cpu.h
> > > > - components/esp_driver_gpio/include/rtc_io.h
> > > >
> > > > I need those includes because sleep_modes.c uses function from there.
> > > >
> > > > Could you please advise if it's possible to incorporate these IDF
> > folders
> > > > into the 3rd-party directory, or if that approach is not recommended?
> > > >
> > > > Thank you for your assistance.
> > > >
> > > > Best regards,
> > > >
> > > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
> > > > tiago.medicci@gmail.com> escreveu:
> > > >
> > > > > Hi,
> > > > >
> > > > > Just another note to guide your development: we don't develop
> > anything
> > > on
> > > > > `esp-hal-3rdparty`: most of the code we use from it is derived from
> > the
> > > > > path
> > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > > (essentially, header files from
> `components/hal/<chip>/include/hal`,
> > > > except
> > > > > for some of the sources files that use the hal functions at
> > > > > `components/hal` to implement some function we may use). You can
> > take a
> > > > > look at the branch `
> > > > >
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > > <
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > and
> > > > > especially the commits beginning
> > > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of
> > > > changes
> > > > > we do in hal. Essentially, we create a wrapper layer to make it
> > > > independent
> > > > > of the host OS.
> > > > >
> > > > > *Drivers must always be implemented on NuttX!*
> > > > >
> > > > > That being said, you can either 1) try to adapt the implementation
> of
> > > > other
> > > > > devices to use the HAL functions or 2) get some inspiration on how
> > IDF
> > > > > implements PM. I'd stick with the 2nd option before simply trying
> to
> > > > adapt
> > > > > an existing implementation (from ESP32-C3 legacy or from
> > > ESP32/ESP32-S3).
> > > > >
> > > > > Best regards,
> > > > >
> > > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> > > > > moura.fmo@gmail.com> escreveu:
> > > > >
> > > > > > Hello Tiago.
> > > > > >
> > > > > > Thank you for clarification, I will follow your instructions.
> > > > > >
> > > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > >
> > > > > > > Hi Felipe,
> > > > > > >
> > > > > > > Just complementing: use your forked version of the HAL during
> the
> > > > > > > development. As soon as you have a working version, you can
> > submit
> > > on
> > > > > the
> > > > > > > official repository.
> > > > > > >
> > > > > > > Best regards,
> > > > > > >
> > > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> > > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > > >
> > > > > > > > Hi Felipe,
> > > > > > > >
> > > > > > > > Thanks for asking! You should follow the path using the
> > functions
> > > > on
> > > > > > > > esp-hal-3rdparty. You can fork the repository and use
> > > > > > > >
> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > > tmedicci/esp-hal-3rdparty.git"`
> > > > > > env
> > > > > > > > vars (globally or before the make command) to use your
> version
> > of
> > > > the
> > > > > > > HAL.
> > > > > > > >
> > > > > > > > I just wanted to share some thoughts: using the HAL enables
> us
> > to
> > > > > make
> > > > > > > the
> > > > > > > > feature available for all the Espressif devices (please don't
> > > > bother
> > > > > > with
> > > > > > > > that now, as soon as you submit it, we can test for the other
> > > > devices
> > > > > > and
> > > > > > > > eventually make any adjustments). Although it's possible to
> > > > > reimplement
> > > > > > > > these functions on NuttX, we don't recommend that because of
> > the
> > > > > first
> > > > > > > > statement (the ability to use for the other devices): in that
> > > case
> > > > we
> > > > > > > > wouldn't be able to support the feature. You can take a look
> on
> > > IDF
> > > > > for
> > > > > > > > some inspiration on how it's implemented.
> > > > > > > >
> > > > > > > > Please let me know if you have any questions.
> > > > > > > >
> > > > > > > > Best regards,
> > > > > > > >
> > > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > > >
> > > > > > > >> Hello everyone,
> > > > > > > >>
> > > > > > > >> Our project has reached a point where we need the Power
> > Manager
> > > > > > > >> functionality, which is not yet available in the ESP32C6. I
> am
> > > > > > studying
> > > > > > > to
> > > > > > > >> start the implementation, but I am confused about the
> correct
> > > way
> > > > to
> > > > > > > >> approach this.
> > > > > > > >>
> > > > > > > >> There is a Power Manager implementation for the ESP32C3, but
> > it
> > > > > seems
> > > > > > to
> > > > > > > >> follow the legacy methodology. In fact, the file
> > esp32c3_idle.c
> > > is
> > > > > > > located
> > > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
> > methodology,
> > > > > > > functions
> > > > > > > >> are re-implemented from the Espressif driver. For example,
> the
> > > > > > function
> > > > > > > >> esp32c3_light_sleep_start(), which is currently available in
> > > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > > >>
> > > > > > > >> I tried using the implementations from esp-hal-3rdparty to
> > > develop
> > > > > the
> > > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files still
> > have
> > > > > many
> > > > > > > >> dependencies on items that are not present in NuttX.
> > > > > > > >>
> > > > > > > >> My question is: Should I try to make the Power Manager work
> > > using
> > > > > the
> > > > > > > >> functions in esp-hal-3rdparty, even if it requires making
> > > changes
> > > > to
> > > > > > the
> > > > > > > >> 3rd-party code? Or should I re-implement the functions
> within
> > > > NuttX,
> > > > > > > even
> > > > > > > >> if, in this case, there are functions with the same scope
> and
> > > > > > > >> implementation in different files, where one is compiled,
> and
> > > the
> > > > > > other
> > > > > > > is
> > > > > > > >> not?
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> --
> > > > > > > >> *Felipe Moura de Oliveira*
> > > > > > > >> *Universidade Federal de Minas Gerais*
> > > > > > > >> Linkedin <
> > https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Tiago Medicci Serrano
> > > > > > > >
> > > > > > > > Embedded Software Engineer
> > > > > > > > MSc Electronics/Microelectronics
> > > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > > e: tiago.medicci@gmail.com
> > > > > > > > a: Campinas, Brazil
> > > > > > > > Follow me:
> > > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > > > > <https://github.com/tmedicci>
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Tiago Medicci Serrano
> > > > > > >
> > > > > > > Embedded Software Engineer
> > > > > > > MSc Electronics/Microelectronics
> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > a: Campinas, Brazil
> > > > > > > Follow me:
> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > > > <https://github.com/tmedicci>
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *Felipe Moura de Oliveira*
> > > > > > *Universidade Federal de Minas Gerais*
> > > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Tiago Medicci Serrano
> > > > >
> > > > > Embedded Software Engineer
> > > > > MSc Electronics/Microelectronics
> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > e: tiago.medicci@gmail.com
> > > > > a: Campinas, Brazil
> > > > > Follow me:
> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > <https://github.com/tmedicci>
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> > >
> > > --
> > > Tiago Medicci Serrano
> > >
> > > Embedded Software Engineer
> > > MSc Electronics/Microelectronics
> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > e: tiago.medicci@gmail.com
> > > a: Campinas, Brazil
> > > Follow me:
> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > <https://github.com/tmedicci>
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi Felipe,
The RTC GPIO is a feature of the GPIO/RTC driver, so a substitute for this
function should be part
of `nuttx/arch/risc-v/src/common/espressif/esp_rtc_gpio.c`. That being
said, you can either implement it (and define it as a macro, on HAL) or you
can either ignore these functions related to GPIO wakeup from sleep for now
(using, for instance, the `#ifndef __NuttX__`). It's up to you: if the GPIO
wakeup isn't mandatory, it'd go baby steps, removing this feature for now.
Best regards,
Em sex., 25 de out. de 2024 às 09:33, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello Tiago,
>
> Thank you for your assistance earlier.
>
> I would like to discuss further the necessity of the
> esp_driver_gpio/include/rtc_io.h file, which is only available in the IDF.
>
> In sleep_modes.c, there is the following code snippet:
> esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
> esp_sleep_ext1_wakeup_mode_t level_mode)
> {
> if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
> return ESP_ERR_INVALID_ARG;
> }
> // Translate bit map of GPIO numbers into the bit map of RTC IO numbers
> uint32_t rtc_gpio_mask = 0;
> for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
> if ((io_mask & 1) == 0) {
> continue;
> }
> if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
> ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
> return ESP_ERR_INVALID_ARG;
> }
> rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
> }
>
> I believe this code is essential for compilation. The function
> rtc_io_number_get is located at the following path in the IDF:
> components/esp_driver_gpio/include/driver/rtc_io.h.
>
> However, the esp_driver_gpio folder is not present in the 3rd-party
> directory. In this case, what is the recommended procedure to proceed?
>
> Thank you again for your support.
>
> Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
> > Hi Felipe,
> >
> > `esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF, which
> is
> > a driver directly. Same for `esp_driver_gpio/include/rtc_io.h` (here, a
> > detail: I wasn't able to find this path on IDF, so make sure you are
> > checking under the `release/v5.1` branch, which the HAL was based). The
> HAL
> > repository doesn't contain ESP-IDF drivers, which are always implemented
> on
> > NuttX. For `esp_cpu.h`, it's already on HAL (at
> > `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
> >
> > The files under `esp-hal-3rdparty/components/esp_hw_support`
> > (`sleep_modes.c`, for instance) MAY be used to implement the driver. This
> > is, mostly, a wrapping layer under the function of `esp_rom` and `hal`
> > components. However, they still may refer to ESP-IDF drivers. That being
> > said, you can check if removing such dependencies is possible. We usually
> > do that with conditional macros. A good starting point is to check for
> > `#ifdef __NuttX__` on these sources and headers: we use them to
> remove/add
> > headers and functions that aren't available on NuttX/needed by NuttX.
> >
> > Best regards,
> >
> > Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> > > Hello all,
> > >
> > > Tiago,
> > >
> > > I have a question regarding the porting process. Specifically, I need
> to
> > > add the sleep_modes.c file to the compilation process. Am I on the
> right
> > > path with this approach?
> > >
> > > To achieve this, I modified the hal_esp32c6.mk file by adding
> > > sleep_modes.c.
> > > However, I am facing some issues: within sleep_modes.c, some #include
> > > statements reference files that are not available in the 3rd-party
> > > directory but are only present in the IDF. For example:
> > >
> > > - esp_private/pm_impl.h
> > > - esp_cpu.h
> > > - components/esp_driver_gpio/include/rtc_io.h
> > >
> > > I need those includes because sleep_modes.c uses function from there.
> > >
> > > Could you please advise if it's possible to incorporate these IDF
> folders
> > > into the 3rd-party directory, or if that approach is not recommended?
> > >
> > > Thank you for your assistance.
> > >
> > > Best regards,
> > >
> > > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
> > > tiago.medicci@gmail.com> escreveu:
> > >
> > > > Hi,
> > > >
> > > > Just another note to guide your development: we don't develop
> anything
> > on
> > > > `esp-hal-3rdparty`: most of the code we use from it is derived from
> the
> > > > path
> > > >
> > > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > > (essentially, header files from `components/hal/<chip>/include/hal`,
> > > except
> > > > for some of the sources files that use the hal functions at
> > > > `components/hal` to implement some function we may use). You can
> take a
> > > > look at the branch `
> > > >
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > > <
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > and
> > > > especially the commits beginning
> > > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of
> > > changes
> > > > we do in hal. Essentially, we create a wrapper layer to make it
> > > independent
> > > > of the host OS.
> > > >
> > > > *Drivers must always be implemented on NuttX!*
> > > >
> > > > That being said, you can either 1) try to adapt the implementation of
> > > other
> > > > devices to use the HAL functions or 2) get some inspiration on how
> IDF
> > > > implements PM. I'd stick with the 2nd option before simply trying to
> > > adapt
> > > > an existing implementation (from ESP32-C3 legacy or from
> > ESP32/ESP32-S3).
> > > >
> > > > Best regards,
> > > >
> > > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> > > > moura.fmo@gmail.com> escreveu:
> > > >
> > > > > Hello Tiago.
> > > > >
> > > > > Thank you for clarification, I will follow your instructions.
> > > > >
> > > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> > > > > tiago.medicci@gmail.com> escreveu:
> > > > >
> > > > > > Hi Felipe,
> > > > > >
> > > > > > Just complementing: use your forked version of the HAL during the
> > > > > > development. As soon as you have a working version, you can
> submit
> > on
> > > > the
> > > > > > official repository.
> > > > > >
> > > > > > Best regards,
> > > > > >
> > > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> > > > > > tiago.medicci@gmail.com> escreveu:
> > > > > >
> > > > > > > Hi Felipe,
> > > > > > >
> > > > > > > Thanks for asking! You should follow the path using the
> functions
> > > on
> > > > > > > esp-hal-3rdparty. You can fork the repository and use
> > > > > > >
> > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > > tmedicci/esp-hal-3rdparty.git"`
> > > > > env
> > > > > > > vars (globally or before the make command) to use your version
> of
> > > the
> > > > > > HAL.
> > > > > > >
> > > > > > > I just wanted to share some thoughts: using the HAL enables us
> to
> > > > make
> > > > > > the
> > > > > > > feature available for all the Espressif devices (please don't
> > > bother
> > > > > with
> > > > > > > that now, as soon as you submit it, we can test for the other
> > > devices
> > > > > and
> > > > > > > eventually make any adjustments). Although it's possible to
> > > > reimplement
> > > > > > > these functions on NuttX, we don't recommend that because of
> the
> > > > first
> > > > > > > statement (the ability to use for the other devices): in that
> > case
> > > we
> > > > > > > wouldn't be able to support the feature. You can take a look on
> > IDF
> > > > for
> > > > > > > some inspiration on how it's implemented.
> > > > > > >
> > > > > > > Please let me know if you have any questions.
> > > > > > >
> > > > > > > Best regards,
> > > > > > >
> > > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > > > > > > moura.fmo@gmail.com> escreveu:
> > > > > > >
> > > > > > >> Hello everyone,
> > > > > > >>
> > > > > > >> Our project has reached a point where we need the Power
> Manager
> > > > > > >> functionality, which is not yet available in the ESP32C6. I am
> > > > > studying
> > > > > > to
> > > > > > >> start the implementation, but I am confused about the correct
> > way
> > > to
> > > > > > >> approach this.
> > > > > > >>
> > > > > > >> There is a Power Manager implementation for the ESP32C3, but
> it
> > > > seems
> > > > > to
> > > > > > >> follow the legacy methodology. In fact, the file
> esp32c3_idle.c
> > is
> > > > > > located
> > > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this
> methodology,
> > > > > > functions
> > > > > > >> are re-implemented from the Espressif driver. For example, the
> > > > > function
> > > > > > >> esp32c3_light_sleep_start(), which is currently available in
> > > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > > >>
> > > > > > >> I tried using the implementations from esp-hal-3rdparty to
> > develop
> > > > the
> > > > > > >> Power Manager for the ESP32C6 in NuttX, but the files still
> have
> > > > many
> > > > > > >> dependencies on items that are not present in NuttX.
> > > > > > >>
> > > > > > >> My question is: Should I try to make the Power Manager work
> > using
> > > > the
> > > > > > >> functions in esp-hal-3rdparty, even if it requires making
> > changes
> > > to
> > > > > the
> > > > > > >> 3rd-party code? Or should I re-implement the functions within
> > > NuttX,
> > > > > > even
> > > > > > >> if, in this case, there are functions with the same scope and
> > > > > > >> implementation in different files, where one is compiled, and
> > the
> > > > > other
> > > > > > is
> > > > > > >> not?
> > > > > > >>
> > > > > > >>
> > > > > > >> --
> > > > > > >> *Felipe Moura de Oliveira*
> > > > > > >> *Universidade Federal de Minas Gerais*
> > > > > > >> Linkedin <
> https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Tiago Medicci Serrano
> > > > > > >
> > > > > > > Embedded Software Engineer
> > > > > > > MSc Electronics/Microelectronics
> > > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > > e: tiago.medicci@gmail.com
> > > > > > > a: Campinas, Brazil
> > > > > > > Follow me:
> > > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > > > <https://github.com/tmedicci>
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Tiago Medicci Serrano
> > > > > >
> > > > > > Embedded Software Engineer
> > > > > > MSc Electronics/Microelectronics
> > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > e: tiago.medicci@gmail.com
> > > > > > a: Campinas, Brazil
> > > > > > Follow me:
> > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > > <https://github.com/tmedicci>
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Felipe Moura de Oliveira*
> > > > > *Universidade Federal de Minas Gerais*
> > > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >
> > > >
> > > >
> > > > --
> > > > Tiago Medicci Serrano
> > > >
> > > > Embedded Software Engineer
> > > > MSc Electronics/Microelectronics
> > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > e: tiago.medicci@gmail.com
> > > > a: Campinas, Brazil
> > > > Follow me:
> > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > <https://github.com/tmedicci>
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
> >
> > --
> > Tiago Medicci Serrano
> >
> > Embedded Software Engineer
> > MSc Electronics/Microelectronics
> > m: +55 (19) 981403886 <+55+(19)+981403886>
> > e: tiago.medicci@gmail.com
> > a: Campinas, Brazil
> > Follow me:
> > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > <https://github.com/tmedicci>
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello Tiago,
Thank you for your assistance earlier.
I would like to discuss further the necessity of the
esp_driver_gpio/include/rtc_io.h file, which is only available in the IDF.
In sleep_modes.c, there is the following code snippet:
esp_err_t esp_sleep_enable_ext1_wakeup_io(uint64_t io_mask,
esp_sleep_ext1_wakeup_mode_t level_mode)
{
if (io_mask == 0 && level_mode > ESP_EXT1_WAKEUP_ANY_HIGH) {
return ESP_ERR_INVALID_ARG;
}
// Translate bit map of GPIO numbers into the bit map of RTC IO numbers
uint32_t rtc_gpio_mask = 0;
for (int gpio = 0; io_mask; ++gpio, io_mask >>= 1) {
if ((io_mask & 1) == 0) {
continue;
}
if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
return ESP_ERR_INVALID_ARG;
}
rtc_gpio_mask |= BIT(rtc_io_number_get(gpio));
}
I believe this code is essential for compilation. The function
rtc_io_number_get is located at the following path in the IDF:
components/esp_driver_gpio/include/driver/rtc_io.h.
However, the esp_driver_gpio folder is not present in the 3rd-party
directory. In this case, what is the recommended procedure to proceed?
Thank you again for your support.
Em sex., 25 de out. de 2024 às 08:52, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi Felipe,
>
> `esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF, which is
> a driver directly. Same for `esp_driver_gpio/include/rtc_io.h` (here, a
> detail: I wasn't able to find this path on IDF, so make sure you are
> checking under the `release/v5.1` branch, which the HAL was based). The HAL
> repository doesn't contain ESP-IDF drivers, which are always implemented on
> NuttX. For `esp_cpu.h`, it's already on HAL (at
> `esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
>
> The files under `esp-hal-3rdparty/components/esp_hw_support`
> (`sleep_modes.c`, for instance) MAY be used to implement the driver. This
> is, mostly, a wrapping layer under the function of `esp_rom` and `hal`
> components. However, they still may refer to ESP-IDF drivers. That being
> said, you can check if removing such dependencies is possible. We usually
> do that with conditional macros. A good starting point is to check for
> `#ifdef __NuttX__` on these sources and headers: we use them to remove/add
> headers and functions that aren't available on NuttX/needed by NuttX.
>
> Best regards,
>
> Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello all,
> >
> > Tiago,
> >
> > I have a question regarding the porting process. Specifically, I need to
> > add the sleep_modes.c file to the compilation process. Am I on the right
> > path with this approach?
> >
> > To achieve this, I modified the hal_esp32c6.mk file by adding
> > sleep_modes.c.
> > However, I am facing some issues: within sleep_modes.c, some #include
> > statements reference files that are not available in the 3rd-party
> > directory but are only present in the IDF. For example:
> >
> > - esp_private/pm_impl.h
> > - esp_cpu.h
> > - components/esp_driver_gpio/include/rtc_io.h
> >
> > I need those includes because sleep_modes.c uses function from there.
> >
> > Could you please advise if it's possible to incorporate these IDF folders
> > into the 3rd-party directory, or if that approach is not recommended?
> >
> > Thank you for your assistance.
> >
> > Best regards,
> >
> > Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
> > tiago.medicci@gmail.com> escreveu:
> >
> > > Hi,
> > >
> > > Just another note to guide your development: we don't develop anything
> on
> > > `esp-hal-3rdparty`: most of the code we use from it is derived from the
> > > path
> > >
> > >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > > (essentially, header files from `components/hal/<chip>/include/hal`,
> > except
> > > for some of the sources files that use the hal functions at
> > > `components/hal` to implement some function we may use). You can take a
> > > look at the branch `
> > > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > and
> > > especially the commits beginning
> > > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of
> > changes
> > > we do in hal. Essentially, we create a wrapper layer to make it
> > independent
> > > of the host OS.
> > >
> > > *Drivers must always be implemented on NuttX!*
> > >
> > > That being said, you can either 1) try to adapt the implementation of
> > other
> > > devices to use the HAL functions or 2) get some inspiration on how IDF
> > > implements PM. I'd stick with the 2nd option before simply trying to
> > adapt
> > > an existing implementation (from ESP32-C3 legacy or from
> ESP32/ESP32-S3).
> > >
> > > Best regards,
> > >
> > > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> > > moura.fmo@gmail.com> escreveu:
> > >
> > > > Hello Tiago.
> > > >
> > > > Thank you for clarification, I will follow your instructions.
> > > >
> > > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> > > > tiago.medicci@gmail.com> escreveu:
> > > >
> > > > > Hi Felipe,
> > > > >
> > > > > Just complementing: use your forked version of the HAL during the
> > > > > development. As soon as you have a working version, you can submit
> on
> > > the
> > > > > official repository.
> > > > >
> > > > > Best regards,
> > > > >
> > > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> > > > > tiago.medicci@gmail.com> escreveu:
> > > > >
> > > > > > Hi Felipe,
> > > > > >
> > > > > > Thanks for asking! You should follow the path using the functions
> > on
> > > > > > esp-hal-3rdparty. You can fork the repository and use
> > > > > >
> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> > tmedicci/esp-hal-3rdparty.git"`
> > > > env
> > > > > > vars (globally or before the make command) to use your version of
> > the
> > > > > HAL.
> > > > > >
> > > > > > I just wanted to share some thoughts: using the HAL enables us to
> > > make
> > > > > the
> > > > > > feature available for all the Espressif devices (please don't
> > bother
> > > > with
> > > > > > that now, as soon as you submit it, we can test for the other
> > devices
> > > > and
> > > > > > eventually make any adjustments). Although it's possible to
> > > reimplement
> > > > > > these functions on NuttX, we don't recommend that because of the
> > > first
> > > > > > statement (the ability to use for the other devices): in that
> case
> > we
> > > > > > wouldn't be able to support the feature. You can take a look on
> IDF
> > > for
> > > > > > some inspiration on how it's implemented.
> > > > > >
> > > > > > Please let me know if you have any questions.
> > > > > >
> > > > > > Best regards,
> > > > > >
> > > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > > > > > moura.fmo@gmail.com> escreveu:
> > > > > >
> > > > > >> Hello everyone,
> > > > > >>
> > > > > >> Our project has reached a point where we need the Power Manager
> > > > > >> functionality, which is not yet available in the ESP32C6. I am
> > > > studying
> > > > > to
> > > > > >> start the implementation, but I am confused about the correct
> way
> > to
> > > > > >> approach this.
> > > > > >>
> > > > > >> There is a Power Manager implementation for the ESP32C3, but it
> > > seems
> > > > to
> > > > > >> follow the legacy methodology. In fact, the file esp32c3_idle.c
> is
> > > > > located
> > > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this methodology,
> > > > > functions
> > > > > >> are re-implemented from the Espressif driver. For example, the
> > > > function
> > > > > >> esp32c3_light_sleep_start(), which is currently available in
> > > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > > >>
> > > > > >> I tried using the implementations from esp-hal-3rdparty to
> develop
> > > the
> > > > > >> Power Manager for the ESP32C6 in NuttX, but the files still have
> > > many
> > > > > >> dependencies on items that are not present in NuttX.
> > > > > >>
> > > > > >> My question is: Should I try to make the Power Manager work
> using
> > > the
> > > > > >> functions in esp-hal-3rdparty, even if it requires making
> changes
> > to
> > > > the
> > > > > >> 3rd-party code? Or should I re-implement the functions within
> > NuttX,
> > > > > even
> > > > > >> if, in this case, there are functions with the same scope and
> > > > > >> implementation in different files, where one is compiled, and
> the
> > > > other
> > > > > is
> > > > > >> not?
> > > > > >>
> > > > > >>
> > > > > >> --
> > > > > >> *Felipe Moura de Oliveira*
> > > > > >> *Universidade Federal de Minas Gerais*
> > > > > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > > >>
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Tiago Medicci Serrano
> > > > > >
> > > > > > Embedded Software Engineer
> > > > > > MSc Electronics/Microelectronics
> > > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > > e: tiago.medicci@gmail.com
> > > > > > a: Campinas, Brazil
> > > > > > Follow me:
> > > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > > <https://github.com/tmedicci>
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Tiago Medicci Serrano
> > > > >
> > > > > Embedded Software Engineer
> > > > > MSc Electronics/Microelectronics
> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > e: tiago.medicci@gmail.com
> > > > > a: Campinas, Brazil
> > > > > Follow me:
> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > <https://github.com/tmedicci>
> > > > >
> > > >
> > > >
> > > > --
> > > > *Felipe Moura de Oliveira*
> > > > *Universidade Federal de Minas Gerais*
> > > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >
> > >
> > >
> > > --
> > > Tiago Medicci Serrano
> > >
> > > Embedded Software Engineer
> > > MSc Electronics/Microelectronics
> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > e: tiago.medicci@gmail.com
> > > a: Campinas, Brazil
> > > Follow me:
> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > <https://github.com/tmedicci>
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
>
> --
> Tiago Medicci Serrano
>
> Embedded Software Engineer
> MSc Electronics/Microelectronics
> m: +55 (19) 981403886 <+55+(19)+981403886>
> e: tiago.medicci@gmail.com
> a: Campinas, Brazil
> Follow me:
> <https://www.linkedin.com/in/tiago-serrano-924458b6>
> <https://github.com/tmedicci>
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi Felipe,
`esp_private/pm_impl.h` is from the component `esp_pm` of ESP-IDF, which is
a driver directly. Same for `esp_driver_gpio/include/rtc_io.h` (here, a
detail: I wasn't able to find this path on IDF, so make sure you are
checking under the `release/v5.1` branch, which the HAL was based). The HAL
repository doesn't contain ESP-IDF drivers, which are always implemented on
NuttX. For `esp_cpu.h`, it's already on HAL (at
`esp-hal-3rdparty/components/esp_hw_support/include/esp_cpu.h`).
The files under `esp-hal-3rdparty/components/esp_hw_support`
(`sleep_modes.c`, for instance) MAY be used to implement the driver. This
is, mostly, a wrapping layer under the function of `esp_rom` and `hal`
components. However, they still may refer to ESP-IDF drivers. That being
said, you can check if removing such dependencies is possible. We usually
do that with conditional macros. A good starting point is to check for
`#ifdef __NuttX__` on these sources and headers: we use them to remove/add
headers and functions that aren't available on NuttX/needed by NuttX.
Best regards,
Em qui., 24 de out. de 2024 às 19:46, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello all,
>
> Tiago,
>
> I have a question regarding the porting process. Specifically, I need to
> add the sleep_modes.c file to the compilation process. Am I on the right
> path with this approach?
>
> To achieve this, I modified the hal_esp32c6.mk file by adding
> sleep_modes.c.
> However, I am facing some issues: within sleep_modes.c, some #include
> statements reference files that are not available in the 3rd-party
> directory but are only present in the IDF. For example:
>
> - esp_private/pm_impl.h
> - esp_cpu.h
> - components/esp_driver_gpio/include/rtc_io.h
>
> I need those includes because sleep_modes.c uses function from there.
>
> Could you please advise if it's possible to incorporate these IDF folders
> into the 3rd-party directory, or if that approach is not recommended?
>
> Thank you for your assistance.
>
> Best regards,
>
> Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
> > Hi,
> >
> > Just another note to guide your development: we don't develop anything on
> > `esp-hal-3rdparty`: most of the code we use from it is derived from the
> > path
> >
> >
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> > (essentially, header files from `components/hal/<chip>/include/hal`,
> except
> > for some of the sources files that use the hal functions at
> > `components/hal` to implement some function we may use). You can take a
> > look at the branch `
> > https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> > <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c>
> and
> > especially the commits beginning
> > with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of
> changes
> > we do in hal. Essentially, we create a wrapper layer to make it
> independent
> > of the host OS.
> >
> > *Drivers must always be implemented on NuttX!*
> >
> > That being said, you can either 1) try to adapt the implementation of
> other
> > devices to use the HAL functions or 2) get some inspiration on how IDF
> > implements PM. I'd stick with the 2nd option before simply trying to
> adapt
> > an existing implementation (from ESP32-C3 legacy or from ESP32/ESP32-S3).
> >
> > Best regards,
> >
> > Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> > > Hello Tiago.
> > >
> > > Thank you for clarification, I will follow your instructions.
> > >
> > > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> > > tiago.medicci@gmail.com> escreveu:
> > >
> > > > Hi Felipe,
> > > >
> > > > Just complementing: use your forked version of the HAL during the
> > > > development. As soon as you have a working version, you can submit on
> > the
> > > > official repository.
> > > >
> > > > Best regards,
> > > >
> > > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> > > > tiago.medicci@gmail.com> escreveu:
> > > >
> > > > > Hi Felipe,
> > > > >
> > > > > Thanks for asking! You should follow the path using the functions
> on
> > > > > esp-hal-3rdparty. You can fork the repository and use
> > > > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > > ESP_HAL_3RDPARTY_URL="git@github.com:
> tmedicci/esp-hal-3rdparty.git"`
> > > env
> > > > > vars (globally or before the make command) to use your version of
> the
> > > > HAL.
> > > > >
> > > > > I just wanted to share some thoughts: using the HAL enables us to
> > make
> > > > the
> > > > > feature available for all the Espressif devices (please don't
> bother
> > > with
> > > > > that now, as soon as you submit it, we can test for the other
> devices
> > > and
> > > > > eventually make any adjustments). Although it's possible to
> > reimplement
> > > > > these functions on NuttX, we don't recommend that because of the
> > first
> > > > > statement (the ability to use for the other devices): in that case
> we
> > > > > wouldn't be able to support the feature. You can take a look on IDF
> > for
> > > > > some inspiration on how it's implemented.
> > > > >
> > > > > Please let me know if you have any questions.
> > > > >
> > > > > Best regards,
> > > > >
> > > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > > > > moura.fmo@gmail.com> escreveu:
> > > > >
> > > > >> Hello everyone,
> > > > >>
> > > > >> Our project has reached a point where we need the Power Manager
> > > > >> functionality, which is not yet available in the ESP32C6. I am
> > > studying
> > > > to
> > > > >> start the implementation, but I am confused about the correct way
> to
> > > > >> approach this.
> > > > >>
> > > > >> There is a Power Manager implementation for the ESP32C3, but it
> > seems
> > > to
> > > > >> follow the legacy methodology. In fact, the file esp32c3_idle.c is
> > > > located
> > > > >> in the path arch/risc-v/src/esp32c3-legacy. In this methodology,
> > > > functions
> > > > >> are re-implemented from the Espressif driver. For example, the
> > > function
> > > > >> esp32c3_light_sleep_start(), which is currently available in
> > > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > > >>
> > > > >> I tried using the implementations from esp-hal-3rdparty to develop
> > the
> > > > >> Power Manager for the ESP32C6 in NuttX, but the files still have
> > many
> > > > >> dependencies on items that are not present in NuttX.
> > > > >>
> > > > >> My question is: Should I try to make the Power Manager work using
> > the
> > > > >> functions in esp-hal-3rdparty, even if it requires making changes
> to
> > > the
> > > > >> 3rd-party code? Or should I re-implement the functions within
> NuttX,
> > > > even
> > > > >> if, in this case, there are functions with the same scope and
> > > > >> implementation in different files, where one is compiled, and the
> > > other
> > > > is
> > > > >> not?
> > > > >>
> > > > >>
> > > > >> --
> > > > >> *Felipe Moura de Oliveira*
> > > > >> *Universidade Federal de Minas Gerais*
> > > > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Tiago Medicci Serrano
> > > > >
> > > > > Embedded Software Engineer
> > > > > MSc Electronics/Microelectronics
> > > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > > e: tiago.medicci@gmail.com
> > > > > a: Campinas, Brazil
> > > > > Follow me:
> > > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > > <https://github.com/tmedicci>
> > > > >
> > > >
> > > >
> > > > --
> > > > Tiago Medicci Serrano
> > > >
> > > > Embedded Software Engineer
> > > > MSc Electronics/Microelectronics
> > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > e: tiago.medicci@gmail.com
> > > > a: Campinas, Brazil
> > > > Follow me:
> > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > <https://github.com/tmedicci>
> > > >
> > >
> > >
> > > --
> > > *Felipe Moura de Oliveira*
> > > *Universidade Federal de Minas Gerais*
> > > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >
> >
> >
> > --
> > Tiago Medicci Serrano
> >
> > Embedded Software Engineer
> > MSc Electronics/Microelectronics
> > m: +55 (19) 981403886 <+55+(19)+981403886>
> > e: tiago.medicci@gmail.com
> > a: Campinas, Brazil
> > Follow me:
> > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > <https://github.com/tmedicci>
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
--
Tiago Medicci Serrano
Embedded Software Engineer
MSc Electronics/Microelectronics
m: +55 (19) 981403886 <+55+(19)+981403886>
e: tiago.medicci@gmail.com
a: Campinas, Brazil
Follow me:
<https://www.linkedin.com/in/tiago-serrano-924458b6>
<https://github.com/tmedicci>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello all,
Tiago,
I have a question regarding the porting process. Specifically, I need to
add the sleep_modes.c file to the compilation process. Am I on the right
path with this approach?
To achieve this, I modified the hal_esp32c6.mk file by adding sleep_modes.c.
However, I am facing some issues: within sleep_modes.c, some #include
statements reference files that are not available in the 3rd-party
directory but are only present in the IDF. For example:
- esp_private/pm_impl.h
- esp_cpu.h
- components/esp_driver_gpio/include/rtc_io.h
I need those includes because sleep_modes.c uses function from there.
Could you please advise if it's possible to incorporate these IDF folders
into the 3rd-party directory, or if that approach is not recommended?
Thank you for your assistance.
Best regards,
Em qua., 23 de out. de 2024 às 15:21, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi,
>
> Just another note to guide your development: we don't develop anything on
> `esp-hal-3rdparty`: most of the code we use from it is derived from the
> path
>
> https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
> (essentially, header files from `components/hal/<chip>/include/hal`, except
> for some of the sources files that use the hal functions at
> `components/hal` to implement some function we may use). You can take a
> look at the branch `
> https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c`
> <https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c> and
> especially the commits beginning
> with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of changes
> we do in hal. Essentially, we create a wrapper layer to make it independent
> of the host OS.
>
> *Drivers must always be implemented on NuttX!*
>
> That being said, you can either 1) try to adapt the implementation of other
> devices to use the HAL functions or 2) get some inspiration on how IDF
> implements PM. I'd stick with the 2nd option before simply trying to adapt
> an existing implementation (from ESP32-C3 legacy or from ESP32/ESP32-S3).
>
> Best regards,
>
> Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
> > Hello Tiago.
> >
> > Thank you for clarification, I will follow your instructions.
> >
> > Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> > tiago.medicci@gmail.com> escreveu:
> >
> > > Hi Felipe,
> > >
> > > Just complementing: use your forked version of the HAL during the
> > > development. As soon as you have a working version, you can submit on
> the
> > > official repository.
> > >
> > > Best regards,
> > >
> > > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> > > tiago.medicci@gmail.com> escreveu:
> > >
> > > > Hi Felipe,
> > > >
> > > > Thanks for asking! You should follow the path using the functions on
> > > > esp-hal-3rdparty. You can fork the repository and use
> > > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > > ESP_HAL_3RDPARTY_URL="git@github.com:tmedicci/esp-hal-3rdparty.git"`
> > env
> > > > vars (globally or before the make command) to use your version of the
> > > HAL.
> > > >
> > > > I just wanted to share some thoughts: using the HAL enables us to
> make
> > > the
> > > > feature available for all the Espressif devices (please don't bother
> > with
> > > > that now, as soon as you submit it, we can test for the other devices
> > and
> > > > eventually make any adjustments). Although it's possible to
> reimplement
> > > > these functions on NuttX, we don't recommend that because of the
> first
> > > > statement (the ability to use for the other devices): in that case we
> > > > wouldn't be able to support the feature. You can take a look on IDF
> for
> > > > some inspiration on how it's implemented.
> > > >
> > > > Please let me know if you have any questions.
> > > >
> > > > Best regards,
> > > >
> > > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > > > moura.fmo@gmail.com> escreveu:
> > > >
> > > >> Hello everyone,
> > > >>
> > > >> Our project has reached a point where we need the Power Manager
> > > >> functionality, which is not yet available in the ESP32C6. I am
> > studying
> > > to
> > > >> start the implementation, but I am confused about the correct way to
> > > >> approach this.
> > > >>
> > > >> There is a Power Manager implementation for the ESP32C3, but it
> seems
> > to
> > > >> follow the legacy methodology. In fact, the file esp32c3_idle.c is
> > > located
> > > >> in the path arch/risc-v/src/esp32c3-legacy. In this methodology,
> > > functions
> > > >> are re-implemented from the Espressif driver. For example, the
> > function
> > > >> esp32c3_light_sleep_start(), which is currently available in
> > > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > > >>
> > > >> I tried using the implementations from esp-hal-3rdparty to develop
> the
> > > >> Power Manager for the ESP32C6 in NuttX, but the files still have
> many
> > > >> dependencies on items that are not present in NuttX.
> > > >>
> > > >> My question is: Should I try to make the Power Manager work using
> the
> > > >> functions in esp-hal-3rdparty, even if it requires making changes to
> > the
> > > >> 3rd-party code? Or should I re-implement the functions within NuttX,
> > > even
> > > >> if, in this case, there are functions with the same scope and
> > > >> implementation in different files, where one is compiled, and the
> > other
> > > is
> > > >> not?
> > > >>
> > > >>
> > > >> --
> > > >> *Felipe Moura de Oliveira*
> > > >> *Universidade Federal de Minas Gerais*
> > > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > > >>
> > > >
> > > >
> > > > --
> > > > Tiago Medicci Serrano
> > > >
> > > > Embedded Software Engineer
> > > > MSc Electronics/Microelectronics
> > > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > > e: tiago.medicci@gmail.com
> > > > a: Campinas, Brazil
> > > > Follow me:
> > > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > > <https://github.com/tmedicci>
> > > >
> > >
> > >
> > > --
> > > Tiago Medicci Serrano
> > >
> > > Embedded Software Engineer
> > > MSc Electronics/Microelectronics
> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > e: tiago.medicci@gmail.com
> > > a: Campinas, Brazil
> > > Follow me:
> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > <https://github.com/tmedicci>
> > >
> >
> >
> > --
> > *Felipe Moura de Oliveira*
> > *Universidade Federal de Minas Gerais*
> > Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >
>
>
> --
> Tiago Medicci Serrano
>
> Embedded Software Engineer
> MSc Electronics/Microelectronics
> m: +55 (19) 981403886 <+55+(19)+981403886>
> e: tiago.medicci@gmail.com
> a: Campinas, Brazil
> Follow me:
> <https://www.linkedin.com/in/tiago-serrano-924458b6>
> <https://github.com/tmedicci>
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi,
Just another note to guide your development: we don't develop anything on
`esp-hal-3rdparty`: most of the code we use from it is derived from the
path
https://github.com/espressif/esp-hal-3rdparty/tree/release/v5.1.c/components/hal
(essentially, header files from `components/hal/<chip>/include/hal`, except
for some of the sources files that use the hal functions at
`components/hal` to implement some function we may use). You can take a
look at the branch `
https://github.com/espressif/esp-hal-3rdparty/commits/release/v5.1.c` and
especially the commits beginning
with faaa46ebfb37fba4250de831efbbf2862958c344 to check the kind of changes
we do in hal. Essentially, we create a wrapper layer to make it independent
of the host OS.
*Drivers must always be implemented on NuttX!*
That being said, you can either 1) try to adapt the implementation of other
devices to use the HAL functions or 2) get some inspiration on how IDF
implements PM. I'd stick with the 2nd option before simply trying to adapt
an existing implementation (from ESP32-C3 legacy or from ESP32/ESP32-S3).
Best regards,
Em qua., 23 de out. de 2024 às 13:35, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello Tiago.
>
> Thank you for clarification, I will follow your instructions.
>
> Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
> > Hi Felipe,
> >
> > Just complementing: use your forked version of the HAL during the
> > development. As soon as you have a working version, you can submit on the
> > official repository.
> >
> > Best regards,
> >
> > Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> > tiago.medicci@gmail.com> escreveu:
> >
> > > Hi Felipe,
> > >
> > > Thanks for asking! You should follow the path using the functions on
> > > esp-hal-3rdparty. You can fork the repository and use
> > > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > > ESP_HAL_3RDPARTY_URL="git@github.com:tmedicci/esp-hal-3rdparty.git"`
> env
> > > vars (globally or before the make command) to use your version of the
> > HAL.
> > >
> > > I just wanted to share some thoughts: using the HAL enables us to make
> > the
> > > feature available for all the Espressif devices (please don't bother
> with
> > > that now, as soon as you submit it, we can test for the other devices
> and
> > > eventually make any adjustments). Although it's possible to reimplement
> > > these functions on NuttX, we don't recommend that because of the first
> > > statement (the ability to use for the other devices): in that case we
> > > wouldn't be able to support the feature. You can take a look on IDF for
> > > some inspiration on how it's implemented.
> > >
> > > Please let me know if you have any questions.
> > >
> > > Best regards,
> > >
> > > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > > moura.fmo@gmail.com> escreveu:
> > >
> > >> Hello everyone,
> > >>
> > >> Our project has reached a point where we need the Power Manager
> > >> functionality, which is not yet available in the ESP32C6. I am
> studying
> > to
> > >> start the implementation, but I am confused about the correct way to
> > >> approach this.
> > >>
> > >> There is a Power Manager implementation for the ESP32C3, but it seems
> to
> > >> follow the legacy methodology. In fact, the file esp32c3_idle.c is
> > located
> > >> in the path arch/risc-v/src/esp32c3-legacy. In this methodology,
> > functions
> > >> are re-implemented from the Espressif driver. For example, the
> function
> > >> esp32c3_light_sleep_start(), which is currently available in
> > >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> > >>
> > >> I tried using the implementations from esp-hal-3rdparty to develop the
> > >> Power Manager for the ESP32C6 in NuttX, but the files still have many
> > >> dependencies on items that are not present in NuttX.
> > >>
> > >> My question is: Should I try to make the Power Manager work using the
> > >> functions in esp-hal-3rdparty, even if it requires making changes to
> the
> > >> 3rd-party code? Or should I re-implement the functions within NuttX,
> > even
> > >> if, in this case, there are functions with the same scope and
> > >> implementation in different files, where one is compiled, and the
> other
> > is
> > >> not?
> > >>
> > >>
> > >> --
> > >> *Felipe Moura de Oliveira*
> > >> *Universidade Federal de Minas Gerais*
> > >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> > >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> > >>
> > >
> > >
> > > --
> > > Tiago Medicci Serrano
> > >
> > > Embedded Software Engineer
> > > MSc Electronics/Microelectronics
> > > m: +55 (19) 981403886 <+55+(19)+981403886>
> > > e: tiago.medicci@gmail.com
> > > a: Campinas, Brazil
> > > Follow me:
> > > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > > <https://github.com/tmedicci>
> > >
> >
> >
> > --
> > Tiago Medicci Serrano
> >
> > Embedded Software Engineer
> > MSc Electronics/Microelectronics
> > m: +55 (19) 981403886 <+55+(19)+981403886>
> > e: tiago.medicci@gmail.com
> > a: Campinas, Brazil
> > Follow me:
> > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > <https://github.com/tmedicci>
> >
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
--
Tiago Medicci Serrano
Embedded Software Engineer
MSc Electronics/Microelectronics
m: +55 (19) 981403886 <+55+(19)+981403886>
e: tiago.medicci@gmail.com
a: Campinas, Brazil
Follow me:
<https://www.linkedin.com/in/tiago-serrano-924458b6>
<https://github.com/tmedicci>
Re: What is the right way to add PM to esp32c6
Posted by Felipe Moura Oliveira <mo...@gmail.com>.
Hello Tiago.
Thank you for clarification, I will follow your instructions.
Em qua., 23 de out. de 2024 às 13:01, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi Felipe,
>
> Just complementing: use your forked version of the HAL during the
> development. As soon as you have a working version, you can submit on the
> official repository.
>
> Best regards,
>
> Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
> tiago.medicci@gmail.com> escreveu:
>
> > Hi Felipe,
> >
> > Thanks for asking! You should follow the path using the functions on
> > esp-hal-3rdparty. You can fork the repository and use
> > `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> > ESP_HAL_3RDPARTY_URL="git@github.com:tmedicci/esp-hal-3rdparty.git"` env
> > vars (globally or before the make command) to use your version of the
> HAL.
> >
> > I just wanted to share some thoughts: using the HAL enables us to make
> the
> > feature available for all the Espressif devices (please don't bother with
> > that now, as soon as you submit it, we can test for the other devices and
> > eventually make any adjustments). Although it's possible to reimplement
> > these functions on NuttX, we don't recommend that because of the first
> > statement (the ability to use for the other devices): in that case we
> > wouldn't be able to support the feature. You can take a look on IDF for
> > some inspiration on how it's implemented.
> >
> > Please let me know if you have any questions.
> >
> > Best regards,
> >
> > Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> > moura.fmo@gmail.com> escreveu:
> >
> >> Hello everyone,
> >>
> >> Our project has reached a point where we need the Power Manager
> >> functionality, which is not yet available in the ESP32C6. I am studying
> to
> >> start the implementation, but I am confused about the correct way to
> >> approach this.
> >>
> >> There is a Power Manager implementation for the ESP32C3, but it seems to
> >> follow the legacy methodology. In fact, the file esp32c3_idle.c is
> located
> >> in the path arch/risc-v/src/esp32c3-legacy. In this methodology,
> functions
> >> are re-implemented from the Espressif driver. For example, the function
> >> esp32c3_light_sleep_start(), which is currently available in
> >> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
> >>
> >> I tried using the implementations from esp-hal-3rdparty to develop the
> >> Power Manager for the ESP32C6 in NuttX, but the files still have many
> >> dependencies on items that are not present in NuttX.
> >>
> >> My question is: Should I try to make the Power Manager work using the
> >> functions in esp-hal-3rdparty, even if it requires making changes to the
> >> 3rd-party code? Or should I re-implement the functions within NuttX,
> even
> >> if, in this case, there are functions with the same scope and
> >> implementation in different files, where one is compiled, and the other
> is
> >> not?
> >>
> >>
> >> --
> >> *Felipe Moura de Oliveira*
> >> *Universidade Federal de Minas Gerais*
> >> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> >> <https://twitter.com/FelipeMOliveir?lang=pt-br>
> >>
> >
> >
> > --
> > Tiago Medicci Serrano
> >
> > Embedded Software Engineer
> > MSc Electronics/Microelectronics
> > m: +55 (19) 981403886 <+55+(19)+981403886>
> > e: tiago.medicci@gmail.com
> > a: Campinas, Brazil
> > Follow me:
> > <https://www.linkedin.com/in/tiago-serrano-924458b6>
> > <https://github.com/tmedicci>
> >
>
>
> --
> Tiago Medicci Serrano
>
> Embedded Software Engineer
> MSc Electronics/Microelectronics
> m: +55 (19) 981403886 <+55+(19)+981403886>
> e: tiago.medicci@gmail.com
> a: Campinas, Brazil
> Follow me:
> <https://www.linkedin.com/in/tiago-serrano-924458b6>
> <https://github.com/tmedicci>
>
--
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi Felipe,
Just complementing: use your forked version of the HAL during the
development. As soon as you have a working version, you can submit on the
official repository.
Best regards,
Em qua., 23 de out. de 2024 às 12:58, Tiago Medicci Serrano <
tiago.medicci@gmail.com> escreveu:
> Hi Felipe,
>
> Thanks for asking! You should follow the path using the functions on
> esp-hal-3rdparty. You can fork the repository and use
> `ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
> ESP_HAL_3RDPARTY_URL="git@github.com:tmedicci/esp-hal-3rdparty.git"` env
> vars (globally or before the make command) to use your version of the HAL.
>
> I just wanted to share some thoughts: using the HAL enables us to make the
> feature available for all the Espressif devices (please don't bother with
> that now, as soon as you submit it, we can test for the other devices and
> eventually make any adjustments). Although it's possible to reimplement
> these functions on NuttX, we don't recommend that because of the first
> statement (the ability to use for the other devices): in that case we
> wouldn't be able to support the feature. You can take a look on IDF for
> some inspiration on how it's implemented.
>
> Please let me know if you have any questions.
>
> Best regards,
>
> Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
> moura.fmo@gmail.com> escreveu:
>
>> Hello everyone,
>>
>> Our project has reached a point where we need the Power Manager
>> functionality, which is not yet available in the ESP32C6. I am studying to
>> start the implementation, but I am confused about the correct way to
>> approach this.
>>
>> There is a Power Manager implementation for the ESP32C3, but it seems to
>> follow the legacy methodology. In fact, the file esp32c3_idle.c is located
>> in the path arch/risc-v/src/esp32c3-legacy. In this methodology, functions
>> are re-implemented from the Espressif driver. For example, the function
>> esp32c3_light_sleep_start(), which is currently available in
>> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
>>
>> I tried using the implementations from esp-hal-3rdparty to develop the
>> Power Manager for the ESP32C6 in NuttX, but the files still have many
>> dependencies on items that are not present in NuttX.
>>
>> My question is: Should I try to make the Power Manager work using the
>> functions in esp-hal-3rdparty, even if it requires making changes to the
>> 3rd-party code? Or should I re-implement the functions within NuttX, even
>> if, in this case, there are functions with the same scope and
>> implementation in different files, where one is compiled, and the other is
>> not?
>>
>>
>> --
>> *Felipe Moura de Oliveira*
>> *Universidade Federal de Minas Gerais*
>> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
>> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>>
>
>
> --
> Tiago Medicci Serrano
>
> Embedded Software Engineer
> MSc Electronics/Microelectronics
> m: +55 (19) 981403886 <+55+(19)+981403886>
> e: tiago.medicci@gmail.com
> a: Campinas, Brazil
> Follow me:
> <https://www.linkedin.com/in/tiago-serrano-924458b6>
> <https://github.com/tmedicci>
>
--
Tiago Medicci Serrano
Embedded Software Engineer
MSc Electronics/Microelectronics
m: +55 (19) 981403886 <+55+(19)+981403886>
e: tiago.medicci@gmail.com
a: Campinas, Brazil
Follow me:
<https://www.linkedin.com/in/tiago-serrano-924458b6>
<https://github.com/tmedicci>
Re: What is the right way to add PM to esp32c6
Posted by Tiago Medicci Serrano <ti...@gmail.com>.
Hi Felipe,
Thanks for asking! You should follow the path using the functions on
esp-hal-3rdparty. You can fork the repository and use
`ESP_HAL_3RDPARTY_VERSION=b4c723a119344b4b71d69819019d55637fb570fd
ESP_HAL_3RDPARTY_URL="git@github.com:tmedicci/esp-hal-3rdparty.git"` env
vars (globally or before the make command) to use your version of the HAL.
I just wanted to share some thoughts: using the HAL enables us to make the
feature available for all the Espressif devices (please don't bother with
that now, as soon as you submit it, we can test for the other devices and
eventually make any adjustments). Although it's possible to reimplement
these functions on NuttX, we don't recommend that because of the first
statement (the ability to use for the other devices): in that case we
wouldn't be able to support the feature. You can take a look on IDF for
some inspiration on how it's implemented.
Please let me know if you have any questions.
Best regards,
Em qua., 23 de out. de 2024 às 12:38, Felipe Moura Oliveira <
moura.fmo@gmail.com> escreveu:
> Hello everyone,
>
> Our project has reached a point where we need the Power Manager
> functionality, which is not yet available in the ESP32C6. I am studying to
> start the implementation, but I am confused about the correct way to
> approach this.
>
> There is a Power Manager implementation for the ESP32C3, but it seems to
> follow the legacy methodology. In fact, the file esp32c3_idle.c is located
> in the path arch/risc-v/src/esp32c3-legacy. In this methodology, functions
> are re-implemented from the Espressif driver. For example, the function
> esp32c3_light_sleep_start(), which is currently available in
> esp32c6/esp-hal-3rdparty/.../sleep_modes.c.
>
> I tried using the implementations from esp-hal-3rdparty to develop the
> Power Manager for the ESP32C6 in NuttX, but the files still have many
> dependencies on items that are not present in NuttX.
>
> My question is: Should I try to make the Power Manager work using the
> functions in esp-hal-3rdparty, even if it requires making changes to the
> 3rd-party code? Or should I re-implement the functions within NuttX, even
> if, in this case, there are functions with the same scope and
> implementation in different files, where one is compiled, and the other is
> not?
>
>
> --
> *Felipe Moura de Oliveira*
> *Universidade Federal de Minas Gerais*
> Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
> <https://twitter.com/FelipeMOliveir?lang=pt-br>
>
--
Tiago Medicci Serrano
Embedded Software Engineer
MSc Electronics/Microelectronics
m: +55 (19) 981403886 <+55+(19)+981403886>
e: tiago.medicci@gmail.com
a: Campinas, Brazil
Follow me:
<https://www.linkedin.com/in/tiago-serrano-924458b6>
<https://github.com/tmedicci>