xperiments-in / xtouch

Other
639 stars 62 forks source link

Source code can't build in Platform.io #103

Closed tgzihg closed 3 months ago

tgzihg commented 8 months ago

Do we need to install nodejs?

Misterke commented 8 months ago

I had the same problem when first trying to make my own derivative. I had to install Python, nodejs and then make some changes to get it to build on Windows.

Apparently the build runs a nodejs script to fetch data from Bambulab and turn that into a description of all the error codes the printer may return (bbl-errors.h en bbl-errors.c). The original versions of those files are checked in already and I have noticed that quite regularly the Bambulab server refuses to provided the requested data. One options it to comment out the invocation of that nodejs script at the bottom of scripts/pre-build.py and just work with the versions of bbl-errors.h/c that are present.

Next problem I had was in post-build.py where the function post_build_merge_bin() tries to invoke esptool.py, but on Windows that won't work and the 'esptool.py' parameter needs to be replaced by two successive ones: 'python', '<PUT-THE-RIGHT-PATH-HERE>\\.platformio\\packages\\tool-esptoolpy\\esptool.py'. If then the esptool.py still complains about "serial" missing, then put the following line in front of the mentioned invocation of esptool.py:

subprocess.run([ "python", "-m", "pip", "install", "--upgrade", "pyserial" ], cwd="./.pio/build/esp32dev")

You can probably comment it out again after the first run and possibly there is some other way to run the pip invocation in the correct context from the command-line, but I couldn't figure it out and hence placing that command in the post-build.py, was the easiest way for me to get things working.

Finally ... the entire build ends with publishing the build results in a folder called xtouch-bin that should be located next to the xtouch folder that contains the platformio.ini and this xtouch-bin folder has to exist and already contain subfolder fw, ota and webusb. I guess this step is not a must if you just want a firmware.bin, but since I wanted to have my own locally hosted OTA server, it is nice to have the JSON and bin file readily available.