libretiny-eu / esphome-kickstart

Precompiled LibreTiny-ESPHome firmware allowing identification of device pins and OTA upgrading
35 stars 4 forks source link

Option for ESP based boards #7

Closed yeyeto2788 closed 8 months ago

yeyeto2788 commented 8 months ago

Hey there!

Is it possible to enable this to work on ESP-based boards so that .bin files are generated for ESP8266 and ESP32 boards? Sometimes it is a bit tricky to track down what pins are used on some devices.

Cheers.

kuba2k2 commented 8 months ago

Yes, it should be possible. Additional YAML files for ESP would have to be added, and pinscan component would need to be modified too.

yeyeto2788 commented 8 months ago

I tried (not an expert) but I'm getting the following error:

image

Here is the code https://github.com/yeyeto2788/esphome-kickstart/commit/c2fd6f0f48a9a30d64c7f643cf18f81c9afd1bd8

kuba2k2 commented 8 months ago

As I said, the pinscan.cpp file must be modified too. A new pin map for ESP must be added, just like in the YAML file.

yeyeto2788 commented 8 months ago

I did for the ESP8266 but maybe I'm doing it wrong, I would appreciate a bit of help there.

kuba2k2 commented 8 months ago

In your fork the #error is on line 69, but in the screenshot it's on line 54. That means you're trying to compile the original version instead of the fork.

yeyeto2788 commented 8 months ago

😢 even changing it to pull my code the error is the same just in a different line.

image

Maybe the elif board variable is wrong? Or even the pin naming?

kuba2k2 commented 8 months ago

You can try USE_ESP8266 as that's an ESPHome macro. I'm not sure if esp8266 defines "ESP8266".

yeyeto2788 commented 8 months ago

Still getting the same issue, I guess that macro is coming from somewhere else. Don't know how to get the value of what is defined.

kuba2k2 commented 8 months ago

Your #elif is on the same line as the closing bracket. Macros must be on their own line.

yeyeto2788 commented 8 months ago

I noticed that earlier and pushed the new code to the repo just to check if that was the issue but it still had the same error (https://github.com/yeyeto2788/esphome-kickstart/commit/1853ed3bb9988fb01aaf7cffbc11234cd2548ee8). It does seem like the define macro is different and compilation verbose output defines several macros but none of them seems to work.

I tried with ESP8266, USE_ESP8266 and nothing.

kuba2k2 commented 8 months ago

Weird, I just checked out your repo and it works just fine. I mean, there are some missing GPIO errors, but that's a different story.

I will push a commit making it reference ../components directory instead of the repository, because it seems it's using an old revision of your fixes.

yeyeto2788 commented 8 months ago

Finally, it compiled.

image

I have created an MR in case this wants to be added to the repo and the build should trigger automatically. The only missing board would be ESP32 which I would add this week or the next one.

yeyeto2788 commented 8 months ago

Changed my mind, I'm trying to add ESP32 as well 😋 but now the error seems to be on the pin name which I could not find what is the naming convention used

image

kuba2k2 commented 8 months ago

Can you enable maintainers write permission for this PR? I'd like to push a little formatting change to build.sh.

kuba2k2 commented 8 months ago

Oh, and I messed up by pushing to the wrong remote... can you create the PR again?

kuba2k2 commented 8 months ago

The file esphome/components/esp8266/boards.py has a list of all pins. It would be helpful to mention the pin function (such as GPIO5 / SCL, just like for LibreTiny boards) - see ESP8266_BASE_PINS. The pin mapping in pinscan.cpp must be 100% consistent with the YAML.

Also, the FUNC_* macros might not be suitable here - the macros are only used to map the YAML "select" index to a GPIO number. If there are no such macros on ESP, just write 0, 1, etc, which will represent the GPIO numbers.

yeyeto2788 commented 8 months ago

Ok, let me add that and create a new MR with those changes so you can double-check. I haven't tried yet the firmware though.