Skip to content

Commit b43f0e7

Browse files
CuttySark1869QY7
andauthored
[bsp][tms320f28379d] Fix compile ti (#6254)
* compile_ok Issues fixed: (1) update .config: select FINSH_USING_SYMTAB (2) add rt_size_t in rtconfig_project.h (3) fix finsh problems of using sym table (4) update .project to include ipc source codes. Todo list: (1) automate the build source selection of ccs and reconcile it with scons * change compiler * msh can run now the key step is to swap the order of rt_interrupt_nest -- and RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,()) in irq.c. This is an improvised solution and an issue has been raised. * Update 2837x_FLASH_lnk_cpu1.cmd The original one is also fine. Just to make it more rigorous since FSymTab is in data section. * update readme.md Complier selection and maintainer update. Co-authored-by: YuQi <[email protected]>
1 parent 5b8a367 commit b43f0e7

File tree

13 files changed

+178
-400
lines changed

13 files changed

+178
-400
lines changed

bsp/tms320f28379d/.config

Lines changed: 43 additions & 263 deletions
Large diffs are not rendered by default.

bsp/tms320f28379d/.cproject

Lines changed: 64 additions & 61 deletions
Large diffs are not rendered by default.

bsp/tms320f28379d/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.launches/

bsp/tms320f28379d/.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
<locationURI>PARENT-2-PROJECT_LOC/components/drivers/serial/serial.c</locationURI>
5252
</link>
5353
<link>
54-
<name>DeviceDrivers/src</name>
54+
<name>DeviceDrivers/ipc</name>
5555
<type>2</type>
56-
<locationURI>PARENT-2-PROJECT_LOC/components/drivers/src</locationURI>
56+
<locationURI>PARENT-2-PROJECT_LOC/components/drivers/ipc</locationURI>
5757
</link>
5858
</linkedResources>
5959
</projectDescription>

bsp/tms320f28379d/.settings/org.eclipse.core.resources.prefs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
eclipse.preferences.version=1
2-
encoding//Debug/DeviceDrivers/src/subdir_rules.mk=UTF-8
3-
encoding//Debug/DeviceDrivers/src/subdir_vars.mk=UTF-8
2+
encoding//Debug/DeviceDrivers/ipc/subdir_rules.mk=UTF-8
3+
encoding//Debug/DeviceDrivers/ipc/subdir_vars.mk=UTF-8
44
encoding//Debug/DeviceDrivers/subdir_rules.mk=UTF-8
55
encoding//Debug/DeviceDrivers/subdir_vars.mk=UTF-8
66
encoding//Debug/Kernel/subdir_rules.mk=UTF-8

bsp/tms320f28379d/2837x_FLASH_lnk_cpu1.cmd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ PAGE 0 : /* Program Memory */
66
/* BEGIN is used for the "boot to Flash" bootloader mode */
77

88
BEGIN : origin = 0x080000, length = 0x000002
9-
RAMM0 : origin = 0x000122, length = 0x0002DE
10-
RAMD0 : origin = 0x00B000, length = 0x000800
119
RAMLS0 : origin = 0x008000, length = 0x000800
1210
RAMLS1 : origin = 0x008800, length = 0x000800
1311
RAMLS2 : origin = 0x009000, length = 0x000800
@@ -39,6 +37,8 @@ PAGE 1 : /* Data Memory */
3937
BOOT_RSVD : origin = 0x000002, length = 0x000120 /* Part of M0, BOOT rom will use this for stack */
4038
RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
4139
RAMD1 : origin = 0x00B800, length = 0x000800
40+
RAMM0 : origin = 0x000122, length = 0x0002DE
41+
RAMD0 : origin = 0x00B000, length = 0x000800
4242

4343
RAMLS5 : origin = 0x00A800, length = 0x000800
4444

@@ -94,7 +94,11 @@ SECTIONS
9494
PAGE = 0, ALIGN(4)
9595
#endif
9696
#endif
97-
97+
98+
FSymTab : > RAMD0, PAGE = 1, ALIGN(4)
99+
LOAD_START(___fsymtab_start)
100+
LOAD_END(___fsymtab_end)
101+
98102
/* Allocate uninitalized data sections: */
99103
.stack : > RAMM1 PAGE = 1
100104
.ebss : >> RAMLS5 | RAMGS0 | RAMGS1 PAGE = 1

