ESP32C6 Arduino 3.00 and Zigbee Support

I am trying to compile the Zigbee Switch and Lamp Arduino examples using PlatformIO. The code compiles, and uploads and appears to run, however its not actually doing what it is supposed to do. The network startup (“Steering” in Zigbee) doesn’t appear to work as it runs for a very short time compared to the same code when compiled from the Arduino IDE, and it never finds and joins a coordinator.

I suspect it may be either related to a mismatched or missing library, but I’d expect a build failure rather than runtime issues, or possibly related to how Zigbee is using the extra FAT partitions on the flash.

I’d really appreciate any input or ideas - I really don’t want to rely on the Arduino IDE for this, it’s so clumsy after using PlatformIO/VSCode.

To get this to work I have had to make a lot of changes to the config to get PlatformIO to support the new Arduino framework, but everything seems to be OK.

I have added a file to the boards definitions (in the platforms/espressif32/boards/ folder) that was configured for esp32c6 and enabled the Arduino framework.

Added support for the new Arduino 3.0.0-rc1 version of the framework.

Added all the extra build time libraries and definitions to the platformio.ini for either a Coordinator or End Device:

[env:seeed_xiao_esp32c6]
platform = espressif32
; platform = espressif32 @ ^6.6.0
board = seeed_xiao_esp32c6
board_build.partitions = partitions.csv
board_build.f_cpu = 160000000L
framework = arduino
platform_packages = 
	platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0-rc1
	platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
upload_speed = 460800
upload_port = /dev/ttyACM0
monitor_speed = 115200
build_flags = 
    -D CORE_DEBUG_LEVEL=5
	-D ARDUINO_USB_MODE=1
	-D ARDUINO_USB_CDC_ON_BOOT=1
	-D ZIGBEE_MODE_ED
        -lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port

; Depending on the Zigbee mode add this
; -D ZIGBEE_MODE_ZCZR
; -lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port
; -D ZIGBEE_MODE_ED
; -lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port
; -D ZIGBEE_MODE_GPD
; -lesp_zb_api_gpd  -lesp_zb_cli_command -lzboss_stack.gpd -lzboss_port
; -D ZIGBEE_MODE_RCP
; -lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port

The partition.csv is defined based on the Arduino IDE version that you select from their menu:

# Name,     Type, SubType, Offset,  Size, Flags
nvs,        data, nvs,     0x9000,  0x5000,
otadata,    data, ota,     0xe000,  0x2000,
app0,       app,  ota_0,   0x10000, 0x140000,
app1,       app,  ota_1,   0x150000,0x140000,
spiffs,     data, spiffs,  0x290000,0x15B000,
zb_storage, data, fat,     0x3EB000,0x4000,
zb_fct,     data, fat,     0x3EF000,0x1000,
coredump,   data, coredump,0x3F0000,0x10000,

When compiled and flashed from the Arduino IDE, I get the following output on my Serial device showing a successfuly connection to my Coordinator…

Starting Zigbee Switch
Zigbee Switch Looping...
Config Ready
Zigbee stack initialized
Start network steering
Joined network successfully (Extended PAN ID: 76:55:e5:ba:33:25:b5:eb, PAN ID: 0x736d, Channel:15, Short Address: 0x5126)

However, the exact same code, compiled and flashed from PlatformIO gives the following output…

Starting Zigbee Switch
Config Ready
Zigbee stack initialized
Start network steering
Zigbee Switch Looping...
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)

With the Arduino IDE version, if I don’t have a coordinator open for connections, then the code will also cycle over the ESP_FAIL attempts, but it will take about 2 minutes for each attempt. The PlatformIO version cycles around every 5 seconds so it seems like it is not really doing a full scan, but aborts sooner.

Hi Euan,

