Skip to content

Commit

Permalink
update frame pointer for backtrack debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh committed Aug 31, 2023
1 parent 78679ef commit 25b03fe
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 22 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl706-night-light-light \
--target bouffalolab-bl706-eth-light \
--target bouffalolab-bl706-wifi-light \
--target bouffalolab-bl706dk-light-ethernet \
--target bouffalolab-bl706dk-light-wifi-fp \
--target bouffalolab-xt-zb6-devkit-light-115200-rpc \
build \
--copy-artifacts-to out/artifacts \
Expand All @@ -92,11 +92,11 @@ jobs:
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl706-eth lighting-app \
out/artifacts/bouffalolab-bl706-eth-light/chip-bl702-lighting-example.out \
out/artifacts/bouffalolab-bl706dk-light-ethernet/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl706-wifi lighting-app \
out/artifacts/bouffalolab-bl706-wifi-light/chip-bl702-lighting-example.out \
out/artifacts/bouffalolab-bl706dk-light-wifi-fp/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl702+rpc lighting-app \
Expand All @@ -110,15 +110,15 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl704l-dvk-light \
--target bouffalolab-bl704ldk-light \
build \
--copy-artifacts-to out/artifacts \
"
- name: Prepare some bloat report from the previous builds
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702l bl702l lighting-app \
out/artifacts/bouffalolab-bl704l-dvk-light/chip-bl702l-lighting-example.out \
out/artifacts/bouffalolab-bl704ldk-light/chip-bl702l-lighting-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out
Expand Down
4 changes: 4 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ bouffalolab_executable("lighting_app") {
"SYS_AOS_LOOP_ENABLE",
]

if (enable_debug_frame_ptr) {
defines += [ "CONF_ENABLE_FRAME_PTR=1" ]
}

if (false == enable_reset_counter) {
defines += [ "BOOT_PIN_RESET=8" ]
}
Expand Down
4 changes: 4 additions & 0 deletions examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ bouffalolab_executable("lighting_app") {
"START_ENTRY=bl702_main",
]

if (enable_debug_frame_ptr) {
defines += [ "CONF_ENABLE_FRAME_PTR=1" ]
}

