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

Commit

Permalink
optimize CDC-UART compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
talpachen committed Oct 16, 2020
1 parent 9fbf74c commit b006a8e
Show file tree
Hide file tree
Showing 32 changed files with 984 additions and 489 deletions.
Binary file added firmware/20201016/vllink_lite_gd32e103xx_app.bin
Binary file not shown.
Binary file not shown.
Binary file added firmware/20201016/vllink_lite_gd32e103xx_full.bin
Binary file not shown.
Binary file added firmware/20201016/vllink_lite_gd32f350xx_app.bin
Binary file not shown.
Binary file not shown.
Binary file added firmware/20201016/vllink_lite_gd32f350xx_full.bin
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
define symbol __ICFEDIT_intvec_start__ = 0x08003000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08003000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0800FFFF;
define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000004;
define symbol __ICFEDIT_region_RAM_end__ = 0x20004FFF;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_cstack__ = 0x800;
define symbol __ICFEDIT_size_heap__ = 0x0;
/**** End of ICF editor section. ###ICF###*/

Expand Down
6 changes: 3 additions & 3 deletions source/project_vllink_lite/vllink_lite/EWARM/project.ewd
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@
</option>
<option>
<name>MemFile</name>
<state>$TOOLKIT_DIR$\CONFIG\debugger\GD\GD32E103x8.ddf</state>
<state>$TOOLKIT_DIR$\CONFIG\debugger\GD\GD32E103xB.ddf</state>
</option>
<option>
<name>RunToEnable</name>
Expand Down Expand Up @@ -1597,7 +1597,7 @@
</option>
<option>
<name>FlashLoadersV3</name>
<state>$TOOLKIT_DIR$\config\flashloader\GD\FlashGD32E103x8.board</state>
<state>$TOOLKIT_DIR$\config\flashloader\GD\FlashGD32E103xB.board</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
Expand Down Expand Up @@ -2591,7 +2591,7 @@
<option>
<name>CCSTLinkJtagSpeedList</name>
<version>2</version>
<state>0</state>
<state>9</state>
</option>
<option>
<name>CCSTLinkDAPNumber</name>
Expand Down
32 changes: 32 additions & 0 deletions source/project_vllink_lite/vllink_lite/EWARM/project.ewp
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,25 @@
<name>$PROJ_DIR$\..\daphost\daphost_swd.h</name>
</file>
</group>
<group>
<name>shell</name>
<excluded>
<configuration>VllinkLite_GD32F350</configuration>
<configuration>VllinkLite_GD32E103</configuration>
</excluded>
<file>
<name>$PROJ_DIR$\..\shell\extrauart.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\shell\extrauart.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\shell\help.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\shell\help.h</name>
</file>
</group>
<file>
<name>$PROJ_DIR$\GD32E103xx_booted.icf</name>
</file>
Expand Down Expand Up @@ -5487,6 +5506,19 @@
</group>
</group>
</group>
<group>
<name>ptshell</name>
<excluded>
<configuration>VllinkLite_GD32F350</configuration>
<configuration>VllinkLite_GD32E103</configuration>
</excluded>
<file>
<name>$PROJ_DIR$\..\..\..\vsf_private\ptshell\vsf_ptshell.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\vsf_private\ptshell\vsf_ptshell.h</name>
</file>
</group>
<file>
<name>$PROJ_DIR$\..\..\..\vsf_private\user_vsf.h</name>
</file>
Expand Down
24 changes: 24 additions & 0 deletions source/project_vllink_lite/vllink_lite/EWARM/project.ewt
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,21 @@
<name>$PROJ_DIR$\..\daphost\daphost_swd.h</name>
</file>
</group>
<group>
<name>shell</name>
<file>
<name>$PROJ_DIR$\..\shell\extrauart.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\shell\extrauart.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\shell\help.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\shell\help.h</name>
</file>
</group>
<file>
<name>$PROJ_DIR$\GD32E103xx_booted.icf</name>
</file>
Expand Down Expand Up @@ -4191,6 +4206,15 @@
</group>
</group>
</group>
<group>
<name>ptshell</name>
<file>
<name>$PROJ_DIR$\..\..\..\vsf_private\ptshell\vsf_ptshell.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\vsf_private\ptshell\vsf_ptshell.h</name>
</file>
</group>
<file>
<name>$PROJ_DIR$\..\..\..\vsf_private\user_vsf.h</name>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
# define APP_CFG_WEBUSB_SUPPORT
# define APP_CFG_CDCEXT_SUPPORT
# define APP_CFG_CDCEXT_PKT_SIZE 64
# define APP_CFG_CDCSHELL_SUPPORT
//# define APP_CFG_CDCSHELL_SUPPORT
# define APP_CFG_CDCSHELL_PKT_SIZE 64
# define APP_CFG_DAPHOST_SUPPORT
# define APP_CFG_DAPHOST_SUPPORT
# define APP_CFG_CDCSHELL_DAPHOST
# define APP_CFG_CDCEXT_DATA_OUT_EP 2
# define APP_CFG_CDCEXT_DATA_IN_EP 2
# define APP_CFG_CDCEXT_NOTIFY_EP 3
//# define APP_CFG_CDCSHELL_DATA_OUT_EP 3
//# define APP_CFG_CDCSHELL_DATA_IN_EP 3
//# define APP_CFG_CDCSHELL_NOTIFY_EP 5
#elif defined(BRD_CFG_VLLINKLITE_GD32F350)
# define APP_CFG_SERIAL_HEADER_STR u"GD32F350."
# define APP_CFG_SERIAL_HEADER_STR_LENGTH (sizeof(APP_CFG_SERIAL_HEADER_STR) - 2)
Expand All @@ -41,10 +46,26 @@
# define APP_CFG_WEBUSB_SUPPORT
# define APP_CFG_CDCEXT_SUPPORT
# define APP_CFG_CDCEXT_PKT_SIZE 64
//# define APP_CFG_CDCSHELL_SUPPORT
//# define APP_CFG_CDCSHELL_PKT_SIZE 64
//# define APP_CFG_DAPHOST_SUPPORT
//# define APP_CFG_DAPHOST_SUPPORT
//# define APP_CFG_CDCSHELL_SUPPORT
# define APP_CFG_CDCEXT_DATA_OUT_EP 2
# define APP_CFG_CDCEXT_DATA_IN_EP 2
# define APP_CFG_CDCEXT_NOTIFY_EP 3
//# define APP_CFG_CDCSHELL_DATA_OUT_EP 3
//# define APP_CFG_CDCSHELL_DATA_IN_EP 3
//# define APP_CFG_CDCSHELL_NOTIFY_EP 5
#endif