I’m also trying to get the zb switch and lamp examples running on XIAO ESP32C6. My standard platform is PlatformIO, but I started in Arduino IDE as the instruction in arduino-esp32/libraries/ESP32/examples/Zigbee/Zigbee_Light_Switch at master · espressif/arduino-esp32 · GitHub was for Arduino IDE. But even there the program crashed probably due to missing partioning of zb_storage. And I gave up setting up another partitioning schememe for A IDE.
Could you share a little more detail about what you added to platforms/espressif32/boards/ folder. And did you add something for the Arduino 3.0.0-rc1 version of the framework, outside of the platformio.ini?
Regards,
Dag

Oh my, kinda hacky. Can you just use the Tasmota version of the Espressif32 platform? It has support for the Arduino-ESP32 3.0.0 in a definitely confirmed-working way. Just set

platform = https://github.com/Jason2866/platform-espressif32#Arduino/IDF5
board = esp32-c6-devkitc-1

in the platformio.ini as a starting point.

Hi Dag,

I just really copied and modified the existing “esp32-c6-devkitm-1.json” one, but customised for my particular board - the Seeed XIAO C6 board - this gives me the additional definitions for the GPIO ports etc that map to my device.

The only other change I made here was to add the arduino platform as this is not yet enabled on the esp32-c6-devkitm-1.json definition.

"frameworks": [
    "arduino",
    "espidf"
  ],

You can just add the platform on the esp32-c6-devkitm-1.json definition and do your GPIO etc mapping directly.

Just one more thing, if you use the esp32-c6-devkitm-1 board in the Arduino IDE, you should see the two Zigbee partitions available directly from the menu. (Make sure you use the m1 board variant as it is configured with 4Mb of memory, the c1 tries to use 8Mb and things break.)

Regards,

Euan.

Hi @maxgerhardt
Thanks for the steer to using the Tasmota fork.

I have now tried using the Tasmota fork, but it doesn’t appear to have the Zigbee components in the Arduino Library.

   34 | #include "esp_zigbee_core.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

Looking directly in the zip files Arduino Library releases here
https://github.com/tasmota/arduino-esp32/releases

I cannot see either the Zigbee include files, or the associated libraries (libesp_zb* and libzboss*).

If I keep the Tasmota fork, but still pull in the official arduino libraries I can get it to compile, but I am back to where I started, it runs, but doesn’t appear to be communicating over the radio as the network startup cycle is still too fast.

Does the Tasmota fork plan to support Zigbee on the supported ESP32 chips?

Now I have failed with ArdionoIDE and PlatformIO.

I installed the Espressif ESP-IDF IDE, and got both light and switch working.

I still prefer PlatformIO, but wanted a working zb example on Seeed XIAO esp32c6, as a reference.

After installing ESP-IDF IDE (in vscode on linux), I clicked the Show examples button on the ESP-IDF Welcome page, searched HA and found light_sample with the projects HA_on_off_light and HA_on_off_switch.
The only code change I made was to replace the rgb led strip driver with the gpio15 led on the seeed board. The switch used was already gpio9 - the boot button.
after flashing and starting the boards I could toggle the light board led on-off with the boot button on the switch board.

The ESP-IDF IDE experience was: it worked, but suffered from file bloat. It was unclear which files to store in git, so I ended up pushing over 200 files to the repo.

I hope we could find how to do the same in PlatformIO.

My code is available in GitHub - dagrende/HA_on_off_switch and GitHub - dagrende/HA_on_off_light.

Platform Espressif32@6.6.0 comes with ESP-IDF version 5.2.1 which has ZigBee support included.

There should be no problems with PlatformIO in pure ESP-IDF projects.

Thank you for this!
I wasn’t aware of the platform.ini syntax:
platform = espressif32 @ 6.6.0

By adding the needed zigbee partitioning table to the ini I may be able to go back to my favourite IDE.

1 Like

No, there is no plan to include the Zigbee support (precompiled libs) in Tasmota fork.
We will not use the embedded zigbee. Zigbee and WiFi using together is working badly.
The share the same hardware. Works as bad as using WiFi and BLE together.
Since WiFi is always needed for Tasmota the zigbee part is obsolete.
Good designs which uses wifi and zigbee needs two MCUs.

1 Like

@dagrende did you ever get the Zigbee example working with PIO?

Ok, what am I doing wrong?

I created a new PlatformIO project in VSCode and select the esp32-c6-devkitm-1 board.

I changed my platformio.ini to below.

[env:esp32-c6-devkitm-1]
platform = espressif32
board = esp32-c6-devkitm-1
board_build.partitions = partitions.csv
board_build.f_cpu = 160000000L
framework = arduino
platform_packages =
   framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.1.1
   framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1

build_flags =  
    -D CORE_DEBUG_LEVEL=5
	-D ARDUINO_USB_MODE=1
	-D ARDUINO_USB_CDC_ON_BOOT=1
	-D ZIGBEE_MODE_ED
        -lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port

I added partitions.csv as mentioned by @euan

# Name,     Type, SubType, Offset,  Size, Flags
nvs,        data, nvs,     0x9000,  0x5000,
otadata,    data, ota,     0xe000,  0x2000,
app0,       app,  ota_0,   0x10000, 0x140000,
app1,       app,  ota_1,   0x150000,0x140000,
spiffs,     data, spiffs,  0x290000,0x15B000,
zb_storage, data, fat,     0x3EB000,0x4000,
zb_fct,     data, fat,     0x3EF000,0x1000,
coredump,   data, coredump,0x3F0000,0x10000,

I changed my C:\Users<username>.platformio\platforms\espressif32\boards\esp32-c6-devkitm-1.json file to include “arduino” in the frameworks

.....
  "frameworks": [
    "arduino",
    "espidf"
  ],
.....

But I get an error, see below

Resolving esp32-c6-devkitm-1 dependencies...
Tool Manager: Installing espressif/toolchain-riscv32-esp @ 13.2.0+20240530
UnknownPackageError: Could not find the package with 'espressif/toolchain-riscv32-esp @ 13.2.0+20240530' requirements for your system 'windows_amd64'

Does anyone have a fully working Zigbee example working on a ESP32-C6 compiled with PlatformIO?

If yes, don’t suppose there is a Git repo with the example by chance?

Additional information for those that may ask.

  • Running VSCode on Windows11 64bit (AMD CPU)
  • PlatformIO is v 6.1.16
  • espressif32 is v6.10.9

image

The ESP32-C6 requires Espressif Arduino 3.x based on ESP-IDF 5.x which is not supported officially by PlatformIO.

Use pioarduino platform.

Do you know if PlatformIO is going to support arduino framework for ESP32-C6?

I can’t see (doesn’t mean its not there) any issues on the Repo for it

I’ve switched over to pioarduino IDE extension in VSCode.

But now I’m getting an error message as below.

riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/username/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory

I tried deleting the .platformio folder and starting from scratch but still the same thing.

I tried adding the below to my platform.ini

[platformio]
core_dir = C:\Users\username\.platformio
workspace_dir = D:\WorkSpace\Zigbee-Scanner\.pio

I’ll explain how I to this point.

I installed pioplatform extension and restarted VS Code.

I create a new project and specified esp32-c6-devkitm-1 with arduino framework.

I then edited the platform.ini file

[platformio]
core_dir = C:\Users\username\.platformio
workspace_dir = D:\WorkSpace\Zigbee-Scanner\.pio

[env:esp32-c6-devkitm-1]
platform = espressif32
board = esp32-c6-devkitm-1
framework = arduino

board_build.partitions = partitions.csv
board_build.filesystem = spiffs
board_build.f_cpu = 160000000L

platform_packages =
   framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.1.1
   framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
   
build_flags = 
	-D CORE_DEBUG_LEVEL=5
	-D ZIGBEE_MODE_ED

created the partitions.csv as per a previous post

I then took the source from arduino-esp32/libraries/Zigbee/examples/Zigbee_Scan_Networks/Zigbee_Scan_Networks.ino at master · espressif/arduino-esp32 · GitHub and copied it into main.cpp

Click the build and get that error.

To use the pioarduino platform-espressif32 you do not need to change the IDE. pioarduino works just fine with PlatformIO!

I think, this will break everything.

To get the latest Espressif32 Arduino core 3.1.1 simply use

platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.11/platform-espressif32.zip

Many thanks for your replies. Greatly appreciated.

I changed my platform.ini to below

[platformio]
core_dir = C:\Users\user\.platformio
workspace_dir = D:\WorkSpace\Zigbee-Scanner\.pio

[env:esp32-c6-devkitm-1]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
board = esp32-c6-devkitm-1
framework = arduino

board_build.partitions = partitions.csv
board_build.filesystem = spiffs
board_build.f_cpu = 160000000L


build_flags = 
	-D CORE_DEBUG_LEVEL=5
	-D ZIGBEE_MODE_ED

But now I get the below error many times for multiple files in the zigbee folder.

*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeOccupancySensor.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeTempSensor.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeThermostat.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeSwitch.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.

I can confirm that ‘C:\Users\user\.platformio\packages\toolchain-riscv32-esp@13.2.0+20240530\riscv32-esp-elf\bin\as.exe’ does indeed exist.

I tried removing the core_dir and workspace_dir from the platform.ini but still the same.

I tried deleting the .platform folder and the .pio folder in the project, but still the same.

This is definitely a VSCode/PlatformIO/pioarduino issue as the code compiled successfully on the ArduinoCC IDE.

Would like to get this working in VSCode as I much prefer the IDE.

Any further ideas?

I guess the package is broken.
To fix this

  • Close VS Code
  • Delete the content of C:\Users\user\.platformio\packages
  • Restart VS Code
  • Wait until platformio finished all tasks (reinstalling the missing files)
  • Then try to build the project again

Additional questions:

1 What’s the reason for this?

[platformio]
core_dir = C:\Users\user\.platformio
workspace_dir = D:\WorkSpace\Zigbee-Scanner\.pio
  1. Do you have a partitions.csv in your project folder?

I had in the core_dir and workspace_dir in the platformio.ini file after a Google search on the problem. It didn’t resolve anything so they’ve been removed.

Yes, I have a partitions.csv file as below

# Name,     Type, SubType, Offset,  Size, Flags
nvs,        data, nvs,     0x9000,  0x5000,
otadata,    data, ota,     0xe000,  0x2000,
app0,       app,  ota_0,   0x10000, 0x140000,
app1,       app,  ota_1,   0x150000,0x140000,
spiffs,     data, spiffs,  0x290000,0x15B000,
zb_storage, data, fat,     0x3EB000,0x4000,
zb_fct,     data, fat,     0x3EF000,0x1000,
coredump,   data, coredump,0x3F0000,0x10000,

I followed the instructions as requested

  • Close VS Code
  • Delete the content of C:\Users\user\.platformio\packages
  • Restart VS Code
  • Wait until platformio finished all tasks (reinstalling the missing files)
  • Then try to build the project again

However same error

*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeOccupancySensor.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeTempSensor.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeThermostat.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\esp32-c6-devkitm-1\lib144\Zigbee\ep\ZigbeeSwitch.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute 'C:/Users/user/.platformio/packages/toolchain-riscv32-esp@13.2.0+20240530/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe': CreateProcess: No such file or directory
compilation terminated.

Any other ideas?

I’ve usually seen in this in relation to extremely long paths or compiler command lines. This is only a problem on Windows.

Try shortening the core path as much as possible, to like C:\p if possible. (https://github.com/platformio/platformio-core/issues/2877#issuecomment-622023465).

Or, try compiling in a Ubuntu virutal machine with VirtualBox as a countertest.

I have included a workaround for the Windows path lenght limit in pioarduino develop branch. Can be used with this platform entry

platform = https://github.com/pioarduino/platform-espressif32.git#develop