remibert / pycameresp

Motion detection with image notification for Esp32CAM and Esp32 flasher with GUI based on esptool.py.
Other
71 stars 20 forks source link

Homekit micropython module for esp8266/esp32 #3

Closed baracudaz closed 2 years ago

baracudaz commented 3 years ago

Hello and thanks for an awesome work!

Is there a way to make your Homekit implementation work as an independent MicroPython module?

I am currently using Arduino HomeKit ESP8266 however I would love to see Homekit for MicroPython module. Any thoughts?

remibert commented 3 years ago

Hello,

The ESP8266 has less RAM and ROM than a generic ESP32. On the generic ESP32 homekit works but it is limited. On the esp32cam, which has a spiram, I was unable to get homekit to work simultaneously with the camera. I'm afraid it's hard to get homekit to work with micropython on esp8266.

Le 5 avr. 2021 à 20:41, baracudaz @.***> a écrit :

Hello and thanks for an awesome work!

Is there a way to make your homekitimplementation working as micropython module for esp8266?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/remibert/pycameresp/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3HE2ELY66H3WRXA4DLFF3THH765ANCNFSM42NIJQYQ.

baracudaz commented 3 years ago

Understood. However I was just wondering whether we could try it despite the constrains. Unfortunately I do not know much about esp32/esp32cam. However I did try the default micropython on ESP8266 in a past successfully. Not sure how to build a custom micropython distro based on your sources to include homekit. Perhaps you can navigate me?

remibert commented 3 years ago

I deliver scripts to easily get and recompile micropython for esp32 (tested on linux and osx, probably not working on windows). I wanted to try to recompile the esp8266, apparently it's not the same compiler, and I know I had a lot of trouble making a script that automates everything for the esp32. I don't have esp8266 either. Then if you know a little about it, and you have the time and the material, I can add your scripts into the project. I can help you patch what you need in micropython for support homekit. I attached the script to rebuild the esp 8266, it would probably also be necessary to create the script getFirmware8266.sh, which would look for the right compiler.

Le 6 avr. 2021 à 15:35, baracudaz @.***> a écrit :

Understood. However I was just wondering whether we could try it despite the constrains. Unfortunately I do not know much about esp32/esp32cam. However I did try the default micropython on ESP8266 in a past successfully. Not sure how to build a custom micropython distro based on your sources to include homekit. Perhaps you can navigate me?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/remibert/pycameresp/issues/3#issuecomment-814124759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3HE2AITGMSH4PCVFNFQHDTHME2TANCNFSM42NIJQYQ.

baracudaz commented 3 years ago

Sure that will do. As it turns out getting the micropython to compile for esp8266 is fairly straightforward especially with docker image. Here is what I did:

docker pull larsks/esp-open-sdk
git clone https://github.com/micropython/micropython.git
cd micropython
export MAKE="docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make"
$MAKE -C ports/esp8266 submodules
$MAKE -C mpy-cross
$MAKE -C ports/esp8266

Voilà! The esp8266 firmware is build! Now onto merging your code ;)

remibert commented 3 years ago

I installed docker on osx, and tried your commands, but it didn't work. I do not know Docker, I watched tutorials on the net, I did not do better. After I looked at the differences between esp32 and esp8266, it's not just a patch, there are a lot of adaptations to be made. Without hardware, not too much time at the moment, without any certainty that on this small processor it works, sorry I could not do more for the moment. All the patches to support homekit on esp32 are available in the "patch/c" and "modules/lib/homekit" directories, maybe if you can manage to compile, patch the makefiles and the sources, to see what happens.

Le 7 avr. 2021 à 22:04, baracudaz @.***> a écrit :

Sure that will do. As it turns out getting the micropython to compile for esp8266 https://github.com/micropython/micropython/tree/master/ports/esp8266 is fairly straightforward especially with docker https://hub.docker.com/r/larsks/esp-open-sdk image. Here is what I did:

docker pull larsks/esp-open-sdk git clone https://github.com/micropython/micropython.git cd micropython export MAKE="docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make" $MAKE -C ports/esp8266 submodules $MAKE -C mpy-cross $MAKE -C ports/esp8266 Voilà! The esp8266 firmware is build! Now onto merging your code ;)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/remibert/pycameresp/issues/3#issuecomment-815206211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3HE2DTGNL6YBMV3SPY3CLTHS3ELANCNFSM42NIJQYQ.

katadelos commented 3 years ago

I attempted to add HomeKit support for ESP8266 boards the other night and am reasonably certain that it's not possible. The main issue is that the SDK used to build MicroPython for the ESP8266 is incompatible with esp-homekit-sdk; you'd likely come up against resource constraints even if the problems with SDK differences could be resolved.

I've created a repository that contains all the necessary patches and changes needed to build the homekit module separately from the pycameresp project here: https://github.com/katadelos/micropython-esp32-homekit

remibert commented 3 years ago

I had tried on my side, and I had also difficulties of this kind. But since it wasn't a priority for me, I put it off until later. I also had some inability to get it to work in conjunction with the camera on the esp32cam, the homekit server needs enough call stack to work, and the call stack can only be internal ram of esp32 (not spiram). With Micropython, there is only 100kb left, on an esp8266 the rest is only 32kb. In any case it would have been very limited to make it work under micropython. Thanks for isolating the homekit part, I think it might interest people.

Le 14 mai 2021 à 19:10, katadelos @.***> a écrit :

I attempted to add HomeKit support for ESP8266 boards the other night and am reasonably certain that it's not possible. The main issue is that the SDK used to build MicroPython for the ESP8266 is incompatible with esp-homekit-sdk; you'd likely come up against resource constraints even if the problems with SDK differences could be resolved.

I've created a repository that contains all the necessary patches and changes needed to build the homekit module separately from the pycameresp project here: https://github.com/katadelos/micropython-esp32-homekit https://github.com/katadelos/micropython-esp32-homekit — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/remibert/pycameresp/issues/3#issuecomment-841384105, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3HE2ETCKVXQVYOATROKYLTNVKR3ANCNFSM42NIJQYQ.

remibert commented 2 years ago

Not possible