bsp/tms320f28379d/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ TMS320F28379D 程序的编译和下载要使用的是 TI 官方提供的 Code Co
4646
![import_dia](figures/import_dia.png)
4747

4848
### 2.2 编译工程
49-
使用 CCS 内置的 C 编译器可以进行工程的编译,本文使用的是 Code Composer Studio 8.1.0 和 TI v18.1.3.LTS 编译器的组合。
50-
51-
导入工程后,在右边的 Project Explorer 列表里可以看到刚刚导入的 rt-thread 工程,右键点击,在弹出的菜单中选择 Build Project 即可开始编译。
49+
使用 CCS 内置的 C 编译器可以进行工程的编译。CCS 8 需要使用 TI v18.1.3.LTS 编译器。CCS 10 需要使用 TI v20.2.1.LTS 及以上版本编译器(v20.2.0.LTS及以下版本的编译器有bug编译时会出现segmentation fault)。本文使用的是 Code Composer Studio 10.1.1 和 TI v20.2.4.LTS 编译器的组合(已经配置在工程文件中)。导入工程后,在右边的 Project Explorer 列表里可以看到刚刚导入的 rt-thread 工程,右键点击,在弹出的菜单中选择 Build Project 即可开始编译。
5250

5351
![build](figures/build.png)
5452

@@ -70,9 +68,9 @@ TMS320F28379D 程序的编译和下载要使用的是 TI 官方提供的 Code Co
7068
```bash
7169
\ | /
7270
- RT - Thread Operating System
73-
/ | \ 4.0.1 build Feb 21 2019
74-
2006 - 2019 Copyright by rt-thread team
75-
finsh >
71+
/ | \ 4.1.1 build Jul 4 2022 22:33:37
72+
2006 - 2022 Copyright by RT-Thread team
73+
msh >
7674
```
7775

7876
## 4. 注意事项
@@ -97,6 +95,8 @@ finsh >
9795
## 6. 联系人信息
9896

9997
维护人:xuzhuoyi < [email protected] >
98+
99+
guyunjie < [email protected] >
100100

101101
## 7. 参考
102102

bsp/tms320f28379d/drivers/board.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2009-09-22 Bernard add board.h to this bsp
99
* 2018-09-02 xuzhuoyi modify for TMS320F28379D version
10+
* 2022-06-21 guyunjie fix bugs in trap_rtosint and enable interrupt nesting
1011
*/
1112
#include <rtthread.h>
1213
#include "board.h"
1314
#include "drv_sci.h"
1415
#include "F28x_Project.h"
1516

17+
#ifndef RT_USING_SMP
18+
extern volatile rt_uint8_t rt_interrupt_nest;
19+
#endif
20+
1621
extern rt_uint32_t rt_thread_switch_interrupt_flag;
1722

1823
extern interrupt void RTOSINT_Handler();
1924

2025
void trap_rtosint()
2126
{
2227
if(rt_thread_switch_interrupt_flag)
23-
asm(" trap #16");
28+
{
29+
/* only do pendsv at the end of the last level of interrupt nesting,
30+
* so that threads do not preempt any isrs. */
31+
if(rt_interrupt_nest == 1)
32+
{
33+
/* rt_interrupt_leave_hook is called before rt_interrupt_nest --
34+
* in rt_interrupt_leave. We need to do this manually here to indicate
35+
* that all isrs have been cleared before we switch to thread. */
36+
rt_interrupt_nest --;
37+
asm(" trap #16");
38+
/* increment rt_interrupt_nest to compensate for the previous decrement. */
39+
rt_interrupt_nest ++;
40+
}
41+
}
2442
}
2543

2644
/**
@@ -30,6 +48,9 @@ void trap_rtosint()
3048
interrupt void cpu_timer2_isr(void)
3149
{
3250
CpuTimer2Regs.TCR.all = 0xC000;
51+
52+
ALLOW_ISR_PREEMPT();
53+
3354
/* enter interrupt */
3455
rt_interrupt_enter();
3556

