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

fixes ESP32-C3 WiFiProv and btInUse() #8243

Merged
merged 1 commit into from
May 31, 2023

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented May 23, 2023

Description of Change

This change is necessary within Arduino Core 2.0.x and 3.0.x.

When testing ESP32-C3 with WiFiProv.ino example to use Bluetooth provisioning, it fails because btInUse() returns false due to a weak/strong symbol resolving within the linker.

This PR sets the origin of the btInUse() function to be with esp32-hal-bt.c and its symbol is an external one for esp32-hal-misc.c making possible for the user to redefine it, is necessary. This solves the Core library C3 linker issue.

Tests scenarios

The PR is tested by using WiFiProv.ino example by removing the #if CONFIG_IDF_TARGET_ESP32 in order to use it with the C3.
This shall use this call: WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");

Tested with ESP32, ESP32-C3, ESP32-S3.

Related links

Fix #7903

@SuGlider SuGlider added the Area: BT&Wifi BT & Wifi related issues label May 23, 2023
@SuGlider SuGlider added this to the 2.0.9 milestone May 23, 2023
@SuGlider SuGlider requested a review from me-no-dev May 23, 2023 18:49
@SuGlider SuGlider self-assigned this May 23, 2023
@SuGlider
Copy link
Collaborator Author

@sanketwadekar - please test it and let me know. Thanks!

@sanketwadekar
Copy link
Contributor

@SuGlider, I have tested the Rainmaker Switch example which uses the WiFiProv library on esp32c3 and it works fine. Have you checked other weak symbols in esp32-hal-misc.c? Also, Arduino 2.0.9 is already released right? You might need to add this PR to the next release milestone.

Tagging @vikramdattu, @dhavalgujar

@sanketwadekar
Copy link
Contributor

Closes #7903

@@ -209,9 +209,8 @@ bool verifyRollbackLater() { return false; }
#endif

#ifdef CONFIG_BT_ENABLED
//overwritten in esp32-hal-bt.c
bool btInUse() __attribute__((weak));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuGlider I am wondering if this change is also applicable for other weak symbols in this file?

cc @sanketwadekar

Copy link
Collaborator Author

@SuGlider SuGlider May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have verified it.
The issue occurs when a weak and strong symbols are part of the same core.a library file.
In the building process with Arduino, it first compiles all the Core Files and build a reusable Library.
The other weak functions are changed/redefined in the Sketch, therefore, its strong symbols are correctly linked.

The issue only happens with this very specific btInUse() function because its strong symbol is in the same core.a file and it is ignored by the RISC-V Linker.

@SuGlider
Copy link
Collaborator Author

@SuGlider, I have tested the Rainmaker Switch example which uses the WiFiProv library on esp32c3 and it works fine.

Thanks for testing and confirming.

Have you checked other weak symbols in esp32-hal-misc.c?

Yes, all other symbols are OK. They can be defined in the Arduino Sketch and the strong symbols are linked correctly (xtensa and RV). The issue is very specific to symbols within the same Core Library (core.a)

Also, Arduino 2.0.9 is already released right? You might need to add this PR to the next release milestone.

Yes. We don't have yet a 2.0.10 version.
I'll talk to @VojtechBartoska and @me-no-dev to check how to include this fix in the Arduino Core.

@SuGlider SuGlider modified the milestones: 2.0.9, 2.0.10 May 24, 2023
@SuGlider
Copy link
Collaborator Author

SuGlider commented May 24, 2023

@VojtechBartoska - I just created the 2.0.10 TAG. I also added this one and another PR to 2.0.10
https://github.com/orgs/espressif/projects/3/views/18

@me-no-dev me-no-dev merged commit 5548fbe into espressif:master May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues
Projects
Development

Successfully merging this pull request may close these issues.

XIAO ESP32-C3 Rainmaker example crash
4 participants