Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bouffalolab] Cherry-pick: Fix BL602 IPv6 address generation failure #23790

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/examples-bl602.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build:latest
image: connectedhomeip/chip-build-bouffalolab:0.6.12
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand All @@ -44,7 +44,7 @@ jobs:
attempt_limit: 3
attempt_delay: 2000
- name: Checkout submodules
run: scripts/checkout_submodules.py --shallow --platform bl602
run: scripts/checkout_submodules.py --shallow --platform bl602 --recursive

- name: Set up environment for size reports
if: ${{ !env.ACT }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build:latest
image: connectedhomeip/chip-build-bouffalolab:0.6.12
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand All @@ -44,7 +44,7 @@ jobs:
attempt_limit: 3
attempt_delay: 2000
- name: Checkout submodules
run: scripts/checkout_submodules.py --shallow --platform bouffalolab
run: scripts/checkout_submodules.py --shallow --platform bouffalolab --recursive

- name: Set up environment for size reports
if: ${{ !env.ACT }}
Expand Down
11 changes: 6 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@
[submodule "third_party/boringssl/repo/src"]
path = third_party/boringssl/repo/src
url = https://github.com/google/boringssl.git
[submodule "boufalolab_repo"]
path = third_party/bouffalolab/repo
url = https://github.com/bouffalolab/bl_iot_sdk.git
branch = master
platforms = bouffalolab,bl602
[submodule "third_party/mt793x_sdk/filogic"]
path = third_party/mt793x_sdk/filogic
url = https://github.com/MediaTek-Labs/genio-matter-bsp.git
Expand All @@ -288,3 +283,9 @@
url = https://github.com/matter-mtk/genio-matter-lwip.git
branch = main
platforms = genio
[submodule "bouffalolab_sdk"]
path = third_party/bouffalolab/repo
url = https://github.com/bouffalolab/bl_iot_sdk_tiny.git
branch = master
platforms = bouffalolab,bl602

3 changes: 1 addition & 2 deletions build_overrides/bouffalolab_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ declare_args() {
# Root directory for bl702 SDK build files.
bl702_sdk_build_root = "//third_party/bouffalolab/bl702"

# Root directory of toolchain of Bouffalolab chips
bouffalolab_toolchain = "//third_party/bouffalolab/repo/toolchain/riscv"
bouffalolab_sdk_root = "/opt/bouffalolab_sdk"
}
3 changes: 1 addition & 2 deletions examples/build_overrides/bouffalolab_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ declare_args() {
bl702_sdk_build_root =
"//third_party/connectedhomeip/third_party/bouffalolab/bl702"

# Root directory of toolchain of Bouffalolab chips
bouffalolab_toolchain = "/third_party/bouffalolab/repo/toolchain/riscv"
bouffalolab_sdk_root = "/opt/bouffalolab_sdk"
}
6 changes: 5 additions & 1 deletion examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ declare_args() {

# OTA periodic query timeout in seconds
ota_periodic_query_timeout = 86400

baudrate = 115200
}

show_qr_code = false
Expand All @@ -68,8 +70,8 @@ bl602_sdk("sdk") {
"CONFIG_PSM_EASYFLASH_SIZE=16384",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"OTA_PERIODIC_QUERY_TIMEOUT=${ota_periodic_query_timeout}",
"UART_BAUDRATE=${baudrate}",
]

if (chip_enable_pw_rpc) {
defines += [ "PW_RPC_ENABLED" ]
}
Expand Down Expand Up @@ -113,6 +115,8 @@ bl602_executable("lighting_app") {
defines = [ "BOARD_ID=1" ]
}

defines += [ "UART_BAUDRATE=${baudrate}" ]

if (show_qr_code) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]

