espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
647 stars 150 forks source link

Only a few pieces of information can be written using 'generate_esp32uchip_factory-bin. py' (CON-1305) #1054

Open MaplestoryAlen opened 3 weeks ago

MaplestoryAlen commented 3 weeks ago

This is the command for writing:

./generate_esp32_chip_factory_bin.py -d 1083 -p 10831125 \ --product-name 81ma1 --product-id 0x8000 \ --vendor-name Testvendor --vendor-id 0xFFF1 \ --hw-ver 1009 --hw-ver-str 1.0.0.9 --serial-num 202408091125 \ --dac-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-01.der \ --dac-key /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-Key-01.der \ --pai-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-PAI-Cert.der \ --cd /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/esp_dac_fff1_8000.der --dac-in-secure-cert --target esp32s3

But other information cannot be written, such as the Product URL and Product Label. Is there any way for me to write this information and burn it into the chip? I saw some API interfaces in "platform/ESP32/ESP32FactorySData Provider. h"

 CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override;
 CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override;

At present, I can only read a few, and I don't know how to write the others, so reading has failed

  ESP32FactoryDataProvider dataProvider;

if(dataProvider.GetProductName(device_info.productName, sizeof(device_info.productName)) == CHIP_NO_ERROR)
{
   ESP_LOGI(TAG,"device_info.productName :%s",device_info.productName); 
}
if(dataProvider.GetHardwareVersionString(device_info.HardwareVersionString, sizeof(device_info.HardwareVersionString)) == CHIP_NO_ERROR)        
{
   ESP_LOGI(TAG,"device_info.HardwareVersionString :%s",device_info.HardwareVersionString);
}

May I ask if there is any way for me to write and read information from the Basic Information Cluster?

shubhamdp commented 3 weeks ago

Those were recently added in https://github.com/project-chip/connectedhomeip/pull/34363, can you try the script from connectedhomeip's master branch?

Or you can use esp-matter-mfg-tool. It supports product label and product URL, and others will be added soon.

# to install
pip install esp-matter-mfg-tool

# usage
esp-matter-mfg-tool -h
MaplestoryAlen commented 3 weeks ago

Those were recently added in project-chip/connectedhomeip#34363, can you try the script from connectedhomeip's master branch?

Or you can use esp-matter-mfg-tool. It supports product label and product URL, and others will be added soon.

# to install
pip install esp-matter-mfg-tool

# usage
esp-matter-mfg-tool -h

I am using the factory mode, and there is a difference between the two tools "generate_esp32uchip_factory-bin" and "esp-mtter-mfg-tool". How can I use "esp-mtter-mfg-tool" to write the file "Esp-Development-PAI-Cert. der" into the chip? If the item '-- pai' is' -- pai/home/alen/esp-matter/connected homeip/connected homeip/out/host/Esp Development PaiCert.der ', an error will occur

1.generate_esp32_chip_factory_bin.py command:

./generate_esp32_chip_factory_bin.py -d 1083 -p 10831125 \ --product-name 81ma1 --product-id 0x8000 \ --vendor-name Testvendor --vendor-id 0xFFF1 \ --hw-ver 1009 --hw-ver-str 1.0.0.9 --serial-num 202408091125 \ --dac-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-01.der \ --dac-key /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-Key-01.der \ --pai-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-PAI-Cert.der \ --cd /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/esp_dac_fff1_8000.der --dac-in-secure-cert --target esp32s3

  1. esp-matter-mfg-tool command
    esp-matter-mfg-tool --discriminator 1083 --passcode 10831022 \ --product-name 81ma1 --product-id 0x8000 \ --vendor-name Testvendor --vendor-id 0xFFF1 \ --hw-ver 1009 --hw-ver-str 1.0.0.9 --serial-num 202408201022 \ --product-label xz.81ma1.202408201022.AirConditioner \ --dac-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-01.der \ --dac-key /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-Key-01.der \ -pai /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-PAI-Cert.der \ -cd /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/esp_dac_fff1_8000.der --dac-in-secure-cert --target esp32s3

log: image

shubhamdp commented 2 weeks ago

@MaplestoryAlen sorry for a delayed response...

--pai do not take in a cert, for providing CA certs you have to use the -c option. please see esp-matter-mfg-tool -h for more details about the options. I have modified the command for you...

esp-matter-mfg-tool --discriminator 1083 --passcode 10831022
--product-name 81ma1 --product-id 0x8000
--vendor-name Testvendor --vendor-id 0xFFF1
--hw-ver 1009 --hw-ver-str 1.0.0.9 --serial-num 202408201022
--product-label xz.81ma1.202408201022.AirConditioner
--dac-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-01.pem
--dac-key /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-Key-01.pem
--pai -C /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-PAI-Cert.pem
-cd /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/esp_dac_fff1_8000.der --dac-in-secure-cert --target esp32s3

If you have these certs in PEM format then that would be great, the utility right now works with PEM certs and need support for DER (will do that soon)

DER to PEM

// certs
openssl x509 -inform der -outform pem -in Esp-Development-DAC-01.der -out Esp-Development-DAC-01.pem
openssl x509 -inform der -outform pem -inEsp-Development-PAI-Cert.der -out Esp-Development-PAI-Cert.pem

//key
openssl ec -inform der -outform pem -in Esp-Development-DAC-Key-01.der -out Esp-Development-DAC-Key-01.pem
MaplestoryAlen commented 6 days ago

@MaplestoryAlen sorry for a delayed response...

--pai do not take in a cert, for providing CA certs you have to use the option. please see for more details about the options. I have modified the command for you...-c``esp-matter-mfg-tool -h

esp-matter-mfg-tool --discriminator 1083 --passcode 10831022
--product-name 81ma1 --product-id 0x8000
--vendor-name Testvendor --vendor-id 0xFFF1
--hw-ver 1009 --hw-ver-str 1.0.0.9 --serial-num 202408201022
--product-label xz.81ma1.202408201022.AirConditioner
--dac-cert /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-01.pem
--dac-key /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-DAC-Key-01.pem
--pai -C /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/Esp-Development-PAI-Cert.pem
-cd /home/alen/esp-matter/connectedhomeip/connectedhomeip/out/host/esp_dac_fff1_8000.der --dac-in-secure-cert --target esp32s3

If you have these certs in PEM format then that would be great, the utility right now works with PEM certs and need support for DER (will do that soon)

DER to PEM

// certs
openssl x509 -inform der -outform pem -in Esp-Development-DAC-01.der -out Esp-Development-DAC-01.pem
openssl x509 -inform der -outform pem -inEsp-Development-PAI-Cert.der -out Esp-Development-PAI-Cert.pem

//key
openssl ec -inform der -outform pem -in Esp-Development-DAC-Key-01.der -out Esp-Development-DAC-Key-01.pem

I used a tool to generate bin files and tried testing mode, but both encountered problems

partition.csv

image

image

CSV file: image

1.Write flash "partition.bin" and "esp_secure_cert.bin" esptool.py -p /dev/ttyUSB0 write_flash 0xd000 /home/alen/esp-matter/connectedhomeip/connectedhomeip/scripts/tools/bin/801e465e-4c1b-45ba-b584-b6ef16972918_esp_secure_cert.bin esptool.py -p /dev/ttyUSB0 write_flash 0x10000 /home/alen/esp-matter/connectedhomeip/connectedhomeip/scripts/tools/bin/801e465e-4c1b-45ba-b584-b6ef16972918-partition.bin 2.chip-tool read basicinformation /chip-tool basicinformation read product-name 0x11 0 log: image

I wrote product name: 81ma1 using esp-mtter-mfg-tool, but the actual read product name :TEST PRODUCT

Set the factory mode and wrote 'XXX_ partition. bin' into fctry, which may result in the inability to distribute the network, (esptool.py -p /dev/ttyUSB0 write_flash 0xE40000 /home/alen/esp-matter/connectedhomeip/connectedhomeip/scripts/tools/bin/801e465e-4c1b-45ba-b584-b6ef16972918-partition.bin)

May I ask where I went wrong? I need to write some information into the chip now, and be able to read this information in cluster ->basic information, such as "productname", "product label" and other information.

shubhamdp commented 5 days ago

Can you please share the sdkconfig. I suspect few config options are not set...

Please enable CONFIG_ ENABLE_ESP32_FACTORY_DATA_PROVIDER and then set

Also, I hope that CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION_LABEL is unchanged and its "nvs", cause you are flashing at "nvs".

I know, the config options are a bit messy, and we are trying to figure out some way to simplify them.

MaplestoryAlen commented 2 days ago
  • FACTORY_DEVICE_INSTANCE_INFO_PROVIDER

Please check the log file log.txt

The Commissioning window is closed when the device is powered on because the Bluetooth broadcast failed image