darkxst / silabs-firmware-builder

Silicon Labs firmware builder
https://darkxst.github.io/silabs-firmware-builder/
263 stars 25 forks source link

[REQUEST] Support for Aeotec Zi-Stick (model “ZGA008”) #19

Closed Hedda closed 2 months ago

Hedda commented 8 months ago

This is a feature request asking for support for the Aeotec Zi-Stick (model “ZGA008”) Zigbee Coordinator USB dongle/adapter:

Checkout the related Home Assistant community forum discussion thread here:

https://community.home-assistant.io/t/aeotec-zi-stick-model-zga008-zigbee-coordinator-usb-dongle-based-on-silicon-labs-efr32mg21-20dbm-radio-soc-mcu/624564

Requesting hardware profile manifest support and unofficial experimental firmware test builds in your manifestjs-SL fork:

https://github.com/darkxst/silabs-firmware-builder/tree/manifestjs-SL

https://github.com/darkxst/silabs-firmware-builder/tree/manifestjs-SL/manifests

https://github.com/darkxst/silabs-firmware-builder/tree/manifestjs-SL/firmware_builds

Note! I do not actually own any Aeotec Zi-Stick dongles myself so do not know the USB product description for identification:

https://community.home-assistant.io/t/community-help-wanted-to-whitelist-all-compatible-zigbee-and-z-wave-dongles-adapters-for-automatic-usb-discovery-in-home-assistant/344412

PS: If anyone else owns one then community would appreciate it if let us know USB product description to be used as identifier:

https://www.home-assistant.io/integrations/zha#discovery-via-usb-or-zeroconf

haade-administrator commented 5 months ago

aeotec send me configuration

// <<< Use Configuration Wizard in Context Menu >>>
#ifndef SL_CPC_DRV_UART_USART_VCOM_SECONDARY_CONFIG_H
#define SL_CPC_DRV_UART_USART_VCOM_SECONDARY_CONFIG_H

// <h> CPC - Secondary UART Driver Configuration

// <o SL_CPC_DRV_UART_VCOM_RX_QUEUE_SIZE> Number of frame that can be queued in the driver receive queue
// <i> Default: 10
#define SL_CPC_DRV_UART_VCOM_RX_QUEUE_SIZE            10

// <o SL_CPC_DRV_UART_VCOM_TX_QUEUE_SIZE> Number of frame that can be queued in the driver transmit queue
// <i> Default: 10
#define SL_CPC_DRV_UART_VCOM_TX_QUEUE_SIZE            10

// <o SL_CPC_DRV_UART_VCOM_BAUDRATE> UART Baudrate
// <i> Default: 115200
#define SL_CPC_DRV_UART_VCOM_BAUDRATE              115200

// <o SL_CPC_DRV_UART_VCOM_FLOW_CONTROL_TYPE> Flow control
// <usartHwFlowControlNone=> None
// <usartHwFlowControlCtsAndRts=> CTS/RTS
// <i> Default: usartHwFlowControlCtsAndRts
#define SL_CPC_DRV_UART_VCOM_FLOW_CONTROL_TYPE usartHwFlowControlCtsAndRts
// </h>

// <<< end of configuration section >>>

// <<< sl:start pin_tool >>>
// <usart signal=TX,RX,(CTS),(RTS)> SL_CPC_DRV_UART_VCOM
// $[USART_SL_CPC_DRV_UART_VCOM]
#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL         
#define SL_CPC_DRV_UART_VCOM_PERIPHERAL          USART0
#endif
#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO      
#define SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO       0
#endif

// USART0 TX on PA05
#ifndef SL_CPC_DRV_UART_VCOM_TX_PORT            
#define SL_CPC_DRV_UART_VCOM_TX_PORT             gpioPortA
#endif
#ifndef SL_CPC_DRV_UART_VCOM_TX_PIN             
#define SL_CPC_DRV_UART_VCOM_TX_PIN              5
#endif

// USART0 RX on PA06
#ifndef SL_CPC_DRV_UART_VCOM_RX_PORT            
#define SL_CPC_DRV_UART_VCOM_RX_PORT             gpioPortA
#endif
#ifndef SL_CPC_DRV_UART_VCOM_RX_PIN             
#define SL_CPC_DRV_UART_VCOM_RX_PIN              6
#endif

// USART0 CTS on PC01
#ifndef SL_CPC_DRV_UART_VCOM_CTS_PORT           
#define SL_CPC_DRV_UART_VCOM_CTS_PORT            gpioPortC
#endif
#ifndef SL_CPC_DRV_UART_VCOM_CTS_PIN            
#define SL_CPC_DRV_UART_VCOM_CTS_PIN             1
#endif

// USART0 RTS on PA04
#ifndef SL_CPC_DRV_UART_VCOM_RTS_PORT           
#define SL_CPC_DRV_UART_VCOM_RTS_PORT            gpioPortA
#endif
#ifndef SL_CPC_DRV_UART_VCOM_RTS_PIN            
#define SL_CPC_DRV_UART_VCOM_RTS_PIN             4
#endif
// [USART_SL_CPC_DRV_UART_VCOM]$
// <<< sl:end pin_tool >>>

#endif /* SL_CPC_DRV_UART_VCOM_SECONDARY_CONFIG_H */
darkxst commented 5 months ago

@haade-administrator Do you have this device? If so can you run:

universal-silabs-flasher --device /dev/ttyUSB0 probe

and capture the config for the default ezsp firmware and paste in here.

Also do you know what variant of EFR32 chip this device uses?

haade-administrator commented 5 months ago

yes i have the dongle zi-stick look the message:

2024-01-19 08:47:56 nico universal_silabs_flasher.flasher[3211] INFO Probing ApplicationType.CPC at 460800 baud
2024-01-19 08:48:01 nico universal_silabs_flasher.flasher[3211] INFO Probing ApplicationType.CPC at 115200 baud
2024-01-19 08:48:05 nico universal_silabs_flasher.flasher[3211] INFO Probing ApplicationType.CPC at 230400 baud
2024-01-19 08:48:09 nico universal_silabs_flasher.flasher[3211] INFO Probing ApplicationType.EZSP at 115200 baud
2024-01-19 08:48:11 nico universal_silabs_flasher.flasher[3211] INFO Detected ApplicationType.EZSP, version '6.10.3.0 build 297' (6.10.3.0.297) at 115200 baudrate (bootloader baudrate None)
2024-01-19 08:48:11 nico universal_silabs_flasher.flash[3211] INFO Dumping EmberZNet Config
CONFIG_PACKET_BUFFER_COUNT=250
CONFIG_NEIGHBOR_TABLE_SIZE=16
CONFIG_APS_UNICAST_MESSAGE_COUNT=10
CONFIG_BINDING_TABLE_SIZE=32
CONFIG_ADDRESS_TABLE_SIZE=16
CONFIG_MULTICAST_TABLE_SIZE=8
CONFIG_ROUTE_TABLE_SIZE=16
CONFIG_DISCOVERY_TABLE_SIZE=8
CONFIG_STACK_PROFILE=0
CONFIG_SECURITY_LEVEL=5
CONFIG_MAX_HOPS=30
CONFIG_MAX_END_DEVICE_CHILDREN=32
CONFIG_INDIRECT_TRANSMISSION_TIMEOUT=3000
CONFIG_END_DEVICE_POLL_TIMEOUT=8
CONFIG_TX_POWER_MODE=0
CONFIG_DISABLE_RELAY=0
CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE=0
CONFIG_SOURCE_ROUTE_TABLE_SIZE=200
CONFIG_FRAGMENT_WINDOW_SIZE=1
CONFIG_FRAGMENT_DELAY_MS=0
CONFIG_KEY_TABLE_SIZE=12
CONFIG_APS_ACK_TIMEOUT=1600
CONFIG_ACTIVE_SCAN_DURATION=3
CONFIG_END_DEVICE_BIND_TIMEOUT=60
CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD=2
CONFIG_REQUEST_KEY_TIMEOUT=0
CONFIG_CERTIFICATE_TABLE_SIZE=0
CONFIG_APPLICATION_ZDO_FLAGS=0
CONFIG_BROADCAST_TABLE_SIZE=15
CONFIG_MAC_FILTER_TABLE_SIZE=0
CONFIG_SUPPORTED_NETWORKS=1
CONFIG_SEND_MULTICASTS_TO_SLEEPY_ADDRESS=0
CONFIG_ZLL_GROUP_ADDRESSES=1
CONFIG_ZLL_RSSI_THRESHOLD=128
CONFIG_MTORR_FLOW_CONTROL=1
CONFIG_RETRY_QUEUE_SIZE=16
CONFIG_NEW_BROADCAST_ENTRY_THRESHOLD=9
CONFIG_TRANSIENT_KEY_TIMEOUT_S=300
CONFIG_BROADCAST_MIN_ACKS_NEEDED=255
CONFIG_TC_REJOINS_USING_WELL_KNOWN_KEY_TIMEOUT_S=300
CONFIG_CTUNE_VALUE=140
CONFIG_ASSUME_TC_CONCENTRATOR_TYPE=1
haade-administrator commented 5 months ago

it use: EFR32MG21A020

darkxst commented 5 months ago

it use: EFR32MG21A020

What size flash? there is another number like F1024 after that....

haade-administrator commented 5 months ago

it's possible to found firmware spec with command line ?

darkxst commented 5 months ago

it's possible to found firmware spec with command line ?

not that I know, I think its only possible with j-link debugger to get the actual part number. You could just ask Aeotec?

haade-administrator commented 5 months ago

i have send question to aeotec.

darkxst commented 5 months ago

ok, I need the full number like this: EFR32MG21A020F768IM32

haade-administrator commented 5 months ago

aeotec confirm: EFR32MG21A020F1024

haade-administrator commented 4 months ago

darkxst do you need anything else or can you give me instructions on how to build the firmware so I can test

haade-administrator commented 3 months ago

hello any news

darkxst commented 3 months ago

I guess I will add this one, puddly firmware builder work is still pending.

darkxst commented 3 months ago

@haade-administrator 4.3.1 and 4.4.1 builds for Aeotec are in the below branch. Please test these before I merge into main. https://github.com/darkxst/silabs-firmware-builder/tree/aeotec/firmware_builds/aeotec-zga008

haade-administrator commented 2 months ago

ncp-uart-hw-v7.3.1.0-aeotec-zga008-115200.gbl work great, after then I wanted to test the openthread version -b 230400 but it seems not to work or I flashed incorrectly I wanted to update the ezsp version but it is no longer possible to put it in bootloader mode do you have a way to return to back

darkxst commented 2 months ago

For thread (or multipan) firmware you should be using 460800 baud. 230400 is not probed by default, so you likely need to use universal-silabs-flasher and manually set baudrate with --spinel-baudrate 230400

haade-administrator commented 2 months ago

i use

universal-silabs-flasher \
    --device /dev/ttyUSB0 \
    --spinel-baudrate 230400 \
    flash \
    --firmware ot-rcp-v2.3.1.0-aeotec-zga008-460800.gbl \
    --allow-cross-flashing \
    --allow-downgrades \
    --force

i have error:

Extracted GBL metadata: NabuCasaMetadata(metadata_version=1, sdk_version='4.3.1', ezsp_version=None, ot_rcp_version='SL-OPENTHREAD/2.3.1.0_GitHub-e6df00dd6' (2.3.1.0), cpc_version=None, fw_type=<FirmwareImageType.OT_RCP: 'ot-rcp'>, baudrate=460800)
2024-04-08 07:48:44.204 nicolas-NBLK-WAX9X universal_silabs_flasher.flasher INFO Probing ApplicationType.GECKO_BOOTLOADER at 230400 baud
2024-04-08 07:48:46.229 nicolas-NBLK-WAX9X universal_silabs_flasher.flasher INFO Probing ApplicationType.SPINEL at 230400 baud
2024-04-08 07:48:46.253 nicolas-NBLK-WAX9X universal_silabs_flasher.flasher INFO Detected ApplicationType.SPINEL, version 'SL-OPENTHREAD/2.3.1.0_GitHub-e6df00dd6' (2.3.1.0) at 230400 baudrate (bootloader baudrate None)
2024-04-08 07:48:46.771 nicolas-NBLK-WAX9X universal_silabs_flasher.flasher INFO Probing ApplicationType.GECKO_BOOTLOADER at 230400 baud
Traceback (most recent call last):
  File "/home/nicolas/.local/bin/universal-silabs-flasher", line 8, in <module>
    sys.exit(main())
  File "/home/nicolas/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/nicolas/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/nicolas/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/nicolas/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/nicolas/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/nicolas/.local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/nicolas/.local/lib/python3.10/site-packages/universal_silabs_flasher/flash.py", line 40, in inner
    return asyncio.run(f(*args, **kwargs))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/nicolas/.local/lib/python3.10/site-packages/universal_silabs_flasher/flash.py", line 408, in flash
    await flasher.enter_bootloader()
  File "/home/nicolas/.local/lib/python3.10/site-packages/universal_silabs_flasher/flasher.py", line 281, in enter_bootloader
    await self.probe_app_type(types=[ApplicationType.GECKO_BOOTLOADER])
  File "/home/nicolas/.local/lib/python3.10/site-packages/universal_silabs_flasher/flasher.py", line 235, in probe_app_type
    raise RuntimeError("Failed to probe running application type")
RuntimeError: Failed to probe running application type
darkxst commented 2 months ago

The thread 2.3.1 backported builds in the aeotec branch probably have the same issue with openthread software bootloader reset not working as was discovered and fixed on slzb-06m. The other 2.4.1 builds were not affected by this.

It was also fixed by these builds in the main branch as of March 30th: https://github.com/darkxst/silabs-firmware-builder/tree/main/firmware_builds/aeotec-zga008

As there is no bootloader button, you may need to disassemble the device and see if there are test pads to trigger hardware reset into bootloader. I dont have access to this device, but if you send me photos of the bare PCB in this device I can point you further along ;)

haade-administrator commented 2 months ago

IMG_20240408_133552 you have G for ground R C D 3V for +

darkxst commented 2 months ago

I am going to guess, R for Reset (reset is top left side on the zigbee chip in your photo)

That leaves C and D which appear to be connected to PA01 and PA02, I would guess its one of those, try shorting each of these to ground (one at a time) while plugging the dongle into power.

You can test for bootloader with:

universal-silabs-flasher --device /dev/tty --probe-method bootloader probe

or as long as you have a recent version of univeral-silabs-flasher, you can just flash normally and if it detects bootloader first up it should immediately start flashing (without trying to probe other apps)