From b2fbd370b7af61606b5e807c31f62ec10b9fda1d Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 12:01:17 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtuple=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0llvm-arm?= 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 1cde6b0d195555aab641c86163f2ad9be4dcb05c Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 12:02:21 +0800 Subject: [PATCH 2/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 7f3794d35263273d32d225cb2f39eaf9808f13ea Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 12:02: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/mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mempool.c b/src/mempool.c index 28bdb6cf896..0b80eea9a2c 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -335,7 +335,7 @@ void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time) if (time > 0) { - time -= rt_tick_get() - before_sleep; + time -= rt_tick_get_delta(before_sleep); if (time < 0) time = 0; } From 7327fb95ef3bc5420825227b384d5da9bd7e38ae Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 12:03:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=97=B6=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/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 7dc540c726dbf2cb4f747f5d014716aa019dae8b Mon Sep 17 00:00:00 2001 From: yueling hu <502966985@qq.com> Date: Sun, 25 May 2025 12:05:20 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4rt=5Fschedule();=20?= =?UTF-8?q?=E5=9C=A8rt=5Fenter=5Fcritical=E4=BD=9C=E7=94=A8=E5=9F=9F?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E6=97=A0=E6=95=88=E9=80=80=E5=87=BA=E4=BD=9C?= =?UTF-8?q?=E7=94=A8=E5=9F=9F=E8=87=AA=E5=8A=A8=E8=B0=83=E7=94=A8rt=5Fsche?= =?UTF-8?q?dule();=20---=20=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=92=9F=E6=BA=A2?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/thread.c b/src/thread.c index ed9dca13b61..2571046fa3f 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,15 @@ 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; + rt_tick_t target_tick; + target_tick = *tick + inc_tick; + left_tick = target_tick - rt_tick_get(); - *tick += inc_tick; - left_tick = *tick - cur_tick; + if (left_tick > target_tick) + left_tick = RT_TICK_MAX - left_tick + 1; /* suspend thread */ rt_thread_suspend_with_flag(thread, RT_UNINTERRUPTIBLE); @@ -735,7 +733,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); }