You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
6.2 KiB

  1. # Flashing the Yeelight Bedside Lamp 2
  2. ## Tools needed
  3. * Allen key (2mm, 5/64") or torx (T8) screw driver
  4. * Soldering Iron
  5. * Perhaps some sticky tape
  6. * A serial to USB adapter (FTDI)
  7. * Some wires
  8. ## Warning
  9. We have writen these instructions with care, but we will give absolutely no
  10. warranty. Perhaps you will destroy your device and your computer.
  11. ## Opening the Yeelight
  12. Remove the rubber pads from the botton of the device.
  13. Unbolt the 4 screws which were hidden by the rubber pads.
  14. ![Photo of the screws](Yeelight_screws.jpg "Use an allen key or torx screw driver to remove the screws.")
  15. Remove the bottom from the device, exposing the PCB.
  16. This might take a bit of force. Just pull it up bit by bit until it pops loose.
  17. For some good picture of disassembling this device, take a look
  18. [at this blog post](https://mysku.ru/blog/china-stores/78455.html)
  19. It is in Russian, but the translation by Google works well and moreover, the
  20. pictures are the most important thing here. If you scroll down, you will
  21. find them easily.
  22. ## Solder the wires
  23. Many of the serial to USB adapter have some header pins to which you can
  24. connect the wires of a device. Therefore, I find it most useful to take some
  25. dupont wires with a female end to them, and cut off the other end. Strip the
  26. wire on the other and, and then it can be used to solder it to the board.
  27. Solder the wires to the RX, TX, GND and GPIO0 debug pads that are shown in this
  28. photo. It is not required to solder a wire to the 3.3V debug pad. This pad
  29. is not directly connected to the 3.3V Vin of the ESP32 chip, making it a
  30. less than optimal candidate for powering the board during flashing. Instead,
  31. powering the lamp using its own power supply works best.
  32. ![Soldering points of a yeelight](https://community-assets.home-assistant.io/optimized/3X/1/3/1340a2367e5894281ac6d042f328d9db80ae7da4_2_790x750.jpeg)
  33. You can use some sticky tape to fixate the cables before soldering.
  34. ## Connect the wires to your serial to USB device
  35. The wires must be connected as follows:
  36. | Soldering point| Serial USB Adapter name |
  37. | -------------- |:------------------------:|
  38. | GND | GND |
  39. | TX | RX |
  40. | RX | TX |
  41. | GPIO0 | GND |
  42. To be able to flash the device, GPIO0 must be connected to ground while the
  43. device is booted. Therefore, connect these wires before plugging in the
  44. device's power adapter. Flashing will not work if you connect these wires
  45. when the device has already been powered up.
  46. ## When you only have one GND pin on your USB Adapter
  47. If your USB Adapter does not have multiple GND pins, then you'll have
  48. to find another way to attach GPIO0 to ground. Some options:
  49. - Use a breadbord, so you can connect the USB Adapter GND pin to a row on
  50. the bread bord, and connect the GND and GPIO0 wires of the board to that
  51. same row.
  52. - Solder a button on the board that connects GPIO0 to GND when pressed. Then
  53. you can hold down this button while plugging in the device's power supply.
  54. After booting up, you can release the button (the serial console will also
  55. mention that the device is now in flash mode). This is not the most
  56. practical solution for most people (since only one such flash operation is
  57. needed, from then on OTA - Over The Air - updates are possible), but it
  58. was a great help to me during the initial reverse engineering and firmware
  59. development.
  60. - Manually hold a wire connected to both a GND surface (e.g. the silver pad
  61. on the left of the board) and the GPIO0 debug pad, while plugging in the
  62. power supply. After booting, the wire can be removed. This is very fiddly
  63. way of doing it, but I did it a few times and it can be done.
  64. ## Download and install esptool
  65. See: https://github.com/espressif/esptool/blob/master/README.md#installation--dependencies
  66. ## Make a backup of the current firmware
  67. ```
  68. python esptool.py -p /dev/ttyUSB0 read_flash 0x0 0x400000 original-yeelight-firmware.bin
  69. ```
  70. /dev/ttyUSB0 is the port of the usb adaper on Linux. You can find what port
  71. is used by the adapter by running `dmesg` after plugging in the USB device.
  72. On Windows this is often `COM1`, `COM2` or `COM3`.
  73. **Caution**: You will find the WLAN SSID and Password of the latest used WiFi in
  74. this file.
  75. **After each step with esptool, you have to unplug you power line and connect it again.**
  76. ## Flash new firmware
  77. Setup an ESPHome Project, see [README.md](../README.md)
  78. You can flash the device using esphome or esptool.
  79. I normally use the [esphome-flasher](https://github.com/esphome/esphome-flasher)
  80. tool, which is an easy to use utility app for flashing ESPHome devices.
  81. If you want to flash with esptool, compile with esphome and download the
  82. generated firmware.
  83. ```
  84. python.exe .\esptool.py --chip esp32 --port COM3 --baud 115200 write_flash 0x1000 <yourfile.bin>
  85. ```
  86. Once your firmware has been flashed, unplug the power and the serial USB Adapter.
  87. Then plug the power back in to boot the device using its new firmware.
  88. From here on, it is possible to flash the device OTA via ESPHOME. Tuck
  89. away those soldered wires in the bottom and add the bottom cover back on.
  90. ## Troubleshooting flash
  91. If you have **A fatal error occurred: MD5 of file does not match data in
  92. flash!**, then make sure you are powering the board using the device's own
  93. power adapter. We've seen these errors when trying to power the board using
  94. the 3.3V debug pad.
  95. After seeing this error, user @tabacha was able to successfully flash his
  96. device using the regular power adapter and the tasmota boot loader using
  97. the following command:
  98. ```
  99. python esptool.py --chip esp32 -p /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 bootloader_dout_40m.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 ~/Downloads/schlafzimmerbedlight.bin
  100. ```
  101. You will find the missing tasmota boot files here:
  102. https://github.com/arendst/Tasmota/tree/firmware/firmware/tasmota32/ESP32_needed_files
  103. User @tabacha was not able to use tasmota with the bedside lamp 2.
  104. (remember that the [esphome-flasher](https://github.com/esphome/esphome-flasher)
  105. will give you a bit less of a hard-core experience during flashing)