@@ -76,5 +97,6 @@ void rt_hw_board_init()
7697
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
7798
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
7899
#endif
100+
/*this hook may cause problem for reasons unknown*/
79101
rt_interrupt_leave_sethook((void (*)(void))trap_rtosint);
80102
}

bsp/tms320f28379d/drivers/drv_sci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -181,6 +181,8 @@ static const struct rt_uart_ops c28x_uart_ops =
181181
//
182182
interrupt void sciaRxFifoIsr(void)
183183
{
184+
ALLOW_ISR_PREEMPT();
185+
184186
/* enter interrupt */
185187
rt_interrupt_enter();
186188

bsp/tms320f28379d/rtconfig.h

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define RT_THREAD_PRIORITY_MAX 8
1616
#define RT_TICK_PER_SECOND 100
1717
#define RT_USING_HOOK
18+
#define RT_HOOK_USING_FUNC_PTR
1819
#define RT_USING_IDLE_HOOK
1920
#define RT_IDLE_HOOK_LIST_SIZE 4
2021
#define IDLE_THREAD_STACK_SIZE 1024
@@ -45,71 +46,53 @@
4546
#define RT_USING_CONSOLE
4647
#define RT_CONSOLEBUF_SIZE 128
4748
#define RT_CONSOLE_DEVICE_NAME "scia"
48-
#define RT_VER_NUM 0x40100
49+
#define RT_VER_NUM 0x40101
4950
#define ARCH_TIDSP
5051
#define ARCH_TIDSP_C28X
5152
#define ARCH_CPU_STACK_GROWS_UPWARD
5253

5354
/* RT-Thread Components */
5455

5556
#define RT_USING_COMPONENTS_INIT
56-
57-
/* C++ features */
58-
59-
60-
/* Command shell */
61-
62-
#define RT_USING_FINSH
6357
#define RT_USING_MSH
58+
#define RT_USING_FINSH
6459
#define FINSH_USING_MSH
6560
#define FINSH_THREAD_NAME "tshell"
66-
#define FINSH_THREAD_PRIORITY 6
61+
#define FINSH_THREAD_PRIORITY 4
6762
#define FINSH_THREAD_STACK_SIZE 4096
6863
#define FINSH_USING_HISTORY
6964
#define FINSH_HISTORY_LINES 5
65+
#define FINSH_USING_SYMTAB
7066
#define FINSH_CMD_SIZE 80
7167
#define MSH_USING_BUILT_IN_COMMANDS
68+
#define FINSH_USING_DESCRIPTION
7269
#define FINSH_ARG_MAX 10
7370

74-
/* Device virtual file system */
75-
76-
7771
/* Device Drivers */
7872

7973
#define RT_USING_DEVICE_IPC
80-
#define RT_PIPE_BUFSZ 512
8174
#define RT_USING_SERIAL
8275
#define RT_USING_SERIAL_V1
83-
#define RT_SERIAL_USING_DMA
8476
#define RT_SERIAL_RB_BUFSZ 64
8577
#define RT_USING_PIN
8678

8779
/* Using USB */
8880

8981

90-
/* POSIX layer and C standard library */
82+
/* C/C++ and POSIX layer */
9183

92-
#define RT_LIBC_USING_TIME
9384
#define RT_LIBC_DEFAULT_TIMEZONE 8
9485

9586
/* POSIX (Portable Operating System Interface) layer */
9687

9788

98-
/* Network */
99-
100-
/* Socket abstraction layer */
101-
102-
103-
/* Network interface device */
89+
/* Interprocess Communication (IPC) */
10490

10591

106-
/* light weight TCP/IP stack */
92+
/* Socket is in the 'Network' category */
10793

10894

109-
/* AT commands */
110-
111-
112-
/* VBUS(Virtual Software BUS) */
95+
/* Network */
11396

11497

11598
/* Utilities */
@@ -142,44 +125,20 @@
142125

143126
/* multimedia packages */
144127

145-
/* LVGL: powerful and easy-to-use embedded GUI library */
146-
147-
148-
/* u8g2: a monochrome graphic library */
149-
150-
151-
/* PainterEngine: A cross-platform graphics application framework written in C language */
152-
153128

154129
/* tools packages */
155130

156131

157132
/* system packages */
158133

159-
/* rt_kprintf: enhanced rt_kprintf packages */
160-
161-
162-
/* acceleration: Assembly language or algorithmic acceleration packages */
163-
164-
165-
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
166-
167-
168-
/* Micrium: Micrium software products porting for RT-Thread */
169-
170134

171135
/* peripheral libraries and drivers */
172136

173137

174-
/* AI packages */
175-
176-
177138
/* miscellaneous packages */
178139

179-
/* samples: kernel and components samples */
180-
181140

182-
/* entertainment: terminal games and other interesting software packages */
141+
/* samples: kernel and components samples */
183142

184143
#include "rtconfig_project.h"
185144

bsp/tms320f28379d/rtconfig_project.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ typedef unsigned char rt_uint8_t; /**< 8bit unsigned inte
1919
typedef unsigned short rt_uint16_t; /**< 16bit unsigned integer type */
2020
typedef unsigned long rt_uint32_t; /**< 32bit unsigned integer type */
2121
typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
22+
typedef unsigned long rt_size_t; /**< Type for size number */
23+
24+
/* C28X automatically disable interrupt in interrupt service routine.
25+
* We need to enable manually to allow for interrupt nesting by calling
26+
* this macro at the start of preemptible interrupt service routines*/
27+
#define ALLOW_ISR_PREEMPT() __asm(" CLRC INTM")
2228

2329
#endif

libcpu/ti-dsp/c28x/context.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; 2019-06-17 zhaoxiaowei fix bugs of old c28x interrupt api.
1010
; 2019-07-03 zhaoxiaowei add _rt_hw_calc_csb function to support __rt_ffs.
1111
; 2019-12-05 xiaolifan add support for hardware fpu32
12-
;
12+
; 2022-06-21 guyunjie trim pendsv (RTOSINT_Handler)
1313

1414
.ref _rt_interrupt_to_thread
1515
.ref _rt_interrupt_from_thread
@@ -191,8 +191,8 @@ _reswitch2:
191191

192192
.asmfunc
193193
_RTOSINT_Handler:
194-
; disable interrupt to protect context switch
195-
DINT
194+
; disable interrupt to protect context switch
195+
; DINT ;this is done by hardware so not needed
196196

197197
; get rt_thread_switch_interrupt_flag
198198
MOV AR0, #_rt_thread_switch_interrupt_flag
@@ -248,8 +248,8 @@ switch_to_thread:
248248
RT_CTX_RESTORE ; pop r4 - r11 register
249249

250250
rtosint_exit:
251-
; restore interrupt
252-
EINT
251+
; do not restore interrupt here: to be restored according to the
252+
; switched-to context during IRET (automaticlly by hardware)
253253

254254
IRET
255255
.endasmfunc

src/irq.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2021, RT-Thread Development Team
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -11,6 +11,7 @@
1111
* 2018-11-22 Jesven rt_interrupt_get_nest function add disable irq
1212
* 2021-08-15 Supperthomas fix the comment
1313
* 2022-01-07 Gabriel Moving __on_rt_xxxxx_hook to irq.c
14+
* 2022-07-04 Yunjie fix RT_DEBUG_LOG
1415
*/
1516

1617
#include <rthw.h>
@@ -87,7 +88,7 @@ void rt_interrupt_enter(void)
8788
rt_hw_interrupt_enable(level);
8889

8990
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq current nest:%d\n",
90-
rt_interrupt_nest));
91+
(rt_int32_t)rt_interrupt_nest));
9192
}
9293
RTM_EXPORT(rt_interrupt_enter);
9394

@@ -104,7 +105,7 @@ void rt_interrupt_leave(void)
104105
rt_base_t level;
105106

106107
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq is going to leave, irq current nest:%d\n",
107-
rt_interrupt_nest));
108+
(rt_int32_t)rt_interrupt_nest));
108109

109110
level = rt_hw_interrupt_disable();
110111
RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,());

0 commit comments

Comments
 (0)