-
Notifications
You must be signed in to change notification settings - Fork 409
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
Cannot load RadioLib.h and can't #include <algorithm> in esp-idf on platformio #748
Comments
I can't test this on MacOS, did you try installing the library using cmake? See this wiki page: https://github.com/jgromes/RadioLib/wiki/Porting-to-non-Arduino-Platforms EDIT: regarding algorithm, I will have to check what exactly needs it, maybe there's a way to get rid of it. |
Hi, I have done the things on that page, including the HAL. Strangely, I haven't had any problems with this until I started referring to the library from different directions. |
I am thinking that a part of the problem may be that I can't refer to it as I can to other packages in PlatformIO. I did add a CMakelists.txt, not sure that PlatformIO cares about it post-install though. |
Just to be clear, realized that I had not actually said it, but for indexing: If I use a relative path (../../../.pio/XX/libdeps and so on), it works, but then the relative path will fail when other parts my system wants to include it. (seems that relative paths aren't all that relative to where they are declared or something). |
I changed to depend on https://github.com/jgromes/RadioLib.git instead and still it didn't work. I also tried with a relative path to it now, for some reason relative paths now work (could it be because of CMakelist?) but still the same result with not finding |
Ok. Well. This seems all to be about the compiler being confused with C/C++ because of the full path #include. After putting all the C++ stuff, like the RadioLib classes in one file, so that RadioLib did not have to be imported by anyone else, it started to compile again. However, and I think that this might be part of the issue; I still cannot include RadioLib normally.
doesn't work. Only thing that works is: Regardless if I am using the latest release or master. |
@nicklasb in the last few commits, the dependency on algorithm should be resolved. As to the rest of your issues, I'll try to replicate them with ESP-IDF. If you could share your HAL implementation and Cmake, that would help me get started. |
Great with the algorithm dependency! The HAL implementation is quite complex as it in turn depends on a framework (which is sort of a HAL itself and still too embarrassing to share) I am developing. That should not be a factor, though. I know, famous last words. :-) But I'll set up a project and try to replicate the issue, and share it with you. |
@jgromes Hi, it doesn't seem like the issue was related to the dependency. I think that you might be onto something with that it has something to do with the HAL. |
Hi, I don't seem to be able to figure this out. It is likely that it has something to do with how I am implementing my HAL, however I see no strange includes in that that could cause issues, it does what ArduinoHal does, basically. It should be noted, though that ArduinoHal is inside the library, and the same folder. There was a comment in /RadioLib/extras/test/SX126x/CMakeLists.txt about having to use add_subdirectory if one haven't built it as a shared library...but if I do that, it would seem that I'd break the dependency-driven model. |
I don't see your HAL implementation in the repository you linked, so I can't really comment on that. In the meantime, I started writing my own ESP-IDF HAL and everything seems to be working so far - although it is without platformio. Once it's done I will add it to the NonArduino examples as a reference. |
That sounds like a great idea!
My HAL works against a framework that already hides if it is Arduino, ESP-IDF or STM32, so I basically just added the above code. I suppose that logging to ESP_LOGX will be something you'd need to implement too. |
OK. I have now recreated the problem in the above mentioned repo: The problem happens when the code #include:ing RadioLib.h is an ESP-IDF-component. I suppose that the solution has something to do with being able to refer to RadioLib as such, currently that doesn't seem possible. But actually, it should not be needed. |
I tried adding an idf_component.yml, to make the component handle its own dependencies:
But then the CMakeLists.txt for the library is configured as a project, so that causes an error. |
So it would appear that in order to be used by ESP-IDF-components, RadioLib needs to have a CMakeLists.txt that works for that purpose. Not sure how that is done, though, obviously project(radiolib) can't be there, at least like that. I asked Espressif for a solution: |
@nicklasb I added a functional ESP-IDF example - functional as in it builds, flashes and transmits via SX1278. Feel free to take a look at it, maybe you will be able to identify the issue you're seeing? It's not using platformio, but I don't think that should be the issue - I didn't have to do any changes to the root RadioLib cmake to make it work (as per your previous comment). |
Hi, WRT the component situation, the implementation has a relative path to the location of the library, so it doesn't help I am afraid as that is my current and very temporary workaround, and the CMakeList of RadioLib has a "project" definition. I proposed that one perhaps could use conditionals in the CMakeLists.txt, I know it is one-pass but I think that it should work. The ESP-IDF HAL is nice. Even though my HAL..eh...works...yours seems way more worked-through, I am not really an embedded dev by trade, so my bag of tricks isn't particularly full, there's a couple of gems there I'll reuse. :-) |
I still don't understand why this is a problem. The project definition in RadioLib is not strictly necessary, so it can be removed, but I don't understand why is this causing trouble. |
Ok, I will try some variants. |
Sorry, that's still not descriptive enough for me to understand. A working example would be nice, or at least the structury (e.g. - copy-paste RadioLib source to components/, make some change to the top-level CMake etc.). As far as I can tell right now there is no problem in the library itself, so I'm closing this issue for the moment. There clearly exists a way to build RadioLib for ESP-IDF. Additionally, I don't think RadioLib CMake should include anything ESP-IDF specific, such as the idf_component command(s). Otherwise we would have to keep adapting the library to different build systems ... |
Hi, In your example, RadioLib is not added as a component, but a local component is added to the project and then Radiolib to it. This is similar to my current workaround, where I have a relative path to where RadioLib resides in LibDeps. IMO, I consider neither that as a very redistributable workaround, I want my stuff to be just one of many easily added dependencies. But I will fork RadioLib and try out a lot of variants, I'll get back to you with something that hopefully works. Adapting to different build systems is something that I feel is a kind of natural chore for shared libraries, though? |
I tried to approach a bit more to your configuration (RadioLib directly cloned into components/), removed the project() command from RadioLib root CMake, and the only thing that this changes is that not even add_library can be used. For me, having this is a hard requirement, because without it, CMake-based build system won't be able to use RadioLib as a ... well, library. The ultimate problem is that ESP-IDF uses CMake in script mode and assumes components will be compatible with it. RadioLib obviously isn't, so the only thing that I can do at this level is to guard the CMake commands that cannot be used in script mode with |
Yes, but in a parallel, and quite unrelated, discussion (ttlappalainen/NMEA2000_esp32#12 (comment)) I saw this guy simply do I haven't tried that myself yet, won't have time for that until the weekend, but it seemed promising and worked for him. |
@jgromes, Granted, I haven't tried with a huge number of projects yet, but at least this example library and my framework (that uses many more parts of RadioLib due to its HAL), works well like this. (Thanks @phatpaul for the inspiration!) |
@jgromes |
I'm not a huge fan of this solution, I don't think it should be the job of the library to adapt to non-standard build systems (and ESP-IDF does require calling idf_component_register). The sheer popularity of ESP platform somewhat forces my hand here, so I will implement it, however, with two modifications:
|
@jgromes Sure, that is probably better, looks better, too. *For example, I am pretty sure that Espressif didn't make ESP-IDF just to mess with the community and lock people in, the costs associated would never justify that singular end. |
@nicklasb added into the root CMake and also updated the example - thanks for investigating this! |
Works great for me! Thanks for implementing!! |
I only seem to be able to use RadioLib.h by way absolute paths; like
/Users/username/Documents/PlatformIO/Projects/RobArch/.pio/libdeps/TTGO-LoRa32-v1/RadioLib/src/RadioLib.h
However, I then get this error:
/Users/username/Documents/PlatformIO/Projects/RobArch/.pio/libdeps/TTGO-LoRa32-v1/RadioLib/src/BuildOpt.h:313:12: fatal error: algorithm: No such file or directory
Which I think that may contribute to the compiler not finding RadioLib.h, as I have tried all tricks to make the component visible to ESP-IDF, like adding CMakelists.txt and similar.
In BuildOpt my builds become "generic non-Arduino platform" builds, and that is when they try to include the algorithms library.
Notably, I run this an a MacOs, but I have tried with all compilers I have found (CLANG 14, GCC 13 etcetera).
Great library, I have almost gotten everything to work now, but I suppose there is always something. :-)
The text was updated successfully, but these errors were encountered: