Skip to content

Commit 709cdbd

Browse files
authored
Merge branch 'RT-Thread:master' into master
2 parents 2b697cd + 2529550 commit 709cdbd

238 files changed

Lines changed: 7565 additions & 2694 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ALL_BSP_COMPILE.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,15 @@
491491
"RTT_BSP": "xuantie",
492492
"RTT_TOOL_CHAIN": "sourcery-Xuantie-900-gcc-elf-newlib",
493493
"SUB_RTT_BSP": [
494-
"xuantie/smartl/e901",
494+
"xuantie/smartl/e901plus",
495495
"xuantie/smartl/e902",
496496
"xuantie/smartl/e906",
497497
"xuantie/smartl/e907",
498498
"xuantie/xiaohui/c906",
499499
"xuantie/xiaohui/c907",
500500
"xuantie/xiaohui/c908",
501501
"xuantie/xiaohui/c908x",
502-
"xuantie/xiaohui/c910",
502+
"xuantie/xiaohui/c920",
503503
"xuantie/xiaohui/r908",
504504
"xuantie/xiaohui/r910",
505505
"xuantie/xiaohui/r920"

.github/workflows/pr_clang_format.yml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,55 @@ jobs:
5252
echo "📋 Checking supported features..."
5353
clang-format --help | grep -i "align\|consecutive" || echo "No align/consecutive options found"
5454
55-
- name: Get changed files from PR
56-
id: get-pr-files
55+
- name: Get PR info (files and author)
56+
id: get-pr-info
5757
run: |
5858
max_retries=3
5959
retry_count=0
6060
changed_files=""
6161
api_response=""
62-
62+
6363
# 获取PR编号(workflow_dispatch时需要手动输入)
6464
PR_NUMBER="${{ github.event.inputs.pr_number }}"
65-
65+
6666
if [ -z "$PR_NUMBER" ]; then
6767
echo "Error: PR number is required"
6868
exit 1
6969
fi
70-
70+
71+
echo "Fetching PR info for #$PR_NUMBER..."
72+
73+
# 获取PR的详细信息(包括作者)
74+
pr_response=$(curl -s \
75+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
76+
-H "Accept: application/vnd.github.v3+json" \
77+
"https://api.github.com/repos/RT-Thread/rt-thread/pulls/$PR_NUMBER")
78+
79+
# 获取PR作者的GitHub用户名
80+
PR_AUTHOR=$(jq -r '.user.login' <<<"$pr_response")
81+
echo "PR Author: $PR_AUTHOR"
82+
83+
# 使用GitHub noreply邮箱格式
84+
PR_AUTHOR_EMAIL="${PR_AUTHOR}+github[bot]@noreply.github.com"
85+
86+
echo "pr_author=$PR_AUTHOR" >> $GITHUB_OUTPUT
87+
echo "pr_author_email=$PR_AUTHOR_EMAIL" >> $GITHUB_OUTPUT
88+
7189
echo "Fetching changed files for PR #$PR_NUMBER..."
72-
90+
7391
while [ $retry_count -lt $max_retries ]; do
7492
# 使用一个curl调用同时获取响应内容和状态码
7593
api_response=$(curl -s -w "\n%{http_code}" \
7694
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
7795
-H "Accept: application/vnd.github.v3+json" \
7896
"https://api.github.com/repos/RT-Thread/rt-thread/pulls/$PR_NUMBER/files")
79-
97+
8098
# 分离HTTP状态码和响应内容
8199
http_status=$(echo "$api_response" | tail -1)
82100
api_response=$(echo "$api_response" | sed '$d')
83-
101+
84102
echo "HTTP Status: $http_status"
85-
103+
86104
# 检查HTTP状态码
87105
if [ "$http_status" -ne 200 ]; then
88106
echo "Retry $((retry_count+1)): HTTP $http_status - API response error"
@@ -91,7 +109,7 @@ jobs:
91109
((retry_count++))
92110
continue
93111
fi
94-
112+
95113
# 验证响应是否为有效JSON且包含文件数组
96114
if jq -e 'if type=="array" then .[0].filename else empty end' <<<"$api_response" >/dev/null 2>&1; then
97115
changed_files=$(jq -r '.[].filename' <<<"$api_response")
@@ -103,18 +121,18 @@ jobs:
103121
((retry_count++))
104122
fi
105123
done
106-
124+
107125
if [ -z "$changed_files" ]; then
108126
echo "Error: Failed to get changed files after $max_retries attempts"
109127
echo "Final API Response: $api_response"
110128
exit 1
111129
fi
112-
130+
113131
# 将文件列表转换为逗号分隔格式
114132
changed_files_comma=$(echo "$changed_files" | tr '\n' ',' | sed 's/,$//')
115-
133+
116134
echo "Successfully fetched $(echo "$changed_files" | wc -l) changed files"
117-
135+
118136
# 设置输出
119137
echo "all_changed_files=$changed_files_comma" >> $GITHUB_OUTPUT
120138
echo "changed_files_count=$(echo "$changed_files" | wc -l)" >> $GITHUB_OUTPUT
@@ -123,7 +141,7 @@ jobs:
123141
id: find-files
124142
run: |
125143
# 获取PR中修改的文件
126-
CHANGED_FILES="${{ steps.get-pr-files.outputs.all_changed_files }}"
144+
CHANGED_FILES="${{ steps.get-pr-info.outputs.all_changed_files }}"
127145
128146
# 将逗号分隔的文件列表转换为换行分隔
129147
CHANGED_FILES_LINES=$(echo "$CHANGED_FILES" | tr ',' '\n')
@@ -250,13 +268,22 @@ jobs:
250268
- name: Commit and push changes
251269
if: steps.check-changes.outputs.has_changes == 'true'
252270
run: |
253-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
254-
git config --local user.name "github-actions[bot]"
255-
271+
# 使用PR作者作为commit author,避免CLA检查失败
272+
# CLA检查只识别PR作者(已签署CLA),而不识别github-actions[bot]
273+
PR_AUTHOR="${{ steps.get-pr-info.outputs.pr_author }}"
274+
PR_AUTHOR_EMAIL="${{ steps.get-pr-info.outputs.pr_author_email }}"
275+
276+
git config --local user.email "$PR_AUTHOR_EMAIL"
277+
git config --local user.name "$PR_AUTHOR"
278+
279+
# 使用GIT_AUTHOR环境变量让commit以贡献者名义提交
280+
export GIT_AUTHOR_NAME="$PR_AUTHOR"
281+
export GIT_AUTHOR_EMAIL="$PR_AUTHOR_EMAIL"
282+
256283
git add -A
257284
git commit -m "style: format code with clang-format [skip ci]"
258285
git push origin HEAD:${{ github.event.inputs.branch }}
259-
286+
260287
echo "✅ 代码格式化完成并已推送到分支 ${{ github.event.inputs.branch }}"
261288
262289
- name: Summary

.github/workflows/pr_format_bot.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,38 @@ jobs:
2020
- name: Check if first commit and add comment
2121
env:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
24+
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
25+
PR_NUMBER: ${{ github.event.pull_request.number }}
26+
PR_ACTION: ${{ github.event.action }}
27+
REPO_FULL_NAME: ${{ github.repository }}
2328
run: |
24-
echo "Event action: ${{ github.event.action }}"
29+
echo "Event action: $PR_ACTION"
2530
2631
# 获取 PR 的提交信息
2732
commits=$(curl -s \
2833
-H "Accept: application/vnd.github.v3+json" \
2934
-H "Authorization: Bearer $GITHUB_TOKEN" \
30-
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits")
35+
"https://api.github.com/repos/${REPO_FULL_NAME}/pulls/${PR_NUMBER}/commits")
3136
3237
# 检查 API 响应是否为数组
3338
if echo "$commits" | jq -e 'type == "array"' > /dev/null; then
3439
commit_count=$(echo "$commits" | jq '. | length')
3540
echo "PR commit count: $commit_count"
3641
3742
should_comment=false
38-
if [ "${{ github.event.action }}" = "opened" ]; then
43+
if [ "$PR_ACTION" = "opened" ]; then
3944
should_comment=true
40-
elif [ "${{ github.event.action }}" = "synchronize" ] && [ "$commit_count" -eq 1 ]; then
45+
elif [ "$PR_ACTION" = "synchronize" ] && [ "$commit_count" -eq 1 ]; then
4146
should_comment=true
4247
fi
4348
4449
if [ "$should_comment" = true ]; then
4550
echo "Adding format notification comment..."
4651
4752
# 构建工作流链接
48-
branch="${{ github.event.pull_request.head.ref }}"
49-
fork_repo="${{ github.event.pull_request.head.repo.full_name }}"
53+
branch="$PR_HEAD_REF"
54+
fork_repo="$PR_HEAD_REPO"
5055
workflow_url="https://github.com/${fork_repo}/actions/workflows/pr_clang_format.yml"
5156
direct_link="${workflow_url}?branch=${branch}"
5257
@@ -69,7 +74,7 @@ jobs:
6974
"- 设置需排除的文件/目录(目录请以\"/\"结尾)"
7075
"Set files/directories to exclude (directories should end with \"/\")"
7176
"- 将目标分支设置为 \ Set the target branch to:**\`${branch}\`**"
72-
"- 设置PR number为 \ Set the PR number to:**\`${{ github.event.pull_request.number }}\`**"
77+
"- 设置PR number为 \ Set the PR number to:**\`${PR_NUMBER}\`**"
7378
""
7479
"3. **等待工作流完成 | Wait for the workflow to complete**"
7580
"格式化后的代码将自动推送至你的分支。"
@@ -92,7 +97,7 @@ jobs:
9297
existing_comment=$(curl -s \
9398
-H "Accept: application/vnd.github.v3+json" \
9499
-H "Authorization: Bearer $GITHUB_TOKEN" \
95-
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \
100+
"https://api.github.com/repos/${REPO_FULL_NAME}/issues/${PR_NUMBER}/comments" | \
96101
jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- PR Format Notification Comment -->"))) | {id: .id, body: .body} | @base64')
97102
98103
# 使用 jq 安全地构建 JSON 负载
@@ -107,7 +112,7 @@ jobs:
107112
-H "Accept: application/vnd.github.v3+json" \
108113
-H "Authorization: Bearer $GITHUB_TOKEN" \
109114
-d "$json_payload" \
110-
"https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id")
115+
"https://api.github.com/repos/${REPO_FULL_NAME}/issues/comments/$comment_id")
111116
else
112117
# 创建新评论
113118
echo "Creating new comment"
@@ -116,7 +121,7 @@ jobs:
116121
-H "Accept: application/vnd.github.v3+json" \
117122
-H "Authorization: Bearer $GITHUB_TOKEN" \
118123
-d "$json_payload" \
119-
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments")
124+
"https://api.github.com/repos/${REPO_FULL_NAME}/issues/${PR_NUMBER}/comments")
120125
fi
121126
122127
# 提取 HTTP 状态码和响应体

