Custom firmware ESPHome-Xiaomi_bslamp2

Hello. I apologize for the silence, I installed the system completely from scratch. Unfortunately I get exactly the same error when compiling as before.
Could you indicate what system you have installed, that everything works for you?

Docker desktop (Docker Desktop for Mac and Windows | Docker) on MacOS and the esphome docker container from docker hub (Docker Hub).

I run both command line esphome (for development purposes) under WSL on Windows, and a docker container that I startup from a docker-compose on a RPi4B running raspbian 10, using an armv7l kernel (so 32 bits).

Hello. I’ll try to install the 64-bit version then. Then I will write if it helped or not.

The 32 bit version you mean?

No. The 64 bit version.

Hi, I’ve tried to compile latest example.yaml without any modifications. I am runnin ESPhome v2022.2.5, latest HA and receive log as below. Does anybody know what could be the issue with this?

INFO Reading configuration /config/esphome/lampka-sypialnia-1.yaml...
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@dev
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@dev
WARNING 'lampka_sypialnia_1': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing lampka_sypialnia_1 (board: esp32doit-devkit-v1; framework: espidf; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - framework-espidf 3.40302.0 (4.3.2) 
 - tool-cmake 3.16.4 
 - tool-ninja 1.7.1 
 - toolchain-riscv32-esp 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
Reading CMake configuration...
KeyError: 'version':
  File "/usr/local/lib/python3.9/dist-packages/platformio/builder/main.py", line 181:
    env.SConscript("$BUILD_SCRIPT")
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/data/cache/platformio/platforms/espressif32/builder/main.py", line 233:
    target_elf = env.BuildProgram()
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Util.py", line 742:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/platformio/builder/tools/platformio.py", line 61:
    env.ProcessProgramDeps()
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Util.py", line 742:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/platformio/builder/tools/platformio.py", line 128:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Util.py", line 742:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/platformio/builder/tools/platformio.py", line 343:
    SConscript(env.GetFrameworkScript(f), exports="env")
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 660:
    return method(*args, **kw)
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/data/cache/platformio/packages/tool-scons/scons-local-4.3.0/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/data/cache/platformio/platforms/espressif32/builder/frameworks/espidf.py", line 1159:
    project_codemodel = get_cmake_code_model(
  File "/data/cache/platformio/platforms/espressif32/builder/frameworks/espidf.py", line 221:
    assert codemodel["version"]["major"] == 2
========================== [FAILED] Took 3.05 seconds ==========================

Hi,
same here. It did work with 2022.1, it is broken since 2022.2.
I switched to a windows computer to install and upload. 2022.3.1 running fine.

ESPHome

Current version: 2022.4.0

INFO Reading configuration /config/esphome/waynes.yaml…
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@dev
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
INFO Generating C++ source…
INFO Compiling app…
Processing bedside-lamp (board: esp32doit-devkit-v1; framework: espidf; platform: platformio/espressif32 @ 3.5.0)

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf 3.40302.0 (4.3.2)
  • tool-cmake 3.16.9
  • tool-ninja 1.10.2
  • toolchain-riscv32-esp 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
    Reading CMake configuration…
    – The C compiler identification is unknown
    – The CXX compiler identification is unknown
    – The ASM compiler identification is unknown
    – Found assembler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc – broken
    – Configuring incomplete, errors occurred!
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeOutput.log”.
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeTmp

Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_3ab46 && [1/2] Building C object CMakeFiles/cmTC_3ab46.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_3ab46.dir/testCCompiler.c.obj 
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_3ab46.dir/testCCompiler.c.obj   -c testCCompiler.c
/bin/sh: 1: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc: not found
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/data/cache/platformio/packages/framework-espidf/tools/cmake/project.cmake:311 (__project)
CMakeLists.txt:3 (project)

========================= [FAILED] Took 16.43 seconds =========================

Hassio core-2022.4.6
supervisor-2022.04.0
RPI 3 32BIT
Home Assistant OS 7.6

I don’t know what is going on there.
I can compile the firmware on ESPHome v2022.3.2 without issues, both in the official Docker container as a command line installation.

Docker ESPHome 2022.4.0 also no problems with compiling.

Is this HASSIO or stand-alone docker installation?

Stand alone

Thanks for the reply, you doing amazing work, and I am very thank full for it, I am so done with the default software, I will try using a docker install
Video gives nice info how to

Tried again log file attached…just not winning

INFO Reading configuration /config/wayne-bedside-lamp.yaml…
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@dev
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
INFO Generating C++ source…
INFO Core config or version changed, cleaning build files…
INFO Compiling app…
Processing bedside-lamp (board: esp32doit-devkit-v1; framework: espidf; platform: platformio/espressif32 @ 3.5.0)

Platform Manager: Installing platformio/espressif32 @ 3.5.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Platform Manager: espressif32 @ 3.5.0 has been installed!
The platform ‘platformio/espressif32 @ 3.5.0’ has been successfully installed!
The rest of the packages will be installed later depending on your build environment.
Tool Manager: Installing platformio/toolchain-esp32ulp @ ~1.22851.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-esp32ulp @ 1.22851.191205 has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch2 has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2 has been installed!
Tool Manager: Installing espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-riscv32-esp @ 8.4.0+2021r2-patch2 has been installed!
Tool Manager: Installing platformio/framework-espidf @ ~3.40302.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: framework-espidf @ 3.40302.0 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.30100.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-esptoolpy @ 1.30100.210531 has been installed!
Tool Manager: Installing platformio/tool-cmake @ ~3.16.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-cmake @ 3.16.9 has been installed!
Tool Manager: Installing platformio/tool-ninja @ ^1.7.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-ninja @ 1.10.2 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40300.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-scons @ 4.40300.1 has been installed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf 3.40302.0 (4.3.2)
  • tool-cmake 3.16.9
  • tool-ninja 1.10.2
  • toolchain-riscv32-esp 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
    Installing ESP-IDF’s Python dependencies
    Collecting future>=0.15.2
    Downloading future-0.18.2.tar.gz (829 kB)
    Collecting pyparsing<2.4.0,>=2.0.3
    Downloading pyparsing-2.3.1-py2.py3-none-any.whl (61 kB)
    Building wheels for collected packages: future
    Building wheel for future (setup.py): started
    Building wheel for future (setup.py): finished with status ‘done’
    Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491058 sha256=6aeeb2d3c82a0a547eb9c86ae6564931653560298339613e76e07326ba6c115a
    Stored in directory: /root/.cache/pip/wheels/2f/a0/d3/4030d9f80e6b3be787f19fc911b8e7aa462986a40ab1e4bb94
    Successfully built future
    Installing collected packages: pyparsing, future
    Attempting uninstall: pyparsing
    Found existing installation: pyparsing 3.0.8
    Uninstalling pyparsing-3.0.8:
    Successfully uninstalled pyparsing-3.0.8
    Successfully installed future-0.18.2 pyparsing-2.3.1
    Reading CMake configuration…
    – Found Git: /usr/bin/git (found version “2.30.2”)
    – The C compiler identification is unknown
    – The CXX compiler identification is unknown
    – The ASM compiler identification is unknown
    – Found assembler: /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc – broken
    – Configuring incomplete, errors occurred!
    See also “/config/.esphome/build/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeOutput.log”.
    See also “/config/.esphome/build/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /config/.esphome/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /config/.esphome/build/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeTmp

Run Build Command(s):/config/.esphome/platformio/packages/tool-ninja/ninja cmTC_f8f3e && [1/2] Building C object CMakeFiles/cmTC_f8f3e.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_f8f3e.dir/testCCompiler.c.obj 
/config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_f8f3e.dir/testCCompiler.c.obj   -c testCCompiler.c
/bin/sh: 1: /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc: not found
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/config/.esphome/platformio/packages/framework-espidf/tools/cmake/project.cmake:311 (__project)
CMakeLists.txt:3 (project)

========================= [FAILED] Took 455.88 seconds =========================

Can you describe the exact steps you took? I might have a spare raspberry lying around to do some testing.

i took a raspi model 3b
default raspi buster 32bit
docker installed
docker pull esphome/esphome
docker run --rm --net=host -v “${PWD}”:/config -it esphome/esphome
Created a start bedside-lamp.yaml

copy and pasted example

--------------------------------------------------------------------------

Substitutions

These are substitutions as used by the configuration packages from below.

You can uncomment and update the ones that you want to modify.

--------------------------------------------------------------------------

substitutions:
name: bedside-lamp
friendly_name: Bedside Lamp
#light_name: ${friendly_name} RGBWW Light
#light_mode_text_sensor_name: ${friendly_name} Light Mode
#default_transition_length: 800ms

--------------------------------------------------------------------------

Load configuration packages

These provide a convenient way to compose your device configuration from

some functional building blocks. Pick and mix the blocks that you need.

For customization you can override options in your config or you can

copy the contents of these packages directly in your config file as

an example for your own customizations.

Available packages are:

- core.yaml : core components & hardware setup

- behavior_default.yaml : default device behavior

- ota_feedback.yaml : enable visual feedback during OTA updates

- activate_preset_svc.yaml : ‘activate_preset’ service for Home Assistant

--------------------------------------------------------------------------

packages:
bslamp2:
url: GitHub - mmakaay/esphome-xiaomi_bslamp2: ESPHome integration for the Xiaomi Mijia Bedside Lamp v2.
ref: dev
files:
- packages/core.yaml
- packages/behavior_default.yaml
- packages/ota_feedback.yaml
- packages/activate_preset_svc.yaml
refresh: 0s

--------------------------------------------------------------------------

Use your own preferences for these components.

--------------------------------------------------------------------------

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

api:

ota:

I will have to dig around a bit tomorrow, but I should have a spare 3B. Maybe there is a difference with the 4B installation that I am using (although docker ought to fully negate that).

Secretly hoping for a big error :wink:

Btw: when pasting code, better put it between code markers here; three backticks before and after the code

```
Like this
For better
Readability
```

Much appreciated, would be great to get the esp loaded. Get the control back :slight_smile:
thanks for the heads up on the code (backticks) much appreciated
I did try a 4B 4gig and 4B 8GIG but that was on 64bit on Hassio.

I came closer generating the.bin file with 32bit.

Hi all
I am going to try to add the custom firmware to my bedside lamps. I never used before a serial to USB adapter so if anyone could help me with the wiring (in order to be 100% sure that I am going to make the connections right)
So I have this one ( I think it is ok)

and I have to follow the below

image

I have connected the 2 pins (?) in 3V so I think this is ok.
I am a little confused about the 2 grounds.

I think I can use the 2 gnd holes the 3.3 hole + rx one. Is that ok?
Can someone point out all the 4 pins in my YP-05 just to be sure please?

I also need some more help with the below.
Can I use a windows 10 laptop to install the firmware?
If I have understand correct I only need the above YP-05 to flash the firmware. Is that right?
I am asking because in the installation guides I see some instructions for ESP32.
Thanks