Skip to content

Commit d22fde6

Browse files
authored
Merge pull request #4193 from greedyhao/bluetrum
[bsp][bluetrum] fix context switch error
2 parents 9a59737 + 08aa4e5 commit d22fde6

File tree

5 files changed

+34
-24
lines changed

5 files changed

+34
-24
lines changed

bsp/bluetrum/ab32vg1-ab-prougen/.config

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ CONFIG_RT_USING_LIBC=y
288288
# CONFIG_PKG_USING_PDULIB is not set
289289
# CONFIG_PKG_USING_BTSTACK is not set
290290
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
291+
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
291292

292293
#
293294
# security packages
@@ -437,6 +438,8 @@ CONFIG_RT_USING_LIBC=y
437438
# CONFIG_PKG_USING_QKEY is not set
438439
# CONFIG_PKG_USING_RS485 is not set
439440
# CONFIG_PKG_USING_NES is not set
441+
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
442+
# CONFIG_PKG_USING_VDEVICE is not set
440443

441444
#
442445
# miscellaneous packages
@@ -495,13 +498,13 @@ CONFIG_RT_USING_LIBC=y
495498
# Onboard Peripheral Drivers
496499
#
497500
CONFIG_BSP_USING_USB_TO_USART=y
501+
CONFIG_BSP_USING_AUDIO=y
502+
CONFIG_BSP_USING_AUDIO_PLAY=y
498503

499504
#
500505
# On-chip Peripheral Drivers
501506
#
502507
CONFIG_BSP_USING_UART0=y
503-
CONFIG_BSP_USING_AUDIO=y
504-
CONFIG_BSP_USING_AUDIO_PLAY=y
505508

506509
#
507510
# Board extended module Drivers

bsp/bluetrum/ab32vg1-ab-prougen/link.lds

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Define the flash max size */
2-
__max_flash_size = 768k;
2+
__max_flash_size = 1024k;
33

4-
__data_ram_size = 5k;
4+
__data_ram_size = 8k;
55
__stack_ram_size = 4k;
6-
__comm_ram_size = 86k;
6+
__comm_ram_size = 83k;
77
__heap_ram_size = 29k;
88

99
__base = 0x10000000;
@@ -34,13 +34,8 @@ SECTIONS
3434
} > init
3535

3636
.ram1 __ram1_vma : {
37-
*hal_drivers**.o(.text*)
38-
*hal_libraries*ab32vg1_hal**.o(.text*)
3937
*components*drivers**.o(.text* .rodata*)
40-
*components*libc**.o(.text*)
41-
*ab32vg1_hal_msp.o(.text*)
42-
*components.o(.text* .rodata*)
43-
*ipc.o(.text* .rodata*)
38+
*device.o(.text*)
4439
. = ALIGN(32);
4540
} > ram1 AT > flash
4641

@@ -65,8 +60,14 @@ SECTIONS
6560
} > ram1 AT > flash
6661

6762
.comm : {
68-
KEEP(*(.vector))
69-
EXCLUDE_FILE (*romfs.o *lib_a**.o) *(.text*)
63+
KEEP (*(.vector))
64+
EXCLUDE_FILE (*hal_drivers**.o *ab32vg1_hal**.o *components*finsh**.o *components*libc**.o *rt-thread*src**.o *kernel*src**.o *romfs.o *lib_a**.o) *(.text*)
65+
*idle.o (.text*)
66+
*ipc.o (.text*)
67+
*irq.o (.text*)
68+
*scheduler.o (.text*)
69+
*timer.o (.text*)
70+
*kservice.o (.text*)
7071
EXCLUDE_FILE (*romfs.o *lib_a**.o) *(.rodata*)
7172
*(.srodata*)
7273
*(.rela*)
@@ -75,12 +76,6 @@ SECTIONS
7576
. = ALIGN(512);
7677
} > comm AT > flash
7778

78-
.flash : {
79-
*romfs.o *(.text* .rodata*)
80-
*lib_a**.o *(.text* .rodata*)
81-
. = ALIGN(512);
82-
} > flash
83-
8479
.bss (NOLOAD):
8580
{
8681
__bss_start = .;
@@ -99,11 +94,17 @@ SECTIONS
9994
} > stack
10095
__irq_stack_size = __irq_stack - __irq_stack_start;
10196

102-
.heap : {
97+
.heap (NOLOAD) : {
10398
__heap_start = .;
10499
. = __heap_ram_size;
105100
__heap_end = .;
106101
} > heap
102+
103+
.flash : {
104+
*(.text*)
105+
*(.rodata*)
106+
. = ALIGN(512);
107+
} > flash
107108
}
108109

109110
/* Calc the lma */

bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@
169169
/* Onboard Peripheral Drivers */
170170

171171
#define BSP_USING_USB_TO_USART
172+
#define BSP_USING_AUDIO
173+
#define BSP_USING_AUDIO_PLAY
172174

173175
/* On-chip Peripheral Drivers */
174176

175177
#define BSP_USING_UART0
176-
#define BSP_USING_AUDIO
177-
#define BSP_USING_AUDIO_PLAY
178178

179179
/* Board extended module Drivers */
180180

bsp/bluetrum/libcpu/cpu/context_gcc.S

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ enable_int_ret:
4444

4545
/* Macro for saving task context */
4646
.macro save_context
47-
addi sp, sp, -120
47+
addi sp, sp, -124
4848

4949
/* Save Context */
5050
sw x1, 0(sp)
@@ -79,6 +79,8 @@ enable_int_ret:
7979

8080
lw a5, EPC(zero) //Saves current program counter (EPC) as task program counter
8181
sw a5, 116(sp)
82+
lw a5, EPICCON(zero)
83+
sw a5, 120(sp)
8284

8385
sw sp, rt_cur_thread_sp, a4 //store sp in preempted tasks tcb
8486
.endm
@@ -93,6 +95,8 @@ enable_int_ret:
9395
/* Load task program counter EPC*/
9496
lw a5, 116(sp)
9597
sw a5, EPC(zero)
98+
lw a5, 120(sp)
99+
sw a5, EPICCON(zero)
96100

97101
/* Restore registers,
98102
Skip global pointer because that does not change */
@@ -126,7 +130,7 @@ enable_int_ret:
126130
lw x30, 108(sp)
127131
lw x31, 112(sp)
128132

129-
addi sp, sp, 120
133+
addi sp, sp, 124
130134
mret
131135
.endm
132136

bsp/bluetrum/libcpu/cpu/cpuport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ rt_uint8_t *rt_hw_stack_init(void *tentry,
3939
stack_addr = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stack_addr, 8);
4040
stk = (rt_uint32_t *)stack_addr;
4141

42+
stk--;
43+
*stk = (rt_uint32_t)0x10003; /* Start address */
4244
stk--;
4345
*stk = (rt_uint32_t)tentry; /* Start address */
4446
stk -= 22;

0 commit comments

Comments
 (0)