bsp/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,15 @@ This document is based on the RT-Thread mainline repository and categorizes the
773773

774774
| BSP Name | GPIO | UART | ADC | I2C | SPI | WDT |
775775
|----------|------|------|-----|-----|-----|-----|
776-
| [e901](xuantie/smartl/e901) | - || - | - | - | - |
776+
| [e901plus](xuantie/smartl/e901plus) | - || - | - | - | - |
777777
| [e902](xuantie/smartl/e902) | - || - | - | - | - |
778778
| [e906](xuantie/smartl/e906) | - || - | - | - | - |
779779
| [e907](xuantie/smartl/e907) | - || - | - | - | - |
780780
| [c906 (RT-Smart)](xuantie/virt64/c906) | - || - | - | - | - |
781781
| [c907](xuantie/xiaohui/c907) | - || - | - | - | - |
782782
| [c908](xuantie/xiaohui/c908) | - || - | - | - | - |
783-
| [c910](xuantie/xiaohui/c910) | - || - | - | - | - |
783+
| [c908x](xuantie/xiaohui/c908x) | - || - | - | - | - |
784+
| [c920](xuantie/xiaohui/c920) | - || - | - | - | - |
784785
| [r908](xuantie/xiaohui/r908) | - || - | - | - | - |
785786
| [r910](xuantie/xiaohui/r910) | - || - | - | - | - |
786787
| [r920](xuantie/xiaohui/r920) | - || - | - | - | - |

