Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 812c2d1

Browse files
committed
fix the critical problem; fix bootloader sp check error
1 parent 78e5389 commit 812c2d1

19 files changed

+160
-42
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

source/project_vllink_lite/vllink_lite/EWARM/GD32F350xx_booted.icf

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ define symbol __ICFEDIT_region_ROM_end__ = 0x0800FFFF;
99
define symbol __ICFEDIT_region_RAM_start__ = 0x20000004;
1010
define symbol __ICFEDIT_region_RAM_end__ = 0x20001FFF;
1111
/*-Sizes-*/
12-
define symbol __ICFEDIT_size_cstack__ = 0x400;
12+
define symbol __ICFEDIT_size_cstack__ = 0x3E0;
1313
define symbol __ICFEDIT_size_heap__ = 0x0;
1414
/**** End of ICF editor section. ###ICF###*/
1515

source/project_vllink_lite/vllink_lite/EWARM/project.ewp

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@
302302
</option>
303303
<option>
304304
<name>IExtraOptionsCheck</name>
305-
<state>1</state>
305+
<state>0</state>
306306
</option>
307307
<option>
308308
<name>IExtraOptions</name>
309-
<state>--no_unaligned_access</state>
309+
<state></state>
310310
</option>
311311
<option>
312312
<name>CCLangConformance</name>

source/project_vllink_lite/vllink_lite/config/brd_cfg_vllinklite_gd32e103.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define GPIOE_ENABLE 0
1414

1515
#define USART_STREAM_ENABLE 1
16+
#define USART_STREAM_EDA_PRIORITY vsf_prio_1 // same as VSF_USBD_CFG_EDA_PRIORITY
1617
#define USART_BUFF_SIZE 64
1718
#define USART0_ENABLE 1
1819
# define USART0_DMA_ENABLE 1

source/project_vllink_lite/vllink_lite/config/brd_cfg_vllinklite_gd32f350.h

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define GPIOF_ENABLE 0
1313

1414
#define USART_STREAM_ENABLE 1
15+
#define USART_STREAM_EDA_PRIORITY vsf_prio_1 // same as VSF_USBD_CFG_EDA_PRIORITY
1516
#define USART_BUFF_SIZE 64
1617
#define USART0_ENABLE 1
1718
# define USART0_DMA_ENABLE 1

