8000 upgrade to Idf v5.3.2, added esp32c6 by hathach · Pull Request #70 · adafruit/nina-fw · GitHub
[go: up one dir, main page]

Skip to content

upgrade to Idf v5.3.2, added esp32c6 #70

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

Merged
merged 25 commits into from
Jun 26, 2025
Merged

upgrade to Idf v5.3.2, added esp32c6 #70

merged 25 commits into from
Jun 26, 2025

Conversation

hathach
Copy link
Member
@hathach hathach commented Mar 12, 2025

based on @dhalbert WIP https://github.com/dhalbert/nina-fw/tree/idf-5.x
This PR update idf to v5.3.2 and added esp32c6. What have done:

  • Wifi tested worked with both esp32 and esp32c6 using simple wifitest sketch with metro m4
  • Use log_i()/log_d() from arduino-esp32, log_d() is enabled with CMAKE_BUILD_TYPE=DEBUG. debug mode is also initialized to true with debug type. Note: since Bluetooth HCI mode use UART1 on existing TX0/RX0 we may need to revert to origianl code to output log to fake stdin/out (previously error with c6).
  • fixed compile error and spis setting with esp32c6
  • ci compile both esp32 & esp32c6 target with release & debug build

Need to do

  • More complicated such as ssl socket test. Update SSL client failed to connect
  • Tet with rp2350 + esp32c6 combo since it is what @ladyada plan to test with
  • test bluetooth (classic) hci mode for esp32 via uart
  • add/test bleutooth ble hci mode for esp32c6 via uart
  • figure out how to do the GPIO0/GPIO9 available pin (netif input hook code right now is commented out because it was crashing).

@ladyada
Copy link
Member
ladyada commented Mar 12, 2025

ok let me know when you want me to test it!

@hathach
Copy link
Member Author
hathach commented Mar 12, 2025

It still has issue with SSL connection, still troubleshooting, maybe certificate-related. Dan does mention it previously HTTPS not working: I need to add explicit calls to use the root cert bundle in the certificate partition

[  7750][D][NetworkManager.cpp:83] hostByName(): Clearing DNS cache
[  7861][D][NetworkManager.cpp:127] hostByName(): DNS found IPv4 146.75.112.159
[  7869][I][NetworkClientSecure.cpp:153] connect(): Actual TLS start postponed.
[  7878][E][NetworkClientSecure.cpp:159] connect(): start_ssl_client: connect failed: -1
[  7889][I][sketch.ino.cpp:64] dumpBuffer(): RESPONSE: 

dhalbert and others added 8 commits March 14, 2025 14:53
testing BLE controller
- move SPIS definition to sketch.ino.cpp
- max log level is info, debug will delay the initial boot causing reading CS incorrectly for BT and wifi mode (only available for 750ms)
fix c6 compile issue in release build type
@hathach
Copy link
Member Author
hathach commented Mar 18, 2025

I have move SPIS definition to sketch.ino.cpp to make parameterize pin easier. Tested WiFI & BT with both esp32 and esp32c6 both working well. Due to the different in BT HCI mode configuraation between esp32 and c6, 2 target specific config is added namely sdkconfig.defaults.esp32 and sdkconfig.defaults.c6, sdkconfig.defaults store only common setting.

The only issue is GPIO0/9 for wifi data available (which I see we don't use much, but will still try to look at this). Except for this, @ladyada I think this is ready for tested.

@hathach hathach marked this pull request as ready for review March 18, 2025 09:15
// Root certificate bundle provided by ESP-IDF. This available by default via ESP-iDF esp_crt_bundle_attach(),
// but arduino-esp32 doesn't provide a way to invoke that default easily, so we declare these to use
// the default bundle explicitly.
extern const uint8_t x509_crt_imported_bundle_bin_start[] asm("_binary_x509_crt_bundle_start");
Copy link
Member Author

Choose a reason for hiding this comment

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

@dhalbert seems like we don't need to use combine.py to convert rootcert to binary + written it to NVS keys anymore ?

I (60) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (79) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (86) boot:  2 certs            NVS keys         01 04 00010000 00020000
I (94) boot:  3 factory          factory app      00 00 00030000 00180000
I (101) boot:  4 storage          Unknown data     01 82 001b0000 00040000
I (109) boot: End of partition table

esp_netif_t *apNetif = get_esp_interface_netif(ESP_IF_WIFI_AP);

if (staNetif != NULL && staNetif->lwip_input_fn != _staNetifInputHook) {
CommandHandler.originalAPNetifInput = staNetif->lwip_input_fn;
Copy link
Member Author
@hathach hathach Mar 19, 2025

Choose a reason for hiding this comment

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

@dhalbert crash is due to typo, this should be original-staNetifInput, I have renamed to make it easier to catch

…our hook as IRAM and also correct the context where handleWiFiReceive() is called
@hathach
Copy link
Member Author
hathach commented Mar 19, 2025

@ladyada @dhalbert wifi available with boot pin IO0 for esp32, IO9 for c6 is fixed and tested. The issue is mostly due to typo causing Null is called --> crash. I also notice that the hook is actually invoked in thread-context rather than isr as old sdk, therefore add a context check just to be safe. Also putting our hook into IRAM hoping to not slow down the lwip thing. It seems to work, screen shot with pulse captured by logic analyzer. So I guess this PR is 100% ready now :)

image

@ladyada
Copy link
Member
ladyada commented Jun 1, 2025

whew i finally got through enough stuff to start testing this. initial test is good! i am uploading the debug bin and there's no MAC address (?) reported when using https://github.com/adafruit/WiFiNINA
will continue to test

15:32:25.705 -> WiFi Scanning test
15:32:25.705 -> 3.0.0
15:32:25.705 -> Firmware OK
15:32:25.705 -> MAC: 00:00:00:00:00:00
15:32:25.705 -> Scanning available networks...
15:32:25.705 -> ** Scan Networks **
15:32:31.076 -> number of available networks:10
15:32:31.076 -> 0) moonfruit 2.4G	Signal: -45 dBm	Encryption: None
15:32:31.124 -> 1) starfruit	Signal: -53 dBm	Encryption: Unknown
15:32:31.124 -> 2) moonfruit 2.4G	Signal: -54 dBm	Encryption: None
15:32:31.124 -> 3) moonfruit guest	Signal: -57 dBm	Encryption: None
15:32:31.124 -> 4) son4space	Signal: -61 dBm	Encryption: Unknown
15:32:31.124 -> 5) fredwifi	Signal: -62 dBm	Encryption: Unknown
15:32:31.124 -> 6) moonfruit 2.4G	Signal: -62 dBm	Encryption: None
15:32:31.172 -> 7) moonfruit guest	Signal: -62 dBm	Encryption: None
15:32:31.172 -> 8) moonfruit guest	Signal: -66 dBm	Encryption: None
15:32:31.172 -> 9) moonfruit 2.4G	Signal: -67 dBm	Encryption: 

update combine.py to take build folder and output filename
run combine.py as postbuild
@hathach
Copy link
Member Author
hathach commented Jun 3, 2025

@ladyada yeah, I also got the MAC all zeroes, does not notice that before. Checking it out, I have update this PR to allow passing -DBOARD= to idf.py build, currently only esp32 and fruitjam_c6 are supported. To add new c6 board, we only need to add board.h and sdkconfig (for BLE uart pin)

@ladyada
Copy link
Member
ladyada commented Jun 3, 2025

ok great, yeah i think if you can find the MAC address lookup fixed we can merge. (or let me know if its not possible to query the MAC)

@hathach
Copy link
Member Author
hathach commented Jun 3, 2025

I think it is possible, we probably didn't get the correct function, I am checking it out. It has been awhile, trying to get back some memory for command handler :)

@hathach
Copy link
Member Author
hathach commented Jun 3, 2025

