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

Support for Thread #484

Merged
merged 60 commits into from
Oct 1, 2024
Merged

Support for Thread #484

merged 60 commits into from
Oct 1, 2024

Conversation

ivmarkov
Copy link
Collaborator

Subject says it all.

This is initial and under the experimental feature, but once bugfixed, should be fairly complete, in that

  • One can run Thread all the way up to L3 (IPv6) or barebones L2 only (for L2 need to figure out how to ingress/egress thread "ethernet" packets though)
  • Thread RCP is supported, via UART and SPI. We need the JTAG-USB peripheral to support the USB transport as well
  • Thread Host is supported via UART and SPI on chips that do not have a Thread radio

@ivmarkov
Copy link
Collaborator Author

Also need to figure out if/what safe APIs are necessary so as to support the Thread Border Router case.

@ivmarkov
Copy link
Collaborator Author

Still WIP but un-drafting it to see the CI.

@turulix
Copy link

turulix commented Sep 19, 2024

Hey, im currently trying out this branch, and noticed it dosn't compile out of the box, with the error that Self::native_host_cfg(modem) dosn't exist.

I'm not sure if im missing something, but i think theres a typo here. Where its "native_host_cfg" once and "host_native_cfg" the other time

cfg: Self::native_host_cfg(modem),

esp-idf-svc/src/thread.rs

Lines 442 to 457 in 9b09e0e

fn host_native_cfg<M: crate::hal::modem::ThreadModemPeripheral>(
_modem: impl Peripheral<P = M> + 'd,
) -> esp_openthread_platform_config_t {
esp_openthread_platform_config_t {
radio_config: esp_openthread_radio_config_t {
radio_mode: esp_openthread_radio_mode_t_RADIO_MODE_NATIVE,
..Default::default()
},
host_config: esp_openthread_host_connection_config_t {
host_connection_mode:
esp_openthread_host_connection_mode_t_HOST_CONNECTION_MODE_NONE,
..Default::default()
},
port_config: Self::PORT_CONFIG,
}
}

@ivmarkov
Copy link
Collaborator Author

Hey, im currently trying out this branch, and noticed it dosn't compile out of the box, with the error that Self::native_host_cfg(modem) dosn't exist.

I'm not sure if im missing something, but i think theres a typo here. Where its "native_host_cfg" once and "host_native_cfg" the other time

cfg: Self::native_host_cfg(modem),

esp-idf-svc/src/thread.rs

Lines 442 to 457 in 9b09e0e

fn host_native_cfg<M: crate::hal::modem::ThreadModemPeripheral>(
_modem: impl Peripheral<P = M> + 'd,
) -> esp_openthread_platform_config_t {
esp_openthread_platform_config_t {
radio_config: esp_openthread_radio_config_t {
radio_mode: esp_openthread_radio_mode_t_RADIO_MODE_NATIVE,
..Default::default()
},
host_config: esp_openthread_host_connection_config_t {
host_connection_mode:
esp_openthread_host_connection_mode_t_HOST_CONNECTION_MODE_NONE,
..Default::default()
},
port_config: Self::PORT_CONFIG,
}
}

I know this could be annoying, but if you could wait a day or so.
I'm actively modifying the whole thread module, so the CI breaks very often ATM.

@ivmarkov
Copy link
Collaborator Author

Currently it breaks because - it seems - the ESP Border Router only builds fine after 5.2.X, where I'm trying to figure out X = ?.
(The error you reported is fixed since a couple of hours.)

@turulix
Copy link

turulix commented Sep 19, 2024

Yea no worries :) Thanks for the work!

@ivmarkov
Copy link
Collaborator Author

Yea no worries :) Thanks for the work!

OK so the PR is at a point, where it has two examples:

  • examples/thread.rs - a regular Thread Node
  • examples/thread_br.rs - a Thread Border Router

Both seem to do something - meaning - once started, they output gobs of logs from OpenThread. Whether they work as they should - this is what we need to find out.

But if you are still interested, you could try the Border Router one.
Make sure that you
(a) use a recent ESP-IDF as in 5.2.2 or later (just in case)
(b) use esp32c6 (though not sure Wifi+Thread co-exist works 100% as I did not test it in detail)
(c) Carefully read the comment at the top of thread_br.rs, as you need to do some extra configurations, and then uncomment a few pieces of code for the Border Router to build successfully

@turulix
Copy link

turulix commented Sep 20, 2024

I've managed to setup a BR using the one provided by espressif and this branch to setup a node and i managed to successfully ping the node from my host device, so this seems to work so far :) Going to try using this for the BR aswell later.

Some of the requests time out after a while, but i don't think this is related to this. But also not sure what would cause this, since the BR keeps being pingable during this time

@ivmarkov
Copy link
Collaborator Author

Some of the requests time out after a while, but i don't think this is related to this. But also not sure what would cause this, since the BR keeps being pingable during this time

Hmmmm, no idea.
Speculation: it might be caused by the co-exist Wifi+Thread code on the esp32c6, though I need to check if this code is even running when you instantiate only the Thread stack and keep Wifi off.

I plan to test the Thread "Node" use-case with rs-matter in the next days, so - indirectly - if the node is losing access, we'll know, as the Matter protocol will start failing (or re-sending UDP packets at least).

@turulix
Copy link

turulix commented Sep 20, 2024

Im using two esp32c6 to not having to use the co-exist of wifi and thread, since its not recommended. So i don't think its this.

if you manage to setup matter keep me updated :)

@turulix
Copy link

turulix commented Sep 20, 2024

I do have troubles getting the thread_br example to run tho.

error: linking with `ldproxy` failed: exit code: 1
  |
  = note: "ldproxy" "C:\\Users\\Tim\\AppData\\Local\\Temp\\rustcb7oWC1\\symbols.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.25x0trzhd0qrux24ww1g2kl0m.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.27k1gvp95pukm6lt1ti6og7bc.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.302sncnl9eqb07d5ux13bfqd0.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.3da8fg1mfvjo6jxmvsn4esvtl.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.40oe0wy9fl8qyejm52aa67fat.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.4frt7utd11d0g2w6g38a0s2hn.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.5frwgsg7b8i30pp6wv53o9b9a.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.67m3j3nlq1fepmsx78hw0wito.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.6qemq54ancsndy31pkpwxuiya.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.7bwwvn2zi6brd1evtfnhqag06.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.7d03el2p3t54bz8wbjijul5sh.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.8c5j5bt6s86h37n5r2dl6m7ai.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.8s0up3a55zm3e79lmgbtn6itk.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.8trflab15g0nilvnrcpneeeey.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.96y9ke4y9yl09otydsqg9vmbd.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.9y1uo7nnu9mk4ocke7zu6esvf.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.aq8isxasmxrpmw029en3wqoas.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.bo6ccjtouuudrve7zdvles56h.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.bwvqse01v7xsmfpikvfis70tx.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.cl26skg04ghakgg5pftr2vviq.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.e4kop0nphgxx33r13xl7yf4u4.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.f00j5p9nol6d3auiufe2um87j.rcgu.o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b.0ic8qphi9j98ja0634r2yc9ur.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libanyhow-b33cf9399c9e9dbc.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libesp_idf_svc-e7b2866437dbf5fb.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembassy_futures-85d5559e3e26be41.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembassy_time_driver-13f56172bc5ca788.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libuncased-689834e8f66e40b9.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libesp_idf_hal-51d21cbb4d4ae0e4.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_hal_async-6c7cc1c189022254.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_can-caf0a4227460f350.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_hal-5a9c670d9375d5bb.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libvoid-f6093741502d06cc.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libnb-ecfdcfe78f7dede3.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_hal_nb-7344c7bc801cf05a.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libnb-06623ef48b107657.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libatomic_waker-036a6a4988ab9284.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembassy_sync-88df7f407f766e10.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libfutures_util-2068392e522ed2b2.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libpin_project_lite-240b998d355c723d.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libfutures_task-08c72c476fc88d29.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libpin_utils-aaf92866cceda744.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libfutures_core-c3d161ef654f63f4.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libcritical_section-de81d1651fadfdfe.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_hal-74db831eb21939e4.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libnum_enum-92f4a5906cb32b3e.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libesp_idf_sys-47b9bb1e32ec96df.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\liblibc-f18e5177ef0e1d45.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libconst_format-56632d604d603ebd.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_svc-a48b15c656b1fa4b.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libheapless-a796edfa80935456.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libhash32-e234ee60d76d3f36.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libbyteorder-df4dbafa0848e9ab.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libenumset-b2608a228e808954.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_io_async-c0acacba1d51429b.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libembedded_io-ba216119d00c08cf.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\liblog-072b085af1a14126.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libstd-2d2cd2a9d2ebed3b.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libpanic_abort-292b8f895abfc05d.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libobject-c2c27bd9e4818295.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libmemchr-1ad93b784de7da3d.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libaddr2line-c7188ef986dc787b.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libgimli-95e6b4eb24d4efe2.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\librustc_demangle-beb63eb075c1cbf4.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libstd_detect-84cb2c15131f992e.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libhashbrown-8567d6893c611cbf.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\librustc_std_workspace_alloc-511785ad5c263887.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libminiz_oxide-692d87cfa13c8621.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libadler-85b89a60e1763913.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libunwind-b3c40552b56f3f20.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libcfg_if-99469d3a29105a6f.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\liblibc-870a262ce113040a.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\liballoc-d8a14272ba385212.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\librustc_std_workspace_core-50f7c4f4fb98a98b.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libcore-0c2f57202e2264b2.rlib" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\libcompiler_builtins-01dfc3c0c527bc85.rlib" "-Wl,-Bdynamic" "-Wl,-z,noexecstack" "-o" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\deps\\ot_br-1ab5971fab28e40b" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "--ldproxy-linker" "D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe" "--ldproxy-cwd" "D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\build\\esp-idf-sys-3979d8e15c47f5d8\\out\\build" "@D:\\Bibliotheken\\Desktop\\Projects\\esp32c6-thread-test\\target\\riscv32imac-esp-espidf\\debug\\build\\esp-idf-sys-3979d8e15c47f5d8\\out\\linker_args.txt"
  = note: [ldproxy] Running ldproxy
          Error: Linker D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe failed: exit code: 1
          STDERR OUTPUT:
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: D:\Bibliotheken\Desktop\Projects\esp32c6-thread-test\.embuild\espressif\esp-idf\v5.3\components\openthread\lib\esp32c6\libopenthread_br.a(esp_openthread_discovery.cpp.obj): in function `.L0 ':␍
          (.text._ZL26handle_discovery_subscribePvPKc+0x1b6): undefined reference to `mdns_query_async_new'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26handle_discovery_subscribePvPKc+0x27c): undefined reference to `mdns_query_async_new'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26handle_discovery_subscribePvPKc+0x332): undefined reference to `mdns_query_async_new'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26handle_discovery_subscribePvPKc+0x352): undefined reference to `mdns_query_async_new'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0x90): undefined reference to `mdns_query_async_get_results'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0xac): undefined reference to `mdns_query_results_free'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0xb6): undefined reference to `mdns_query_async_delete'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0x100): undefined reference to `mdns_lookup_selfhosted_service'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0x118): undefined reference to `mdns_query_results_free'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0x1fa): undefined reference to `mdns_lookup_selfhosted_service'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text._ZL26discovery_delegate_processP10otInstancePK33esp_openthread_mainloop_context_t+0x29e): undefined reference to `mdns_hostname_get'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: D:\Bibliotheken\Desktop\Projects\esp32c6-thread-test\.embuild\espressif\esp-idf\v5.3\components\openthread\lib\esp32c6\libopenthread_br.a(esp_openthread_meshcop_mdns.c.obj): in function `.L0 ':␍
          (.text.esp_openthread_publish_meshcop_mdns+0x208): undefined reference to `mdns_service_add'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcop_mdns+0x294): undefined reference to `mdns_service_txt_set'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcop_mdns+0x2de): undefined reference to `mdns_service_txt_item_set_with_explicit_value_len'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcop_mdns+0x328): undefined reference to `mdns_service_txt_item_set_with_explicit_value_len'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcop_mdns+0x370): undefined reference to `mdns_service_txt_item_set_with_explicit_value_len'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcop_mdns+0x3b8): undefined reference to `mdns_service_txt_item_set_with_explicit_value_len'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcop_mdns+0x400): undefined reference to `mdns_service_txt_item_set_with_explicit_value_len'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: D:\Bibliotheken\Desktop\Projects\esp32c6-thread-test\.embuild\espressif\esp-idf\v5.3\components\openthread\lib\esp32c6\libopenthread_br.a(esp_openthread_meshcop_mdns.c.obj):(.text.esp_openthread_publish_meshcop_mdns+0x448): more undefined references to `mdns_service_txt_item_set_with_explicit_value_len' follow␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: D:\Bibliotheken\Desktop\Projects\esp32c6-thread-test\.embuild\espressif\esp-idf\v5.3\components\openthread\lib\esp32c6\libopenthread_br.a(esp_openthread_meshcop_mdns.c.obj): in function `.L0 ':␍
          (.text.esp_openthread_remove_meshcop_mdns+0x28): undefined reference to `mdns_service_remove'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_publish_meshcope_mdns+0x8e): undefined reference to `mdns_service_add'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.esp_openthread_remove_meshcope_mdns+0x64): undefined reference to `mdns_service_remove'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: D:\Bibliotheken\Desktop\Projects\esp32c6-thread-test\.embuild\espressif\esp-idf\v5.3\components\openthread\lib\esp32c6\libopenthread_br.a(esp_openthread_srp_server.c.obj): in function `.L0 ':␍
          (.text.handle_host_update+0x76): undefined reference to `mdns_hostname_get'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x82): undefined reference to `mdns_hostname_exists'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x192): undefined reference to `mdns_delegate_hostname_set_address'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x200): undefined reference to `mdns_delegate_hostname_add'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x3f6): undefined reference to `mdns_service_subtype_add_for_host'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x57e): undefined reference to `mdns_service_exists_with_instance'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x60a): undefined reference to `mdns_service_add_for_host'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_host_update+0x6a6): undefined reference to `mdns_service_remove_for_host'␍
          D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: (.text.handle_service_update+0x76): undefined reference to `mdns_delegate_hostname_remove'␍
          collect2.exe: error: ld returned 1 exit status

I did setup the sdkconfig.defaults and added:

[[package.metadata.esp-idf-sys.extra_components]]
remote_component = { name = "espressif/mdns", version = "1.2" }

to my cargo.toml
using ESP_IDF v5.3

@ivmarkov
Copy link
Collaborator Author

Just do cargo clean. Adding/removing ESP IDF components is not supported with incremental builds.

@turulix
Copy link

turulix commented Sep 20, 2024

This sadly didn't fix it. Does it work when the project is within a workspace?

@ivmarkov
Copy link
Collaborator Author

This sadly didn't fix it. Does it work when the project is within a workspace?

I never tried from within a workspace to be honest.

Where do you currently have this metadata?
In the Cargo.toml of the workspace, or in the binary esp32 crate one? Perhaps you can try moving from one location to the other?

I'm very certain it does work in regular crates (as in, just tested yesterday).

BTW, this long path:

D:/Bibliotheken/Desktop/Projects/esp32c6-thread-test/

... is really asking for trouble.

@turulix
Copy link

turulix commented Sep 20, 2024

Okey, the workspace was the problem...

Yea ik about the path, but theres an option on windows to disable the PATH_MAX, which apparently works

@ivmarkov
Copy link
Collaborator Author

Okey, the workspace was the problem...

Yea ik about the path, but theres an option on windows to disable the PATH_MAX, which apparently works

It doesn't but let's not go there... I'm super tired with the misinformation which is being spread out by users about this issue...

@turulix
Copy link

turulix commented Sep 20, 2024

Anyways. The BR now compiles and seems to run. co-exist seems to cause some issues tho. The device dosn't seem to be reachable, and does crash after a while maybe these Logs can give some more insight.

I tried setting it up with UART but that was unsuccessfull aswell. Logs.
But maybe i missed something.

let uart_config = UartConfig::new()
    .baudrate(Hertz::from(460800))
    .data_bits(DataBits8)
    .parity_none()
    .stop_bits(STOP1)
    .flow_control(FlowControl::None)
    .flow_control_rts_threshold(0)
    .source_clock(SourceClock::default());

let mut thread = EspThread::new_br_uart(
    peripherals.uart0,
    peripherals.pins.gpio16,
    peripherals.pins.gpio17,
    &uart_config,
    sys_loop,
    nvs,
    mounted_event_fs,
    wifi.wifi().sta_netif(),
)?;

@ivmarkov
Copy link
Collaborator Author

It is crashing at the same place which is weird.

  • What ESP-IDF version do you use?
  • can you paste your sdkconfig.defaults here
  • when you say "after a while", how much is that "while" if it is just a few seconds, it is likely a stack overflow. For me it worked for more than a minute before I stopped it.

@turulix
Copy link

turulix commented Sep 20, 2024

ESP-IDF v5.3

# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000

CONFIG_OPENTHREAD_ENABLED=y

# Thread Border Router
CONFIG_OPENTHREAD_BORDER_ROUTER=y

# These are also necessary for the Joiner feature
CONFIG_MBEDTLS_CMAC_C=y
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
CONFIG_MBEDTLS_ECJPAKE_C=y

# Border Router again, lwIP
CONFIG_LWIP_IPV6_NUM_ADDRESSES=12
CONFIG_LWIP_NETIF_STATUS_CALLBACK=y
CONFIG_LWIP_IPV6_FORWARD=y
CONFIG_LWIP_MULTICAST_PING=y
CONFIG_LWIP_NETIF_STATUS_CALLBACK=y
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM=y
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM=y
CONFIG_LWIP_IPV6_AUTOCONFIG=y
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096

# Border Router again, mDNS
CONFIG_MDNS_MULTIPLE_INSTANCE=y

Its not consistent, earlier it crashed after like 10-15 seconds and now it just crashes on startup while trying to send the first IPv6 msg.

I(5119) OPENTHREAD:[I] RouterTable---: Route table
I(5129) OPENTHREAD:[I] MeshForwarder-: Sent IPv6 UDP msg, len:82, chksum:6b5b, ecn:no, to:0xffff, sec:no, prio:net
I(5139) OPENTHREAD:[I] MeshForwarder-:     src:[fe80:0:0:0:5c71:4328:48f8:8177]:19788
I(5139) OPENTHREAD:[I] MeshForwarder-:     dst:[ff02:0:0:0:0:0:0:2]:19788
Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.

Core  0 register dump:
MEPC    : 0x4080ea64  RA      : 0x4080ee78  SP      : 0x40835150  GP      : 0x40819e54
0x4080ea64 - sta_rx_eapol
    at ??:??
0x4080ee78 - sta_input
    at ??:??
0x40819e54 - g_coex_param

@ivmarkov
Copy link
Collaborator Author

Hm can you add the stack increases of the additional esp idf tasks from here:
https://github.com/esp-rs/esp-idf-svc/blob/master/.github/configs/sdkconfig.defaults#L5

@ivmarkov
Copy link
Collaborator Author

Especially the system event loop stack increase seems important as the esp idf br example also has it:
https://github.com/espressif/esp-idf/blob/v5.3.1/examples/openthread/ot_br/sdkconfig.defaults#L53

@turulix
Copy link

turulix commented Sep 20, 2024

Okay, I'm officially 100% lost now.

It's now working sometimes??

After completely erasing the flash and reflashing the binary, it works for about 30 seconds, then crashes. Upon restarting, it fails with ESP_ERR_TIMEOUT while trying to connect to Wi-Fi. The only way I've found to recover from this state is to fully erase the flash again and reflash it (EDIT: this also doesn't seem to be 100% reliable). Simply resetting via Ctrl + R in the monitor leads to one of two outcomes: either the Wi-Fi connects and then instantly crashes, or it times out during connection.

EDIT: This seems random. Right now its just working with me changing absolutely nothing

@ivmarkov
Copy link
Collaborator Author

Let's call it a day. I will recheck at my end tomorrow.

@ivmarkov
Copy link
Collaborator Author

ivmarkov commented Sep 21, 2024

@turulix

  • Regarding the spurious ESP_ERR_TIMEOUT:
    If you pull latest from the PR, this problem is now fixed.
    The problem was in the Wifi adapter, not in Thread, in that for c6, the adapter was not configured correctly.

  • Regarding the LoadProhibited crash:

    • With ESP-IDF 5.3.1 it DOES work stable for me, and does not crash. Left it working for 10 minutes or so
    • Every earlier ESP IDF though - including ESP IDF 5.3.0, 5.2.2, 5.1.4 it does crash on me also

I'm still not sure what is the reason for the crash with earlier ESP-IDF versions.
To debug it further, I need first to print a proper crash backtrace on the c6 (what it dumps and what you see is raw stack memory, sd we can't see where exactly it is crashing). I'll spend some time working on that. (This is an old problem, valid for all riscv Esp chips.)

@ivmarkov
Copy link
Collaborator Author

Btw CI fails because latest nightly changed the formatting rules of cargo fmt. Likely, a regression.

Copy link
Collaborator

@Vollbrecht Vollbrecht left a comment

Choose a reason for hiding this comment

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

Looks pretty good for an experimental first introduction. And it only come with this tiny little breaking change in NetifConfiguration/NetifStack so nothing to swat about.

Thanks!

@ivmarkov ivmarkov merged commit fdd4606 into master Oct 1, 2024
15 checks passed
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