Skip to content

Commit

Permalink
[Bouffalolab] Add factory data support on BL70x family (#29401)
Browse files Browse the repository at this point in the history
* [Bouffalolab] Add factory data support on BL70x famliy

* fix lintcode

* update targets for workflow

* fix restyle

* use static variables for tasks

* change MACRO using method and remove unnecessary escapes
  • Loading branch information
wy-hh authored and pull[bot] committed Oct 31, 2023
1 parent 292076b commit ddb5e46
Show file tree
Hide file tree
Showing 18 changed files with 214 additions and 120 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl602-night-light-light \
--target bouffalolab-bl602-night-light-light-mfd \
--target bouffalolab-bl602-iot-matter-v1-light-115200-rpc \
build \
--copy-artifacts-to out/artifacts \
Expand All @@ -66,6 +67,10 @@ jobs:
bl602 bl602 lighting-app \
out/artifacts/bouffalolab-bl602-night-light-light/chip-bl602-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl602 bl602+mfd lighting-app \
out/artifacts/bouffalolab-bl602-night-light-light-mfd/chip-bl602-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl602 bl602+rpc lighting-app \
out/artifacts/bouffalolab-bl602-iot-matter-v1-light-115200-rpc/chip-bl602-lighting-example.out \
Expand All @@ -78,6 +83,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl706-night-light-light \
--target bouffalolab-bl706-night-light-light-mfd \
--target bouffalolab-bl706dk-light-ethernet \
--target bouffalolab-bl706dk-light-wifi-fp \
--target bouffalolab-xt-zb6-devkit-light-115200-rpc \
Expand All @@ -90,6 +96,10 @@ jobs:
bl702 bl702 lighting-app \
out/artifacts/bouffalolab-bl706-night-light-light/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl702+mfd lighting-app \
out/artifacts/bouffalolab-bl706-night-light-light-mfd/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl706-eth lighting-app \
out/artifacts/bouffalolab-bl706dk-light-ethernet/chip-bl702-lighting-example.out \
Expand All @@ -111,6 +121,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl704ldk-light \
--target bouffalolab-bl704ldk-light-mfd \
build \
--copy-artifacts-to out/artifacts \
"
Expand All @@ -120,6 +131,10 @@ jobs:
bl702l bl702l lighting-app \
out/artifacts/bouffalolab-bl704ldk-light/chip-bl702l-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702l bl702l+mfd lighting-app \
out/artifacts/bouffalolab-bl704ldk-light-mfd/chip-bl702l-lighting-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out

Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ bouffalolab_executable("lighting_app") {
}

if (chip_enable_factory_data) {
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE" ]
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=1" ]
}

if (chip_enable_factory_data_test) {
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST" ]
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST=1" ]
}

bl_plat_name = "bl602"
Expand Down
8 changes: 8 additions & 0 deletions examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ bouffalolab_executable("lighting_app") {
defines += [ "BOOT_PIN_RESET=31" ]
}

if (chip_enable_factory_data) {
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=1" ]
}

if (chip_enable_factory_data_test) {
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST=1" ]
}

if ("XT-ZB6-DevKit" == board) {
defines += [ "XT_ZB6_DevKit" ]
} else if ("BL706-NIGHT-LIGHT" == board) {
Expand Down
9 changes: 9 additions & 0 deletions examples/lighting-app/bouffalolab/bl702l/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import("${bouffalolab_iot_sdk_build_root}/bl702l/bl_iot_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/bouffalolab/common/args.gni")
import("${chip_root}/src/platform/device.gni")

import("${chip_root}/src/app/chip_data_model.gni")
Expand Down Expand Up @@ -126,6 +127,14 @@ bouffalolab_executable("lighting_app") {
defines += [ "BOOT_PIN_RESET=16" ]
}

if (chip_enable_factory_data) {
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=1" ]
}

if (chip_enable_factory_data_test) {
defines += [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST=1" ]
}

if ("BL704LDK" == board) {
defines += [ "XT_ZB6_DevKit" ]
}
Expand Down
29 changes: 14 additions & 15 deletions examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ __RAM_END = 0x4200C000 + 256K - __EM_SIZE; /* leave 8K left for BLE */
__RAM_TCM_LEN = (16K + 16K + 48K + 64K + 64K - 16K - 16K);
__RAM_WIFI_LEN = (__RAM_END - __RAM_START - __RAM_TCM_LEN);

__OCRAM_START_ADDRESS = 0x42030000 + 0x8000;
__OCRAM_SIZE = 112K;

MEMORY
{
rom (rxai!w) : ORIGIN = 0x21015000, LENGTH = 44K
Expand Down Expand Up @@ -201,13 +198,13 @@ SECTIONS

.boot2 (NOLOAD) :
{
PROVIDE ( __boot2_pt_addr_start = . );
*(.bss.boot2_partition_table)
PROVIDE ( __boot2_pt_addr_end = . );
PROVIDE ( __boot2_pt_addr_start = . );
*(.bss.boot2_partition_table)
PROVIDE ( __boot2_pt_addr_end = . );

PROVIDE ( __boot2_flashCfg_start = . );
*(.bss.boot2_flashCfg)
PROVIDE ( __boot2_flashCfg_end = . );
PROVIDE ( __boot2_flashCfg_start = . );
*(.bss.boot2_flashCfg)
PROVIDE ( __boot2_flashCfg_end = . );

} > ram_tcm

Expand All @@ -216,11 +213,16 @@ SECTIONS
PROVIDE( __bss_start = ADDR(.bss) );
PROVIDE( __bss_end = ADDR(.bss) + SIZEOF(.bss) );

*(.sbss*)
*(.sbss)
*(EXCLUDE_FILE(*libCHIP.a:BL602.PlatformManagerImpl.cpp.o) .sbss.*)
*(.gnu.linkonce.sb.*)
*(.bss .bss.*)
*(.bss)
*(EXCLUDE_FILE(*libCHIP.a:BL602.PlatformManagerImpl.cpp.o) .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
*(EXCLUDE_FILE(*libCHIP.a:BL602.PlatformManagerImpl.cpp.o) COMMON)

. = ALIGN(4);
*libCHIP.a:BL602.PlatformManagerImpl.cpp.o(.sbss.* .bss.* COMMON)
} > ram_tcm

.stack (NOLOAD) :
Expand Down Expand Up @@ -258,9 +260,6 @@ SECTIONS
PROVIDE( _ld_ram_size2 = LENGTH(ram_wifi) );
PROVIDE( _ld_ram_addr2 = ORIGIN(ram_wifi) );

PROVIDE(__ocram_start_addr = __OCRAM_START_ADDRESS);
PROVIDE(__ocram_size = __OCRAM_SIZE);

/*BOOT2 sections*/
PROVIDE ( __boot2_pt_addr_src = BOOT2_PT_ADDR );
PROVIDE ( __boot2_flashCfg_src = BOOT2_FLASHCFG_ADDR );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[pt_table]
#partition table is 4K in size
address0 = 0x1000
address1 = 0x2000
address0 = 0xE000
address1 = 0xF000

[[pt_entry]]
type = 0
name = "FW"
device = 0
address0 = 0x3000
size0 = 0x134000
address1 = 0x137000
size1 = 0xBB000
address0 = 0x10000
size0 = 0x12A000
address1 = 0x13A000
size1 = 0xB8000
# compressed image must set len,normal image can left it to 0
len = 0
activeindex = 0
Expand All @@ -20,8 +20,8 @@ age = 0
type = 1
name = "mfg"
device = 0
address0 = 0x137000
size0 = 0xBB000
address0 = 0x13A000
size0 = 0xB8000
address1 = 0
size1 = 0
# compressed image must set len,normal image can left it to 0
Expand Down
43 changes: 20 additions & 23 deletions examples/platform/bouffalolab/bl702/ldscripts/psram_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ OUTPUT_ARCH( "riscv" )
ENTRY( bl702_start )

__EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K;
__SHA_LINK_CFG_SIZE = DEFINED(mbedtls_sha256_init) ? 72 : 0;
__OCRAM_BSS_REGION_SIZE = 12K;
__CACHE_SIZE = DEFINED(__CACHE_SIZE) ? __CACHE_SIZE : 16K;
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;

MEMORY
{
flash (rxai!w) : ORIGIN = 0x23000000, LENGTH = (2M)
tcm_ocram (wxa) : ORIGIN = 0x42010000 + __CACHE_SIZE, LENGTH = (64K - __CACHE_SIZE + 64K - __EM_SIZE - __stack_size - __SHA_LINK_CFG_SIZE)
sha_ocram (wxa) : ORIGIN = ORIGIN(tcm_ocram) + LENGTH(tcm_ocram), LENGTH = __SHA_LINK_CFG_SIZE
sys_stack (wxa) : ORIGIN = ORIGIN(tcm_ocram) + LENGTH(tcm_ocram) + __SHA_LINK_CFG_SIZE, LENGTH = __stack_size
tcm_ocram (wxa) : ORIGIN = 0x42010000 + __CACHE_SIZE, LENGTH = (64K - __CACHE_SIZE + 64K - __OCRAM_BSS_REGION_SIZE - __stack_size - __EM_SIZE)
ocram_bss (wxa) : ORIGIN = ORIGIN(tcm_ocram) + LENGTH(tcm_ocram), LENGTH = __OCRAM_BSS_REGION_SIZE
sys_stack (wxa) : ORIGIN = ORIGIN(tcm_ocram) + LENGTH(tcm_ocram) + __OCRAM_BSS_REGION_SIZE, LENGTH = __stack_size
hbnram (wxa) : ORIGIN = 0x40010000, LENGTH = (4K)
psram (wxa) : ORIGIN = 0x26000000, LENGTH = (2M)
}
Expand Down Expand Up @@ -207,6 +207,21 @@ SECTIONS
PROVIDE ( __boot2_flashCfg_end = . );
} >tcm_ocram

.ocram_bss (NOLOAD) :
{
PROVIDE( __ocram_bss_start = ADDR(.ocram_bss) );
PROVIDE( __ocram_bss_end = ADDR(.ocram_bss) + SIZEOF(.ocram_bss) );

*libCHIP.a:BL702.PlatformManagerImpl.cpp.o(.sbss.* .bss.* COMMON)
. = ALIGN(4);
*(.sha_ocram*)

} > ocram_bss

. = ALIGN(4);
PROVIDE( _heap2_start = .);
PROVIDE( _heap2_size = ADDR(.stack) - _heap2_start );

.bss_psram (NOLOAD) :
{
PROVIDE( __bss_psram_start = ADDR(.bss_psram) );
Expand Down Expand Up @@ -290,26 +305,8 @@ SECTIONS

. = ALIGN(8);
PROVIDE( _heap_start = . );
PROVIDE( _heap_size = ADDR(.stack) - _heap_start );

PROVIDE( _heap2_start = 0 );
PROVIDE( _heap2_size = 0 );

.psram (NOLOAD) :
{
*(.wifi_ram*)
. = ALIGN(16);
} > psram
PROVIDE( _heap_size = ADDR(.ocram_bss) - _heap_start );

. = ALIGN(8);
PROVIDE( _heap3_start = .);
PROVIDE( _heap3_size = ORIGIN(psram) + LENGTH(psram) - _heap3_start );

.sha_ocram (NOLOAD) :
{
*(.sha_ocram*)
} > sha_ocram

.stack (NOLOAD) :
{
PROVIDE ( _sp_base = . );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ device = 0
address0 = 0x3000
size0 = 0x12b000
address1 = 0x12e000
size1 = 0xC9000
size1 = 0xC8000
# compressed image must set len,normal image can left it to 0
len = 0
activeindex = 0
Expand All @@ -21,7 +21,7 @@ type = 1
name = "mfg"
device = 0
address0 = 0x12A000
size0 = 0xC9000
size0 = 0xC8000
address1 = 0
size1 = 0
# compressed image must set len,normal image can left it to 0
Expand All @@ -33,8 +33,8 @@ age = 0
type = 2
name = "PSM"
device = 0
address0 = 0x1F7000
size0 = 0x4000
address0 = 0x1F2000
size0 = 0x8000
address1 = 0
size1 = 0
# compressed image must set len,normal image can left it to 0
Expand All @@ -46,7 +46,7 @@ age = 0
type = 3
name = "media"
device = 0
address0 = 0x1FB000
address0 = 0x1FA000
size0 = 0x4000
address1 = 0
size1 = 0
Expand All @@ -57,6 +57,19 @@ age = 0

[[pt_entry]]
type = 4
name = "MFD"
device = 0
address0 = 0x1FE000
size0 = 0x1000
address1 = 0
size1 = 0
# compressed image must set len,normal image can left it to 0
len = 0
activeindex = 0
age = 0

[[pt_entry]]
type = 5
name = "factory"
device = 0
address0 = 0x1FF000
Expand Down
16 changes: 14 additions & 2 deletions examples/platform/bouffalolab/common/iot_sdk/platform_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,12 @@ static const HeapRegion_t xHeapRegions[] = {
{ NULL, 0 } /* Terminates the array. */
};
#elif BL702_ENABLE
extern uint8_t _heap2_start;
extern uint8_t _heap2_size; // @suppress("Type cannot be resolved")
static const HeapRegion_t xHeapRegions[] = {
{ &_heap_start, (size_t) &_heap_size }, // set on runtime
{ NULL, 0 } /* Terminates the array. */
{ &_heap_start, (size_t) &_heap_size }, // set on runtime
{ &_heap2_start, (size_t) &_heap2_size }, // set on runtime
{ NULL, 0 } /* Terminates the array. */
};
#elif BL702L_ENABLE
static const HeapRegion_t xHeapRegions[] = {
Expand Down Expand Up @@ -338,6 +341,14 @@ void setup_heap()
memcpy((void *) &_rom_data_run, (void *) &_rom_data_load, (size_t) &_rom_data_size);
#endif

#if BL702_ENABLE
extern uint8_t __ocram_bss_start[], __ocram_bss_end[];
if (NULL != __ocram_bss_start && NULL != __ocram_bss_end && __ocram_bss_end > __ocram_bss_start)
{
memset(__ocram_bss_start, 0, __ocram_bss_end - __ocram_bss_start);
}
#endif

vPortDefineHeapRegions(xHeapRegions);

#ifdef CFG_USE_PSRAM
Expand Down Expand Up @@ -394,6 +405,7 @@ void platform_port_init(void)
#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED
uartInit();
#endif

#ifdef SYS_AOS_LOOP_ENABLE
aos_loop_start();
#else
Expand Down
Loading

0 comments on commit ddb5e46

Please sign in to comment.