if (chip_config_network_layer_ble) {
defines += [
"CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=1"
Expand Down
4 changes: 4 additions & 0 deletions examples/lighting-app/bouffalolab/bl702l/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ bouffalolab_executable("lighting_app") {
"START_ENTRY=bl702_main",
]

if (enable_debug_frame_ptr) {
defines += [ "CONF_ENABLE_FRAME_PTR=1" ]
}

if (chip_config_network_layer_ble) {
defines += [
"CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=1"
Expand Down
16 changes: 12 additions & 4 deletions examples/platform/bouffalolab/common/iot_sdk/platform_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ void vAssertCalled(void)
{
void * ra = (void *) __builtin_return_address(0);

#if CONF_ENABLE_FRAME_PTR == 0
taskDISABLE_INTERRUPTS();
#endif

if (xPortIsInsideInterrupt())
{
printf("vAssertCalled, ra = %p in ISR\r\n", (void *) ra);
Expand All @@ -172,8 +175,11 @@ void vAssertCalled(void)
printf("vAssertCalled, ra = %p in task %s\r\n", (void *) ra, pcTaskGetName(NULL));
}

while (true)
;
#if CONF_ENABLE_FRAME_PTR
portABORT();
#endif

while (true);
}
#endif

Expand All @@ -183,6 +189,7 @@ void __attribute__((weak)) user_vAssertCalled(void)
void * ra = (void *) __builtin_return_address(0);

taskDISABLE_INTERRUPTS();

if (xPortIsInsideInterrupt())
{
printf("vAssertCalled, ra = %p in ISR\r\n", (void *) ra);
Expand All @@ -192,8 +199,7 @@ void __attribute__((weak)) user_vAssertCalled(void)
printf("vAssertCalled, ra = %p in task %s\r\n", (void *) ra, pcTaskGetName(NULL));
}

while (true)
;
while (true);
}

void __attribute__((weak)) user_vApplicationStackOverflowHook(TaskHandle_t xTask, char * pcTaskName)
Expand Down Expand Up @@ -221,8 +227,10 @@ void __attribute__((weak)) user_vApplicationMallocFailedHook(void)
}
}

void bflb_assert(void) __attribute__ ((weak, alias ("user_vAssertCalled")));
#else
void user_vAssertCalled(void) __attribute__((weak, alias("vAssertCalled")));
void bflb_assert(void) __attribute__ ((weak, alias ("vAssertCalled")));
#endif

// ================================================================================
Expand Down
2 changes: 1 addition & 1 deletion integrations/cloudbuild/build-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ steps:
--target android-arm64-tv-server
--target android-x64-chip-tool
--target bouffalolab-bl602-iot-matter-v1-light
--target bouffalolab-bl704l-dvk-light
--target bouffalolab-bl704ldk-light
--target bouffalolab-xt-zb6-devkit-light-rpc
--target cc13x2x7_26x2x7-lighting
--target cc13x2x7_26x2x7-lock-mtd
Expand Down
6 changes: 5 additions & 1 deletion scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

from .gn import GnBuilder


def raise_exception(info):
logging.fatal('*' * 80)
logging.fatal('\t%s', info)
logging.fatal('*' * 80)

raise Exception(info)


class BouffalolabApp(Enum):
LIGHT = auto()

Expand Down Expand Up @@ -164,7 +166,7 @@ def __init__(self,
self.argsOpt.append('chip_enable_wifi=true')
else:
self.argsOpt.append('chip_enable_wifi=false')

if enable_thread:
self.argsOpt.append('chip_enable_openthread=true')
else:
Expand Down Expand Up @@ -214,6 +216,8 @@ def __init__(self,

if enable_frame_ptr:
self.argsOpt.append("enable_debug_frame_ptr=true")
else:
self.argsOpt.append("enable_debug_frame_ptr=false")

try:
self.argsOpt.append('bouffalolab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT'])
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ameba-amebad-{all-clusters,all-clusters-minimal,light,light-switch,pigweed}
asr-{asr582x,asr595x,asr550x}-{all-clusters,all-clusters-minimal,lighting,light-switch,lock,bridge,temperature-measurement,thermostat,ota-requestor,dishwasher}[-ota][-shell][-no_logging][-factory][-rotating_id][-rio]
android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x86,androidstudio-x64}-{chip-tool,chip-test,tv-server,tv-casting-app,java-matter-controller,virtual-device-app}[-no-debug]
bouffalolab-{bl602-iot-matter-v1,bl602-night-light,xt-zb6-devkit,bl706-night-light,bl706-eth,bl706-wifi,bl704l-dvk}-light[-shell][-115200][-rpc][-cdc][-resetcnt][-rotating_device_id][-mfd][-mfdtest]
bouffalolab-{bl602-iot-matter-v1,bl602-night-light,xt-zb6-devkit,bl706-night-light,bl706dk,bl704ldk}-light[-shell][-115200][-rpc][-cdc][-resetcnt][-rotating_device_id][-mfd][-mfdtest][-ethernet][-wifi][-thread][-fp]
cc32xx-lock
ti-cc13x2x7_26x2x7-{lighting,lock,pump,pump-controller}[-mtd]
ti-cc13x4_26x4-{all-clusters,lighting,lock,pump,pump-controller}[-mtd][-ftd]
Expand Down
3 changes: 3 additions & 0 deletions src/platform/bouffalolab/common/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#include <stdint.h>

extern "C" void bflb_assert(void);
#define CHIP_CONFIG_ABORT() bflb_assert()

// ==================== General Platform Adaptations ====================
#define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE const char *
#define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID 1
Expand Down
8 changes: 4 additions & 4 deletions third_party/bouffalolab/bl602/bl_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import("${chip_root}/src/lib/lib.gni")
declare_args() {
bl_iot_sdk_root = "${chip_root}/third_party/bouffalolab/repo"

enable_debug_frame_ptr = true
enable_debug_frame_ptr = false
debug_output_file = ""
}

Expand Down Expand Up @@ -62,8 +62,8 @@ template("bl_iot_sdk") {
rebase_path("${invoker.freertos_config}", root_build_dir),
]

if (defined(invoker.enable_frame_ptr) && invoker.enable_frame_ptr) {
cflags += [ "-fno-omit-frame-pointer" ]
if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
cflags = [ "-fno-omit-frame-pointer" ]
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ template("bl_iot_sdk") {
source_set("${sdk_target_name}_bl602_freertos") {
defines = [ "portasmHANDLE_INTERRUPT=interrupt_entry" ]

if (defined(invoker.enable_frame_ptr) && invoker.enable_frame_ptr) {
if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
defines += [
"CONF_ENABLE_FRAME_PTR=1",
"CONF_ENABLE_FUNC_BACKTRACE_ELF=${invoker.debug_output_file}",
Expand Down
19 changes: 15 additions & 4 deletions third_party/bouffalolab/bl702/bl_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare_args() {
bl_iot_sdk_root = "${chip_root}/third_party/bouffalolab/repo"

enable_debug_frame_ptr = true
debug_output_file = ""
}

assert(bl_iot_sdk_root != "", "bl_iot_sdk_root must be specified")
Expand Down Expand Up @@ -61,8 +62,8 @@ template("bl_iot_sdk") {
rebase_path("${invoker.freertos_config}", root_build_dir),
]

if (defined(invoker.enable_frame_ptr) && invoker.enable_frame_ptr) {
cflags += [ "-fno-omit-frame-pointer" ]
if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
cflags = [ "-fno-omit-frame-pointer" ]
}
}

Expand Down Expand Up @@ -167,8 +168,11 @@ template("bl_iot_sdk") {

source_set("${sdk_target_name}_bl702_freertos") {
defines = [ "portasmHANDLE_INTERRUPT=interrupt_entry" ]
if (defined(invoker.enable_frame_ptr) && invoker.enable_frame_ptr) {
defines += [ "CONF_ENABLE_FRAME_PTR" ]
if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
defines += [
"CONF_ENABLE_FRAME_PTR=1",
"CONF_ENABLE_FUNC_BACKTRACE_ELF=${invoker.debug_output_file}",
]
}

include_dirs = [ "${bl_iot_sdk_root}/components/platform/soc/bl702/bl702_freertos/portable/GCC/RISC-V/chip_specific_extensions/RV32F_float_abi_single" ]
Expand All @@ -194,6 +198,13 @@ template("bl_iot_sdk") {
"-Wno-old-style-declaration",
]

if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
cflags_c += [
"-Wno-incompatible-pointer-types",
"-Wno-int-conversion",
]
}

public_configs = [
":${sdk_target_name}_config",
":${sdk_target_name}_config_freertos",
Expand Down
13 changes: 13 additions & 0 deletions third_party/bouffalolab/bl702l/bl_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import("${mbedtls_root}/mbedtls.gni")

declare_args() {
bl_iot_sdk_root = "${chip_root}/third_party/bouffalolab/repo"

enable_debug_frame_ptr = true
debug_output_file = ""
}

assert(bl_iot_sdk_root != "", "bl_iot_sdk_root must be specified")
Expand Down Expand Up @@ -60,6 +63,10 @@ template("bl_iot_sdk") {
"-include",
rebase_path("${invoker.freertos_config}", root_build_dir),
]

if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
cflags = [ "-fno-omit-frame-pointer" ]
}
}

config("${sdk_target_name}_config_soc") {
Expand Down Expand Up @@ -137,6 +144,12 @@ template("bl_iot_sdk") {
source_set("${sdk_target_name}_bl702l_rom_a0") {
defines = [ "portasmHANDLE_INTERRUPT=interrupt_entry" ]

if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) {
defines += [
"CONF_ENABLE_FRAME_PTR=1",
]
}

include_dirs = [ "${bl_iot_sdk_root}/components/platform/soc/bl702l/bl702l_std/BSP_Driver/regs" ]

libs = [ "${bl_iot_sdk_root}/components/platform/soc/bl702l/bl702l_rom_a0/bl702l_rom_ext/lib/libbl702l_rom_ext.a" ]
Expand Down
2 changes: 1 addition & 1 deletion third_party/bouffalolab/repo
Submodule repo updated from 90329c to c93da5

0 comments on commit 25b03fe

Please sign in to comment.