Skip to content

Commit

Permalink
commit v2.3c (drag-and-drop test ok)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxx committed May 29, 2020
1 parent b7909f8 commit 9730b56
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 118 deletions.
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@

<Group>
<GroupName>cmsis-dap</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg1>1</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name>..\..\..\tools\post_build_script.bat $L@L $KARM</UserProg1Name>
<UserProg2Name></UserProg2Name>
Expand Down
2 changes: 2 additions & 0 deletions software/v2.3/DAPLink/source/daplink/cmsis-dap/DAP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1589,9 +1589,11 @@ uint32_t DAP_ExecuteCommand(const uint8_t *request, uint8_t *response) {

void set_target_soft_reset()
{
#if 0
if (DAP_Data.debug_port == DAP_PORT_SWD) {
swd_set_target_soft_reset();
}
#endif
#if 0
else if {DAP_Data.debug_port = DAP_PORT_JTAG} {
}
Expand Down
4 changes: 2 additions & 2 deletions software/v2.3/DAPLink/tools/flash_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import binascii
import argparse
import logging
import StringIO
import io
import jinja2
from collections import namedtuple
from itertools import count
Expand Down Expand Up @@ -311,7 +311,7 @@ class ElfFileSimple(ELFFile):

def __init__(self, data):
"""Construct a ElfFileSimple from bytes or a bytearray"""
super(ElfFileSimple, self).__init__(StringIO.StringIO(data))
super(ElfFileSimple, self).__init__(io.StringIO.StringIO(data))
self.symbols = self._read_symbol_table()

def _read_symbol_table(self):
Expand Down
6 changes: 3 additions & 3 deletions software/v2.3/DAPLink/tools/post_build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ def post_build_script(input_file, output_file, board_id=None, family_id=None, bi
new_hex_file.puts(program_target_addr,struct.pack('<' + program_target_fmt,
pack_flash_algo.symbols['Init'] + blob_header_size + flash_blob_entry,
pack_flash_algo.symbols['UnInit'] + blob_header_size + flash_blob_entry,
pack_flash_algo.symbols['EraseChip'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['EraseChip'] != 0xffffffffL else 0,
pack_flash_algo.symbols['EraseChip'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['EraseChip'] != 0xffffffff else 0,
pack_flash_algo.symbols['EraseSector'] + blob_header_size + flash_blob_entry,
pack_flash_algo.symbols['ProgramPage'] + blob_header_size + flash_blob_entry,
pack_flash_algo.symbols['Verify'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['Verify'] != 0xffffffffL else 0,
pack_flash_algo.symbols['Verify'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['Verify'] != 0xffffffff else 0,
flash_blob_entry + 1, #BKPT : start of blob + 1
flash_blob_entry + blob_header_size + pack_flash_algo.rw_start, #RSB : blob start + header + rw data offset
stack_pointer, #RSP : stack pointer
Expand All @@ -170,7 +170,7 @@ def post_build_script(input_file, output_file, board_id=None, family_id=None, bi
sector_info_len, #Sector start and length list total
*regions_flags
))
board_info_flag = 1 if pack_flash_algo.symbols['EraseSector'] != 0xffffffffL else 0 #kEnablePageErase
board_info_flag = 1 if pack_flash_algo.symbols['EraseSector'] != 0xffffffff else 0 #kEnablePageErase
new_hex_file.puts(target_addr_unpack + 12,struct.pack('<1I', board_info_flag)) #always enable page erase EraseSector is a required symbol in flash algo
new_hex_file.puts(target_addr_unpack + 16,struct.pack('<1I', target_cfg_addr))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
<yPos>-1</yPos>
</MaxPosition>
<NormalPosition>
<Top>92</Top>
<Left>323</Left>
<Right>1712</Right>
<Bottom>1010</Bottom>
<Top>78</Top>
<Left>357</Left>
<Right>1746</Right>
<Bottom>996</Bottom>
</NormalPosition>
</WindowPosition>
<MDIClientArea>
Expand Down Expand Up @@ -1822,7 +1822,7 @@
<Name>Build</Name>
<Buttons>
<Len>1012</Len>
<Data>00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000004001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000002001E000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6EC7040000000000006A0000000C4261746368204275696C2664000000000000000000000000010000000100000000000000000000000100000004000580C7040000000000006A0000000C4261746368204275696C266400000000000000000000000001000000010000000000000000000000010000000000058046070000000000006B0000000D42617463682052656275696C640000000000000000000000000100000001000000000000000000000001000000000005804707000000000000FFFFFFFF0B426174636820436C65616E0100000000000000000000000100000001000000000000000000000001000000000005809E8A0000000000001F0000000F4261746326682053657475702E2E2E000000000000000000000000010000000100000000000000000000000100000000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA00000000000000000000000000000000000000000000000001000000010000009600000003002050000000001A73746D33326631303378625F73746D33326631303372625F6966960000000000000001001A73746D33326631303378625F73746D33326631303372625F6966000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64DC010000</Data>
<Data>00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000004001C0000000000000000000000000000000001000000010000000180D07F0000000002001D000000000000000000000000000000000100000001000000018030800000000000001E000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6EC7040000000000006A0000000C4261746368204275696C2664000000000000000000000000010000000100000000000000000000000100000004000580C7040000000000006A0000000C4261746368204275696C266400000000000000000000000001000000010000000000000000000000010000000000058046070000000000006B0000000D42617463682052656275696C640000000000000000000000000100000001000000000000000000000001000000000005804707000000000000FFFFFFFF0B426174636820436C65616E0100000000000000000000000100000001000000000000000000000001000000000005809E8A0000000000001F0000000F4261746326682053657475702E2E2E000000000000000000000000010000000100000000000000000000000100000000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA00000000000000000000000000000000000000000000000001000000010000009600000003002050000000001A73746D33326631303378625F73746D33326631303372625F6966960000000000000001001A73746D33326631303378625F73746D33326631303372625F6966000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64DC010000</Data>
</Buttons>
<OriginalItems>
<Len>583</Len>
Expand Down
2 changes: 1 addition & 1 deletion software/v2.3c/source/daplink/cmsis-dap/DAP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ uint8_t RST_Transfer(uint32_t request, uint32_t data)
return ((uint8_t)ack); \
}

void target_soft_reset()
void set_target_soft_reset()
{
uint32_t i;
//soft-reset for Cortex-M
Expand Down
5 changes: 5 additions & 0 deletions software/v2.3c/source/daplink/interface/swd_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,11 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state)
return 1;
}

void swd_set_target_soft_reset()
{
swd_write_word(NVIC_AIRCR, VECTKEY | 0x7);
}

uint8_t swd_set_target_state_sw(TARGET_RESET_STATE state)
{
uint32_t val;
Expand Down
49 changes: 40 additions & 9 deletions software/v2.3c/source/hic_hal/stm32/stm32f103xb/DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ Provides definitions about:

/// Indicate that JTAG communication mode is available at the Debug Port.
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
#define DAP_JTAG 0 ///< JTAG Mode: 1 = available, 0 = not available.
#define DAP_JTAG 1 ///< JTAG Mode: 1 = available, 0 = not available.

/// Configure maximum number of JTAG devices on the scan chain connected to the Debug Access Port.
/// This setting impacts the RAM requirements of the Debug Unit. Valid range is 1 .. 255.
#define DAP_JTAG_DEV_CNT 0 ///< Maximum number of JTAG devices on scan chain
#define DAP_JTAG_DEV_CNT 8 ///< Maximum number of JTAG devices on scan chain

/// Default communication mode on the Debug Access Port.
/// Used for the command \ref DAP_Connect when Port Default mode is selected.
Expand Down Expand Up @@ -217,7 +217,26 @@ Configures the DAP Hardware I/O pins for JTAG mode:
static __inline void PORT_JTAG_SETUP(void)
{
#if (DAP_JTAG != 0)
// TCK output
pin_out_init(JTAG_TCK_PIN_PORT, JTAG_TCK_PIN_Bit);
JTAG_TCK_PIN_PORT->BSRR = JTAG_TCK_PIN;
// TMS output
pin_out_init(JTAG_TMS_PIN_PORT, JTAG_TMS_PIN_Bit);
JTAG_TMS_PIN_PORT->BSRR = JTAG_TMS_PIN;

// TDI output
pin_out_init(JTAG_TDI_PIN_PORT, JTAG_TDI_PIN_Bit);
JTAG_TDI_PIN_PORT->BSRR = JTAG_TDI_PIN;

// TDO input
pin_in_init(JTAG_TDO_PIN_PORT, JTAG_TDO_PIN_Bit, 1);

pin_in_init(SWDIO_IN_PIN_PORT, SWDIO_IN_PIN_Bit, 1);

// Set RESET HIGH
pin_out_od_init(nRESET_PIN_PORT, nRESET_PIN_Bit);//TODO - fix reset logic
nRESET_PIN_PORT->BSRR = nRESET_PIN;

#endif
}

Expand Down Expand Up @@ -351,15 +370,24 @@ static __forceinline void PIN_SWDIO_OUT_DISABLE(void)
*/
static __forceinline uint32_t PIN_TDI_IN(void)
{
return (0); // Not available
#if ( DAP_JTAG != 0 )
return (JTAG_TDI_PIN_PORT->IDR >> JTAG_TDI_PIN_Bit) & 1;
#else
return 0;
#endif
}

/** TDI I/O pin: Set Output.
\param bit Output value for the TDI DAP hardware I/O pin.
*/
static __forceinline void PIN_TDI_OUT(uint32_t bit)
{
; // Not available
#if ( DAP_JTAG != 0 )
if (bit & 1)
JTAG_TDI_PIN_PORT->BSRR = JTAG_TDI_PIN;
else
JTAG_TDI_PIN_PORT->BRR = JTAG_TDI_PIN;
#endif
}


Expand All @@ -370,7 +398,11 @@ static __forceinline void PIN_TDI_OUT(uint32_t bit)
*/
static __forceinline uint32_t PIN_TDO_IN(void)
{
return (0); // Not available
#if ( DAP_JTAG != 0 )
return (JTAG_TDO_PIN_PORT->IDR >> JTAG_TDO_PIN_Bit) & 1;
#else
return 0;
#endif
}


Expand Down Expand Up @@ -410,12 +442,11 @@ static __forceinline uint32_t PIN_nRESET_IN(void)
- 1: release device hardware reset.
*/
// TODO - sw specific implementation should be created
extern void target_soft_reset();

extern void set_target_soft_reset(void);
static __forceinline void PIN_nRESET_OUT(uint32_t bit)
{
target_soft_reset();

set_target_soft_reset();
if (bit & 1)
nRESET_PIN_PORT->BSRR = nRESET_PIN;
else
Expand Down
30 changes: 26 additions & 4 deletions software/v2.3c/source/hic_hal/stm32/stm32f103xb/IO_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_STM32F103XB);

//USB control pin
#define USB_CONNECT_PORT_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define USB_CONNECT_PORT_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define USB_CONNECT_PORT_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define USB_CONNECT_PORT_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define USB_CONNECT_PORT GPIOB
#define USB_CONNECT_PIN GPIO_PIN_15
#define USB_CONNECT_ON() (USB_CONNECT_PORT->BRR = USB_CONNECT_PIN)
Expand All @@ -43,8 +43,8 @@ COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_STM32F103XB);

//When bootloader, disable the target port(not used)
#define POWER_EN_PIN_PORT GPIOB
#define POWER_EN_PIN GPIO_PIN_15
#define POWER_EN_Bit 15
#define POWER_EN_PIN GPIO_PIN_8
#define POWER_EN_Bit 8

// nRESET OUT Pin
#define nRESET_PIN_PORT GPIOB
Expand All @@ -64,6 +64,28 @@ COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_STM32F103XB);
#define SWDIO_IN_PIN GPIO_PIN_12
#define SWDIO_IN_PIN_Bit 12


// JTAG-TCK
#define JTAG_TCK_PIN_PORT SWCLK_TCK_PIN_PORT
#define JTAG_TCK_PIN SWCLK_TCK_PIN
#define JTAG_TCK_PIN_Bit SWCLK_TCK_PIN_Bit

// JTAG-TMS
#define JTAG_TMS_PIN_PORT SWDIO_OUT_PIN_PORT
#define JTAG_TMS_PIN SWDIO_OUT_PIN
#define JTAG_TMS_PIN_Bit SWDIO_OUT_PIN_Bit

// JTAG-TDI
#define JTAG_TDI_PIN_PORT GPIOA
#define JTAG_TDI_PIN GPIO_PIN_7
#define JTAG_TDI_PIN_Bit 7

// JTAG-TDO
#define JTAG_TDO_PIN_PORT GPIOA
#define JTAG_TDO_PIN GPIO_PIN_5
#define JTAG_TDO_PIN_Bit 5


//LEDs
//USB status LED
#define RUNNING_LED_PORT GPIOA
Expand Down

0 comments on commit 9730b56

Please sign in to comment.