Skip to content

cpu/esp: cleanup of ESP SDK log outputs#12998

Merged
benpicco merged 5 commits intoRIOT-OS:masterfrom
gschorcht:cpu/esp/common_sdk_log_output
Jan 15, 2020
Merged

cpu/esp: cleanup of ESP SDK log outputs#12998
benpicco merged 5 commits intoRIOT-OS:masterfrom
gschorcht:cpu/esp/common_sdk_log_output

Conversation

@gschorcht
Copy link
Copy Markdown
Contributor

@gschorcht gschorcht commented Dec 20, 2019

Contribution description

The ESP SDK libraries generate a lot of log outputs at the default log level, which are usually not of interest. Especially, the WiFi SDK libraries that are used by esp_now and esp_wifi produce a lot of such output about driver internals, for example

add if0
add if1
bcn 100
main(): This is RIOT! (Version: 2020.01-devel-1500-g31330-cpu/esp ...)
RIOT network stack example application
All up, running the shell now
> scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 15
cnt 

connected with SSID, channel 8
WiFi connected to ssid SSID, channel 8

This PR implements a set of library-specific printf functions that intercept the log output from the SDK libraries and redirect them to the RIOT log macros. This allows to control the log output of the ESP SDK libraries according to the defined log level.

The PR contains also some small cleanups of log outputs in initialization functions.

Note: This PR requires a modified SDK version for ESP8266 boards to use the changes. The modified SDK version is available at GitHub.

Testing procedure

Test any ESP32 board with:

USEMODULE='esp_wifi' CFLAGS='-DESP_WIFI_SSID=\"pass\" -DESP_WIFI_PASS=\"ssid\"' \
make BOARD=esp32-wroom-32 -C examples/gnrc_networking flash term
LOG_LEVEL=4 USEMODULE='esp_wifi' CFLAGS='-DESP_WIFI_SSID=\"pass\" -DESP_WIFI_PASS=\"ssid\"' \
make BOARD=esp32-wroom-32 -C examples/gnrc_networking flash term

With LOG_LEVEL=4, you should see the log output as before. At default log level you should only see

main(): This is RIOT! (Version: 2020.01-devel-1500-g31330-cpu/esp ...)
RIOT network stack example application
All up, running the shell now
> WiFi connected to ssid SSID, channel 8

The test of the PR with an ESP8266 board requires a modified SDK Version. Without the modified version of the modified SDK Version, ESP8266 should be compilable. The modified version of the SDK can be installed with:

cd /path/to
git clone https://github.com/gschorcht/RIOT-Xtensa-ESP8266-RTOS-SDK.git
git checkout release/v3.1-for-riot-os-v2
export ESP8266_RTOS_SDK_DIR=/path/to/RIOT-Xtensa-ESP8266-RTOS-SDK

Once the modified SDK version is installed, you can use:

USEMODULE='esp_wifi' CFLAGS='-DESP_WIFI_SSID=\"pass\" -DESP_WIFI_PASS=\"ssid\"' \
make BOARD=esp8266-esp-12x -C examples/gnrc_networking flash term
LOG_LEVEL=4 USEMODULE='esp_wifi' CFLAGS='-DESP_WIFI_SSID=\"pass\" -DESP_WIFI_PASS=\"ssid\"' \
make BOARD=esp8266-esp-12x -C examples/gnrc_networking flash term

Issues/PRs references

This PR is prerequisite for PR RIOT-OS/riotdocker#95

LOG_TAG macro is required for LOG_VERBOSE level in ESP SDK log output handling.
The log level for normal information should be LOG_DEBUG.
@gschorcht gschorcht added Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Dec 20, 2019
@gschorcht
Copy link
Copy Markdown
Contributor Author

gschorcht commented Dec 20, 2019

@benpicco This PR could be interesting for you. For example, it solves the problem with bunches scandone messages with esp_now

To control the log level and the format of the log output of SDK libraries, a bunch of library-specific printf functions are realized which map the log output from SDK libraries to RIOT's log macros.
@gschorcht
Copy link
Copy Markdown
Contributor Author

@benpicco Do you think that there is a chance to get this PR merged before the soft freeze of release 2020.01. The reason for my question is that a modified tool chain is required for this PR to take affect on the ESP8266, see RIOT-OS/riotdocker#95 and we have to merge this PR before we can merge RIOT-OS/riotdocker#95.

If this PR will not become part of release 2020.01, we would have to keep RIOT-OS/riotdocker#95 on hold until this PR is released with 2020.04. Otherwise ESP8266 would not be compilable anymore with the current release.

It would be OK for me, if you think it's too short notice. It was just a question.

@benpicco
Copy link
Copy Markdown
Contributor

benpicco commented Jan 11, 2020

Sorry, I've been sick the last couple days.
This looks rather straightforward though. And I enjoy the silence :)

Btw.: since the SDK version tends to move in tandem with the RIOT code, have you thought of moving it to pkg/ so it will automatically be the right version?

@gschorcht
Copy link
Copy Markdown
Contributor Author

gschorcht commented Jan 12, 2020

Btw.: since the SDK version tends to move in tandem with the RIOT code, have you thought of moving it to pkg/ so it will automatically be the right version?

Yeah, but it doesn't seem like a reasonable way. The ESP8266 SDK contains a lot of binary blobs and has a size of about 109 MByte. Using it as a package would pull the SDK for each compiled application. It would slow down the compilation a lot and would take a lot of disk space, for example if you compile all applications.

@gschorcht
Copy link
Copy Markdown
Contributor Author

gschorcht commented Jan 12, 2020

The SDK contains a lot of binary blobs and has a size of about 109 MByte.

OK, if I prepare a lightweight ESP8266 SDK by removing everything but the required header files and binary libraries, the SDK would only have 5.9 MB. But 5.9 MB can still be a lot if you have a very slow internet connection and it has to be pulled on every compilation.

@gschorcht
Copy link
Copy Markdown
Contributor Author

@benpicco All lights are green.

@gschorcht
Copy link
Copy Markdown
Contributor Author

Today is hard feature freeze. Can wie merge it?

@benpicco
Copy link
Copy Markdown
Contributor

If you want it in, we should merge it.

@benpicco benpicco merged commit 3672502 into RIOT-OS:master Jan 15, 2020
@fjmolinas
Copy link
Copy Markdown
Contributor

Note: This PR requires a modified SDK version for ESP8266 boards to use the changes. The modified SDK version is available at GitHub.

Does this work in master? Can I still build with docker? @gschorcht @benpicco

Today is hard feature freeze. Can wie merge it?

BTW if there was a reason to question this, AFAIK I should have been consulted.

@fjmolinas
Copy link
Copy Markdown
Contributor

Does this work in master? Can I still build with docker? @gschorcht @benpicco

Well If murdock passes it builds, but I would like to know why you though there was need of holding back.

@gschorcht
Copy link
Copy Markdown
Contributor Author

Does this work in master? Can I still build with docker? @gschorcht @benpicco

The PR has only added some new functions that are required by the ESP8266 toolchain update in PR RIOT-OS/riotdocker#95. They are not yet used but will take effect as soon as the toolchain in the docker is updated. That is, the toolchain update depends on this PR. That's why this PR had to merge first even though it doesn't take effect on ESP8266 at the moment. I just wanted to have it in release 2020.01 so that we are able to do the toolchain update in next few month.

@fjmolinas
Copy link
Copy Markdown
Contributor

The PR has only added some new functions that are required by the ESP8266 toolchain update in PR RIOT-OS/riotdocker#95. They are not yet used but will take effect as soon as the toolchain in the docker is updated. That is, the toolchain update depends on this PR. That's why this PR had to merge first even though it doesn't take effect on ESP8266 at the moment. I just wanted to have it in release 2020.01 so that we are able to do the toolchain update in next few month.

Ok thanks for the clarification, sorry for stressing for nothing.

@fjmolinas fjmolinas added this to the Release 2020.01 milestone Jan 15, 2020
@gschorcht
Copy link
Copy Markdown
Contributor Author

@benpicco Thanks for reviewing and merging this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants