diff --git a/builder/frameworks/beken-72xx-sdk.py b/builder/frameworks/beken-72xx-sdk.py index d6593e7..087beee 100644 --- a/builder/frameworks/beken-72xx-sdk.py +++ b/builder/frameworks/beken-72xx-sdk.py @@ -94,6 +94,7 @@ env.Append( "-Wl,-wrap,snprintf", "-Wl,-wrap,sprintf", "-Wl,-wrap,vsnprintf", + "-Wl,-wrap,bk_printf", ], ) @@ -137,6 +138,7 @@ env.AddLibrary( "+", "+", "+", + "+", *srcs_fixups, ], ) diff --git a/platform/beken-72xx/fixups/arch_main.c b/platform/beken-72xx/fixups/arch_main.c index 7c43e00..d3f3a67 100644 --- a/platform/beken-72xx/fixups/arch_main.c +++ b/platform/beken-72xx/fixups/arch_main.c @@ -9,14 +9,15 @@ * **************************************************************************************** */ -#include "app.h" +#include "BkDriverFlash.h" +#include "BkDriverWdg.h" #include "driver_pub.h" #include "func_pub.h" #include "include.h" +#include "intc.h" +#include "param_config.h" #include "start_type_pub.h" -extern void user_main_entry(void); - #if CFG_SUPPORT_BOOTLOADER void entry_set_world_flag(void) { *(volatile uint32_t *)0x00400000 = 1; @@ -24,12 +25,15 @@ void entry_set_world_flag(void) { #endif // CFG_SUPPORT_BOOTLOADER extern void main(void); +extern unsigned char __disable_bk_printf; void entry_main(void) { // compatibility with BK7231S_1.0.5 #if CFG_SUPPORT_BOOTLOADER entry_set_world_flag(); #endif + // suppress all output during initialization + __disable_bk_printf = 1; // read reboot cause into bk_misc_get_start_type() bk_misc_init_start_type(); // clear driver registration arrays @@ -37,10 +41,16 @@ void entry_main(void) { // reboot the board if start_type == RESET_SOURCE_CRASH_PER_XAT0 bk_misc_check_start_type(); // init drivers - func_init_basic(); - func_init_extended(); - // run core initialization tasks - app_pre_start(); + intc_init(); + hal_flash_init(); + cfg_param_init(); + // enable watchdog +#if CFG_INT_WDG_ENABLED + bk_wdg_initialize(CFG_INT_WDG_PERIOD_MS); + bk_wdg_reload(); +#endif + // enable bk_printf output again + __disable_bk_printf = 0; // run the app main(); } diff --git a/platform/beken-72xx/fixups/inc/param_config.h b/platform/beken-72xx/fixups/inc/param_config.h new file mode 100644 index 0000000..759eda6 --- /dev/null +++ b/platform/beken-72xx/fixups/inc/param_config.h @@ -0,0 +1,8 @@ +/* Copyright (c) Kuba SzczodrzyƄski 2022-06-14. */ + +#pragma once + +#include_next "param_config.h" + +#undef WIFI_MAC_POS +#define WIFI_MAC_POS -1 // do not use stored MAC address by default diff --git a/platform/beken-72xx/fixups/wrap.c b/platform/beken-72xx/fixups/wrap.c new file mode 100644 index 0000000..3cbbf7e --- /dev/null +++ b/platform/beken-72xx/fixups/wrap.c @@ -0,0 +1,22 @@ +/* Copyright (c) Kuba SzczodrzyƄski 2022-06-14. */ + +#include +#include + +extern int __wrap_vsnprintf(char *str, size_t size, const char *format, va_list args); +extern void bk_send_string(unsigned char uport, const char *string); +extern int uart_print_port; + +unsigned char __disable_bk_printf = 0; + +void __wrap_bk_printf(const char *fmt, ...) { + if (__disable_bk_printf) + return; + va_list ap; + char string[128]; + va_start(ap, fmt); + __wrap_vsnprintf(string, sizeof(string) - 1, fmt, ap); + string[127] = 0; + bk_send_string(uart_print_port, string); + va_end(ap); +}