Expand Down
16 changes: 16 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
source ./scripts/activate.sh
```

- Setup build environment for `Bouffalo Lab` SoC

Run `setup.sh` to install `Bouffalo Lab` SDK to /opt/bouffalolab_sdk

```
cd third_party/bouffalolab/repo
sudo bash script/setup.sh
```

Please execute following command export `BOUFFALOLAB_SDK_ROOT` before
building.

```
export BOUFFALOLAB_SDK_ROOT=/opt/bouffalolab_sdk
```

## Build the image and flash the board

- Build the
Expand Down
2 changes: 0 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ void AppTask::AppTaskMain(void * pvParameter)
CHIP_ERROR err;

log_info("App Task entered\r\n");
log_async_init();
enable_async_log();

err = sWiFiNetworkCommissioningInstance.Init();
if (CHIP_NO_ERROR != err)
Expand Down
15 changes: 15 additions & 0 deletions examples/lighting-app/bouffalolab/bl702/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ following boards:
```shell
source scripts/activate.sh
```
- Setup build environment for `Bouffalo Lab` SoC

Run `setup.sh` to install `Bouffalo Lab` SDK to /opt/bouffalolab_sdk

```
cd third_party/bouffalolab/repo
sudo bash script/setup.sh
```

Please execute following command export `BOUFFALOLAB_SDK_ROOT` before
building.

```
export BOUFFALOLAB_SDK_ROOT=/opt/bouffalolab_sdk
```

## Build CHIP BL702 Lighting App example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ template("riscv_toolchain") {
_tool_name_root = ""

if ("linux" == host_os) {
_tool_name_root = "${root_build_dir}/../../${bouffalolab_toolchain}/Linux/bin/riscv64-unknown-elf-"
_tool_name_root = "${bouffalolab_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
} else if ("mac" == host_os || "darwin" == host_os) {
_tool_name_root = "${root_build_dir}/../../${bouffalolab_toolchain}/Darwin/bin/riscv64-unknown-elf-"
_tool_name_root = "${bouffalolab_sdk_root}/toolchain/riscv/Darwin/bin/riscv64-unknown-elf-"
}

ar = _tool_name_root + "ar"
Expand Down
3 changes: 2 additions & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ def TizenTargets():
def Bl602Targets():
target = Target('bl602', Bl602Builder)

yield target.Extend('light', board=Bl602Board.BL602BOARD, app=Bl602App.LIGHT)
yield target.Extend('light', board=Bl602Board.BL602BOARD, app=Bl602App.LIGHT, baudrate=115200)
yield target.Extend('light-2m-uart', board=Bl602Board.BL602BOARD, app=Bl602App.LIGHT, baudrate=2000000)


def BouffalolabTargets():
Expand Down
8 changes: 6 additions & 2 deletions scripts/build/builders/bl602.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def __init__(self,
root,
runner,
app: Bl602App = Bl602App.LIGHT,
board: Bl602Board = Bl602Board.BL602BOARD):
board: Bl602Board = Bl602Board.BL602BOARD,
baudrate=115200):
super(Bl602Builder, self).__init__(
root=os.path.join(root, 'examples',
app.ExampleName(), 'bouffalolab', 'bl602'),
Expand All @@ -72,9 +73,12 @@ def __init__(self,

self.app = app
self.board = board
self.baudrate = baudrate

self.argsOpt.append('bouffalolab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT'])

def GnBuildArgs(self):
return self.argsOpt + ['bl602_board="%s"' % self.board.GnArgName()]
return self.argsOpt + ['bl602_board="%s"' % self.board.GnArgName()] + ['baudrate=%d' % self.baudrate]

def build_outputs(self):
items = {
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def __init__(self,
if enable_rpcs:
self.argsOpt.append('import("//with_pw_rpc.gni")')

self.argsOpt.append('bouffalolab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT'])

def GnBuildArgs(self):
return self.argsOpt

Expand Down
1 change: 1 addition & 0 deletions scripts/build/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def build_actual_output(root: str, out: str, args: List[str]) -> List[str]:
'NXP_K32W0_SDK_ROOT': 'TEST_NXP_K32W0_SDK_ROOT',
'IMX_SDK_ROOT': 'IMX_SDK_ROOT',
'TI_SYSCONFIG_ROOT': 'TEST_TI_SYSCONFIG_ROOT',
'BOUFFALOLAB_SDK_ROOT': 'TEST_BOUFFALOLAB_SDK_ROOT',
})

retval = subprocess.run([
Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android-x64-tv-server
android-x86-chip-tool
android-x86-tv-server
bl602-light
bl602-light-2m-uart
bouffalolab-BL706-IoT-DVK-light
bouffalolab-BL706-IoT-DVK-light-rpc
bouffalolab-BL706-NIGHT-LIGHT-light
Expand Down
14 changes: 10 additions & 4 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,19 @@ gn gen --check --fail-on-unused-args {out}/android-x86-tv-server '--args=target_
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating bl602-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl602 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" bl602_board="BL-HWC-G1"' {out}/bl602-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl602 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" bouffalolab_sdk_root="TEST_BOUFFALOLAB_SDK_ROOT" bl602_board="BL-HWC-G1" baudrate=115200' {out}/bl602-light

# Generating bl602-light-2m-uart
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl602 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" bouffalolab_sdk_root="TEST_BOUFFALOLAB_SDK_ROOT" bl602_board="BL-HWC-G1" baudrate=2000000' {out}/bl602-light-2m-uart

# Generating bouffalolab-BL706-IoT-DVK-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22"' {out}/bouffalolab-BL706-IoT-DVK-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22" bouffalolab_sdk_root="TEST_BOUFFALOLAB_SDK_ROOT"' {out}/bouffalolab-BL706-IoT-DVK-light

# Generating bouffalolab-BL706-IoT-DVK-light-rpc
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22" import("//with_pw_rpc.gni")' {out}/bouffalolab-BL706-IoT-DVK-light-rpc
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22" import("//with_pw_rpc.gni") bouffalolab_sdk_root="TEST_BOUFFALOLAB_SDK_ROOT"' {out}/bouffalolab-BL706-IoT-DVK-light-rpc

# Generating bouffalolab-BL706-NIGHT-LIGHT-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-NIGHT-LIGHT" module_type="BL702"' {out}/bouffalolab-BL706-NIGHT-LIGHT-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-NIGHT-LIGHT" module_type="BL702" bouffalolab_sdk_root="TEST_BOUFFALOLAB_SDK_ROOT"' {out}/bouffalolab-BL706-NIGHT-LIGHT-light

# Generating cc13x2x7_26x2x7-all-clusters
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/cc13x2x7_26x2x7 '--args=ti_sysconfig_root="TEST_TI_SYSCONFIG_ROOT"' {out}/cc13x2x7_26x2x7-all-clusters
Expand Down Expand Up @@ -1577,6 +1580,9 @@ cp {out}/android-x86-tv-server/lib/TvApp.jar {root}/examples/tv-app/android/App/
# Building bl602-light
ninja -C {out}/bl602-light

# Building bl602-light-2m-uart
ninja -C {out}/bl602-light-2m-uart

# Building bouffalolab-BL706-IoT-DVK-light
ninja -C {out}/bouffalolab-BL706-IoT-DVK-light

Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/glob_star_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android-x64-tv-server
android-x86-chip-tool
android-x86-tv-server
bl602-light
bl602-light-2m-uart
bouffalolab-BL706-IoT-DVK-light
bouffalolab-BL706-IoT-DVK-light-rpc
bouffalolab-BL706-NIGHT-LIGHT-light
Expand Down
2 changes: 1 addition & 1 deletion scripts/examples/gn_bl602_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ for arg; do
esac
done

gn gen --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]} custom_toolchain=\"$MATTER_ROOT/examples/platform/bouffalolab/common/toolchain:riscv_gcc\""
gn gen --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]} bouffalolab_sdk_root=\"$BOUFFALOLAB_SDK_ROOT\" custom_toolchain=\"$MATTER_ROOT/examples/platform/bouffalolab/common/toolchain:riscv_gcc\""

ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}"
2 changes: 2 additions & 0 deletions scripts/examples/gn_bouffalolab_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ else
exit 1
fi

optArgs=$optArgs' bouffalolab_sdk_root="'$BOUFFALOLAB_SDK_ROOT'"'

example_dir=$MATTER_ROOT/examples/$example_name/bouffalolab/$bouffalo_chip
output_dir=$MATTER_ROOT/$output_folder

Expand Down
17 changes: 17 additions & 0 deletions src/platform/bouffalolab/BL602/lwip_default_hooks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _LWIP_DEFAULT_HOOKS_H_
#define _LWIP_DEFAULT_HOOKS_H_
#include "lwip/arch.h"
#include "lwip/err.h"
#include "lwip/ip_addr.h"

#ifdef CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT
extern struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest);
#define LWIP_HOOK_IP6_ROUTE lwip_hook_ip6_route
#endif

#ifdef CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT
extern const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest);
#define LWIP_HOOK_ND6_GET_GW lwip_hook_nd6_get_gw
#endif

#endif /* _LWIP_DEFAULT_HOOKS_H_ */
6 changes: 2 additions & 4 deletions third_party/bouffalolab/bl602/bl602_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ template("bl602_executable") {
objcopy_image_format = "binary"
objcopy = "riscv64-unknown-elf-objcopy"
if ("linux" == host_os) {
objcopy =
"../../${bouffalolab_toolchain}/Linux/bin/riscv64-unknown-elf-objcopy"
objcopy = "${bouffalolab_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-objcopy"
} else if ("mac" == host_os || "darwin" == host_os) {
objcopy =
"../../${bouffalolab_toolchain}/Darwin/bin/riscv64-unknown-elf-objcopy"
objcopy = "${bouffalolab_sdk_root}/toolchain/riscv/Darwin/bin/riscv64-unknown-elf-objcopy"
}

# Copy flashing dependencies to the output directory so that the output
Expand Down
4 changes: 4 additions & 0 deletions third_party/bouffalolab/bl602/bl602_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/network/wifi_manager/bl60x_wifi_driver/include",
"${bl602_sdk_root}/components/network/wifi_manager/bl60x_wifi_driver",
"${bl602_sdk_root}/components/network/dns_server/include",
"${bl602_sdk_root}/components/network/rfparam_adapter_tmp/rftlv",

"${bl602_sdk_root}/components/platform/soc/bl602/bl602_std/bl602_std/StdDriver/Inc",
"${bl602_sdk_root}/components/security/blcrypto_suite/inc/blcrypto_suite",
Expand Down Expand Up @@ -251,6 +252,7 @@ template("bl602_sdk") {
#include defines
"OS_USING_FREERTOS",
"BL602_MATTER_SUPPORT",
"PBUF_POOL_SIZE=20",
"TD_DIAGNOSIS_STA",
"CONFIG_ENABLE_IPV6_ADDR_CALLBACK",
"CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT",
Expand Down Expand Up @@ -330,6 +332,7 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/stage/easyflash4/src/ef_utils.c",
"${bl602_sdk_root}/components/sys/blmtd/bl_mtd.c",
"${bl602_sdk_root}/components/sys/blota/bl_sys_ota_cli.c",
"${bl602_sdk_root}/components/utils/src/utils_hex.c",
"${bl602_sdk_root}/components/utils/src/utils_hexdump.c",
"${bl602_sdk_root}/components/utils/src/utils_sha256.c",
"${chip_root}/third_party/mbedtls/repo/library/aes.c",
Expand Down Expand Up @@ -557,6 +560,7 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/utils/src/utils_rbtree.c",

#rebase add
"${bl602_sdk_root}/components/network/rfparam_adapter_tmp/rftlv/phy_rftlv.c",
"${bl602_sdk_root}/components/network/wifi_hosal/port/wifi_hosal_bl602.c",
"${bl602_sdk_root}/components/network/wifi_hosal/wifi_hosal.c",
"${bl602_sdk_root}/components/os/bl_os_adapter/bl_os_adapter/bl_os_hal.c",
Expand Down
2 changes: 1 addition & 1 deletion third_party/bouffalolab/bl602/portable/bfl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <bl_romfs.h>
#endif

HOSAL_UART_DEV_DECL(uart_stdio, 0, 16, 7, 115200);
HOSAL_UART_DEV_DECL(uart_stdio, 0, 16, 7, UART_BAUDRATE);

extern uint8_t _heap_start;
extern uint8_t _heap_size; // @suppress("Type cannot be resolved")
Expand Down
6 changes: 2 additions & 4 deletions third_party/bouffalolab/bl702/bl702_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ template("bl702_executable") {

objcopy = "riscv64-unknown-elf-objcopy"
if ("linux" == host_os) {
objcopy =
"../../${bouffalolab_toolchain}/Linux/bin/riscv64-unknown-elf-objcopy"
objcopy = "${bouffalolab_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-objcopy"
} else if ("mac" == host_os || "darwin" == host_os) {
objcopy =
"../../${bouffalolab_toolchain}/Darwin/bin/riscv64-unknown-elf-objcopy"
objcopy = "${bouffalolab_sdk_root}/toolchain/riscv/Darwin/bin/riscv64-unknown-elf-objcopy"
}

# Copy flashing dependencies to the output directory so that the output
Expand Down
2 changes: 1 addition & 1 deletion third_party/bouffalolab/repo
Submodule repo updated from dc5263 to ae0622