source/project_vllink_lite/vllink_lite/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static void usrapp_config_usart(enum usart_idx_t idx, uint32_t *mode, uint32_t *
135135
vsfhal_usart_config(PERIPHERAL_UART_EXT_IDX, usrapp.usart_ext_baud, usrapp.usart_ext_mode);
136136
if (baudrate)
137137
*baudrate = usrapp.usart_ext_baud;
138-
vsfhal_usart_stream_init(PERIPHERAL_UART_EXT_IDX, PERIPHERAL_UART_EXT_PRIORITY, tx, rx);
138+
vsfhal_usart_stream_init(PERIPHERAL_UART_EXT_IDX, USART_STREAM_EDA_PRIORITY, PERIPHERAL_UART_EXT_PRIORITY, tx, rx);
139139
} else if (baudrate && *baudrate != usrapp.usart_ext_baud) {
140140
usrapp.usart_ext_baud = *baudrate;
141141
if (return_actual_baud)
@@ -162,7 +162,7 @@ static void usrapp_config_usart(enum usart_idx_t idx, uint32_t *mode, uint32_t *
162162
vsfhal_usart_config(PERIPHERAL_UART_SWO_IDX, usrapp.usart_swo_baud, usrapp.usart_swo_mode);
163163
if (baudrate)
164164
*baudrate = usrapp.usart_swo_baud;
165-
vsfhal_usart_stream_init(PERIPHERAL_UART_SWO_IDX, PERIPHERAL_UART_EXT_PRIORITY, tx, rx);
165+
vsfhal_usart_stream_init(PERIPHERAL_UART_SWO_IDX, USART_STREAM_EDA_PRIORITY, PERIPHERAL_UART_EXT_PRIORITY, tx, rx);
166166
} else if (baudrate && *baudrate != usrapp.usart_swo_baud) {
167167
usrapp.usart_swo_baud = *baudrate;
168168
if (return_actual_baud)

source/project_vllink_lite/vllink_lite_bootloader/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int main(void)
8686
uint32_t sp_addr = *(uint32_t *)(FIRMWARE_AREA_ADDR);
8787

8888
if ((app_main_addr >= FIRMWARE_AREA_ADDR) && (app_main_addr < (FIRMWARE_AREA_ADDR + FIRMWARE_AREA_SIZE_MAX)) &&
89-
(sp_addr >= FIRMWARE_SP_ADDR) && (sp_addr < (FIRMWARE_SP_ADDR + FIRMWARE_SP_SIZE_MAX))) {
89+
(sp_addr >= FIRMWARE_SP_ADDR) && (sp_addr <= (FIRMWARE_SP_ADDR + FIRMWARE_SP_SIZE_MAX))) {
9090
uint32_t (*app_main)(void) = (uint32_t(*)(void))app_main_addr;
9191
__set_MSP(sp_addr);
9292
app_main();

source/vsf/component/usb/driver/otg/dwcotg/vsf_dwcotg_dcd.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,10 @@ vsf_err_t vk_dwcotg_dcd_ep_transaction_read_buffer(vk_dwcotg_dcd_t *dwcotg_dcd,
467467
vsf_err_t vk_dwcotg_dcd_ep_transaction_enable_out(vk_dwcotg_dcd_t *dwcotg_dcd, uint_fast8_t ep, uint8_t *buffer)
468468
{
469469
VSF_USB_ASSERT(!(ep & 0x80));
470-
VSF_USB_ASSERT(ep < dwcotg_dcd->ep_num);
471-
470+
472471
uint_fast8_t ep_idx = ep;
472+
VSF_USB_ASSERT(ep_idx < dwcotg_dcd->ep_num);
473+
473474
uint_fast16_t ep_size = vk_dwcotg_dcd_ep_get_size(dwcotg_dcd, ep);
474475
struct dwcotg_dev_out_ep_regs_t *out_regs = &dwcotg_dcd->reg.dev.ep.out_regs[ep_idx];
475476

@@ -485,7 +486,7 @@ vsf_err_t vk_dwcotg_dcd_ep_transaction_set_data_size(vk_dwcotg_dcd_t *dwcotg_dcd
485486
VSF_USB_ASSERT(ep & 0x80);
486487

487488
uint_fast8_t ep_idx = ep & 0x0F;
488-
VSF_USB_ASSERT(ep < dwcotg_dcd->ep_num);
489+
VSF_USB_ASSERT(ep_idx < dwcotg_dcd->ep_num);
489490

490491
struct dwcotg_dev_in_ep_regs_t *in_regs = &dwcotg_dcd->reg.dev.ep.in_regs[ep_idx];
491492

@@ -503,7 +504,7 @@ vsf_err_t vk_dwcotg_dcd_ep_transaction_write_buffer(vk_dwcotg_dcd_t *dwcotg_dcd,
503504

504505
uint32_t data;
505506
uint_fast8_t ep_idx = ep & 0x0F;
506-
VSF_USB_ASSERT(ep < dwcotg_dcd->ep_num);
507+
VSF_USB_ASSERT(ep_idx < dwcotg_dcd->ep_num);
507508

508509
struct dwcotg_dev_in_ep_regs_t *in_regs = &dwcotg_dcd->reg.dev.ep.in_regs[ep_idx];
509510

@@ -524,9 +525,10 @@ vsf_err_t vk_dwcotg_dcd_ep_transaction_write_buffer(vk_dwcotg_dcd_t *dwcotg_dcd,
524525
uint_fast32_t vk_dwcotg_dcd_ep_get_data_size(vk_dwcotg_dcd_t *dwcotg_dcd, uint_fast8_t ep)
525526
{
526527
VSF_USB_ASSERT(!(ep & 0x80));
527-
VSF_USB_ASSERT(ep < dwcotg_dcd->ep_num);
528528

529529
uint_fast8_t ep_idx = ep;
530+
VSF_USB_ASSERT(ep_idx < dwcotg_dcd->ep_num);
531+
530532
return dwcotg_dcd->out_size[ep_idx];
531533
}
532534

@@ -757,7 +759,7 @@ void vk_dwcotg_dcd_irq(vk_dwcotg_dcd_t *dwcotg_dcd)
757759
//case RXSTAT_GOUT_NAK:
758760
//case RXSTAT_SETUP_COMP:
759761
default:
760-
VSF_HAL_ASSERT(false);
762+
//VSF_HAL_ASSERT(false);
761763
break;
762764
}
763765

source/vsf_private/hal/driver/GigaDevice/GD32E10X/common/usart.c

+71-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "io.h"
77
#include "dma.h"
88

9+
#if USART_STREAM_ENABLE
10+
# include "vsf.h" // use eda
11+
#endif
12+
913
/*============================ MACROS ========================================*/
1014

1115
#ifndef USART_BUFF_SIZE
@@ -19,6 +23,7 @@ typedef struct usart_control_t {
1923
#if USART_STREAM_ENABLE
2024
vsf_stream_t *tx;
2125
vsf_stream_t *rx;
26+
vsf_eda_t eda;
2227
#endif
2328
void (*ontx)(void *);
2429
void (*onrx)(void *);
@@ -549,11 +554,10 @@ ROOT void TIMER6_IRQHandler(void)
549554
#endif // USART3_ENABLE || USART4_ENABLE
550555

551556
#if USART_STREAM_ENABLE
552-
static void stream_ontx(void *param)
557+
558+
static void stream_dotx(usart_control_t *ctrl, vsf_stream_t *stream)
553559
{
554560
uint32_t size;
555-
usart_control_t *ctrl = param;
556-
vsf_stream_t *stream = ctrl->tx;
557561
enum usart_idx_t idx = ((uint32_t)ctrl - (uint32_t)usart_control) / sizeof(usart_control_t);
558562

559563
size = vsfhal_usart_tx_get_free_size(idx);
@@ -575,11 +579,9 @@ static void stream_ontx(void *param)
575579
}
576580
}
577581

578-
static void stream_onrx(void *param)
582+
static void stream_dorx(usart_control_t *ctrl, vsf_stream_t *stream)
579583
{
580584
uint32_t size;
581-
usart_control_t *ctrl = param;
582-
vsf_stream_t *stream = ctrl->rx;
583585
enum usart_idx_t idx = ((uint32_t)ctrl - (uint32_t)usart_control) / sizeof(usart_control_t);
584586

585587
if (stream->op == &vsf_fifo_stream_op) {
@@ -604,20 +606,69 @@ static void stream_onrx(void *param)
604606
}
605607
}
606608

609+
enum {
610+
VSF_EVT_TX_STREAM_ONRX = VSF_EVT_USER + 0,
611+
VSF_EVT_TX_STREAM_ONTX = VSF_EVT_USER + 1,
612+
VSF_EVT_RX_STREAM_ONRX = VSF_EVT_USER + 2,
613+
VSF_EVT_RX_STREAM_ONTX = VSF_EVT_USER + 3,
614+
};
615+
616+
static void usart_stream_evthandler(vsf_eda_t *eda, vsf_evt_t evt)
617+
{
618+
usart_control_t *ctrl = container_of(eda, usart_control_t, eda);
619+
vsf_stream_t *tx_stream = ctrl->tx;
620+
vsf_stream_t *rx_stream = ctrl->rx;
621+
622+
switch (evt) {
623+
case VSF_EVT_INIT:
624+
break;
625+
case VSF_EVT_TX_STREAM_ONRX:
626+
case VSF_EVT_TX_STREAM_ONTX:
627+
if (VSF_STREAM_GET_DATA_SIZE(tx_stream)) {
628+
stream_dotx(ctrl, tx_stream);
629+
}
630+
break;
631+
case VSF_EVT_RX_STREAM_ONRX:
632+
stream_dorx(ctrl, rx_stream);
633+
break;
634+
case VSF_EVT_RX_STREAM_ONTX:
635+
if (VSF_STREAM_GET_DATA_SIZE(rx_stream)) {
636+
// used to call __vsf_stream_on_write
637+
vsf_stream_set_rx_threshold(rx_stream, rx_stream->rx.threshold);
638+
}
639+
break;
640+
}
641+
}
642+
607643
static void tx_stream_rx_evthandler(void *param, vsf_stream_evt_t evt)
608644
{
609645
usart_control_t *ctrl = param;
610-
vsf_stream_t *stream = ctrl->tx;
611646

612647
if (evt == VSF_STREAM_ON_RX) {
613-
if (VSF_STREAM_GET_DATA_SIZE(stream)) {
614-
stream_ontx(ctrl);
615-
}
648+
vsf_eda_post_evt(&ctrl->eda, VSF_EVT_TX_STREAM_ONRX);
649+
}
650+
}
651+
652+
static void rx_stream_tx_evthandler(void *param, vsf_stream_evt_t evt)
653+
{
654+
usart_control_t *ctrl = param;
655+
656+
if (evt == VSF_STREAM_ON_TX) {
657+
vsf_eda_post_evt(&ctrl->eda, VSF_EVT_RX_STREAM_ONTX);
616658
}
617659
}
618660

619-
//static void rx_stream_tx_evthandler(void *param, vsf_stream_evt_t evt) {}
661+
static void stream_ontx(void *param)
662+
{
663+
usart_control_t *ctrl = param;
664+
vsf_eda_post_evt(&ctrl->eda, VSF_EVT_TX_STREAM_ONTX);
665+
}
620666

667+
static void stream_onrx(void *param)
668+
{
669+
usart_control_t *ctrl = param;
670+
vsf_eda_post_evt(&ctrl->eda, VSF_EVT_RX_STREAM_ONRX);
671+
}
621672

622673
static void vsfhal_usart_stream_fini(enum usart_idx_t idx)
623674
{
@@ -635,13 +686,19 @@ static void vsfhal_usart_stream_fini(enum usart_idx_t idx)
635686
}
636687
}
637688

638-
void vsfhal_usart_stream_init(enum usart_idx_t idx, int32_t int_priority, vsf_stream_t *tx, vsf_stream_t *rx)
689+
void vsfhal_usart_stream_init(enum usart_idx_t idx, int32_t eda_priority, int32_t int_priority, vsf_stream_t *tx, vsf_stream_t *rx)
639690
{
640691
vsfhal_usart_stream_fini(idx);
641692

642693
if (!tx && !rx)
643694
return;
644695

696+
const vsf_eda_cfg_t cfg = {
697+
.fn.evthandler = usart_stream_evthandler,
698+
.priority = eda_priority,
699+
};
700+
vsf_eda_init_ex(&usart_control[idx].eda, (vsf_eda_cfg_t *)&cfg);
701+
645702
usart_control[idx].tx = tx;
646703
usart_control[idx].rx = rx;
647704
vsfhal_usart_config_cb(idx, int_priority, &usart_control[idx], stream_ontx, stream_onrx);
@@ -652,8 +709,8 @@ void vsfhal_usart_stream_init(enum usart_idx_t idx, int32_t int_priority, vsf_st
652709
VSF_STREAM_CONNECT_RX(tx);
653710
}
654711
if (rx) {
655-
//rx->tx.evthandler = rx_stream_tx_evthandler;
656-
//rx->tx.param = &usart_control[idx];
712+
rx->tx.evthandler = rx_stream_tx_evthandler;
713+
rx->tx.param = &usart_control[idx];
657714
VSF_STREAM_CONNECT_TX(rx);
658715
}
659716
}

source/vsf_private/hal/driver/GigaDevice/GD32E10X/common/usart.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ uint16_t vsfhal_usart_tx_get_free_size(enum usart_idx_t idx);
8787
uint16_t vsfhal_usart_rx_bytes(enum usart_idx_t idx, uint8_t *data, uint16_t size);
8888
uint16_t vsfhal_usart_rx_get_data_size(enum usart_idx_t idx);
8989
#if USART_STREAM_ENABLE
90-
void vsfhal_usart_stream_init(enum usart_idx_t idx, int32_t int_priority, vsf_stream_t *tx, vsf_stream_t *rx);
90+
void vsfhal_usart_stream_init(enum usart_idx_t idx, int32_t eda_priority, int32_t int_priority, vsf_stream_t *tx, vsf_stream_t *rx);
9191
#endif
9292
#endif
9393

0 commit comments

Comments
 (0)