#ifdef APP_CFG_CDCSHELL_SUPPORT
# define VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL ENABLED
# define VSF_KERNEL_CFG_EDA_SUPPORT_FSM ENABLED
# define VSF_USE_HEAP ENABLED
# define VSF_HEAP_CFG_MCB_MAGIC_EN ENABLED
# define VSF_HEAP_SIZE 0x2000
# define VSF_USE_PTSHELL ENABLED
#else
# define VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL DISABLED
# define VSF_KERNEL_CFG_EDA_SUPPORT_FSM DISABLED
# define VSF_USE_HEAP DISABLED
#endif

#define CMSIS_DAP_V2_PACKET_SIZE 512
Expand Down
5 changes: 0 additions & 5 deletions source/project_vllink_lite/vllink_lite/config/vsf_usr_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@
#define VSF_KERNEL_CFG_EDA_SUPPORT_PT ENABLED
#define VSF_KERNEL_CFG_EDA_SUPPORT_TIMER ENABLED
# define VSF_KERNEL_CFG_CALLBACK_TIMER ENABLED
#define VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL DISABLED
#define VSF_KERNEL_CFG_EDA_SUPPORT_FSM DISABLED

#define VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED ENABLED
# define VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY DISABLED
# define VSF_OS_CFG_EVTQ_BITSIZE 4

#define VSF_USE_HEAP DISABLED
# define VSF_HEAP_SIZE 0x1000

#define VSF_USE_KERNEL_SIMPLE_SHELL ENABLED
#define VSF_KERNEL_CFG_SUPPORT_THREAD DISABLED

Expand Down
2 changes: 1 addition & 1 deletion source/project_vllink_lite/vllink_lite/dap/dap.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ declare_vsf_task(dap_task_t);

typedef struct dap_param_t {
uint16_t (*get_serial)(uint8_t *serial);
void (*config_usart)(enum usart_idx_t idx, uint32_t *mode, uint32_t *baudrate, vsf_stream_t *tx, vsf_stream_t *rx);
void (*config_usart)(enum usart_idx_t idx, uint32_t *mode, uint32_t *baudrate, vsf_stream_t *tx, vsf_stream_t *rx, bool return_actual_baud);
uint32_t (*get_usart_baud)(enum usart_idx_t idx, uint32_t baudrate);

#if VENDOR_UART
Expand Down
4 changes: 2 additions & 2 deletions source/project_vllink_lite/vllink_lite/dap/dap_swo.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ uint32_t dap_swo_request_handler(dap_param_t* param, uint8_t* request,
param->trace_timestamp = 0;
#endif
if (param->config_usart) {
param->config_usart(PERIPHERAL_UART_SWO_IDX, &mode, &param->swo_baudrate, NULL, (vsf_stream_t *)&param->swo_rx);
param->config_usart(PERIPHERAL_UART_SWO_IDX, &mode, &param->swo_baudrate, NULL, (vsf_stream_t *)&param->swo_rx, true);
}
VSF_STREAM_CONNECT_RX(&param->swo_rx);
} else {
VSF_STREAM_DISCONNECT_RX(&param->swo_rx);
param->config_usart(PERIPHERAL_UART_SWO_IDX, NULL, NULL, NULL, NULL);
param->config_usart(PERIPHERAL_UART_SWO_IDX, NULL, NULL, NULL, NULL, false);
}
param->trace_status = active;
}
Expand Down
70 changes: 43 additions & 27 deletions source/project_vllink_lite/vllink_lite/daphost/daphost.c
Original file line number Diff line number Diff line change
@@ -1,50 +1,70 @@
#include "vsf.h"
#include "../dap/dap.h"
#include "daphost_priv.h"
#include "daphost_jtag.h"
#include "daphost_swd.h"

xxxxxxxxxxxx
static daphost_op_t const *daphost_op = NULL;

vsf_err_t daphost_init(void)
{
// TODO
//daphost_op = &daphost_jtag_op;
daphost_op = &daphost_swd_op;
return VSF_ERR_NONE;
}

vsf_err_t daphost_fini(void)
{
if (daphost_op)
daphost_op = NULL;
return VSF_ERR_NONE;
}

vsf_err_t daphost_read_dp(uint8_t adr, uint32_t *val)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->read_dp(adr, val);
if (daphost_op)
return daphost_op->read_dp(adr, val);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_write_dp(uint8_t adr, uint32_t val)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->write_dp(adr, val);
if (daphost_op)
return daphost_op->write_dp(adr, val);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_read_ap(uint32_t adr, uint32_t *val)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->read_ap(adr, val);
if (daphost_op)
return daphost_op->read_ap(adr, val);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_write_ap(uint32_t adr, uint32_t val)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->write_ap(adr, val);
if (daphost_op)
return daphost_op->write_ap(adr, val);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_read_memory(uint32_t addr, uint32_t size, uint8_t *buf)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->read_memory(addr, size, buf);
if (daphost_op)
return daphost_op->read_memory(addr, size, buf);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_write_memory(uint32_t addr, uint32_t size, uint8_t *buf)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->write_memory(addr, size, buf);
if (daphost_op)
return daphost_op->write_memory(addr, size, buf);
else
return VSF_ERR_NOT_SUPPORT;
}
Expand All @@ -53,40 +73,36 @@ vsf_err_t daphost_flash_syscall_exec(const program_syscall_t *sysCallParam,
uint32_t entry, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
flash_algo_return_t return_type)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->daphost_flash_syscall_exec(sysCallParam, entry, arg1, arg2, arg3, arg4, return_type);
if (daphost_op)
return daphost_op->flash_syscall_exec(sysCallParam, entry, arg1, arg2, arg3, arg4, return_type);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_set_target_state_hw(target_state_t state)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->set_target_state_hw(state);
if (daphost_op)
return daphost_op->set_target_state_hw(state);
else
return VSF_ERR_NOT_SUPPORT;
}

vsf_err_t daphost_set_target_state_sw(target_state_t state)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->set_target_state_sw(state);
if (daphost_op)
return daphost_op->set_target_state_sw(state);
else
return VSF_ERR_NOT_SUPPORT;
}

void daphost_set_reset_connect(SWD_CONNECT_TYPE type)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->set_reset_connect(type);
else
return VSF_ERR_NOT_SUPPORT;
if (daphost_op)
daphost_op->set_reset_connect(type);
}

void daphost_set_soft_reset(uint32_t soft_reset_type)
{
if (xxxxxxxxxxxx)
return xxxxxxxxxxxx->set_soft_reset(soft_reset_type);
else
return VSF_ERR_NOT_SUPPORT;
if (daphost_op)
daphost_op->set_soft_reset(soft_reset_type);
}
5 changes: 5 additions & 0 deletions source/project_vllink_lite/vllink_lite/daphost/daphost.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
extern "C" {
#endif

vsf_err_t daphost_init(void);
vsf_err_t daphost_fini(void);
void daphost_jtag2swd(void);
vsf_err_t daphost_read_dp(uint8_t adr, uint32_t *val);
vsf_err_t daphost_write_dp(uint8_t adr, uint32_t val);
vsf_err_t daphost_read_ap(uint32_t adr, uint32_t *val);
vsf_err_t daphost_write_ap(uint32_t adr, uint32_t val);
vsf_err_t daphost_read_memory(uint32_t addr, uint32_t size, uint8_t *buf);
vsf_err_t daphost_write_memory(uint32_t addr, uint32_t size, uint8_t *buf);
vsf_err_t daphost_read_core_register(uint32_t n, uint32_t *val);
vsf_err_t daphost_write_core_register(uint32_t n, uint32_t val);
vsf_err_t daphost_flash_syscall_exec(const program_syscall_t *sysCallParam, uint32_t entry, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, flash_algo_return_t return_type);
vsf_err_t daphost_set_target_state_hw(target_state_t state);
vsf_err_t daphost_set_target_state_sw(target_state_t state);
Expand Down
Loading

0 comments on commit b006a8e

Please sign in to comment.