bsp/stm32/libraries/HAL_Drivers/drivers/drv_fdcan.c

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* 2020-02-24 heyuan the first version
99
* 2020-08-17 malongwei Fix something
1010
* 2025-10-27 pandafeng Fix some bugs
11+
* 2026-03-16 sayaZhao Fix some bugs
1112
*/
1213

1314
#include "drv_fdcan.h"
@@ -54,12 +55,30 @@ static const stm32_fdcan_timing_t st_FDCAN_ArbTiming[] =
5455
static const stm32_fdcan_timing_t st_FDCAN_DataTiming[] =
5556
{
5657
{CAN1MBaud * 8, {1, 3, 1, 1, 0}}, /* 8Mbps */
58+
{CAN1MBaud * 5, {1, 5, 2, 1, 0}}, /* 5Mbps */
5759
{CAN500kBaud *8, {1, 7, 2, 1, 0}}, /* 4Mbps */
5860
{CAN250kBaud * 8, {4, 3, 1, 1, 0}}, /* 2Mbps */
5961
{CAN125kBaud *8, {1, 31, 8, 1, 0}}, /* 1Mkbps */
6062
{CAN100kBaud*8, {2, 19, 5, 1, 0}}, /* 800kbps */
6163
{CAN50kBaud *8, {5, 15, 4, 1, 0}}, /* 400kbps */
6264
};
65+
66+
/**
67+
* @brief Convert CAN-FD DLC (Data Length Code) back to actual frame length
68+
* @param dlc DLC code (0~15)
69+
* @return Actual length in bytes (0~64)
70+
*/
71+
static uint8_t dlc_to_length(uint32_t dlc)
72+
{
73+
const uint8_t dlc_to_len_table[16] = {
74+
0, 1, 2, 3, 4, 5, 6, 7,
75+
8, 12, 16, 20, 24, 32, 48, 64
76+
};
77+
78+
if (dlc > 15) return 8;
79+
return dlc_to_len_table[dlc];
80+
}
81+
6382
/**
6483
* @brief Convert CAN-FD frame length to DLC (Data Length Code)
6584
*
@@ -208,8 +227,18 @@ static rt_err_t _inline_can_config(struct rt_can_device *can, struct can_configu
208227
{
209228
return -RT_ERROR;
210229
}
230+
/* Transceiver Delay Compensation */
231+
#ifdef RT_CAN_USING_CANFD
232+
if (cfg->enable_canfd)
233+
{
234+
HAL_FDCAN_ConfigTxDelayCompensation(&pdrv_can->fdcanHandle, 0x0C, 0x00);
235+
HAL_FDCAN_EnableTxDelayCompensation(&pdrv_can->fdcanHandle);
236+
}
237+
#endif
211238
/* default filter config */
212239
HAL_FDCAN_ConfigFilter(&pdrv_can->fdcanHandle , &pdrv_can->FilterConfig);
240+
/* FIFO RX INT */
241+
HAL_FDCAN_ActivateNotification(&pdrv_can->fdcanHandle, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);
213242
/*init fdcan tx header*/
214243
pdrv_can->TxHeader.Identifier = 0x000000;
215244
pdrv_can->TxHeader.IdType = FDCAN_EXTENDED_ID;
@@ -352,7 +381,7 @@ static rt_err_t _inline_can_control(struct rt_can_device *can, int cmd, void *ar
352381
argval = (rt_uint32_t) arg;
353382
uint32_t arb_idx = _inline_get_ArbBaudIndex(argval);
354383
if (arb_idx == (uint32_t) -1) {
355-
return -RT_ERROR;
384+
return -RT_ERROR;
356385
}
357386
if (argval != pdrv_can->device.config.baud_rate) {
358387
pdrv_can->device.config.baud_rate = argval;
@@ -452,6 +481,12 @@ static int _inline_can_sendmsg(struct rt_can_device *can, const void *buf, rt_ui
452481
pdrv_can->TxHeader.FDFormat = FDCAN_CLASSIC_CAN;
453482
}
454483

484+
if (pmsg->brs == 1) {
485+
pdrv_can->TxHeader.BitRateSwitch = FDCAN_BRS_ON;
486+
} else {
487+
pdrv_can->TxHeader.BitRateSwitch = FDCAN_BRS_OFF;
488+
}
489+
455490
if(HAL_FDCAN_AddMessageToTxBuffer(&pdrv_can->fdcanHandle, &pdrv_can->TxHeader, pmsg->data, FDCAN_TX_BUFFER0 + box_num) != HAL_OK)
456491
{
457492
return -RT_ERROR;
@@ -499,13 +534,14 @@ static int _inline_can_recvmsg(struct rt_can_device *can, void *buf, rt_uint32_t
499534
}
500535
pmsg->id = pdrv_can->RxHeader.Identifier;
501536

502-
pmsg->len = pdrv_can->RxHeader.DataLength;
503-
pmsg->hdr_index = pdrv_can->RxHeader.FilterIndex;
537+
uint32_t actual_dlc = pdrv_can->RxHeader.DataLength;
538+
pmsg->len = dlc_to_length(actual_dlc);
504539

505-
#ifdef RT_CAN_USING_CANFD
540+
pmsg->hdr_index = pdrv_can->RxHeader.FilterIndex;
541+
#ifdef RT_CAN_USING_CANFD
506542
pmsg->fd_frame = (pdrv_can->RxHeader.FDFormat >> 16) && 0x20;
507543
pmsg->brs = (pdrv_can->RxHeader.BitRateSwitch >> 16) && 0x10;
508-
#endif
544+
#endif
509545

510546
return sizeof(struct rt_can_msg);
511547
}

bsp/xuantie/libraries/xuantie_libraries/SConscript

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ cwd = GetCurrentDir()
77
objs = []
88
list = os.listdir(cwd)
99

10+
# Include source files in current directory
11+
src = []
12+
if GetDepend(['RT_USING_SMP']):
13+
src += ['smp_demo.c']
14+
if src:
15+
objs = objs + DefineGroup('xuantie_libraries', src, depend=[''])
16+
17+
# Include subdirectories with SConscript
1018
for d in list:
1119
path = os.path.join(cwd, d)
1220
if os.path.isfile(os.path.join(path, 'SConscript')):

0 commit comments

Comments
 (0)