From 97783697efe2dd87dd09f5c1d793bc3f98bb6840 Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 09:30:28 +0800 Subject: [PATCH 1/5] =?UTF-8?q?linux=20=E4=B8=8B=20tuple=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8Cllvm-arm=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/cmake.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/cmake.py b/tools/cmake.py index e998a48e8cd..6e8b9dcfc8d 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -45,7 +45,7 @@ def GenerateCFiles(env, project, project_name): tool_path_conv["CMAKE_ASM_COMPILER"] = tool_path_conv_helper(rtconfig.AS) tool_path_conv["CMAKE_AR"] = tool_path_conv_helper(rtconfig.AR) tool_path_conv["CMAKE_LINKER"] = tool_path_conv_helper(rtconfig.LINK) - if rtconfig.PLATFORM in ['gcc']: + if rtconfig.PLATFORM in ['gcc','llvm-arm']: tool_path_conv["CMAKE_SIZE"] = tool_path_conv_helper(rtconfig.SIZE) tool_path_conv["CMAKE_OBJDUMP"] = tool_path_conv_helper(rtconfig.OBJDUMP) tool_path_conv["CMAKE_OBJCOPY"] = tool_path_conv_helper(rtconfig.OBJCPY) @@ -99,7 +99,7 @@ def GenerateCFiles(env, project, project_name): AS += ".exe" AR += ".exe" LINK += ".exe" - if rtconfig.PLATFORM in ['gcc']: + if rtconfig.PLATFORM in ['gcc','llvm-arm']: SIZE += ".exe" OBJDUMP += ".exe" OBJCOPY += ".exe" @@ -129,7 +129,7 @@ def GenerateCFiles(env, project, project_name): cm_file.write("SET(CMAKE_CXX_FLAGS \""+ CXXFLAGS + "\")\n") cm_file.write("SET(CMAKE_CXX_COMPILER_WORKS TRUE)\n\n") - if rtconfig.PLATFORM in ['gcc']: + if rtconfig.PLATFORM in ['gcc','llvm-arm']: cm_file.write("SET(CMAKE_OBJCOPY \""+ OBJCOPY + "\")\n") cm_file.write("SET(CMAKE_SIZE \""+ SIZE + "\")\n\n") elif rtconfig.PLATFORM in ['armcc', 'armclang']: @@ -137,7 +137,7 @@ def GenerateCFiles(env, project, project_name): LINKER_FLAGS = '' LINKER_LIBS = '' - if rtconfig.PLATFORM in ['gcc']: + if rtconfig.PLATFORM in ['gcc','llvm-arm']: LINKER_FLAGS += '-T' elif rtconfig.PLATFORM in ['armcc', 'armclang']: LINKER_FLAGS += '--scatter' @@ -186,7 +186,7 @@ def GenerateCFiles(env, project, project_name): cm_file.write("ADD_DEFINITIONS(\n") for i in env['CPPDEFINES']: - cm_file.write("\t-D" + i + "\n") + cm_file.write("\t-D" + str(i).replace("(", "").replace(")","").replace(",", " ") + "\n") cm_file.write(")\n\n") libgroups = [] @@ -290,7 +290,7 @@ def GenerateCFiles(env, project, project_name): cm_file.write("\n") cm_file.write("# Interface library search paths\n") - if rtconfig.PLATFORM in ['gcc']: + if rtconfig.PLATFORM in ['gcc','llvm-arm']: for group in libgroups: if not 'LIBPATH' in group.keys(): continue From 973a19329986ece4f5db83485eebb930455b1726 Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 09:31:17 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0rt=5Ftick=5Fget=5Fleft?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 1 + src/clock.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/rtthread.h b/include/rtthread.h index 103e26e894e..265bd074d96 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -99,6 +99,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object)); */ rt_tick_t rt_tick_get(void); rt_tick_t rt_tick_get_delta(rt_tick_t base); +rt_tick_t rt_tick_get_left(rt_tick_t base); void rt_tick_set(rt_tick_t tick); void rt_tick_increase(void); void rt_tick_increase_tick(rt_tick_t tick); diff --git a/src/clock.c b/src/clock.c index 4277fadc0c0..4d5b0268e01 100644 --- a/src/clock.c +++ b/src/clock.c @@ -89,6 +89,22 @@ rt_tick_t rt_tick_get_delta(rt_tick_t base) } RTM_EXPORT(rt_tick_get_delta); +/** + * @brief This function will return left tick from base. + * + * @param base to consider + * + * @return Return left tick. + */ +rt_tick_t rt_tick_get_left(rt_tick_t base) +{ + rt_tick_t left = base - rt_tick_get(); + if (left <= base) + return left; + return RT_TICK_MAX - left + 1; +} +RTM_EXPORT(rt_tick_get_left); + /** * @brief This function will set current tick. * From d97558115d1cdb17fd4d8a1855c5323100852622 Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 09:31:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=92=9F?= =?UTF-8?q?=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ipc.c b/src/ipc.c index 35c0146dd33..6628d1b5bfd 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -2650,7 +2650,7 @@ static rt_err_t _rt_mb_send_wait(rt_mailbox_t mb, /* if it's not waiting forever and then re-calculate timeout tick */ if (timeout > 0) { - tick_delta = rt_tick_get() - tick_delta; + tick_delta = rt_tick_get_delta(tick_delta); timeout -= tick_delta; if (timeout < 0) timeout = 0; @@ -2930,7 +2930,7 @@ static rt_err_t _rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeo /* if it's not waiting forever and then re-calculate timeout tick */ if (timeout > 0) { - tick_delta = rt_tick_get() - tick_delta; + tick_delta = rt_tick_get_delta(tick_delta); timeout -= tick_delta; if (timeout < 0) timeout = 0; @@ -3475,7 +3475,7 @@ static rt_err_t _rt_mq_send_wait(rt_mq_t mq, /* if it's not waiting forever and then re-calculate timeout tick */ if (timeout > 0) { - tick_delta = rt_tick_get() - tick_delta; + tick_delta = rt_tick_get_delta(tick_delta); timeout -= tick_delta; if (timeout < 0) timeout = 0; @@ -3855,7 +3855,7 @@ static rt_ssize_t _rt_mq_recv(rt_mq_t mq, /* if it's not waiting forever and then re-calculate timeout tick */ if (timeout > 0) { - tick_delta = rt_tick_get() - tick_delta; + tick_delta = rt_tick_get_delta(tick_delta); timeout -= tick_delta; if (timeout < 0) timeout = 0; From 21e926e914a2649ddf57cb833a21facf89214ed2 Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 09:32:45 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=92=9F?= =?UTF-8?q?=E6=BA=A2=E5=87=BA=20=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/timer.c b/src/timer.c index ae6da29f760..d04e91db331 100644 --- a/src/timer.c +++ b/src/timer.c @@ -494,8 +494,6 @@ static void _timer_check(rt_list_t *timer_list, struct rt_spinlock *lock) level = rt_spin_lock_irqsave(lock); - current_tick = rt_tick_get(); - rt_list_init(&list); while (!rt_list_isempty(&timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1])) @@ -762,7 +760,7 @@ void rt_timer_check(void) rt_tick_t next_timeout; ret = _timer_list_next_timeout(_soft_timer_list, &next_timeout); - if ((ret == RT_EOK) && (next_timeout <= rt_tick_get())) + if ((ret == RT_EOK) && ((rt_tick_get() - next_timeout) < RT_TICK_MAX / 2)) { rt_sem_release(&_soft_timer_sem); } From 98ddabd587836725ac40041dd68a3b42d7498fa1 Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 09:35:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99=20?= =?UTF-8?q?=E5=9C=A8rt=5Fenter=5Fcritical=20=E8=8C=83=E5=9B=B4=E5=86=85?= =?UTF-8?q?=E8=B0=83=E7=94=A8rt=5Fschedule=20=E6=97=A0=E6=95=88=EF=BC=8C?= =?UTF-8?q?=E9=80=80=E5=87=BA=E8=8C=83=E5=9B=B4=E8=87=AA=E5=8A=A8=E8=B0=83?= =?UTF-8?q?=E7=94=A8rt=5Fschedule=20=E3=80=82=E4=BF=AE=E5=A4=8D=E6=97=B6?= =?UTF-8?q?=E9=92=9F=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/thread.c b/src/thread.c index ed9dca13b61..e0bd3115812 100644 --- a/src/thread.c +++ b/src/thread.c @@ -647,9 +647,6 @@ static rt_err_t _thread_sleep(rt_tick_t tick) thread->error = -RT_EINTR; - /* notify a pending rescheduling */ - rt_schedule(); - /* exit critical and do a rescheduling */ rt_exit_critical_safe(critical_level); @@ -692,7 +689,6 @@ RTM_EXPORT(rt_thread_delay); rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) { struct rt_thread *thread; - rt_tick_t cur_tick; rt_base_t critical_level; RT_ASSERT(tick != RT_NULL); @@ -708,13 +704,11 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) /* disable interrupt */ critical_level = rt_enter_critical(); - cur_tick = rt_tick_get(); - if (cur_tick - *tick < inc_tick) + if (rt_tick_get_delta(*tick) < inc_tick) { rt_tick_t left_tick; - *tick += inc_tick; - left_tick = *tick - cur_tick; + left_tick = rt_tick_get_left(*tick + inc_tick); /* suspend thread */ rt_thread_suspend_with_flag(thread, RT_UNINTERRUPTIBLE); @@ -735,7 +729,7 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) } else { - *tick = cur_tick; + *tick = rt_tick_get(); rt_exit_critical_safe(critical_level); }