From 85d275b399b052e529134d2ca632b0a5602c30f3 Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Fri, 30 Nov 2018 16:12:35 +0800 Subject: [PATCH 01/17] =?UTF-8?q?[components/utilities][add]=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=A1=86=E6=9E=B6=20utest=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/utest/SConscript | 8 + components/utilities/utest/utest.c | 236 ++++++++++++++++++++++ components/utilities/utest/utest.h | 69 +++++++ components/utilities/utest/utest_assert.h | 36 ++++ components/utilities/utest/utest_log.h | 31 +++ 5 files changed, 380 insertions(+) create mode 100644 components/utilities/utest/SConscript create mode 100644 components/utilities/utest/utest.c create mode 100644 components/utilities/utest/utest.h create mode 100644 components/utilities/utest/utest_assert.h create mode 100644 components/utilities/utest/utest_log.h diff --git a/components/utilities/utest/SConscript b/components/utilities/utest/SConscript new file mode 100644 index 0000000000..91ff8a553e --- /dev/null +++ b/components/utilities/utest/SConscript @@ -0,0 +1,8 @@ +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] +group = DefineGroup('utest', src, depend = [], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c new file mode 100644 index 0000000000..f8881de2d0 --- /dev/null +++ b/components/utilities/utest/utest.c @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-19 MurphyZhao the first version + */ + +#include "utest.h" +#include +#include + +#undef DBG_SECTION_NAME +#undef DBG_LEVEL +#undef DBG_COLOR +#undef DBG_ENABLE + +#define DBG_ENABLE +#define DBG_SECTION_NAME "utest" +#ifdef UTEST_DEBUG +#define DBG_LEVEL DBG_LOG +#else +#define DBG_LEVEL DBG_INFO +#endif +#define DBG_COLOR +#include + +#if RT_CONSOLEBUF_SIZE < 256 +#error "RT_CONSOLEBUF_SIZE is less than 256!" +#endif + +static utest_tc_export_t tc_table = RT_NULL; +static rt_size_t tc_num; +static struct utest local_utest = {UTEST_PASSED, 0, 0}; + +#if defined(__ICCARM__) || defined(__ICCRX__) /* for IAR compiler */ +#pragma section="UtestTcTab" +#endif + +int utest_init(void) +{ + /* initialize the utest commands table.*/ +#if defined(__CC_ARM) /* ARM C Compiler */ + extern const int UtestTcTab$$Base; + extern const int UtestTcTab$$Limit; + tc_table = (utest_tc_export_t)&UtestTcTab$$Base; + tc_num = (utest_tc_export_t)&UtestTcTab$$Limit - tc_table; +#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */ + tc_table = (utest_tc_export_t)__section_begin("UtestTcTab"); + tc_num = (utest_tc_export_t)__section_end("UtestTcTab") - tc_table; +#elif defined (__GNUC__) /* for GCC Compiler */ + extern const int __rtatcmdtab_start; + extern const int __rtatcmdtab_end; + tc_table = (utest_tc_export_t)&__rtatcmdtab_start; + tc_num = (utest_tc_export_t) &__rtatcmdtab_end - tc_table; +#endif /* defined(__CC_ARM) */ + + LOG_D("[ ] total utest testcase num: (%d)", tc_num); + return tc_num; +} +INIT_COMPONENT_EXPORT(utest_init); + +static void utest_tc_list(void) +{ + rt_size_t i = 0; + + LOG_D("Commands list : "); + + for (i = 0; i < tc_num; i++) + { + LOG_D("%s", tc_table[i].name); + } +} +MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_tc_list, output all utest testcase); + +static char *file_basename(const char *file) +{ + char *ptr = RT_NULL; + char *rst = RT_NULL; + char *file_bak = rt_strdup(file); + uint8_t len = 0; + if ((ptr = strrchr(file_bak, '\\')) != RT_NULL || (ptr = strrchr(file_bak, '/')) != RT_NULL) + { + rst = ptr; + } + else + { + rst = file_bak; + } + + len = rst - file_bak; + if (rst != file) + { + file_bak[len] = '\0'; + + if ((ptr = strrchr(file_bak, '\\')) != RT_NULL || (ptr = strrchr(file_bak, '/')) != RT_NULL) + { + rst = ptr; + } + else + { + rst = file_bak; + } + len = rst - file_bak; + } + + rt_free(file_bak); + len = len != 0? len + 1 : len; + return (char *)(file + len); +} + +static void utest_run(const char *utest_name) +{ + rt_size_t i = 0; + + LOG_D("[ ] total utest testcase num: (%d)", tc_num); + + LOG_I("[==========] [ utest ] started"); + while(i < tc_num) + { + if (utest_name && rt_strcmp(utest_name, tc_table[i].name)) + { + i++; + continue; + } + + if (tc_table[i].init != RT_NULL) + { + tc_table[i].init(); + } + + LOG_I("[----------] [ testcase ] (%s) started", tc_table[i].name); + tc_table[i].tc(); + if (local_utest.failed_num == 0) + { + LOG_I("[ PASSED ] [ result ] testcase (%s)", tc_table[i].name); + } + else + { + LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name); + } + LOG_I("[----------] [ testcase ] (%s) finished", tc_table[i].name); + + if (tc_table[i].cleanup != RT_NULL) + { + tc_table[i].cleanup(); + } + + i++; + } + LOG_I("[==========] [ utest ] finished"); +} + +static void utest_testcase_run(int argc, char** argv) +{ + char utest_name[UTEST_NAME_MAX_LEN]; + + if (argc == 1) + { + utest_run(RT_NULL); + } + else if (argc == 2) + { + rt_memset(utest_name, 0x0, sizeof(utest_name)); + rt_strncpy(utest_name, argv[1], sizeof(utest_name) -1); + utest_run(utest_name); + } + else + { + LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__); + } +} +MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [testcase name]); + +utest_t utest_handle_get(void) +{ + return (utest_t)&local_utest; +} + +void utest_unit_run(test_unit_func func, const char *unit_func_name) +{ + // LOG_I("[==========] utest unit name: (%s)", unit_func_name); + local_utest.error = UTEST_PASSED; + local_utest.passed_num = 0; + local_utest.failed_num = 0; + func(); +} + +void utest_assert(int value, const char *file, int line, const char *func, const char *msg) +{ + if (!(value)) + { + local_utest.error = UTEST_FAILED; + local_utest.failed_num ++; + LOG_E("[ ASSERT ] [ unit ] at (%s); func: (%s:%d); msg: (%s)", file_basename(file), func, line, msg); + } + else + { + LOG_D("[ OK ] [ unit ] (%s:%d) is passed", func, line); + local_utest.error = UTEST_PASSED; + local_utest.passed_num ++; + } +} + +void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const char *file, int line, const char *func, const char *msg) +{ + if (a == RT_NULL || b == RT_NULL) + { + utest_assert(0, file, line, func, msg); + } + + if (equal) + { + if (rt_strcmp(a, b) == 0) + { + utest_assert(1, file, line, func, msg); + } + else + { + utest_assert(0, file, line, func, msg); + } + } + else + { + if (rt_strcmp(a, b) == 0) + { + utest_assert(0, file, line, func, msg); + } + else + { + utest_assert(1, file, line, func, msg); + } + } +} diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h new file mode 100644 index 0000000000..3db5895462 --- /dev/null +++ b/components/utilities/utest/utest.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-19 MurphyZhao the first version + */ + +#ifndef __UTEST_H__ +#define __UTEST_H__ + +#include +#include "utest_log.h" + +#define UTEST_SW_VERSION "0.0.1" + +enum utest_error +{ + UTEST_PASSED = 0, + UTEST_FAILED = 1, + UTEST_SKIPPED = 2 +}; +typedef enum utest_error utest_err_e; + +struct utest +{ + utest_err_e error; + uint32_t passed_num; + uint32_t failed_num; +}; +typedef struct utest *utest_t; + +struct utest_tc_export { + const char *name; + rt_err_t (*init)(void); + void (*tc)(void); + rt_err_t (*cleanup)(void); +}; +typedef struct utest_tc_export *utest_tc_export_t; + +typedef void (*test_unit_func)(void); + +#define TC_LOG_I(...) LOG_I(__VA_ARGS__) +#define TC_LOG_D(...) LOG_D(__VA_ARGS__) +#define TC_LOG_E(...) LOG_E(__VA_ARGS__) +#define TC_LOG_W(...) LOG_W(__VA_ARGS__) + +void utest_unit_run(test_unit_func func, const char *unit_func_name); +utest_t utest_handle_get(void); + +#define UTEST_NAME_MAX_LEN (128u) + +#define UTEST_TC_EXPORT(testcase, name, init, cleanup) \ + RT_USED static const struct utest_tc_export _utest_testcase \ + SECTION("UtestTcTab") = \ + { \ + name, \ + init, \ + testcase, \ + cleanup \ + } + +#define UTEST_UNIT_RUN(test_unit_func) \ + utest_unit_run(test_unit_func, #test_unit_func); \ + if(utest_handle_get()->failed_num != 0) return; + +#endif diff --git a/components/utilities/utest/utest_assert.h b/components/utilities/utest/utest_assert.h new file mode 100644 index 0000000000..57346b701f --- /dev/null +++ b/components/utilities/utest/utest_assert.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-19 MurphyZhao the first version + */ + +#ifndef __UTEST_ASSERT_H__ +#define __UTEST_ASSERT_H__ + +#include "utest.h" +#include + +void utest_assert(int value, const char *file, int line, const char *func, const char *msg); +void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const char *file, int line, const char *func, const char *msg); + +#define __utest_assert(value, msg) utest_assert(value, __FILE__, __LINE__, __func__, msg) + +#define uassert_true(value) __utest_assert(value, "(" #value ") is false") +#define uassert_false(value) __utest_assert(!(value), "(" #value ") is true") +#define uassert_null(value) __utest_assert((value) == NULL, "(" #value ") is not null") +#define uassert_not_null(value) __utest_assert((value) != NULL, "(" #value ") is null") + +#define uassert_int_equal(a, b) __utest_assert((a) == (b), "(" #a ") not equal to (" #b ")") +#define uassert_int_not_equal(a, b) __utest_assert((a) != (b), "(" #a ") equal to (" #b ")") + +#define uassert_str_equal(a, b) utest_assert_string((const char*)(a), (const char*)(b), RT_TRUE, __FILE__, __LINE__, __func__, "string not equal") +#define uassert_str_not_equal(a, b) utest_assert_string((const char*)(a), (const char*)(b), RT_FALSE, __FILE__, __LINE__, __func__, "string equal") + +#define uassert_in_range(value, min, max) __utest_assert(((value >= min) && (value <= max)), "(" #value ") not in range("#min","#max")") +#define uassert_not_in_range(value, min, max) __utest_assert(!((value >= min) && (value <= max)), "(" #value ") in range("#min","#max")") + +#endif /* __UTEST_ASSERT_H__ */ diff --git a/components/utilities/utest/utest_log.h b/components/utilities/utest/utest_log.h new file mode 100644 index 0000000000..c954046b76 --- /dev/null +++ b/components/utilities/utest/utest_log.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-19 MurphyZhao the first version + */ + +#ifndef __UTEST_LOG_H__ +#define __UTEST_LOG_H__ + +#define UTEST_DEBUG + +#undef DBG_SECTION_NAME +#undef DBG_LEVEL +#undef DBG_COLOR +#undef DBG_ENABLE + +#define DBG_ENABLE +#define DBG_SECTION_NAME "testcase" +#ifdef UTEST_DEBUG +#define DBG_LEVEL DBG_LOG +#else +#define DBG_LEVEL DBG_INFO +#endif +#define DBG_COLOR +#include + +#endif /* __UTEST_LOG_H__ */ From 1ecf6cbc7c7dfd32bb77d551ccd391be6705900a Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Wed, 5 Dec 2018 14:53:13 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91utest?= =?UTF-8?q?=20gcc=20=E9=93=BE=E6=8E=A5=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/utest/utest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index f8881de2d0..4226738ce7 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -51,10 +51,10 @@ int utest_init(void) tc_table = (utest_tc_export_t)__section_begin("UtestTcTab"); tc_num = (utest_tc_export_t)__section_end("UtestTcTab") - tc_table; #elif defined (__GNUC__) /* for GCC Compiler */ - extern const int __rtatcmdtab_start; - extern const int __rtatcmdtab_end; - tc_table = (utest_tc_export_t)&__rtatcmdtab_start; - tc_num = (utest_tc_export_t) &__rtatcmdtab_end - tc_table; + extern const int __rt_utest_tc_tab_start; + extern const int __rt_utest_tc_tab_end; + tc_table = (utest_tc_export_t)&__rt_utest_tc_tab_start; + tc_num = (utest_tc_export_t) &__rt_utest_tc_tab_end - tc_table; #endif /* defined(__CC_ARM) */ LOG_D("[ ] total utest testcase num: (%d)", tc_num); From 0759b66eb971f0baad1148586ba0db8ab98a1c82 Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Wed, 5 Dec 2018 18:06:33 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91compo?= =?UTF-8?q?nents/utilities/utest=20=E5=A2=9E=E5=8A=A0=20SConscript=20depen?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/utest/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/utilities/utest/SConscript b/components/utilities/utest/SConscript index 91ff8a553e..dc77bc2591 100644 --- a/components/utilities/utest/SConscript +++ b/components/utilities/utest/SConscript @@ -3,6 +3,6 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -group = DefineGroup('utest', src, depend = [], CPPPATH = CPPPATH) +group = DefineGroup('utest', src, depend = ['RT_USING_UTEST'], CPPPATH = CPPPATH) Return('group') From 8824b2ca7780c3874de7703a6c4e17b97fe63595 Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Thu, 6 Dec 2018 17:11:27 +0800 Subject: [PATCH 04/17] =?UTF-8?q?[components/utilities]=20[Kconfig]=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20kconfig=20RT=5FUSING=5FUTEST=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20[components/utilities]=20[utest]=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20testcase=20=E8=BF=90=E8=A1=8C=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/Kconfig | 4 ++++ components/utilities/utest/utest.c | 9 ++++----- components/utilities/utest/utest.h | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig index e830d94578..8e43cfa0a0 100644 --- a/components/utilities/Kconfig +++ b/components/utilities/Kconfig @@ -230,4 +230,8 @@ config RT_USING_ULOG sfotware module version number endif +config RT_USING_UTEST + bool "Enable utest (RT-Thread test framework)" + default n + endmenu diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 4226738ce7..18d2c88d0a 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -57,7 +57,8 @@ int utest_init(void) tc_num = (utest_tc_export_t) &__rt_utest_tc_tab_end - tc_table; #endif /* defined(__CC_ARM) */ - LOG_D("[ ] total utest testcase num: (%d)", tc_num); + LOG_I("utest is initialize success."); + LOG_I("total utest testcase num: (%d)", tc_num); return tc_num; } INIT_COMPONENT_EXPORT(utest_init); @@ -66,11 +67,11 @@ static void utest_tc_list(void) { rt_size_t i = 0; - LOG_D("Commands list : "); + LOG_I("Commands list : "); for (i = 0; i < tc_num; i++) { - LOG_D("%s", tc_table[i].name); + LOG_I("[testcase name]:%s; [run timeout]:%d", tc_table[i].name, tc_table[i].run_timeout); } } MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_tc_list, output all utest testcase); @@ -115,8 +116,6 @@ static void utest_run(const char *utest_name) { rt_size_t i = 0; - LOG_D("[ ] total utest testcase num: (%d)", tc_num); - LOG_I("[==========] [ utest ] started"); while(i < tc_num) { diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h index 3db5895462..9532b115e6 100644 --- a/components/utilities/utest/utest.h +++ b/components/utilities/utest/utest.h @@ -34,6 +34,7 @@ typedef struct utest *utest_t; struct utest_tc_export { const char *name; + uint32_t run_timeout; rt_err_t (*init)(void); void (*tc)(void); rt_err_t (*cleanup)(void); @@ -52,18 +53,19 @@ utest_t utest_handle_get(void); #define UTEST_NAME_MAX_LEN (128u) -#define UTEST_TC_EXPORT(testcase, name, init, cleanup) \ +#define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \ RT_USED static const struct utest_tc_export _utest_testcase \ - SECTION("UtestTcTab") = \ + SECTION("UtestTcTab") = \ { \ - name, \ - init, \ - testcase, \ - cleanup \ + name, \ + timeout, \ + init, \ + testcase, \ + cleanup \ } -#define UTEST_UNIT_RUN(test_unit_func) \ - utest_unit_run(test_unit_func, #test_unit_func); \ +#define UTEST_UNIT_RUN(test_unit_func) \ + utest_unit_run(test_unit_func, #test_unit_func); \ if(utest_handle_get()->failed_num != 0) return; #endif From 51b17a15e4393495d72ec350fbfc392dc129753e Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Thu, 6 Dec 2018 18:58:23 +0800 Subject: [PATCH 05/17] =?UTF-8?q?[components/utilities/utest]=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/utest/utest.c | 37 ++++++-- components/utilities/utest/utest.h | 108 +++++++++++++++++++++- components/utilities/utest/utest_assert.h | 22 +++++ 3 files changed, 158 insertions(+), 9 deletions(-) diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 18d2c88d0a..5ba36ff397 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -125,28 +125,45 @@ static void utest_run(const char *utest_name) continue; } + LOG_I("[----------] [ testcase ] (%s) started", tc_table[i].name); if (tc_table[i].init != RT_NULL) { - tc_table[i].init(); + if (tc_table[i].init() != RT_EOK) + { + LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name); + goto __tc_continue; + } } - LOG_I("[----------] [ testcase ] (%s) started", tc_table[i].name); - tc_table[i].tc(); - if (local_utest.failed_num == 0) + if (tc_table[i].tc != RT_NULL) { - LOG_I("[ PASSED ] [ result ] testcase (%s)", tc_table[i].name); + tc_table[i].tc(); + if (local_utest.failed_num == 0) + { + LOG_I("[ PASSED ] [ result ] testcase (%s)", tc_table[i].name); + } + else + { + LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name); + } } else { LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name); } - LOG_I("[----------] [ testcase ] (%s) finished", tc_table[i].name); if (tc_table[i].cleanup != RT_NULL) { - tc_table[i].cleanup(); + if (tc_table[i].cleanup() != RT_EOK) + { + LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name); + goto __tc_continue; + } } +__tc_continue: + LOG_I("[----------] [ testcase ] (%s) finished", tc_table[i].name); + i++; } LOG_I("[==========] [ utest ] finished"); @@ -184,7 +201,11 @@ void utest_unit_run(test_unit_func func, const char *unit_func_name) local_utest.error = UTEST_PASSED; local_utest.passed_num = 0; local_utest.failed_num = 0; - func(); + + if (func != RT_NULL) + { + func(); + } } void utest_assert(int value, const char *file, int line, const char *func, const char *msg) diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h index 9532b115e6..9a5e58fc57 100644 --- a/components/utilities/utest/utest.h +++ b/components/utilities/utest/utest.h @@ -16,6 +16,16 @@ #define UTEST_SW_VERSION "0.0.1" +/** + * utest_error + * + * @brief Test result. + * + * @member UTEST_PASSED Test success. + * @member UTEST_FAILED Test failed. + * @member UTEST_PASSED Test skipped. + * +*/ enum utest_error { UTEST_PASSED = 0, @@ -24,6 +34,16 @@ enum utest_error }; typedef enum utest_error utest_err_e; +/** + * utest + * + * @brief utest data structure. + * + * @member error Error number from enum `utest_error`. + * @member passed_num Total number of tests passed. + * @member failed_num Total number of tests failed. + * +*/ struct utest { utest_err_e error; @@ -32,6 +52,19 @@ struct utest }; typedef struct utest *utest_t; +/** + * utest_tc_export + * + * @brief utest testcase data structure. + * Will export the data to `UtestTcTab` section in flash. + * + * @member name Testcase name. + * @member run_timeout Testcase maximum test time. + * @member init Necessary initialization before executing the test case function. + * @member tc Total number of tests failed. + * @member cleanup Total number of tests failed. + * +*/ struct utest_tc_export { const char *name; uint32_t run_timeout; @@ -41,18 +74,80 @@ struct utest_tc_export { }; typedef struct utest_tc_export *utest_tc_export_t; +/** + * test_unit_func + * + * @brief Unit test handler function pointer. + * +*/ typedef void (*test_unit_func)(void); +/** + * TC_LOG_x + * + * @brief Log output interface used in test cases. + * + * @type TC_LOG_I Output info level log. + * @type TC_LOG_D Output debug level log. + * @type TC_LOG_E Output error level log. + * @type TC_LOG_W Output warning level log. + * +*/ #define TC_LOG_I(...) LOG_I(__VA_ARGS__) #define TC_LOG_D(...) LOG_D(__VA_ARGS__) #define TC_LOG_E(...) LOG_E(__VA_ARGS__) #define TC_LOG_W(...) LOG_W(__VA_ARGS__) +/** + * utest_unit_run + * + * @brief Unit test function executor. + * No need for the user to call this function directly + * + * @param func Unit test function. + * @param unit_func_name Unit test function name. + * + * @return void + * +*/ void utest_unit_run(test_unit_func func, const char *unit_func_name); + +/** + * utest_handle_get + * + * @brief Get the utest data structure handle. + * No need for the user to call this function directly + * + * @param void + * + * @return utest_t type. (struct utest *) + * +*/ utest_t utest_handle_get(void); +/** + * UTEST_NAME_MAX_LEN + * + * @brief Testcase name maximum length. + * +*/ #define UTEST_NAME_MAX_LEN (128u) +/** + * UTEST_TC_EXPORT + * + * @brief Export testcase function to `UtestTcTab` section in flash. + * Used in application layer. + * + * @param testcase The testcase function. + * @param name The testcase name. + * @param init The initialization function of the test case. + * @param cleanup The cleanup function of the test case. + * @param timeout Testcase maximum test time. + * + * @return None + * +*/ #define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \ RT_USED static const struct utest_tc_export _utest_testcase \ SECTION("UtestTcTab") = \ @@ -64,8 +159,19 @@ utest_t utest_handle_get(void); cleanup \ } +/** + * UTEST_UNIT_RUN + * + * @brief Unit test function executor. + * Used in `testcase` function in application. + * + * @param test_unit_func Unit test function + * + * @return None + * +*/ #define UTEST_UNIT_RUN(test_unit_func) \ utest_unit_run(test_unit_func, #test_unit_func); \ if(utest_handle_get()->failed_num != 0) return; -#endif +#endif /* __UTEST_H__ */ diff --git a/components/utilities/utest/utest_assert.h b/components/utilities/utest/utest_assert.h index 57346b701f..e36fdc8af4 100644 --- a/components/utilities/utest/utest_assert.h +++ b/components/utilities/utest/utest_assert.h @@ -14,11 +14,33 @@ #include "utest.h" #include +/* No need for the user to use this function directly */ void utest_assert(int value, const char *file, int line, const char *func, const char *msg); + +/* No need for the user to use this function directly */ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const char *file, int line, const char *func, const char *msg); +/* No need for the user to use this macro directly */ #define __utest_assert(value, msg) utest_assert(value, __FILE__, __LINE__, __func__, msg) +/** + * uassert_x macros + * + * @brief Get the utest data structure handle. + * No need for the user to call this function directly. + * + * @macro uassert_true if @value is true, not assert, means passing. + * @macro uassert_false if @value is false, not assert, means passing. + * @macro uassert_null if @value is null, not assert, means passing. + * @macro uassert_not_null if @value is not null, not assert, means passing. + * @macro uassert_int_equal if @a equal to @b, not assert, means passing. Integer type test. + * @macro uassert_int_not_equal if @a not equal to @b, not assert, means passing. Integer type test. + * @macro uassert_str_equal if @a equal to @b, not assert, means passing. String type test. + * @macro uassert_str_not_equal if @a not equal to @b, not assert, means passing. String type test. + * @macro uassert_in_range if @value is in range of min and max, not assert, means passing. + * @macro uassert_not_in_range if @value is not in range of min and max, not assert, means passing. + * +*/ #define uassert_true(value) __utest_assert(value, "(" #value ") is false") #define uassert_false(value) __utest_assert(!(value), "(" #value ") is true") #define uassert_null(value) __utest_assert((value) == NULL, "(" #value ") is not null") From 7ac5bd992fe4a07342ca720baff27c53aa30cdff Mon Sep 17 00:00:00 2001 From: HubretXie Date: Fri, 7 Dec 2018 19:05:24 +0800 Subject: [PATCH 06/17] Update at_socket.c --- components/net/at/at_socket/at_socket.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 84325c1501..80b86f8198 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -715,7 +715,19 @@ __exit: } else { - at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); + /* try to read Legacy data */ + /* receive packet list last transmission of remaining data */ + rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER); + recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len); + rt_mutex_release(sock->recv_lock); + if(recv_len<=0) + { + at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); + } + else + { + result = recv_len; + } } return result; From 98b10877e7e885da961b571bdb8cc3460021ba4d Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Sat, 8 Dec 2018 14:46:38 +0800 Subject: [PATCH 07/17] =?UTF-8?q?[components/utilities/utest]=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20gcc=20=E7=BC=96=E8=AF=91=E8=AD=A6=E5=91=8A=20[compo?= =?UTF-8?q?nents/utilities/utest]=20=E7=A7=BB=E9=99=A4=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E7=89=88=E6=9C=AC=E5=8F=B7=20[components/utilities/ut?= =?UTF-8?q?est]=20=E4=BC=98=E5=8C=96=20basename=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/utest/utest.c | 38 ++++++----------------- components/utilities/utest/utest.h | 2 -- components/utilities/utest/utest_assert.h | 4 +-- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 5ba36ff397..0f5a206d3c 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -74,42 +74,24 @@ static void utest_tc_list(void) LOG_I("[testcase name]:%s; [run timeout]:%d", tc_table[i].name, tc_table[i].run_timeout); } } -MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_tc_list, output all utest testcase); +MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_list, output all utest testcase); -static char *file_basename(const char *file) +static const char *file_basename(const char *file) { - char *ptr = RT_NULL; + char *end_ptr = RT_NULL; char *rst = RT_NULL; - char *file_bak = rt_strdup(file); - uint8_t len = 0; - if ((ptr = strrchr(file_bak, '\\')) != RT_NULL || (ptr = strrchr(file_bak, '/')) != RT_NULL) + + if (!((end_ptr = strrchr(file, '\\')) != RT_NULL || \ + (end_ptr = strrchr(file, '/')) != RT_NULL) || \ + (rt_strlen(file) < 2)) { - rst = ptr; + rst = (char *)file; } else { - rst = file_bak; + rst = (char *)(end_ptr + 1); } - - len = rst - file_bak; - if (rst != file) - { - file_bak[len] = '\0'; - - if ((ptr = strrchr(file_bak, '\\')) != RT_NULL || (ptr = strrchr(file_bak, '/')) != RT_NULL) - { - rst = ptr; - } - else - { - rst = file_bak; - } - len = rst - file_bak; - } - - rt_free(file_bak); - len = len != 0? len + 1 : len; - return (char *)(file + len); + return (const char *)rst; } static void utest_run(const char *utest_name) diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h index 9a5e58fc57..fc01852b6a 100644 --- a/components/utilities/utest/utest.h +++ b/components/utilities/utest/utest.h @@ -14,8 +14,6 @@ #include #include "utest_log.h" -#define UTEST_SW_VERSION "0.0.1" - /** * utest_error * diff --git a/components/utilities/utest/utest_assert.h b/components/utilities/utest/utest_assert.h index e36fdc8af4..997e8ae7f3 100644 --- a/components/utilities/utest/utest_assert.h +++ b/components/utilities/utest/utest_assert.h @@ -43,8 +43,8 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch */ #define uassert_true(value) __utest_assert(value, "(" #value ") is false") #define uassert_false(value) __utest_assert(!(value), "(" #value ") is true") -#define uassert_null(value) __utest_assert((value) == NULL, "(" #value ") is not null") -#define uassert_not_null(value) __utest_assert((value) != NULL, "(" #value ") is null") +#define uassert_null(value) __utest_assert((const char *)(value) == NULL, "(" #value ") is not null") +#define uassert_not_null(value) __utest_assert((const char *)(value) != NULL, "(" #value ") is null") #define uassert_int_equal(a, b) __utest_assert((a) == (b), "(" #a ") not equal to (" #b ")") #define uassert_int_not_equal(a, b) __utest_assert((a) != (b), "(" #a ") equal to (" #b ")") From bce7f85907a3ef233111ca6799228b1598017bdc Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Sat, 8 Dec 2018 15:00:06 +0800 Subject: [PATCH 08/17] =?UTF-8?q?[components/utilities/utest]=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E4=B8=8D=E9=82=A3=E4=B9=88=E5=BF=85=E8=A6=81=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=8E=A5=E5=8F=A3=20redefine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- components/utilities/utest/utest.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h index fc01852b6a..5a7e8af721 100644 --- a/components/utilities/utest/utest.h +++ b/components/utilities/utest/utest.h @@ -80,22 +80,6 @@ typedef struct utest_tc_export *utest_tc_export_t; */ typedef void (*test_unit_func)(void); -/** - * TC_LOG_x - * - * @brief Log output interface used in test cases. - * - * @type TC_LOG_I Output info level log. - * @type TC_LOG_D Output debug level log. - * @type TC_LOG_E Output error level log. - * @type TC_LOG_W Output warning level log. - * -*/ -#define TC_LOG_I(...) LOG_I(__VA_ARGS__) -#define TC_LOG_D(...) LOG_D(__VA_ARGS__) -#define TC_LOG_E(...) LOG_E(__VA_ARGS__) -#define TC_LOG_W(...) LOG_W(__VA_ARGS__) - /** * utest_unit_run * From b3e1507bcff974167a34ca78382ac85b5e66b890 Mon Sep 17 00:00:00 2001 From: shaojinchun Date: Wed, 12 Dec 2018 09:36:39 +0800 Subject: [PATCH 09/17] 1 RT_THREAD_CTRL_BIND_CPU define to 4 2 RTM_EXPORT(rt_cpus_lock_status_restore) 3 sync ARCH_CPU_STACK_GROWS_UPWARD in _rt_scheduler_stack_check() --- include/rtdef.h | 2 +- src/cpu.c | 2 +- src/scheduler.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/rtdef.h b/include/rtdef.h index 253ec36968..6d5263ef62 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -500,7 +500,7 @@ typedef siginfo_t rt_siginfo_t; #define RT_THREAD_CTRL_CLOSE 0x01 /**< Close thread. */ #define RT_THREAD_CTRL_CHANGE_PRIORITY 0x02 /**< Change thread priority. */ #define RT_THREAD_CTRL_INFO 0x03 /**< Get thread information. */ -#define RT_THREAD_CTRL_BIND_CPU 0x03 /**< Set thread bind cpu. */ +#define RT_THREAD_CTRL_BIND_CPU 0x04 /**< Set thread bind cpu. */ #ifdef RT_USING_SMP diff --git a/src/cpu.c b/src/cpu.c index ef6dce1787..3e2d65dfb9 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -86,6 +86,6 @@ void rt_cpus_lock_status_restore(struct rt_thread *thread) rt_hw_spin_unlock(&_cpus_lock); } } -RTM_EXPORT(rt_post_switch); +RTM_EXPORT(rt_cpus_lock_status_restore); #endif diff --git a/src/scheduler.c b/src/scheduler.c index e177bde6b7..aafa1f4529 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -99,11 +99,19 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) level = rt_hw_interrupt_disable(); while (level); } +#if defined(ARCH_CPU_STACK_GROWS_UPWARD) + else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size)) + { + rt_kprintf("warning: %s stack is close to the top of stack address.\n", + thread->name); + } +#else else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32)) { rt_kprintf("warning: %s stack is close to end of stack address.\n", thread->name); } +#endif } #endif From 3a8c6f32c09fdf744697eff85d80ad083a424881 Mon Sep 17 00:00:00 2001 From: HubretXie Date: Wed, 12 Dec 2018 11:29:14 +0800 Subject: [PATCH 10/17] Update at_socket.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改socket读取遗留数据逻辑 --- components/net/at/at_socket/at_socket.c | 32 ++++++++----------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 80b86f8198..3925f0f57c 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -627,6 +627,15 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f at_dev_ops->at_set_event_cb(AT_SOCKET_EVT_CLOSED, at_closed_notice_cb); } + /* receive packet list last transmission of remaining data */ + rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER); + if((recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len)) > 0) + { + rt_mutex_release(sock->recv_lock); + goto __exit; + } + rt_mutex_release(sock->recv_lock); + /* socket passively closed, receive function return 0 */ if (sock->state == AT_SOCKET_CLOSED) { @@ -640,15 +649,6 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f goto __exit; } - /* receive packet list last transmission of remaining data */ - rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER); - if((recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len)) > 0) - { - rt_mutex_release(sock->recv_lock); - goto __exit; - } - rt_mutex_release(sock->recv_lock); - /* non-blocking sockets receive data */ if (flags & MSG_DONTWAIT) { @@ -715,19 +715,7 @@ __exit: } else { - /* try to read Legacy data */ - /* receive packet list last transmission of remaining data */ - rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER); - recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len); - rt_mutex_release(sock->recv_lock); - if(recv_len<=0) - { - at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); - } - else - { - result = recv_len; - } + at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); } return result; From 3af4e3b404ce24831a1bf20ff43ad1b84b86ce6d Mon Sep 17 00:00:00 2001 From: e190 <39932163+e190@users.noreply.github.com> Date: Thu, 13 Dec 2018 08:33:21 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8DI2C=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=B2=97=E5=BF=83BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I2C2_BUS_CONFIG改为I2C3_BUS_CONFIG --- bsp/stm32/libraries/HAL_Drivers/drv_soft_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_soft_i2c.c b/bsp/stm32/libraries/HAL_Drivers/drv_soft_i2c.c index 5f8e300d08..a19c5c2984 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_soft_i2c.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_soft_i2c.c @@ -32,7 +32,7 @@ static const struct stm32_soft_i2c_config soft_i2c_config[] = I2C2_BUS_CONFIG, #endif #ifdef BSP_USING_I2C3 - I2C2_BUS_CONFIG, + I2C3_BUS_CONFIG, #endif }; From c042da4e9d73bb5d10ef042b6defcea5ff1b5290 Mon Sep 17 00:00:00 2001 From: e190 <39932163+e190@users.noreply.github.com> Date: Thu, 13 Dec 2018 08:38:53 +0800 Subject: [PATCH 12/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRTC=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E4=B8=AD=E4=B8=80=E4=B8=AA=E7=B2=97=E5=BF=83BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 137行多了() --- bsp/stm32/libraries/HAL_Drivers/drv_rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c b/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c index 50bbc7cc33..0f6ac24dfe 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c @@ -134,7 +134,7 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args) { case RT_DEVICE_CTRL_RTC_GET_TIME: *(rt_uint32_t *)args = get_rtc_timestamp(); - LOG_D("RTC: get rtc_time %x\n", *(rt_uint32_t *)args()); + LOG_D("RTC: get rtc_time %x\n", *(rt_uint32_t *)args); break; case RT_DEVICE_CTRL_RTC_SET_TIME: From 968110ffd61dcc30a48c98308b034fcaf532cdb7 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Thu, 13 Dec 2018 10:56:09 +0800 Subject: [PATCH 13/17] [bsp][stm32] add scons --dist function --- .../libraries/templates/stm32f10x/SConstruct | 14 +++++-- .../templates/stm32f10x/board/SConscript | 27 +++++++------ .../libraries/templates/stm32f10x/rtconfig.py | 3 ++ .../libraries/templates/stm32f4xx/SConstruct | 14 +++++-- .../templates/stm32f4xx/board/SConscript | 18 ++++++--- .../libraries/templates/stm32f4xx/rtconfig.py | 3 ++ .../libraries/templates/stm32l4xx/SConstruct | 14 +++++-- .../templates/stm32l4xx/board/SConscript | 18 ++++++--- .../libraries/templates/stm32l4xx/rtconfig.py | 3 ++ bsp/stm32/stm32f103-atk-nano/SConstruct | 14 +++++-- bsp/stm32/stm32f103-atk-nano/board/SConscript | 17 ++++++--- bsp/stm32/stm32f103-atk-nano/rtconfig.py | 3 ++ bsp/stm32/stm32f103-fire-arbitrary/SConstruct | 14 +++++-- .../stm32f103-fire-arbitrary/board/SConscript | 15 ++++++-- .../stm32f103-fire-arbitrary/rtconfig.py | 3 ++ bsp/stm32/stm32f407-atk-explorer/SConstruct | 14 +++++-- .../stm32f407-atk-explorer/board/SConscript | 16 +++++--- bsp/stm32/stm32f407-atk-explorer/rtconfig.py | 3 ++ bsp/stm32/stm32f429-atk-apollo/SConstruct | 14 +++++-- .../stm32f429-atk-apollo/board/SConscript | 18 +++++---- bsp/stm32/stm32f429-atk-apollo/rtconfig.py | 3 ++ .../stm32f429-fire-challenger/SConstruct | 14 +++++-- .../board/SConscript | 19 ++++++---- .../stm32f429-fire-challenger/rtconfig.py | 3 ++ tools/building.py | 3 ++ tools/mkdist.py | 38 +++++++++++++++++++ 26 files changed, 248 insertions(+), 77 deletions(-) diff --git a/bsp/stm32/libraries/templates/stm32f10x/SConstruct b/bsp/stm32/libraries/templates/stm32f10x/SConstruct index b541737671..5514659688 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f10x/SConstruct @@ -38,11 +38,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') bsp_vdir = 'build' -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F1xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/SConscript b/bsp/stm32/libraries/templates/stm32f10x/board/SConscript index a0011e100f..1ddc236ef5 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32f10x/board/SConscript @@ -1,23 +1,28 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -# add the general drivers. -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') -path = [cwd] +path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] -if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] -elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s'] -elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' +if rtconfig.CROSS_TOOL == 'gcc': + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] +elif rtconfig.CROSS_TOOL == 'keil': + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s'] +elif rtconfig.CROSS_TOOL == 'iar': + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s'] + CPPDEFINES = ['STM32F103xB'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) - -Return('group') \ No newline at end of file +Return('group') diff --git a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py index 7906918058..79904118e5 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m3' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/libraries/templates/stm32f4xx/SConstruct b/bsp/stm32/libraries/templates/stm32f4xx/SConstruct index f9b3d33a62..bcfdc31e22 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f4xx/SConstruct @@ -37,11 +37,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F4xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript b/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript index 5709200ba1..e7b053a70a 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript @@ -1,21 +1,27 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -# add the general drivers. -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') -path = [cwd] +path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' + if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s'] CPPDEFINES = ['STM32F407xx'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py index ce04832ca5..2e3b7cf492 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m4' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/libraries/templates/stm32l4xx/SConstruct b/bsp/stm32/libraries/templates/stm32l4xx/SConstruct index 23a8f6755c..c8abfbd6ec 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32l4xx/SConstruct @@ -37,11 +37,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32L4xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32FL4xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript b/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript index a0bf277556..eaa002ca9a 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript @@ -1,21 +1,27 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -# add the general drivers. -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32l4xx_hal_msp.c') -path = [cwd] +path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' + if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l475xx.s'] + src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l475xx.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l475xx.s'] + src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l475xx.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/iar/startup_stm32l475xx.s'] + src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/iar/startup_stm32l475xx.s'] CPPDEFINES = ['STM32L475xx'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py index 53f5cd79bc..50c1d8a0f7 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m4' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/stm32f103-atk-nano/SConstruct b/bsp/stm32/stm32f103-atk-nano/SConstruct index b541737671..5514659688 100644 --- a/bsp/stm32/stm32f103-atk-nano/SConstruct +++ b/bsp/stm32/stm32f103-atk-nano/SConstruct @@ -38,11 +38,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') bsp_vdir = 'build' -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F1xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f103-atk-nano/board/SConscript b/bsp/stm32/stm32f103-atk-nano/board/SConscript index 16ac2f078b..fe2f1bb3f5 100644 --- a/bsp/stm32/stm32f103-atk-nano/board/SConscript +++ b/bsp/stm32/stm32f103-atk-nano/board/SConscript @@ -1,24 +1,31 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') if GetDepend(['BSP_USING_SPI_FLASH']): src += Glob('ports/spi_flash_init.c') -path = [cwd] +path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' + if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s'] + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s'] + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s'] CPPDEFINES = ['STM32F103xB'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/stm32f103-atk-nano/rtconfig.py b/bsp/stm32/stm32f103-atk-nano/rtconfig.py index 7906918058..79904118e5 100644 --- a/bsp/stm32/stm32f103-atk-nano/rtconfig.py +++ b/bsp/stm32/stm32f103-atk-nano/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m3' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/stm32f103-fire-arbitrary/SConstruct b/bsp/stm32/stm32f103-fire-arbitrary/SConstruct index b541737671..5514659688 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/SConstruct +++ b/bsp/stm32/stm32f103-fire-arbitrary/SConstruct @@ -38,11 +38,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') bsp_vdir = 'build' -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F1xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript b/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript index 892d5d6fec..868e5b8a48 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript @@ -1,9 +1,11 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') if GetDepend(['BSP_USING_ETH']): @@ -16,12 +18,17 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' + if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s'] + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xe.s'] + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xe.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xe.s'] + src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xe.s'] CPPDEFINES = ['STM32F103xE'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.py b/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.py index 7906918058..79904118e5 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.py +++ b/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m3' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/stm32f407-atk-explorer/SConstruct b/bsp/stm32/stm32f407-atk-explorer/SConstruct index f9b3d33a62..bcfdc31e22 100644 --- a/bsp/stm32/stm32f407-atk-explorer/SConstruct +++ b/bsp/stm32/stm32f407-atk-explorer/SConstruct @@ -37,11 +37,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F4xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f407-atk-explorer/board/SConscript b/bsp/stm32/stm32f407-atk-explorer/board/SConscript index bcaf10e784..861030d80f 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/SConscript +++ b/bsp/stm32/stm32f407-atk-explorer/board/SConscript @@ -1,10 +1,11 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -# add the general drivers. -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') if GetDepend(['BSP_USING_ETH']): @@ -17,12 +18,17 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' + if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s'] CPPDEFINES = ['STM32F407xx'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/stm32f407-atk-explorer/rtconfig.py b/bsp/stm32/stm32f407-atk-explorer/rtconfig.py index ce04832ca5..2e3b7cf492 100644 --- a/bsp/stm32/stm32f407-atk-explorer/rtconfig.py +++ b/bsp/stm32/stm32f407-atk-explorer/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m4' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/stm32f429-atk-apollo/SConstruct b/bsp/stm32/stm32f429-atk-apollo/SConstruct index f9b3d33a62..bcfdc31e22 100644 --- a/bsp/stm32/stm32f429-atk-apollo/SConstruct +++ b/bsp/stm32/stm32f429-atk-apollo/SConstruct @@ -37,11 +37,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F4xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f429-atk-apollo/board/SConscript b/bsp/stm32/stm32f429-atk-apollo/board/SConscript index f58944ccbf..9e38a44209 100644 --- a/bsp/stm32/stm32f429-atk-apollo/board/SConscript +++ b/bsp/stm32/stm32f429-atk-apollo/board/SConscript @@ -1,9 +1,10 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -# add the general drivers. +# add general drivers src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') @@ -16,17 +17,18 @@ if GetDepend(['BSP_USING_SPI_FLASH']): path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] - - -if GetDepend(['BSP_USING_SDRAM']): - path += [cwd + '/ports'] + +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s'] CPPDEFINES = ['STM32F429xx'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/stm32f429-atk-apollo/rtconfig.py b/bsp/stm32/stm32f429-atk-apollo/rtconfig.py index ce04832ca5..2e3b7cf492 100644 --- a/bsp/stm32/stm32f429-atk-apollo/rtconfig.py +++ b/bsp/stm32/stm32f429-atk-apollo/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m4' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/bsp/stm32/stm32f429-fire-challenger/SConstruct b/bsp/stm32/stm32f429-fire-challenger/SConstruct index f9b3d33a62..bcfdc31e22 100644 --- a/bsp/stm32/stm32f429-fire-challenger/SConstruct +++ b/bsp/stm32/stm32f429-fire-challenger/SConstruct @@ -37,11 +37,19 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) SDK_ROOT = os.path.abspath('./') -# include drivers -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript')) +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries/' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + +stm32_library = 'STM32F4xx_HAL' +rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) +objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) + +# include drivers +objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f429-fire-challenger/board/SConscript b/bsp/stm32/stm32f429-fire-challenger/board/SConscript index b42904e35d..00d86f2c33 100644 --- a/bsp/stm32/stm32f429-fire-challenger/board/SConscript +++ b/bsp/stm32/stm32f429-fire-challenger/board/SConscript @@ -1,10 +1,11 @@ +import os import rtconfig from building import * cwd = GetCurrentDir() -# add the general drivers. -src = Glob('board.c') +# add general drivers +src = Glob('board.c') src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') if GetDepend(['BSP_USING_ETH']): @@ -13,19 +14,21 @@ if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_SPI_FLASH']): src += Glob('ports/spi_flash_init.c') -path = [cwd] +path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] -if GetDepend(['BSP_USING_SDRAM']): - path += [cwd + '/ports'] +if os.path.exists(cwd + '/../libraries'): + startup_path_prefix = cwd + '/../libraries' +else: + startup_path_prefix = cwd + '/../../libraries' if rtconfig.CROSS_TOOL == 'gcc': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] elif rtconfig.CROSS_TOOL == 'keil': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s'] elif rtconfig.CROSS_TOOL == 'iar': - src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s'] + src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s'] CPPDEFINES = ['STM32F429xx'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) diff --git a/bsp/stm32/stm32f429-fire-challenger/rtconfig.py b/bsp/stm32/stm32f429-fire-challenger/rtconfig.py index ce04832ca5..2e3b7cf492 100644 --- a/bsp/stm32/stm32f429-fire-challenger/rtconfig.py +++ b/bsp/stm32/stm32f429-fire-challenger/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m4' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): diff --git a/tools/building.py b/tools/building.py index ba6c5000e4..eb2da2fab9 100644 --- a/tools/building.py +++ b/tools/building.py @@ -810,6 +810,9 @@ def EndBuilding(target, program = None): Env['target'] = program Env['project'] = Projects + if hasattr(rtconfig, 'BSP_LIBRARY_TYPE'): + Env['bsp_lib_type'] = rtconfig.BSP_LIBRARY_TYPE + Env.AddPostAction(target, rtconfig.POST_ACTION) # Add addition clean files Clean(target, 'cconfig.h') diff --git a/tools/mkdist.py b/tools/mkdist.py index eef6bfd118..e927417fc4 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -122,6 +122,24 @@ def bsp_update_kconfig(dist_dir): line = line[0:position] + 'default: "rt-thread"\n' found = 0 f.write(line) + +def bsp_update_kconfig_library(dist_dir): + # change RTT_ROOT in Kconfig + if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): + return + + with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: + data = f.readlines() + with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: + found = 0 + for line in data: + if line.find('RTT_ROOT') != -1: + found = 1 + if line.find('../libraries') != -1 and found: + position = line.find('../libraries') + line = line[0:position] + 'libraries/Kconfig"\n' + found = 0 + f.write(line) def bs_update_ide_project(bsp_root, rtt_root): import subprocess @@ -169,6 +187,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): print('=> %s' % os.path.basename(BSP_ROOT)) bsp_copy_files(BSP_ROOT, dist_dir) + # copy stm32 bsp libiary files + if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32': + print("=> copy stm32 bsp library") + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') + library_dir = os.path.join(dist_dir, 'libraries') + bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers')) + bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # get all source files from program for item in program: walk_children(item) @@ -260,6 +287,7 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): bsp_update_sconstruct(dist_dir) # change RTT_ROOT in Kconfig bsp_update_kconfig(dist_dir) + bsp_update_kconfig_library(dist_dir) # update all project files bs_update_ide_project(dist_dir, target_path) @@ -280,6 +308,15 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env): print('=> %s' % os.path.basename(BSP_ROOT)) bsp_copy_files(BSP_ROOT, dist_dir) + # copy stm32 bsp libiary files + if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32': + print("=> copy stm32 bsp library") + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') + library_dir = os.path.join(dist_dir, 'libraries') + bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers')) + bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # copy tools directory print('=> components') do_copy_folder(os.path.join(RTT_ROOT, 'components'), os.path.join(target_path, 'components')) @@ -316,6 +353,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env): bsp_update_sconstruct(dist_dir) # change RTT_ROOT in Kconfig bsp_update_kconfig(dist_dir) + bsp_update_kconfig_library(dist_dir) # update all project files bs_update_ide_project(dist_dir, target_path) From 1f37de29c4ee4dac488aa9c4f8f0990263f94c1a Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Thu, 13 Dec 2018 14:54:26 +0800 Subject: [PATCH 14/17] Fix the value width issue under 32/64 bit arch. --- components/dfs/src/dfs_file.c | 2 +- components/dfs/src/poll.c | 2 +- components/drivers/sdio/mmcsd_core.c | 4 ++-- components/net/lwip-2.0.2/src/arch/sys_arch.c | 4 ++-- components/net/lwip-2.0.2/src/netif/ethernetif.c | 4 ++-- src/memheap.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 646ae58e36..e7071522ce 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -171,7 +171,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args) return fd->flags; /* return flags */ case F_SETFL: { - int flags = (int)args; + int flags = (int)(rt_base_t)args; int mask = O_NONBLOCK | O_APPEND; flags &= mask; diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index 6655a8a667..6f83762082 100644 --- a/components/dfs/src/poll.c +++ b/components/dfs/src/poll.c @@ -40,7 +40,7 @@ static int __wqueue_pollwake(struct rt_wqueue_node *wait, void *key) { struct rt_poll_node *pn; - if (key && !((rt_uint32_t)key & wait->key)) + if (key && !((rt_ubase_t)key & wait->key)) return -1; pn = rt_container_of(wait, struct rt_poll_node, wqn); diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index d1f5978374..2206960a69 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -595,7 +595,7 @@ static void mmcsd_power_off(struct rt_mmcsd_host *host) int mmcsd_wait_cd_changed(rt_int32_t timeout) { struct rt_mmcsd_host *host; - if (rt_mb_recv(&mmcsd_hotpluge_mb, (rt_uint32_t*)&host, timeout) == RT_EOK) + if (rt_mb_recv(&mmcsd_hotpluge_mb, (rt_ubase_t *)&host, timeout) == RT_EOK) { if(host->card == RT_NULL) { @@ -623,7 +623,7 @@ void mmcsd_detect(void *param) while (1) { - if (rt_mb_recv(&mmcsd_detect_mb, (rt_uint32_t*)&host, RT_WAITING_FOREVER) == RT_EOK) + if (rt_mb_recv(&mmcsd_detect_mb, (rt_ubase_t *)&host, RT_WAITING_FOREVER) == RT_EOK) { if (host->card == RT_NULL) { diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index 7a92170886..b2abaeab54 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -508,7 +508,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) t = timeout / (1000/RT_TICK_PER_SECOND); } - ret = rt_mb_recv(*mbox, (rt_uint32_t *)msg, t); + ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t); if(ret == -RT_ETIMEOUT) return SYS_ARCH_TIMEOUT; @@ -539,7 +539,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) { int ret; - ret = rt_mb_recv(*mbox, (rt_uint32_t *)msg, 0); + ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, 0); if(ret == -RT_ETIMEOUT) return SYS_ARCH_TIMEOUT; diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 8b05e592d4..f9a798f594 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -329,7 +329,7 @@ static void eth_tx_thread_entry(void* parameter) while (1) { - if (rt_mb_recv(ð_tx_thread_mb, (rt_uint32_t*)&msg, RT_WAITING_FOREVER) == RT_EOK) + if (rt_mb_recv(ð_tx_thread_mb, (rt_ubase_t *)&msg, RT_WAITING_FOREVER) == RT_EOK) { struct eth_device* enetif; @@ -361,7 +361,7 @@ static void eth_rx_thread_entry(void* parameter) while (1) { - if (rt_mb_recv(ð_rx_thread_mb, (rt_uint32_t*)&device, RT_WAITING_FOREVER) == RT_EOK) + if (rt_mb_recv(ð_rx_thread_mb, (rt_ubase_t *)&device, RT_WAITING_FOREVER) == RT_EOK) { struct pbuf *p; diff --git a/src/memheap.c b/src/memheap.c index eb5d710029..aef56e1a74 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -34,7 +34,7 @@ #define RT_MEMHEAP_MINIALLOC 12 #define RT_MEMHEAP_SIZE RT_ALIGN(sizeof(struct rt_memheap_item), RT_ALIGN_SIZE) -#define MEMITEM_SIZE(item) ((rt_uint32_t)item->next - (rt_uint32_t)item - RT_MEMHEAP_SIZE) +#define MEMITEM_SIZE(item) ((rt_ubase_t)item->next - (rt_ubase_t)item - RT_MEMHEAP_SIZE) /* * The initialized memory pool will be: From 6df6a7519aba12213dba8bad2d74cb7d237f4d60 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Thu, 13 Dec 2018 15:05:48 +0800 Subject: [PATCH 15/17] [bsp][stm32] modify sconstruct --- .../libraries/templates/stm32f10x/SConstruct | 18 ++++++++++-------- .../libraries/templates/stm32f4xx/SConstruct | 17 ++++++++++------- .../libraries/templates/stm32l4xx/SConstruct | 19 +++++++++++-------- bsp/stm32/stm32f103-atk-nano/SConstruct | 18 ++++++++++-------- bsp/stm32/stm32f103-fire-arbitrary/SConstruct | 18 ++++++++++-------- bsp/stm32/stm32f407-atk-explorer/SConstruct | 17 ++++++++++------- bsp/stm32/stm32f429-atk-apollo/SConstruct | 17 ++++++++++------- .../stm32f429-fire-challenger/SConstruct | 17 ++++++++++------- 8 files changed, 81 insertions(+), 60 deletions(-) diff --git a/bsp/stm32/libraries/templates/stm32f10x/SConstruct b/bsp/stm32/libraries/templates/stm32f10x/SConstruct index 5514659688..c28354a99d 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f10x/SConstruct @@ -32,25 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') -bsp_vdir = 'build' if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F1xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/libraries/templates/stm32f4xx/SConstruct b/bsp/stm32/libraries/templates/stm32f4xx/SConstruct index bcfdc31e22..c1609bf526 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f4xx/SConstruct @@ -32,24 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F4xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/libraries/templates/stm32l4xx/SConstruct b/bsp/stm32/libraries/templates/stm32l4xx/SConstruct index c8abfbd6ec..f28e552248 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32l4xx/SConstruct @@ -32,24 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' -stm32_library = 'STM32FL4xx_HAL' +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) + +stm32_library = 'STM32L4xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f103-atk-nano/SConstruct b/bsp/stm32/stm32f103-atk-nano/SConstruct index 5514659688..c28354a99d 100644 --- a/bsp/stm32/stm32f103-atk-nano/SConstruct +++ b/bsp/stm32/stm32f103-atk-nano/SConstruct @@ -32,25 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') -bsp_vdir = 'build' if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F1xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f103-fire-arbitrary/SConstruct b/bsp/stm32/stm32f103-fire-arbitrary/SConstruct index 5514659688..c28354a99d 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/SConstruct +++ b/bsp/stm32/stm32f103-fire-arbitrary/SConstruct @@ -32,25 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') -bsp_vdir = 'build' if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F1xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f407-atk-explorer/SConstruct b/bsp/stm32/stm32f407-atk-explorer/SConstruct index bcfdc31e22..c1609bf526 100644 --- a/bsp/stm32/stm32f407-atk-explorer/SConstruct +++ b/bsp/stm32/stm32f407-atk-explorer/SConstruct @@ -32,24 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F4xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f429-atk-apollo/SConstruct b/bsp/stm32/stm32f429-atk-apollo/SConstruct index bcfdc31e22..c1609bf526 100644 --- a/bsp/stm32/stm32f429-atk-apollo/SConstruct +++ b/bsp/stm32/stm32f429-atk-apollo/SConstruct @@ -32,24 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F4xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/stm32/stm32f429-fire-challenger/SConstruct b/bsp/stm32/stm32f429-fire-challenger/SConstruct index bcfdc31e22..c1609bf526 100644 --- a/bsp/stm32/stm32f429-fire-challenger/SConstruct +++ b/bsp/stm32/stm32f429-fire-challenger/SConstruct @@ -32,24 +32,27 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') -# prepare building environment -objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) - SDK_ROOT = os.path.abspath('./') if os.path.exists(SDK_ROOT + '/libraries'): - libraries_path_prefix = SDK_ROOT + '/libraries/' + libraries_path_prefix = SDK_ROOT + '/libraries' else: - libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries/' + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) stm32_library = 'STM32F4xx_HAL' rtconfig.BSP_LIBRARY_TYPE = stm32_library # include libraries -objs.extend(SConscript(libraries_path_prefix + stm32_library + '/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'))) # include drivers -objs.extend(SConscript(libraries_path_prefix + '/HAL_Drivers/SConscript')) +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) From 6ef13c82aaa03a9b0a1200cb8c9cb34b33172890 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Thu, 13 Dec 2018 15:09:35 +0800 Subject: [PATCH 16/17] [bsp][stm32] modify board/SConscript --- bsp/stm32/libraries/templates/stm32f10x/board/SConscript | 7 +++---- bsp/stm32/libraries/templates/stm32f4xx/board/SConscript | 7 +++---- bsp/stm32/libraries/templates/stm32l4xx/board/SConscript | 7 +++---- bsp/stm32/stm32f103-atk-nano/board/SConscript | 7 +++---- bsp/stm32/stm32f103-fire-arbitrary/board/SConscript | 7 +++---- bsp/stm32/stm32f407-atk-explorer/board/SConscript | 7 +++---- bsp/stm32/stm32f429-atk-apollo/board/SConscript | 7 +++---- bsp/stm32/stm32f429-fire-challenger/board/SConscript | 7 +++---- 8 files changed, 24 insertions(+), 32 deletions(-) diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/SConscript b/bsp/stm32/libraries/templates/stm32f10x/board/SConscript index 1ddc236ef5..2220836b65 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32f10x/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -11,10 +13,7 @@ src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] diff --git a/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript b/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript index e7b053a70a..4a2bfc231f 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -11,10 +13,7 @@ src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] diff --git a/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript b/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript index eaa002ca9a..0266cdaa24 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -11,10 +13,7 @@ src += Glob('CubeMX_Config/Src/stm32l4xx_hal_msp.c') path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l475xx.s'] diff --git a/bsp/stm32/stm32f103-atk-nano/board/SConscript b/bsp/stm32/stm32f103-atk-nano/board/SConscript index fe2f1bb3f5..2403d7fb3d 100644 --- a/bsp/stm32/stm32f103-atk-nano/board/SConscript +++ b/bsp/stm32/stm32f103-atk-nano/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -15,10 +17,7 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript b/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript index 868e5b8a48..f26304c6d2 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -18,10 +20,7 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s'] diff --git a/bsp/stm32/stm32f407-atk-explorer/board/SConscript b/bsp/stm32/stm32f407-atk-explorer/board/SConscript index 861030d80f..cb20cf76e8 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/SConscript +++ b/bsp/stm32/stm32f407-atk-explorer/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -18,10 +20,7 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] diff --git a/bsp/stm32/stm32f429-atk-apollo/board/SConscript b/bsp/stm32/stm32f429-atk-apollo/board/SConscript index 9e38a44209..2cf3a648da 100644 --- a/bsp/stm32/stm32f429-atk-apollo/board/SConscript +++ b/bsp/stm32/stm32f429-atk-apollo/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -18,10 +20,7 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] diff --git a/bsp/stm32/stm32f429-fire-challenger/board/SConscript b/bsp/stm32/stm32f429-fire-challenger/board/SConscript index 00d86f2c33..c633cff75c 100644 --- a/bsp/stm32/stm32f429-fire-challenger/board/SConscript +++ b/bsp/stm32/stm32f429-fire-challenger/board/SConscript @@ -2,6 +2,8 @@ import os import rtconfig from building import * +Import('SDK_LIB') + cwd = GetCurrentDir() # add general drivers @@ -18,10 +20,7 @@ path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/ports'] -if os.path.exists(cwd + '/../libraries'): - startup_path_prefix = cwd + '/../libraries' -else: - startup_path_prefix = cwd + '/../../libraries' +startup_path_prefix = SDK_LIB if rtconfig.CROSS_TOOL == 'gcc': src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] From c692e194a6a261b571b14328f3c1bc7ad44ff56b Mon Sep 17 00:00:00 2001 From: SummerGift Date: Thu, 13 Dec 2018 15:13:30 +0800 Subject: [PATCH 17/17] [bsp][stm32] optimize board/SConscript code --- bsp/stm32/libraries/templates/stm32f10x/board/SConscript | 6 ++++-- bsp/stm32/libraries/templates/stm32f4xx/board/SConscript | 6 ++++-- bsp/stm32/libraries/templates/stm32l4xx/board/SConscript | 6 ++++-- bsp/stm32/stm32f103-atk-nano/board/SConscript | 6 ++++-- bsp/stm32/stm32f103-fire-arbitrary/board/SConscript | 6 ++++-- bsp/stm32/stm32f407-atk-explorer/board/SConscript | 6 ++++-- bsp/stm32/stm32f429-atk-apollo/board/SConscript | 6 ++++-- bsp/stm32/stm32f429-fire-challenger/board/SConscript | 6 ++++-- 8 files changed, 32 insertions(+), 16 deletions(-) diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/SConscript b/bsp/stm32/libraries/templates/stm32f10x/board/SConscript index 2220836b65..a88ecd435d 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32f10x/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f1xx_hal_msp.c +''') path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] diff --git a/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript b/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript index 4a2bfc231f..c62947164b 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32f4xx/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f4xx_hal_msp.c +''') path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] diff --git a/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript b/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript index 0266cdaa24..e826c7212d 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript +++ b/bsp/stm32/libraries/templates/stm32l4xx/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32l4xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32l4xx_hal_msp.c +''') path = [cwd] path += [cwd + '/CubeMX_Config/Inc'] diff --git a/bsp/stm32/stm32f103-atk-nano/board/SConscript b/bsp/stm32/stm32f103-atk-nano/board/SConscript index 2403d7fb3d..9659e84a2b 100644 --- a/bsp/stm32/stm32f103-atk-nano/board/SConscript +++ b/bsp/stm32/stm32f103-atk-nano/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f1xx_hal_msp.c +''') if GetDepend(['BSP_USING_SPI_FLASH']): src += Glob('ports/spi_flash_init.c') diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript b/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript index f26304c6d2..24b0a3b97a 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f1xx_hal_msp.c +''') if GetDepend(['BSP_USING_ETH']): src += Glob('ports/w5500_device.c') diff --git a/bsp/stm32/stm32f407-atk-explorer/board/SConscript b/bsp/stm32/stm32f407-atk-explorer/board/SConscript index cb20cf76e8..ee12fe4ce6 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/SConscript +++ b/bsp/stm32/stm32f407-atk-explorer/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f4xx_hal_msp.c +''') if GetDepend(['BSP_USING_ETH']): src += Glob('ports/phy_reset.c') diff --git a/bsp/stm32/stm32f429-atk-apollo/board/SConscript b/bsp/stm32/stm32f429-atk-apollo/board/SConscript index 2cf3a648da..e67a62e1e8 100644 --- a/bsp/stm32/stm32f429-atk-apollo/board/SConscript +++ b/bsp/stm32/stm32f429-atk-apollo/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f4xx_hal_msp.c +''') if GetDepend(['BSP_USING_ETH']): src += Glob('ports/phy_reset.c') diff --git a/bsp/stm32/stm32f429-fire-challenger/board/SConscript b/bsp/stm32/stm32f429-fire-challenger/board/SConscript index c633cff75c..7345e4e191 100644 --- a/bsp/stm32/stm32f429-fire-challenger/board/SConscript +++ b/bsp/stm32/stm32f429-fire-challenger/board/SConscript @@ -7,8 +7,10 @@ Import('SDK_LIB') cwd = GetCurrentDir() # add general drivers -src = Glob('board.c') -src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') +src = Split(''' +board.c +CubeMX_Config/Src/stm32f4xx_hal_msp.c +''') if GetDepend(['BSP_USING_ETH']): src += Glob('ports/phy_reset.c')