-
-
Notifications
You must be signed in to change notification settings - Fork 724
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
AVR folder removal appears to have caused issues with libraries #587
Comments
Hi Tim, |
Hi Martino, Thanks for responding so quickly! As with some of the other I don't know enough about |
Note that you could make an argument that all these avr-specific header files are not part of the official, documented Arduino API, so any sketches that use it limit themselves to being AVR-only. Some elements of these header files are part of the official API (i.e. However, the name |
Hi Matthijs, I'm not including these files in my sketch directly, they are included from within libraries I am using. From an initial search, this error is not uncommon and the pattern of achitecture/platform specific imports appears to be seen to be a reasonable workaround (see here and here). I will look into changing the header in the libraries I am using to Thanks, Tim |
If you want to move this to a new issue, please feel free, but it's still very related to this one. To be honest, I think there's a lot more to it than just this one change, the new core API appears to be incompatible with many libraries in the wild, this will hit many beginners of Arduino using libraries, and I'm sure that's not what's intended here - especially with this being the core for MKR and Zero that are very commonly used. I can see what you're trying to do and agree with the idea, but the changes are probably going to break a lot of libraries. Three examples, my libraries IoAbstraction and TaskManagerIO did not compile because of the PinStatus change on attachInterrupt - this one is easily fixed with a check for the API version define. However, AUnit no longer compiles either for many reasons. This is just from my locally installed libraries. To name a few incompatibilities I found this morning (and this is not exhaustive):
If this is now the default, is this good timing when so many newcomers will be using these boards at Christmas? |
I will make sure TaskManagerIO and IoAbstraction are updated today so that they compile again in a backwards compatible way, for the benefit of other library developers hitting this, I assume that the following is the way to determine if a board's core has moved to the core API: If not could someone correct me please with a better approach? |
I don't have problems with my libraries after this change, maybe because I made them compatible with megaavr and mbed cores, which use the core API from the beginning. always use |
Task manager and IoAbstraction are compatible with Uno, Mighty, and Mega. Fully tested with unit tests for each release - even with extra tests for AVR! Unfortunately, Aunit (a library I use for unit testing) seems to be very badly hit by these changes. Some APIs are not the same on different boards, if we take a look at The changes in my libraries were very small and will be released today, I pretty much stick to the rules where they are set, but there are still some edge cases, like attachInterrupt tricky to deal with. |
First of all, thanks everyone for the discussion and for bringing this up.
@davetcc to accomodate different signatures you can just check for |
Thanks for the help @facchinm! |
Many thanks for picking this up so quickly. I have released both IoAbstraction and TaskManagerIO libraries now, tcMenu was fine. As far as I can tell, all the libraries are working on all supported boards and should be safe if other cores move to the new API. |
Hi,
Part A: Forward DeclarationsThe patch provided by @facchinm replaces forward declarations like:
in my various
There are 2 reasons I explicitly use forward declarations in my header files. 1) Working Around Bugs in the Arduino APIThere are a number of cases where bugs of a particular platform's
If in the chain of header file includes, the order is reversed, the compiler generates an error, such as a There are 2 examples that I can think of the top of my head (there may have been more): a) For an Arduino Zero, that platform defines
b) For an ESP32, until recently, the
I found that if I included It might be possible to solve this inclusion order problem by following the rule that every instance of 2) Avoiding Unnecessary Dependency and Reducing Compile TimeThe validation test suite for the AceTime library currently takes about 40 minutes to run on a quad-core i7 machine with 32GB of RAM. The removal of all of the It seems wasteful to include the entire 3) (Appended) Avoid Leaking "compat.h" ExternallyEdit: I just remembered a 3rd reason why I had to take out the My I spent dozens of hours of trial and error, to work around these various bugs on various platforms. This all worked fine, until now. Part B: Arduino API MigrationI often read comments from some people, saying that the problems experienced by 3rd party libraries are caused by violation of some "official Arduino API" or the use of some "undocumented" features. I find these comments to be unhelpful. As far as I know, there is no official Arduino API that is sufficiently detailed and technical enough for 3rd party library developers to write non-trivial libraries. The Arduino Reference (https://www.arduino.cc/reference/en/) is essentially useless. For one thing, none of the function/method parameters have any type information (int, long, uint16_t, etc). For another, the word "Arduino.h" does not appear anywhere in that Reference. The only way for 3rd party library developers to figure out how to write Arduino libraries is to learn from the examples of other 3rd party libraries, then dive into the source code of I feel like 3rd party library developers should be given more respect and credit for being able to navigate the numerous variants of the Arduino API across different hardware platforms, finding creative workarounds for various bugs, and then producing libraries which are useful and reasonably robust. Instead, we are constantly admonished for not using the "official Arduino API" or using "undocumented features", whatever that means, since most technical information can be found only by reading the implementation code. Perhaps it would be more helpful to improve the technical documentation of the Arduino API to define exactly what those features are. So maybe the Arduino Core API project is attempting to provide that "official API". But I don't understand this project at all. It does not document the current Arduino API. It makes sweeping backwards incompatible breaking changes. Why is How can we improve this situation? Unless the following document already exists, I think it would be immensely helpful if there was an authoritative design document that contained the following information:
Part C: My Plans for the New Arduino APIBefore this issue, I had decided to blacklist the MegaAVR platform for my libraries. In addition to using the new Arduino API, the MegaAVR breaks the It looks like the SAMD is migrating to the new API, so my current inclination is to blacklist that too. I don't use the SAMD. I have only a single hardware board that I can test it on, and I would be very happy not to deal with the broken I don't know if the AVR architecture will move to the new API, but if it does, I may end up dropping support for that too. I have only a limited amount of time and energy. Currently, I am mostly invested in the ESP8266, ESP32, and potentially the STM32duino. If those remain on the old API, then that's where I will spend my time. At the end of the day, it's all about whether I enjoy working on this. And fixing obscure backwards compatibility breaking changes on hardware that I cannot test on is not something that I enjoy. And finally, I would like to ask for some lenience if I have misunderstood something fundamental, or am lacking some historical background of the Arduino project. I started playing with Arduino less than 3 years ago, so anything that happened before then is not familiar to me. |
only some comment from a 3rd library developer:
|
This is maybe not the best place for such an open letter, but it is public and easily available for anyone who wants to read it. There are many users of the Arduino eco-system from beginner right through to seasoned developers like myself (background in assembly, C, C++, Software design, C#, and Java). Regardless of skill level, we all want the same thing, a stable, well-documented eco-system where libraries work on all boards, and I think the API has the ability to help get there, but more care is needed around backward compatibility to avoid making things worse in the interim period. To have a chance of gaining traction, the API needs to be the easiest option for forks, otherwise, they will not take it and we will all end up in an even worse position with another variant to support, with library writers taking the worst of it. You need to understand that a lot of the good-will that you have, and the size of the developer community is down to the wide range of generally high-quality libraries written by many people such as @bxparks, @ladyada et al, and even my humble offerings. It's then further widened by the other boards offered by SparkFun, AdaFruit, Seeed, Espressif, Teensy, etc. If there's a serious effort to make that API viable, then someone needs to reach out to some of the most popular forks and ask them to take the API too. Is there a need for a new forum category for the discussion of libraries and the API? I don't really know how third-party developers are seen internally, so It is hard for me to determine. I agree with a lot of what @bxparks has said, traditionally, it was impossible to work out what the Arduino API was, many things were found either by searching google or looking at the code. I think even the new API is lacking documentation quite honestly. Also, I think that deprecation should be done in a more reliable way with at least a few months' notice. Personally, for my projects, I document all classes and files and use Doxygen to generate a series of HTML pages. I'm trying my best not to "tell people how to drive on the public highway here" but this breaking change was made in a patch release version, this should have been 1.9.0 at the very least if not 2.0.0 quite honestly. It was released a few days before Christmas when many. many new MKR and Zero users would be expected, and quite honestly on my MKR1300 even an AdaFruit ST7735 SPI display didn't work properly on 1.8.10; which would certainly be the starting point after "blink" for many users. If things are genuinely deprecated a comment would not get through to the end-user:
I think the following would be better:
Then when it's finally no longer supported, for a release leave it in place and move to For functions, methods, and classes that are deprecated, if you used Doxygen, it has a deprecation tag that many IDEs pick up. In CLion/platformio (and I think VSCode with C++ support enabled) anything deprecated is highlighted in the IDE. As a company, we're fully committed to supporting as many Arduino boards as we can with our libraries, even though it's sometimes hard to do, from Uno to dual-core RTOS boards. Further, I'll always be grateful to the Arduino framework for getting me back into embedded development; which started for me about 2013/4, when I first started other options still needed special hardware, lacked any abstraction, and had no supporting libraries. Dave Cherry - thecoderscorner.com |
So, I was going to start blacklisting My plan now is to tweak things with the least amount of change, which I think has the highest chance of success: I'm going to replace my forward declarations with something like this:
(If I recall, C++11 does not allow forward declarations with just The trouble with replacing the forward declaration with Apparently, I have 236 Hopefully, this will take care of the samd >=1.8.10 boards. The megaAVR seems hopeless. I have too much code that depend on the |
@bxparks
Also, @bxparks , you should take a look at our new tool for project/library/platform validation |
@bxparks I've extensively used your excellent aunit library for many of my open-source projects. I would try my best to help out in any way needed if it would help you to support the core API, and not drop support for platforms. Honestly, my only other option would be to change unit testing frameworks. Please feel free to reach out to me on github, or using the help button on the lower right of my site (https://www.thecoderscorner.com) if you think an additional tester / contributor would help matters for you. I work with Mega, Mighty, SAMD, Nano BLE, ESP8266, ESP32 on Arduino, and STM32 using mbed.
|
Subscribing for interest, I have a unit testing library in which it's unclear how far the library mocks should extend. |
@ubidefeo: Hi, when you wrote, "I really thought you were developing AceButton for the Arduino community", I think you meant to write something different than what you actually wrote, but I'm not exactly sure what you intended to write. I'm sure it was benign though. I mean, I created AceButton mostly for myself, but I published it for the benefit of the Arduino community. I think I can say honestly that the documentation of the library, the testing, and quality of the library is far above average, and a lot of that was for the benefit of the community. I do this on my free time, I don't get paid for this. Oh, btw, the https://github.com/arduino/arduino-lint link is a 404. Maybe it's still private? I tried searching for it on GitHub and on search-engines, but couldn't find it. I think we would all agree that having a consistent Arduino API is beneficial to everyone. Ubi's video is a good example. He uses my AceButton library on a Nano 33 IoT. I don't own that board and I have never validated AceButton on it. However, last year, I decided that I should officially support the SAMD21, so I got a couple of cheap SAMD21 M0+ clones on eBay, which claimed to be "Arduino Zero compatible", but of course, I could not get But the new Arduino API breaks that compatibility, for reasons which aren't clear to me. Yes, there is some attention to backwards compatibility to older Cores, e.g. in the I realize that the Arduino devs are all busy, overloaded, with competing priorities and deadlines. But I think it would help 3rd party developers significantly if we got more technical guidance on this new Arduino API. I think this is a reasonable request. I'll make a concrete suggestion: There is no longer a publicly editable wiki on the https://www.arduino.cc/reference website. But GitHub has a wiki for each project, so the wiki at https://github.com/arduino/ArduinoCore-API would be a convenient place to capture information about the new Arduino API. @davetcc: Thanks for your offer to help, I may take you up on it for validation testing on boards that I don't have access to. Two quick questions for you:
|
hey @bxparks
let me rephrase that: also making sure that it would be compatible with the needs of the Arduino community.
I really meant you were putting effort into making it compile successfully on Arduino
oops! I might have given that away 24-48hrs before time.
You have a fair point there, Brian.
I'll chime in on this, although the question is to @davetcc cheers.ubi |
Following on from @ubidefeo, I think most official Arduino SAMD boards use pretty much the same core, although someone with more knowledge please correct me if I am wrong. I have an MKR1300 board with an MKR ethernet shield attached, it should be good enough for testing. Along with this I also have a Seeed SAMD21 device with BLE connectivity - because it's used by one of my clients and therefore I need like for like. Sorry to bring mbed into the picture, it's there because all of my libraries need to work on mbed too, but I don't run the unit tests there as I can't presently, so I have at least a smoke test project instead.
It would be very good if someone from the Arduino team could give us more details on the plans. It would help at least with expectations around where this API is heading. IE: is there a plan to work with the various third party cores such as ESP, Seeed, Mighty etc to get them to adopt it too? |
I think you are trying to say that you assumed that I was targeting my libraries to be accessible to Arduino novices? The answer is: Definitely Not, I'm targeting Advanced users. Just reading my README.md file should have told you that. :-) It seems to me that the "Community" is composed of people of varying levels of interest, skills and knowledge. Some are beginners, just getting started with connecting a button. Some are trying to make COVID-19 ventilators using Arduino (as scary as that sounds). I lean towards the more advanced users, but I am willing to support as many hardware platforms and 3rd party Cores as reasonably possible. This has become more difficult with the spread of the new Arduino API. Which is why it would be awesome to have more technical guidance about the new API from @facchinm, or whoever is responsible for such things (I am not familiar with the internal division of labor within the Arduino team). Information like the following:
With regards to the MKR boards, thanks for the info @davetcc and @ubidefeo. What I'm hearing is that all the MKRs use a SAMD21, just like the Nano 33 IoT. So if I validate on one of those, I should be ok with the others. In theory, of course. |
Most definitely, can't wait. |
@bxparks, for Sparkfun M0 try Arduino M0 in SAMD core. M0 has a different bootloader then Zero and MKRs. (or replace the bootloader) |
Hello,
Firstly, thanks for providing this core module! It works really well and has enabled me to get the MKR WiFi 1010 board working quickly!
In the 1.8.10 release, it appears the "avr" directory, which includes a number of basic files such as
pgmspace.h
, was moved:This has caused an issue in my project where I am using Arduino libraries which make the assumption that these files will exist.
For example, I have a simple program which uses the AceTime library:
The offending lines in that library are:
which makes it very clear that this path is expected to exist. I have similar issues with other libraries and have seen this mentioned on forums as a reasonable workaround for Arduino libraries which need to work over a wide range of boards/platforms.
So my questions are:
I hope that the information I have provided makes sense, please let me know if further diagnostics or information would be of use to you. I have obscured some of the file paths slightly for privacy purposes.
Thanks,
Tim
The text was updated successfully, but these errors were encountered: