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
Disallow variant/family override for known boards #6512
Conversation
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @kuba2k2, mind taking a look at this pull request as it has been labeled with an integration ( |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #6512 +/- ##
==========================================
- Coverage 53.70% 53.43% -0.28%
==========================================
Files 50 50
Lines 9408 9537 +129
Branches 1654 1685 +31
==========================================
+ Hits 5053 5096 +43
- Misses 4056 4130 +74
- Partials 299 311 +12 ☔ View full report in Codecov by Sentry. |
Hi, The Since the term "variant" is not used internally in LibreTiny (instead "family" is used), I'd propose to keep the original naming (maybe even replace the Also, adding each chip type to ESPHome might make maintaining it more involving - each new chip type supported by LibreTiny will need to be added and users will not be able to just choose a family of a newly supported board. The following test YAML: rtl87xx:
board: generic-rtl8710bn-2mb-788k
variant: rtl8720cf will compile the firmware for the RTL8710BN chip, not the RTL8720CF. These belong to different families (AmebaZ vs AmebaZ2). I hope this will make it easier to understand how LibreTiny handles the compilation for different chips. |
Thanks for the response.
And currently that (the PIO board file) is where PIO gets the Let me backtrack a bit to explain the reason for going down this rabbit hole: The original problem (which came up for ESP32) was that if a board is specified but a variant also specified, internally ESPHome uses the variant, but does not pass that to Platformio, which leads to C++ compile-time failures if e.g. pins or libraries dependent on ESP32S3 are compiled for ESP32. E.g:
That's clearly undesirable - config errors should be caught at ESPHome build time - one of the strong points of ESPHome is that the average user should never see a compiler error, only YAML validation errors. So the logical solution is to pass the But, tests for Libretiny failed because for some of the chips, the There is the question of what purpose the But if they are going to remain, they should work properly.
No, that will (after this PR) compile for rtl8720cf. The current implementation would look like this:
And that (currently) fails to pass YAML verification:
If you use one of the suggested options, it now builds, but as you pointed out, for rtl8710bn. That's an unexpected result since something different was requested. So basically the |
There's a script that does that so the effort is small. If there is a board file in Platformio then ESPHome supports it. New variants would also automagically become available via the same process.
I'd argue that the typical user doesn't need to know what happens internally in LibreTiny, and |
Unfortunately, that's not the case in LibreTiny. It uses
I do 100% agree with that - I was trying to find a solution for LibreTiny too.
Because
You're right, there's no reason to override the
Continuing: there is a script that generates the
Unfortunately, it is not that simple. Let's say you want to compile for the
As mentioned in the 1st paragraph of this comment, LibreTiny will ignore that change. It will still compile for RTL8710BN. If you change
In conclusion: there's no reason to change the chip family in LibreTiny - it is not even possible. The
I think the right solution would be to make the Maybe it would help to rename it, e.g. |
Ok, so I understand more about what's going on, and the motivation for the option. It does seem to work differently to using PIO with esp-idf.
I think this is probably the best idea right now. And it should be disallowed if the
It seems only effect of specifying the How does that sound? And I can't see any reason not to use the same approach with ESP32, since the motivation for the Not important - but what's the difference between RTL8710B (a family) and RTL8710BN (or X) - which are mcu types within that family. The BK series apparently has no such oddities. |
Yes, this solution seems to fit really well.
Correct, the macros are only supposed to enable/disable certain features available on a certain family only, however as you have noticed they aren't used so far. Up to this point, the family type validation required it to be known to ESPHome - after all, there's no benefit of specifying the family name unknown to ESPHome, as there will be no macros using that name anyway. Removing the macros would allow to remove the In the current codebase the family name for known boards is in I can't speak for the ESP32 variant field, because I'm not familiar enough with the differences that it introduces.
Good question, it seems to be a bit confusing at first. LibreTiny configures most compilation options based on the family - SDK to use, files to compile, #defines to enable, etc. The MCU type is less important and not generally used. In short, the family divides chips by their similarity and compatibility. |
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration ( |
What does this implement/fix?
Types of changes
Currently setting
variant:
(family:
for LibreTiny) in the esp32 component makes ESPHome think it's compiling for a variant that may be different to the default one fromboard:
. This option should not be allowed if the board type is known, since the user may infer it actually changes something.This is a breaking change since any yamls currently includingvariant:
will now fail to compile.Now the variant will be allowed without any warning or error message if it matches the board.
Tests have not been added since the ESPHome testing structure currently has no provision for tests that must fail.
Related issue or feature (if applicable): fixes esphome/issues#5664
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3754
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: