From 38c4b9385bfe2585b515087bfd221358578b691d Mon Sep 17 00:00:00 2001 From: bernard Date: Thu, 4 Dec 2025 21:18:28 +0800 Subject: [PATCH 1/2] [rt-link] fix the compiling issue under 64bit arch --- components/utilities/rt-link/src/rtlink.c | 23 ++++++++++++------- components/utilities/rt-link/src/rtlink_dev.c | 10 ++++---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/components/utilities/rt-link/src/rtlink.c b/components/utilities/rt-link/src/rtlink.c index 9c7bc1513c1..fa06fa54e91 100644 --- a/components/utilities/rt-link/src/rtlink.c +++ b/components/utilities/rt-link/src/rtlink.c @@ -48,7 +48,7 @@ #define RT_LINK_THREAD_NAME "rtlink" #define RT_LINK_THREAD_TICK 20 #define RT_LINK_THREAD_PRIORITY 25 -#define RT_LINK_THREAD_STACK_SIZE 1024 /* 32 bytes aligned */ +#define RT_LINK_THREAD_STACK_SIZE (4 * 1024) /* 32 bytes aligned */ #define RT_LINK_FRAME_SENT 1 #define RT_LINK_FRAME_NOSEND 0 @@ -905,8 +905,8 @@ static void rt_link_frame_recv_timeout(void) static void rt_link_send_timeout(void) { - LOG_D("send count(%d)", (rt_uint32_t)rt_link_scb->sendtimer.parameter); - if ((rt_uint32_t)rt_link_scb->sendtimer.parameter >= 5) + LOG_D("send count(%d)", (rt_ubase_t)rt_link_scb->sendtimer.parameter); + if ((rt_ubase_t)rt_link_scb->sendtimer.parameter >= 5) { rt_timer_stop(&rt_link_scb->sendtimer); LOG_W("Send timeout, please check the link status!"); @@ -929,7 +929,7 @@ static void rt_link_send_timeout(void) static void rt_link_long_recv_timeout(void) { - if ((rt_uint32_t)rt_link_scb->longframetimer.parameter >= 5) + if ((rt_ubase_t)rt_link_scb->longframetimer.parameter >= 5) { LOG_W("long package receive timeout"); rt_link_scb->longframetimer.parameter = 0x00; @@ -996,7 +996,7 @@ void rt_link_thread(void *parameter) static void rt_link_sendtimer_callback(void *parameter) { - rt_uint32_t count = (rt_uint32_t)rt_link_scb->sendtimer.parameter + 1; + rt_ubase_t count = (rt_ubase_t)rt_link_scb->sendtimer.parameter + 1; rt_link_scb->sendtimer.parameter = (void *)count; rt_event_send(&rt_link_scb->event, RT_LINK_SEND_TIMEOUT_EVENT); } @@ -1008,7 +1008,7 @@ static void rt_link_recvtimer_callback(void *parameter) static void rt_link_receive_long_frame_callback(void *parameter) { - rt_uint32_t count = (rt_uint32_t)rt_link_scb->longframetimer.parameter + 1; + rt_ubase_t count = (rt_ubase_t)rt_link_scb->longframetimer.parameter + 1; rt_link_scb->longframetimer.parameter = (void *)count; rt_event_send(&rt_link_scb->event, RT_LINK_RECV_TIMEOUT_LONG_EVENT); } @@ -1174,15 +1174,15 @@ MSH_CMD_EXPORT(rtlink_status, Display RTLINK status); * */ rt_err_t rt_link_deinit(void) { - rt_enter_critical(); rt_link_hw_deinit(); + rt_enter_critical(); if (rt_link_scb) { rt_timer_detach(&rt_link_scb->longframetimer); rt_timer_detach(&rt_link_scb->sendtimer); rt_timer_detach(&rt_link_scb->recvtimer); rt_event_detach(&rt_link_scb->event); - rt_free(rt_link_scb); + rt_free(rt_link_scb); rt_link_scb = RT_NULL; } rt_thread_t thread = rt_thread_find(RT_LINK_THREAD_NAME); @@ -1235,6 +1235,13 @@ int rt_link_init(void) rt_slist_init(&rt_link_scb->tx_data_slist); rt_link_scb->tx_seq = RT_LINK_INIT_FRAME_SEQENCE; + if (RT_EOK != rt_link_hw_init()) + { + LOG_E("rtlink hw init failed."); + result = -RT_ERROR; + goto __exit; + } + /* create rtlink core work thread */ thread = rt_thread_create(RT_LINK_THREAD_NAME, rt_link_thread, diff --git a/components/utilities/rt-link/src/rtlink_dev.c b/components/utilities/rt-link/src/rtlink_dev.c index ab21004ef9d..b4f1add6788 100644 --- a/components/utilities/rt-link/src/rtlink_dev.c +++ b/components/utilities/rt-link/src/rtlink_dev.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include int rtlink_fops_open(struct dfs_file *fd) { @@ -82,9 +84,9 @@ int rtlink_fops_ioctl(struct dfs_file *fd, int cmd, void *args) } } -int rtlink_fops_read(struct dfs_file *fd, void *buf, size_t count) +ssize_t rtlink_fops_read(struct dfs_file *fd, void *buf, size_t count) { - int size = 0; + ssize_t size = 0; rt_device_t device; device = (rt_device_t)fd->vnode->data; @@ -96,9 +98,9 @@ int rtlink_fops_read(struct dfs_file *fd, void *buf, size_t count) return size; } -int rtlink_fops_write(struct dfs_file *fd, const void *buf, size_t count) +ssize_t rtlink_fops_write(struct dfs_file *fd, const void *buf, size_t count) { - int size = 0; + ssize_t size = 0; rt_device_t device; device = (rt_device_t)fd->vnode->data; From 28ae3b3ed24b08621a233473ff8c1206d7cd0541 Mon Sep 17 00:00:00 2001 From: bernard Date: Thu, 4 Dec 2025 21:28:11 +0800 Subject: [PATCH 2/2] [rt-link] fix the indentation issue in the rt_link_deinit function --- components/utilities/rt-link/src/rtlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/utilities/rt-link/src/rtlink.c b/components/utilities/rt-link/src/rtlink.c index fa06fa54e91..db691601282 100644 --- a/components/utilities/rt-link/src/rtlink.c +++ b/components/utilities/rt-link/src/rtlink.c @@ -1182,7 +1182,7 @@ rt_err_t rt_link_deinit(void) rt_timer_detach(&rt_link_scb->sendtimer); rt_timer_detach(&rt_link_scb->recvtimer); rt_event_detach(&rt_link_scb->event); - rt_free(rt_link_scb); + rt_free(rt_link_scb); rt_link_scb = RT_NULL; } rt_thread_t thread = rt_thread_find(RT_LINK_THREAD_NAME);