Skip to content

Commit

Permalink
disable SWD on F103
Browse files Browse the repository at this point in the history
issue #9
  • Loading branch information
dmitrystu committed Mar 2, 2020
1 parent 136c4a0 commit 0b6b847
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ You can find configuration parameters in the following tables. Defaults marked *
|DFU_BOOTSTRAP_LEVEL | Level on bootstrap pin to activate | **_LOW**/_HIGH | |
|DFU_BOOTSTRAP_PULL | Bootstrap pin pullup control | _DISABLE/**_AUTO**/_LOW/_HIGH | |
|DFU_DBLRESET_MS | Doublereset activation time (ms) | TIMEOUT/_DISABLE | **300** |
|DFU_SEAL_LEVEL | RDP level | **0**, 1, 2 (if available) | |
|DFU_DISABLE_SWD | Disable SWD/JTAG on strart | _ENABLE/**_DISABLE** | |
|DFU_APP_START | Start address for user code | ROM ADDRESS/**_AUTO** | must be page aligned |
|DFU_APP_SIZE | User application max size | AMMOUNT/**_AUTO** | up to the ROM end |
|DFU_CIPHER | Type of ciper | See Table 3 | **DFU_CIPHER_RC5** |
Expand Down
4 changes: 4 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
#ifndef DFU_SEAL_LEVEL
#define DFU_SEAL_LEVEL 0
#endif
/** Disable SWD/JTAG interface **/
#ifndef DFU_DISABLE_SWD
#define DFU_DISABLE_SWD _DISABLE
#endif
/* USB VID */
#ifndef DFU_VENDOR_ID
#define DFU_VENDOR_ID 0x0483
Expand Down
9 changes: 8 additions & 1 deletion mcu/stm32f103.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define RCC_APB2RSTR 0x0C
#define RCC_APB2ENR 0x18

#define AFIO_BASE 0x40010000

#define GPIOA 0x40010800
#define GPIOB 0x40010C00
#define GPIOC 0x40011000
Expand Down Expand Up @@ -113,8 +115,13 @@ Reset_Handler:
/* pulling down GPIOA12 (USB-DP)*/
/* this will force re-enumeration. Very useful if no DP control pin used */
ldr r0, =#RCC_BASE
movs r2, #(0x04 | BOOTSTRAP_RCC)
movs r2, #(0x05 | BOOTSTRAP_RCC)
strb r2, [r0, #RCC_APB2ENR]
#if (DFU_DISABLE_SWD == _ENABLE)
ldr r1, =#AFIO_BASE
ldr r3, =#0x04000000
str r3, [r1, #0x04]
#endif
ldr r1, =#GPIOA
ldr r2, [r1, #GPIO_CRH]
ldr r3, =#0x000F0000
Expand Down

0 comments on commit 0b6b847

Please sign in to comment.