From c79b941558f7f9359f0d0cfbd7d79d88aa4e046d Mon Sep 17 00:00:00 2001 From: fangye Date: Mon, 1 Aug 2022 14:35:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=BA=90=E5=90=AF=E5=8A=A8=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BA=8C=E8=BF=9B=E5=88=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B8=85=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fangye Change-Id: I1d72718625e886e7bec82595ac264bc24dfd008b --- OAT.xml | 1 - niobeu4/liteos_m/target/BUILD.gn | 23 +-- .../liteos_m/target/lib/libtarget_startup.a | Bin 7310 -> 0 bytes niobeu4/liteos_m/target/src/target_run.c | 80 ---------- niobeu4/liteos_m/target/src/target_startup.c | 146 ++++++++++++++++++ 5 files changed, 147 insertions(+), 103 deletions(-) delete mode 100644 niobeu4/liteos_m/target/lib/libtarget_startup.a delete mode 100644 niobeu4/liteos_m/target/src/target_run.c create mode 100644 niobeu4/liteos_m/target/src/target_startup.c diff --git a/OAT.xml b/OAT.xml index c5f3286..ca495a5 100644 --- a/OAT.xml +++ b/OAT.xml @@ -62,7 +62,6 @@ - diff --git a/niobeu4/liteos_m/target/BUILD.gn b/niobeu4/liteos_m/target/BUILD.gn index 5856c73..7c079df 100755 --- a/niobeu4/liteos_m/target/BUILD.gn +++ b/niobeu4/liteos_m/target/BUILD.gn @@ -15,33 +15,12 @@ import("//kernel/liteos_m/liteos.gni") module_name = get_path_info(rebase_path("."), "name") kernel_module(module_name) { sources = [ - "src/target_run.c", + "src/target_startup.c", ] deps = [ - ":target_startup", "//vendor/openvalley/niobeu4/demo:demo", ] } -use_local_libaray = true -lite_library("target_startup") { - target_type = "static_library" - if(use_local_libaray == true) { - sources = [] - deps = [ - ":copy_target_startup" - ] - } else { - sources = [ - "src/target_startup.c", - ] - } -} - -build_ext_component("copy_target_startup") { - exec_path = rebase_path(".", root_build_dir) - out_root_path = rebase_path(root_out_dir) - command = "cp lib/libtarget_startup.a $out_root_path/libs/libtarget_startup.a" -} config("public") { ESP_SDK_PATH="//device/soc/esp/esp32/components/" diff --git a/niobeu4/liteos_m/target/lib/libtarget_startup.a b/niobeu4/liteos_m/target/lib/libtarget_startup.a deleted file mode 100644 index c5087d8d16e14aed91e6807f07ae4764913e669b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7310 zcmc&(e~eUD6~1q0sq4%j3v3Y(?35nvNldi>B6*Q4zOVw(Fkeb>*YR2!obMDUF z#}HOi^(5!s?|k>XbMHOxzWeUHiLFcJ28KT!ZgHnet7Vq4UAk^tqFp?8hm}$vQp#z+ zneOq1vNY#dHJaM%<@)?o z&QSNKhtg$x+vaV3$-YB*-y7j2-J^c)keUjoT7pxtW>O7)a;C-dxj z|5!X=W?RB7c4}~`ZQ40nok-}wtJer{cZa{y-SZj8ageaGIO;)Fv6LFW9ehZsgl=wD z%hV^tQ>oP{RrqJ=SyvseLvf;wh()nkJ-ldE;UA^Tb!zFgDfj=-KU#BR4@c^%bxSr$@ZCO?kH|&sC?obGd9TK5YfLUM{z` z^Z<)X|3?IbFD*J$_@Azt&in>%$8kaGpHn z6n;r=@*5M+mwpy1{6agNXUVo#2zDG(6X!~WN!_GNOyCGtW=BoqDfOv^vkEV=jcb$n zX5IpM*N?C}kn>W$=MJUP8E>$150qQZbX~c+pfhW%GGIo6W4c_ioqAkFCO5ZOgT)nW>qUjEwBU3T4U6Vw+vbX<-%s&2#rH2Y&Y`1iqnJ+IgV9Qb383j%D*$7 z|5qI5lX+&%4TATZ_hki?^Ev_LR?c~ygThtgE2z0f$aC-J{E3$$z{do4051{T56pP< z*}+aA)$-E-p5tMyF>3a?3(D&cLl;3A=UY${^9f*z9ka~nQhL<5R$VVyO?YihzbK?W zY&WCbdZy75QjtLW?0`KdV9yQM^8+?to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=N4z4@x}z<)dX8?8Aatv0qT?VeymKt~w3de6})vtc&1zO(zY=3+VSE z7DWtr0o2UnNr`9r<-%FX3q(x6&xoJtcP0FuFixoHM|nEX?@8PQzAIyB<49h_}29b%|y@-wOb8G|>EY_;m#QXuc)!Ow$TfSFhbd0UcAP`P UrZcbxaxL0^<5)~3(`fnq3x-o{ApigX diff --git a/niobeu4/liteos_m/target/src/target_run.c b/niobeu4/liteos_m/target/src/target_run.c deleted file mode 100644 index 6242d73..0000000 --- a/niobeu4/liteos_m/target/src/target_run.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include "los_task.h" - -#define DEALY_10_TICKS 10 -#define NUM_2048 2048 - -void *__attribute__((weak)) OHOS_APP_FUNC_ENTRY = NULL; -void *__attribute__((weak)) BEFORE_OHOS_RUN_FUNC_ENTRY = NULL; - -void ohos_app_main() -{ - LOS_TaskDelay(DEALY_10_TICKS); - if (OHOS_APP_FUNC_ENTRY) { - printf("\n\033[1;32m<--------------- OHOS Application Start Here --------------->\033[0m\n"); - ((void (*)(void))OHOS_APP_FUNC_ENTRY)(); - } else { - printf("\n\033[1;31m<--------------- OHOS_APP_FUNC_ENTRY is NULL --------------->\033[0m\n"); - } - while (1) { - LOS_TaskDelay(DEALY_10_TICKS * DEALY_10_TICKS); - IoTWatchDogKick(); - } -} - -void before_ohos_run() -{ - if (BEFORE_OHOS_RUN_FUNC_ENTRY) { - ((void (*)(void))BEFORE_OHOS_RUN_FUNC_ENTRY)(); - } -} - -#ifdef CONFIG_BUILD_TYPE_TEST - -__attribute__((weak)) UINT32 lwip_ifconfig(INT32 argc, const CHAR **argv) -{ - return 0; -} - -__attribute__((weak)) UINT32 OsShellPing(INT32 argc, const CHAR **argv) -{ - return 0; -} - -void TaskCreateExtensionHook(VOID *taskCB) -{ - LosTaskCB *p = (LosTaskCB *)taskCB; - UINTPTR topOfStack; - if (!p) { - return; - } - if ((p->stackSize <= 0) || (p->stackSize >= NUM_2048)) { - return; - } - p->stackSize = NUM_2048; - topOfStack = (UINTPTR)LOS_MemAllocAlign(OS_TASK_STACK_ADDR, p->stackSize, - LOSCFG_STACK_POINT_ALIGN_SIZE); - p->stackPointer = ArchTskStackInit(p->taskID, p->stackSize, (VOID *)topOfStack); - LOS_MemFree(OS_TASK_STACK_ADDR, (void *)p->topOfStack); - p->topOfStack = topOfStack; -} -#else -void TaskCreateExtensionHook(VOID *taskCB) -{ - (void)taskCB; -} -#endif diff --git a/niobeu4/liteos_m/target/src/target_startup.c b/niobeu4/liteos_m/target/src/target_startup.c new file mode 100644 index 0000000..f199024 --- /dev/null +++ b/niobeu4/liteos_m/target/src/target_startup.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "los_compiler.h" +#include "los_task.h" +#include "los_debug.h" +#include "samgr_lite.h" +#include "ohos_init.h" +#include "ohos_types.h" +#include "nvs.h" +#include "cmsis_os2.h" + +#include "hiview_def.h" +#include "hiview_output_log.h" + +#define SYSTEM_INIT_TASK_PRIO (LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO + 1) +#define SYSTEM_INIT_TASK_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE * 2) +#define DEALY_10_TICKS 10 +#define MIN_STACK_SIZE 2048 + +void* __attribute__((weak)) OHOS_APP_FUNC_ENTRY = NULL; +void* __attribute__((weak)) BEFORE_OHOS_RUN_FUNC_ENTRY = NULL; + +void __attribute__((weak)) OHOS_SystemInit(void) +{ + return 0; +} + +int __attribute__((weak)) DeviceManagerStart(void) +{ + return 0; +} + +int __attribute__((weak)) DeviceWifiStart(void) +{ + return 0; +} + +void ohos_app_main() +{ + LOS_TaskDelay(DEALY_10_TICKS); + if (OHOS_APP_FUNC_ENTRY) { + printf("\n\033[1;32m<--------------- OHOS Application Start Here --------------->\033[0m\n"); + ((void (*)(void))OHOS_APP_FUNC_ENTRY)(); + } else { + printf("\n\033[1;31m<--------------- OHOS_APP_FUNC_ENTRY is NULL --------------->\033[0m\n"); + } + while (1) { + LOS_TaskDelay(DEALY_10_TICKS * DEALY_10_TICKS); + IoTWatchDogKick(); + } +} + +void before_ohos_run() +{ + if (BEFORE_OHOS_RUN_FUNC_ENTRY) { + ((void (*)(void))BEFORE_OHOS_RUN_FUNC_ENTRY)(); + } +} + +#ifdef CONFIG_BUILD_TYPE_TEST + +__attribute__((weak)) UINT32 lwip_ifconfig(INT32 argc, const CHAR** argv) +{ + return 0; +} + +__attribute__((weak)) UINT32 OsShellPing(INT32 argc, const CHAR** argv) +{ + return 0; +} + +void TaskCreateExtensionHook(VOID* taskCB) +{ + LosTaskCB* p = (LosTaskCB*)taskCB; + UINTPTR topOfStack; + if (!p) { + return; + } + if ((p->stackSize <= 0) || (p->stackSize >= MIN_STACK_SIZE)) { + return; + } + p->stackSize = MIN_STACK_SIZE; + topOfStack = (UINTPTR)LOS_MemAllocAlign(OS_TASK_STACK_ADDR, p->stackSize, + LOSCFG_STACK_POINT_ALIGN_SIZE); + p->stackPointer = ArchTskStackInit(p->taskID, p->stackSize, (VOID*)topOfStack); + LOS_MemFree(OS_TASK_STACK_ADDR, (void*)p->topOfStack); + p->topOfStack = topOfStack; +} +#else +void TaskCreateExtensionHook(VOID* taskCB) +{ + (void)taskCB; +} +#endif + +VOID* OHOS_SystemInitEntry(VOID) +{ + int err; + printf("Code Build Time:%s %s\n", __DATE__, __TIME__); + before_ohos_run(); + esp_err_t ret = nvs_flash_init(); + if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { + nvs_flash_erase(); + ret = nvs_flash_init(); + } + DeviceWifiStart(); + init_trace_system(); + err = DeviceManagerStart(); + if (err) { + printf("DeviceManagerStart.ret=0x%X\n", err); + } + OHOS_SystemInit(); + ohos_app_main(); + return NULL; +} + +void app_main(void) +{ + UINT32 ret; + UINT32 taskID; + TSK_INIT_PARAM_S stTask = { 0 }; + stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)OHOS_SystemInitEntry; + stTask.uwStackSize = SYSTEM_INIT_TASK_STACK_SIZE; + stTask.pcName = "OHOS"; + stTask.usTaskPrio = SYSTEM_INIT_TASK_PRIO; + ret = LOS_TaskCreate(&taskID, &stTask); + if (ret != LOS_OK) { + printf("OHOS_SystemInitEntry create failed!\n"); + } + LOS_Start(); +} \ No newline at end of file