Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oneshot ADC log verbosity can't be controlled separately (IDFGH-11248) #12409

Closed
3 tasks done
cyberhuman opened this issue Oct 14, 2023 · 5 comments
Closed
3 tasks done
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@cyberhuman
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.1

Espressif SoC revision.

ESP32-C3

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

custom board

Power Supply used.

USB

What is the expected behavior?

When testing ADC on my board, I noticed calling adc_oneshot_read produces two lines on every invocation:

D (379929) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (379929) adc_hal: delay: 3

I have CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y but I expect the log level of adc_hal to be controllable separately from the default log level.

I noticed there exists a CONFIG_HAL_LOG_LEVEL setting but it's not configurable as soon as LOG_DEFAULT_LEVEL is defined.

Another issue is that adc_oneshot_hal uses HAL_EARLY_LOGD instead of HAL_LOGD; the former doesn't check CONFIG_HAL_LOG_LEVEL and calls ESP_EARLY_LOGD instead, which checks the default log level (and LOG_LOCAL_LEVEL, which isn't set by adc_oneshot_hal and thus defaults to LOG_MAXIMUM_LEVEL).

What is the actual behavior?

when CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y, it's not possible to suppress the output of adc_oneshot_hal.

Steps to reproduce.

  1. get the ADC oneshot_read example: https://github.com/espressif/esp-idf/tree/master/examples/peripherals/adc/oneshot_read
  2. run idf.py menuconfig
  3. set the "Default log verbosity" setting to Debug
  4. notice the "HAL layer log verbosity" setting is not available
  5. run the example and observe the debug output from adc_hal.

Debug Logs.

...
D (400250) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (400250) adc_hal: delay: 3
D (400289) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (400289) adc_hal: delay: 3
D (401268) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (401268) adc_hal: delay: 3
D (401307) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (401307) adc_hal: delay: 3
D (402286) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (402286) adc_hal: delay: 3
D (402325) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (402325) adc_hal: delay: 3
D (403304) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (403304) adc_hal: delay: 3
D (403343) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (403343) adc_hal: delay: 3
D (404322) adc_hal: clk_src_freq_hz: 80000000, digi_clk: 5000000, delay: 3
D (404322) adc_hal: delay: 3
...

More Information.

No response

@cyberhuman cyberhuman added the Type: Bug bugs in IDF label Oct 14, 2023
@cyberhuman cyberhuman changed the title Oneshot ADC log output can't be controlled separately Oneshot ADC log verbosity can't be controlled separately Oct 14, 2023
@github-actions github-actions bot changed the title Oneshot ADC log verbosity can't be controlled separately Oneshot ADC log verbosity can't be controlled separately (IDFGH-11248) Oct 14, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 14, 2023
@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels Oct 17, 2023
@Icarus113
Copy link
Collaborator

Hi again @cyberhuman ,

  • If you use the ESP-IDF project, the log component is always included, so the hal layer log will also use the log implementation.
  • If you only use the ESP-IDF hal component, then CONFIG_HAL_LOG_LEVEL is configurable.

Another issue is that adc_oneshot_hal uses HAL_EARLY_LOGD instead of HAL_LOGD

Yes, this is intended as this hal function is in critical section. And the “EARLY” log macros do not support per module setting of log verbosity. These macros will always log at the “default” verbosity level.

So in a word, we will not make this hal layer function log to be controlled separately.

On the other hand, we can provide a workaround by controlling the adc_oneshot driver logs independently. Then you can see adc_oneshot driver layer debug logs, without seeing the hal layer debug logs.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Selected for Development Issue is selected for development labels Oct 31, 2023
@cyberhuman
Copy link
Author

Hi @Icarus113!
Thank you for the explanation.

On the other hand, we can provide a workaround by controlling the adc_oneshot driver logs independently.

This would be nice!

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: In Progress Work is in progress labels Nov 2, 2023
@Bruce297
Copy link
Contributor

Bruce297 commented Nov 2, 2023

Now there is a new commit that add a config ADC_ENABLE_DEBUG_LOG allow you to control the adc_oneshot driver logs independently. If you enable it, you can see adc_oneshot driver debug logs without CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y

@Icarus113
Copy link
Collaborator

It's done in this commit c14d7fb

We'll close this issue, feel free to reopen if there's any further issue. @cyberhuman

@cyberhuman
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants