Skip to content

Commit f114123

Browse files
[bouffalo lab] Cherry-pick: fix on wifi scan & write operation of bl config littlefs & header reserved size, and update script to generate DAC & MFD (#2)
* [bouffalo lab] update scripts and documents to support more options t… (project-chip#37454) * [bouffalo lab] update scripts and documents to support more options to generate and download test mfd * Restyled by prettier-markdown * Restyled by autopep8 * Restyled by isort * Restyled by prettier-markdown --------- Co-authored-by: Restyled.io <commits@restyled.io> * [bouffalolab] update macro define for header reserve size and etherne… (project-chip#37516) * [bouffalolab] update macro define for header reserve size and ethernet zap configuration * re-generate lighting-app-ethernet.matter * [bouffalo lab] open commission window when last fabric is removed (project-chip#37517) * [bouffalo lab] open commission window when last fabric is removed * Restyled by whitespace * fix compile error --------- Co-authored-by: Restyled.io <commits@restyled.io> * [bouffalo lab] fix wifi scan issues and update some platform changes (project-chip#37455) * [bouffalo lab] fix wifi scan issues and update some platform changes * Restyled by clang-format * Restyled by gn * Restyled by clang-format * fix wifi scan on bl706 + bl602 platform * Restyled by whitespace * Restyled by clang-format * use strncpy to copy ssid * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io> * [bouffalo lab] Advertise commissionable on last fabric removal is disabled by default (project-chip#37531) * [bouffalo lab] Make it possible for application to implement its own fabric delegate * Advertise commissionable on last fabric removal is disabled by default --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 68caf63 commit f114123

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+739
-185
lines changed

docs/guides/bouffalolab/getting_started.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,34 @@ git clone --recurse-submodules https://github.com/project-chip/connectedhomeip.g
1717
git clone --depth=1 https://github.com/project-chip/connectedhomeip.git
1818
```
1919
20-
- check out `Bouffalo Lab` platform support repos as follows:
20+
- Check out necessary submodules
21+
22+
Checkout `BL_IOT_SDK` for `BL602`, `BL702` and `BL702L` platform:
23+
24+
```
25+
./scripts/checkout_submodules.py --shallow --recursive --platform bouffalolab
26+
```
27+
28+
Checkout `bouffalo_sdk` for `BL616` platform:
2129
2230
```
23-
scripts/checkout_submodules.py --shallow --recursive --platform bouffalolab
31+
./scripts/checkout_submodules.py --shallow --recursive --platform bouffalo_sdk
2432
```
2533
34+
> Please contact `Bouffalo Lab` for `BL616` SDK access.
35+
2636
If you want to checkout Matter Linux example and development tools, please
2737
try as follows:
2838
2939
```
30-
scripts/checkout_submodules.py --shallow --recursive --platform linux bouffalolab
40+
./scripts/checkout_submodules.py --shallow --recursive --platform linux bouffalolab
3141
```
3242
3343
Or if you want to checkout Matter Darwin example and development tools,
3444
please try as follows:
3545
3646
```
37-
scripts/checkout_submodules.py --shallow --recursive --platform darwin bouffalolab
47+
./scripts/checkout_submodules.py --shallow --recursive --platform darwin bouffalolab
3848
```
3949
4050
# Setup build environment

docs/guides/bouffalolab/matter_factory_data.md

+116-24
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Script tool
7171
call `chip-cert` to generate test certificates and verify certificates.
7272

7373
Please run below command to compile `chip-cert` tool under `connnectedhomeip`
74-
repo.
74+
repo for Linux platform.
7575

7676
```shell
7777
./scripts/build/build_examples.py --target linux-x64-chip-cert build
@@ -111,24 +111,47 @@ repo.
111111

112112
Please reference to `--help` for more detail.
113113

114-
## Generate with default test certificates
114+
## Generate with default configuration
115115

116-
- Run following command to generate all plain text factory data
116+
- Default setting uses the following parameters
117+
118+
- PAI certification:
119+
[test PAI certification](../../../credentials/test/attestation/Chip-Test-PAI-FFF1-8000-Key.pem)
120+
121+
- Vendor ID for DAC: 0xFFF1; Vendor ID for CD: 0x130d
122+
123+
- Product ID for DAC: 0x8000, Product ID for CD: 0x1001
124+
125+
* Run following command to generate all plain text factory data
117126

118127
Please create output folder first. Here takes `out/test-cert` as example.
119128

120129
```shell
121130
./scripts/tools/bouffalolab/generate_factory_data.py --output out/test-cert
122131
```
123132

124-
- Run following command to generate factory data which encrypt private of
133+
- Check DAC certificate. Here takes `out_130d_1001_106_dac_cert.pem` as
134+
generated test certificate.
135+
136+
```shell
137+
openssl x509 -noout -text -in out/test-cert/out_130d_1001_106_dac_cert.pem
138+
```
139+
140+
- Check Certification Declare. Here takes `out_130d_1001_cd.der` as
141+
generated test certificate.
142+
143+
```shell
144+
./out/linux-x64-chip-cert/chip-cert print-cd out/test-cert/out_130d_1001_cd.der
145+
```
146+
147+
* Run following command to generate factory data which encrypt private of
125148
device attestation data
126149

127150
```shell
128151
./scripts/tools/bouffalolab/generate_factory_data.py --output out/test-cert --key <hex string of 16 bytes>
129152
```
130153

131-
> An example of hex string of 16 bytes: 12345678123456781234567812345678
154+
> An example of hex string of 16 bytes: 12345678123456781234567812345678.
132155

133156
After command executes successfully, the output folder will has files as below:
134157

@@ -153,20 +176,26 @@ After command executes successfully, the output folder will has files as below:
153176
Self-defined PAA/PAI certificates may use in development and test scenario. But,
154177
user should know it has limit to work with real ecosystem.
155178

156-
- Export environment variables in terminal for easy operations
179+
- Export environment variables in terminal for certificates generation
157180

158181
```
159-
export TEST_CERT_VENDOR_ID=130D # Vendor ID hex string
160-
export TEST_CERT_CN=BFLB # Common Name
182+
export TEST_CERT_VENDOR_ID=130D # Vendor ID hex string
183+
export TEST_CERT_PRODUCT_ID=1001 # Product ID hex string
184+
export TEST_CERT_CN=BFLB # Common Name
161185
```
162186

163187
- Generate PAA certificate and key to `out/cert` folder.
164188

165189
```shell
166-
mkdir out/test-cert
167190
./out/linux-x64-chip-cert/chip-cert gen-att-cert --type a --subject-cn "${TEST_CERT_CN} PAA 01" --valid-from "2020-10-15 14:23:43" --lifetime 7305 --out-key out/test-cert/Chip-PAA-Key-${TEST_CERT_VENDOR_ID}.pem --out out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem --subject-vid ${TEST_CERT_VENDOR_ID}
168191
```
169192

193+
- Check PAA certificate
194+
195+
```shell
196+
openssl x509 -noout -text -in out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem
197+
```
198+
170199
- Convert PAA PEM format file to PAA DER format file
171200

172201
```shell
@@ -182,14 +211,84 @@ user should know it has limit to work with real ecosystem.
182211
./out/linux-x64-chip-cert/chip-cert gen-att-cert --type i --subject-cn "${TEST_CERT_CN} PAI 01" --subject-vid ${TEST_CERT_VENDOR_ID} --valid-from "2020-10-15 14:23:43" --lifetime 7305 --ca-key out/test-cert/Chip-PAA-Key-${TEST_CERT_VENDOR_ID}.pem --ca-cert out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem --out-key out/test-cert/Chip-PAI-Key-${TEST_CERT_VENDOR_ID}.pem --out out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem
183212
```
184213

185-
- Generate `MFD` in plain text data
214+
- Check PAI certificate
186215

187-
```shell
188-
./scripts/tools/bouffalolab/generate_factory_data.py --output out/test-cert --paa_cert out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem --paa_key out/test-cert/Chip-PAA-Key-${TEST_CERT_VENDOR_ID}.pem --pai_cert out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --pai_key out/test-cert/Chip-PAI-Key-${TEST_CERT_VENDOR_ID}.pem
189-
```
216+
```shell
217+
openssl x509 -noout -text -in out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem
218+
```
190219

191-
> Appending `--key <hex string of 16 bytes>` option to enable encrypt
192-
> private key of attestation device data.
220+
- Generate `MFD` in plain text data with same VID/PID in DAC and CD
221+
222+
- Use same environment variables `TEST_CERT_VENDOR_ID` and
223+
`TEST_CERT_PRODUCT_ID` for CD.
224+
225+
```shell
226+
./scripts/tools/bouffalolab/generate_factory_data.py --output out/test-cert --paa_cert out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem --paa_key out/test-cert/Chip-PAA-Key-${TEST_CERT_VENDOR_ID}.pem --pai_cert out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --pai_key out/test-cert/Chip-PAI-Key-${TEST_CERT_VENDOR_ID}.pem --dac_pid 0x${TEST_CERT_PRODUCT_ID} --vendor_id 0x${TEST_CERT_VENDOR_ID} --product_id 0x${TEST_CERT_PRODUCT_ID}
227+
```
228+
229+
> Appending `--key <hex string of 16 bytes>` option to enable encrypt
230+
> private key of attestation device data.
231+
232+
- Check DAC certificate. Here takes `out_130d_1001_1349_dac_cert.pem` as
233+
generated test certification.
234+
235+
```shell
236+
openssl x509 -noout -text -in out/test-cert/out_130d_1001_1349_dac_cert.pem
237+
```
238+
239+
- Check PAA/PAI/DAC certificate chain.
240+
241+
```shell
242+
./out/linux-x64-chip-cert/chip-cert validate-att-cert --dac out/test-cert/out_130d_1001_1349_dac_cert.pem --pai out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --paa out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem
243+
```
244+
245+
- Check Certification Declare. Here takes `out_130d_1001_cd.der` as
246+
generated test certification.
247+
248+
```shell
249+
./out/linux-x64-chip-cert/chip-cert print-cd out/test-cert/out_130d_1001_cd.der
250+
```
251+
252+
- Generate `MFD` in plain text data with different VID/PID in DAC and CD
253+
254+
- Export vendor ID and product ID for CD
255+
256+
```shell
257+
export TEST_CD_VENDOR_ID=730D # Vendor ID hex string
258+
export TEST_CD_PRODUCT_ID=7001 # Product ID hex string
259+
```
260+
261+
- Run script to generate DAC/CD and `MFD`.
262+
263+
```shell
264+
./scripts/tools/bouffalolab/generate_factory_data.py --output out/test-cert --paa_cert out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem --paa_key out/test-cert/Chip-PAA-Key-${TEST_CERT_VENDOR_ID}.pem --pai_cert out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --pai_key out/test-cert/Chip-PAI-Key-${TEST_CERT_VENDOR_ID}.pem --dac_pid 0x${TEST_CERT_PRODUCT_ID} --vendor_id 0x${TEST_CD_VENDOR_ID} --product_id 0x${TEST_CD_PRODUCT_ID}
265+
```
266+
267+
> Appending `--key <hex string of 16 bytes>` option to enable encrypt
268+
> private key of attestation device data.
269+
>
270+
> Please use --`vendor_name` and `--product_name` to change vendor name
271+
> and product name.
272+
273+
- Check DAC certificate. Here takes `out_130d_1001_1349_dac_cert.pem` as
274+
generated test certification.
275+
276+
```shell
277+
openssl x509 -noout -text -in out/test-cert/out_130d_1001_1349_dac_cert.pem
278+
```
279+
280+
- Check PAA/PAI/DAC certificate chain.
281+
282+
```shell
283+
./out/linux-x64-chip-cert/chip-cert validate-att-cert --dac out/test-cert/out_130d_1001_1349_dac_cert.pem --pai out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --paa out/test-cert/Chip-PAA-Cert-${TEST_CERT_VENDOR_ID}.pem
284+
```
285+
286+
- Check Certification Declare. Here takes `out_730D_7001_cd.der` as
287+
generated test certification.
288+
289+
```shell
290+
./out/linux-x64-chip-cert/chip-cert print-cd out/test-cert/out_130d_1001_cd.der
291+
```
193292

194293
## Generate with self-defined DAC certificate and key
195294

@@ -200,14 +299,14 @@ user should know it has limit to work with real ecosystem.
200299

201300
```
202301
export TEST_CERT_VENDOR_ID=130D # Vendor ID hex string
203-
export TEST_CERT_PRODUCT_ID=1001 # Vendor ID hex string
302+
export TEST_CERT_PRODUCT_ID=1001 # Product ID hex string
204303
export TEST_CERT_CN=BFLB # Common Name
205304
```
206305

207306
- Generate DAC certificate and key
208307

209308
```shell
210-
out/linux-x64-chip-cert/chip-cert gen-att-cert --type d --subject-cn "${TEST_CERT_CN} PAI 01" --subject-vid ${TEST_CERT_VENDOR_ID} --subject-pid ${TEST_CERT_VENDOR_ID} --valid-from "2020-10-16 14:23:43" --lifetime 5946 --ca-key out/test-cert/Chip-PAI-Key-${TEST_CERT_VENDOR_ID}.pem --ca-cert out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --out-key out/test-cert/Chip-DAC-Key-${TEST_CERT_VENDOR_ID}-${TEST_CERT_PRODUCT_ID}.pem --out out/test-cert/Chip-DAC-Cert-${TEST_CERT_VENDOR_ID}-${TEST_CERT_PRODUCT_ID}.pem
309+
out/linux-x64-chip-cert/chip-cert gen-att-cert --type d --subject-cn "${TEST_CERT_CN} PAI 01" --subject-vid ${TEST_CERT_VENDOR_ID} --subject-pid ${TEST_CERT_PRODUCT_ID} --valid-from "2020-10-16 14:23:43" --lifetime 5946 --ca-key out/test-cert/Chip-PAI-Key-${TEST_CERT_VENDOR_ID}.pem --ca-cert out/test-cert/Chip-PAI-Cert-${TEST_CERT_VENDOR_ID}.pem --out-key out/test-cert/Chip-DAC-Key-${TEST_CERT_VENDOR_ID}-${TEST_CERT_PRODUCT_ID}.pem --out out/test-cert/Chip-DAC-Cert-${TEST_CERT_VENDOR_ID}-${TEST_CERT_PRODUCT_ID}.pem
211310
```
212311

213312
> **Note**, `--valid-from` and `--lifetime` should be in `--valid-from` and
@@ -238,12 +337,5 @@ key.
238337
> If `MFD` file has cipher text data, please append
239338
> `--key <hex string of 16 bytes>` option to program to this key to efuse.
240339

241-
- Limits on BL IOT SDK
242-
243-
If developer would like to program `MFD` with all plain text data, option
244-
`--key <hex string of 16 bytes>` needs pass to script, otherwise, flash tool
245-
will raise an error. And SoC BL602, BL702 and BL702L use BL IOT SDK for
246-
Matter Application.
247-
248340
Please free contact to `Bouffalo Lab` for DAC provider service and higher
249341
security solution, such as SoC inside certificate requesting.

examples/contact-sensor-app/bouffalolab/bl702l/app_pds.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,9 @@ extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime)
5959
extern BaseType_t TrapNetCounter, *pTrapNetCounter;
6060
if (app_pds_wakeup_source == PDS_WAKEUP_BY_RTC)
6161
{
62-
extern void * pxCurrentTCB;
63-
64-
ChipLogProgress(NotSpecified, "wakeup source: rtc. %lu vs %lu ms @ %lu\r\n", xExpectedIdleTime,
65-
(uint32_t) (bl_rtc_get_timestamp_ms() - sleep_before), (uint32_t) bl_rtc_get_timestamp_ms());
66-
67-
ChipLogProgress(NotSpecified, "application_sleep; %lu, %lu, %lu\r\n", (uint32_t) sleep_calling_time, (uint32_t) sleep_time,
68-
(uint32_t) wakeup_time);
6962
}
7063
else if (app_pds_wakeup_source == PDS_WAKEUP_BY_GPIO)
7164
{
72-
7365
if (((1 << CHIP_RESET_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler)
7466
{
7567
app_pds_irq_handler(&gpio_key);
@@ -79,10 +71,6 @@ extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime)
7971
{
8072
app_pds_irq_handler(&gpio_contact);
8173
}
82-
83-
ChipLogProgress(NotSpecified, "wakeup source: gpio -> 0x%08lX. %lu vs %lu ms @ %lu\r\n", app_pds_wakeup_pin,
84-
xExpectedIdleTime, (uint32_t) (bl_rtc_get_timestamp_ms() - sleep_before),
85-
(uint32_t) bl_rtc_get_timestamp_ms());
8674
}
8775

8876
app_pds_wakeup_source = -1;

examples/lighting-app/bouffalolab/bl602/BUILD.gn

+9-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ bl_iot_sdk("sdk") {
7676
"OTA_AUTO_REBOOT_DELAY=${ota_auto_reboot_delay_seconds}",
7777
"CHIP_UART_BAUDRATE=${baudrate}",
7878
"SYS_AOS_LOOP_ENABLE",
79-
"CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE=48",
8079
]
8180

8281
defines += [ "PW_RPC_ENABLED=${chip_enable_pw_rpc}" ]
@@ -97,7 +96,7 @@ bouffalolab_executable("lighting_app") {
9796
output_name = "chip-bl602-lighting-example.out"
9897

9998
defines = [
100-
"APP_TASK_STACK_SIZE=2044",
99+
"APP_TASK_STACK_SIZE=4096",
101100
"CHIP_UART_BAUDRATE=${baudrate}",
102101
"START_ENTRY=bfl_main",
103102
"SYS_AOS_LOOP_ENABLE",
@@ -110,6 +109,10 @@ bouffalolab_executable("lighting_app") {
110109
defines +=
111110
[ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ]
112111

112+
if (enable_lwip_pbuf_ram) {
113+
defines += [ "CHIP_SYSTEM_CONFIG_PACKETBUFFER_LWIP_PBUF_RAM=1" ]
114+
}
115+
113116
bl_plat_name = "bl602"
114117
sources = [
115118
"${examples_plat_dir}/common/route_hook/bl_route_hook.c",
@@ -228,6 +231,10 @@ bouffalolab_executable("lighting_app") {
228231
inputs = [ ldscript ]
229232

230233
if (chip_print_memory_usage) {
234+
if (enable_lwip_pbuf_ram) {
235+
ldflags += [ "-Wl,--defsym=__RAM_PBUF_POOL=0" ]
236+
}
237+
231238
ldflags += [
232239
"-Wl,--print-memory-usage",
233240
"-fstack-usage",

examples/lighting-app/bouffalolab/bl616/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ bouffalolab_executable("lighting_app") {
121121
defines += [ "BOOT_PIN_RESET=2" ]
122122
}
123123

124+
if (enable_lwip_pbuf_ram) {
125+
defines += [ "CHIP_SYSTEM_CONFIG_PACKETBUFFER_LWIP_PBUF_RAM=1" ]
126+
}
127+
124128
defines += [ "BL616DK" ]
125129

126130
sources = [

examples/lighting-app/bouffalolab/bl616/args.gni

+1-10
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,7 @@ import("${chip_root}/src/platform/bouffalolab/BL616/args.gni")
1919

2020
bouffalo_sdk_target = get_label_info(":sdk", "label_no_toolchain")
2121

22-
pw_log_BACKEND = "${chip_root}/src/pw_backends/log"
23-
pw_assert_BACKEND = "${chip_root}/src/pw_backends/assert"
24-
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"
25-
26-
chip_detail_logging = true
22+
chip_detail_logging = false
2723

2824
# use -Os instead of -Og
2925
is_debug = false
30-
31-
pw_build_LINK_DEPS = [
32-
"$dir_pw_assert:impl",
33-
"$dir_pw_log:impl",
34-
]

examples/lighting-app/bouffalolab/bl702/BUILD.gn

+1-4
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ bl_iot_sdk("sdk") {
9696
}
9797

9898
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_ETHERNET=${chip_enable_ethernet}" ]
99-
if (chip_enable_ethernet) {
100-
defines += [ "CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE=48" ]
101-
}
10299

103100
if (enable_psram) {
104101
defines += [ "CFG_USE_PSRAM=1" ]
@@ -129,7 +126,7 @@ bouffalolab_executable("lighting_app") {
129126
bl_plat_name = "bl702"
130127

131128
defines = [
132-
"APP_TASK_STACK_SIZE=2048",
129+
"APP_TASK_STACK_SIZE=4096",
133130
"CHIP_UART_BAUDRATE=${baudrate}",
134131
"START_ENTRY=bl702_main",
135132
]

examples/lighting-app/bouffalolab/bl702l/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ bouffalolab_executable("lighting_app") {
106106
bl_plat_name = "bl702l"
107107

108108
defines = [
109-
"APP_TASK_STACK_SIZE=2048",
109+
"APP_TASK_STACK_SIZE=4096",
110110
"CHIP_UART_BAUDRATE=${baudrate}",
111111
"START_ENTRY=bl702_main",
112112
]

0 commit comments

Comments
 (0)