diff --git a/README.md b/README.md index c7c86fe..c0e06f0 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ The underlying template also supports following board: - [blue pill](ihttps://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill), based on a STM32F103C8T6 - [core board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#core_board), based on a STM32F103C8T6 - [ST-LINK V2 mini](https://wiki.cuvoodoo.info/doku.php?id=jtag#mini_st-link_v2), a ST-LINK/V2 clone based on a STM32F101C8T6 +- [USB-Blaster](https://wiki.cuvoodoo.info/doku.php?id=jtag#armjishu_usb-blaster), an Altera USB-Blaster clone based on a STM32F101C8T6 **Which board is used is defined in the Makefile**. This is required to map the user LED and button provided on the board @@ -33,6 +34,13 @@ The ST-LINK V2 mini clone has SWD test points on the board. Because read protection is enabled, you will first need to remove the protection to be able to flash the firmware. To remove the read protection (and erase flash), run `rake remove_protection` while a SWD adapter is connected. +The Altera USB-Blaster clone has a pin header for SWD and UART1 on the board. +SWD is disabled in the main firmware, and it has read protection. +To be able to flash using SWD (or the serial port), the BOOT0 pin must be set to 1 to boot the system memory install of the flash memory. +To set BOOT0 to 1, apply 3.3 V on R11, between the resistor and the reference designator, when powering the device. +The red LED should stay off while the green LED is on. +Now you can remove the read protection (and erase flash), run `rake remove_protection` while a SWD adapter is connected. + connections =========== diff --git a/Rakefile b/Rakefile index 7743954..d658dfe 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ APPLICATION = "application" FIRMWARES = [BOOTLOADER, APPLICATION] # which development board is used -# supported are: SYSTEM_BOARD, MAPLE_MINI, BLUE_PILL, CORE_BOARD, STLINKV2, BUSVOODOO +# supported are: SYSTEM_BOARD, MAPLE_MINI, BLUE_PILL, CORE_BOARD, STLINKV2, BLASTER, BUSVOODOO BOARD = ENV["BOARD"] || "CORE_BOARD" # libopencm3 definitions diff --git a/application.c b/application.c index 28497ba..ff1a1c6 100644 --- a/application.c +++ b/application.c @@ -372,7 +372,7 @@ void main(void) // setup RTC printf("setup internal RTC: "); -#if defined(BLUE_PILL) || defined(STLINKV2) // for boards without a Low Speed External oscillator +#if defined(BLUE_PILL) || defined(STLINKV2) || defined(BLASTER) // for boards without a Low Speed External oscillator // note: the blue pill LSE oscillator is affected when toggling the onboard LED, thus prefer the HSE rtc_auto_awake(RCC_HSE, 8000000 / 128 - 1); // use High Speed External oscillator (8 MHz / 128) as RTC clock (VBAT can't be used to keep the RTC running) #else // for boards with an precise Low Speed External oscillator diff --git a/global.h b/global.h index f9afbfd..4db388b 100644 --- a/global.h +++ b/global.h @@ -622,10 +622,14 @@ /* on maple mini LED is on pin 19/PB1 */ #define LED_PIN PB1 /**< GPIO pin (pin PB1 on maple mini) */ #define LED_ON 1 /**< LED is on when pin is high */ -#elif defined (STLINKV2) // it's actually a STM32F101, but it seems to have all STM32F103 features +#elif defined (STLINKV2) // it's sometimes a STM32F101, but it seems to have all STM32F103 features /* on ST-Link V2 clone dongle in aluminum case LED is on pin PA9 (remap USART1_TX if used) */ #define LED_PIN PA9 /**< GPIO pin (pin PA9) */ #define LED_ON 1 /**< the color and on level depends on the clone */ +#elif defined (BLASTER) + /* on Altera USB blaster clone LED is on pin PA5 */ + #define LED_PIN PA5 /**< GPIO pin (pin PA5) */ + #define LED_ON 0 /**< red LED on when low (green LED is on when device is powered) */ #elif defined (BUSVOODOO) /* on BusVoodoo LED is on pin PA8 */ #define LED_PIN PA8 /**< GPIO pin (pin PA8) */ @@ -658,6 +662,9 @@ /* use button */ #define DFU_FORCE_PIN BUTTON_PIN /**< button pin */ #define DFU_FORCE_VALUE BUTTON_PRESSED /**< button floating unpressed, connected to ground pressed to force DFU mode */ +#elif defined (BLASTER) + #define DFU_FORCE_PIN PA8 /**< GPIO pin (pin PA8, not SWD and UART pin on debug port) */ + #define DFU_FORCE_VALUE 0 /**< short to nearby ground connection to force DFU */ #elif defined(BUSVOODOO) #if BUSVOODOO_HARDWARE_VERSION==0 /* on BusVoodoo v0 DFU input is on PC7 */ diff --git a/lib/usb_cdcacm.c b/lib/usb_cdcacm.c index 4cdcf6e..7d25abc 100644 --- a/lib/usb_cdcacm.c +++ b/lib/usb_cdcacm.c @@ -258,6 +258,11 @@ static void usb_disconnect(void) rcc_periph_clock_enable(RCC_GPIOB); gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); gpio_set(GPIOB, GPIO9); +#elif defined(BLASTER) + // enable USB D+ pull-up + rcc_periph_clock_enable(RCC_GPIOB); + gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6); + gpio_set(GPIOB, GPIO6); #endif // pull USB D+ low for a short while rcc_periph_clock_enable(RCC_GPIOA); @@ -446,6 +451,11 @@ void usb_cdcacm_setup(void) rcc_periph_clock_enable(RCC_GPIOB); gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); gpio_clear(GPIOB, GPIO9); +#elif defined(BLASTER) + // enable USB D+ pull-up using GPIO + rcc_periph_clock_enable(RCC_GPIOB); + gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6); + gpio_set(GPIOB, GPIO6); #endif rcc_periph_clock_enable(RCC_GPIOA); // enable clock for GPIO used for USB rcc_periph_clock_enable(RCC_USB); // enable clock for USB domain diff --git a/lib/usb_dfu.c b/lib/usb_dfu.c index eac8b31..eab0ec1 100644 --- a/lib/usb_dfu.c +++ b/lib/usb_dfu.c @@ -139,6 +139,11 @@ static void usb_disconnect(void) rcc_periph_clock_enable(RCC_GPIOB); gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); gpio_set(GPIOB, GPIO9); +#elif defined(BLASTER) + // enable USB D+ pull-up + rcc_periph_clock_enable(RCC_GPIOB); + gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6); + gpio_set(GPIOB, GPIO6); #endif // pull USB D+ low for a short while rcc_periph_clock_enable(RCC_GPIOA); @@ -312,6 +317,11 @@ void usb_dfu_setup(void) rcc_periph_clock_enable(RCC_GPIOB); gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); gpio_clear(GPIOB, GPIO9); +#elif defined(BLASTER) + // enable USB D+ pull-up using GPIO + rcc_periph_clock_enable(RCC_GPIOB); + gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6); + gpio_set(GPIOB, GPIO6); #endif rcc_periph_clock_enable(RCC_GPIOA); // enable clock for GPIO used for USB rcc_periph_clock_enable(RCC_USB); // enable clock for USB domain