just found out the root cause for mac address issue, the latest arduino-esp32 (which use idf 5.3.2 by this PR) required the interface (STA/AP) must be initialized before getting mac _esp_netif != NULL. This is probbly not the issue with previous arduino-esp32.

https://github.com/espressif/arduino-esp32/blob/master/libraries/Network/src/NetworkInterface.cpp#L637

for example if we print mac after attempting to scan (which cause STA is enabled), or conect to an ssid, it will print out the mac just fine

void loop() {
  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();

  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  printMacAddress(mac);

  delay(10000);
}
** Scan Networks **
number of available networks:10
0) fabulous     Signal: -53 dBm Encryption: Unknown
1) Thao Nguyen  Signal: -55 dBm Encryption: Unknown
2) Thao Nguyen  Signal: -61 dBm Encryption: WPA2
3) Scotkield    Signal: -62 dBm Encryption: WPA2
4) fabulous4    Signal: -65 dBm Encryption: Unknown
5) Thao Nguyen  Signal: -68 dBm Encryption: WPA2
6) fabulous     Signal: -69 dBm Encryption: Unknown
7) Tenda_F5B050 Signal: -70 dBm Encryption: Unknown
8) fabulous     Signal: -72 dBm Encryption: Unknown
9) TP-LINK_966AEE       Signal: -73 dBm Encryption: Unknown
MAC: 30:7B:59:CA:4C:40

@hathach
Copy link
Member Author
hathach commented Jun 3, 2025

I tried to use efuse default mac addres in case the iterface is not up but it is not the same. They probably slight change the mac depending on the iterface in used (probably has more factors).

3.0.0
Firmware OK
MAC: 59:FE:FF:CA:4C:40 <---- from efuse
Scanning available networks...
** Scan Networks **
number of available networks:10
MAC: 30:7B:59:CA:4C:40 <--- from STA interface

@ladyada
Copy link
Member
ladyada commented Jun 3, 2025

huh what if you run esptool read_mac command?

@hathach
Copy link
Member Author
hathach commented Jun 10, 2025

sorry, I miss gh notification, seemns like BASE MAC: 40:4c:ca:59:7b:30 is what we want, and 6 bytes from efuse got part of the MAC. Let me try to get the mac working

esptool.py read_mac 
esptool.py v4.8.1
Found 3 serial ports
Serial port /dev/ttyACM2
Connecting...
Detecting chip type... ESP32-C6
Chip is ESP32-C6FH4 (QFN32) (revision v0.1)
Features: WiFi 6, BT 5, IEEE802.15.4
Crystal is 40MHz
MAC: 40:4c:ca:ff:fe:59:7b:30
BASE MAC: 40:4c:ca:59:7b:30
MAC_EXT: ff:fe
Uploading stub...
Running stub...
Stub running...
MAC: 40:4c:ca:ff:fe:59:7b:30
BASE MAC: 40:4c:ca:59:7b:30
MAC_EXT: ff:fe
Hard resetting via RTS pin...

@hathach
Copy link
Member Author
hathach commented Jun 10, 2025

found it esp_base_mac_addr_get(mac) is what we need, we will use that if esp_netif_get_mac() failed when interface is not up. @ladyada please try again to see if it works for you. I will also update the WiFiNINA example for fruitjam pinout.

PS: PR to add fruitjam + c6 pinout to WiFiNINA adafruit/WiFiNINA#13 (also refactor to move pin config to its own file to make it easier to update)

@ladyada
Copy link
Member
ladyada commented Jun 10, 2025

thanks, ill test later this week, when i get the new hardware!

@hathach
Copy link
Member Author
hathach commented Jun 26, 2025

C6 seems to work well, I guess we can merge this now. Any issues can be fixed in follow-up PR. @ladyada let me know if you also want to make the release or wait a bit more.

@hathach hathach merged commit 36c78d4 into master Jun 26, 2025
8 checks passed
@ladyada
Copy link
Member
ladyada commented Jun 26, 2025

yes lets do a release now, cc @brentru

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0