Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Here is an example `local.mk` that changes the default target to the STLink/v2 a
TARGET ?= STLINK
OOCD_INTERFACE ?= interface/stlink-v2.cfg

You can also use the env variable `DEFS` to override default configuration for a target, like:

# Disable LED on BluePill
DEFS="-DHAVE_LED=0" make TARGET=BLUEPILL

# Allow access to all Flash on MapleMini and change the app base address
DEFS="-DFLASH_SIZE_OVERRIDE=0x20000 -DAPP_BASE_ADDRESS=0x08004000" make TARGET=MAPLEMINI LDSCRIPT="/some/folder/stm32f103x8-16kb-boot.ld"

## Using the bootloader
### Building for the bootloader
The bootloader occupies the lower 8KiB of flash, so your application must offset its flash contents by 8KiB. This can be done by modifying your linker script or flags as appropriate.
Expand Down
67 changes: 67 additions & 0 deletions src/stm32f103/bluepill/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2016, Devan Lai
*
* Permission to use, copy, modify, and/or distribute this software
* for any purpose with or without fee is hereby granted, provided
* that the above copyright notice and this permission notice
* appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED

#ifndef APP_BASE_ADDRESS
#define APP_BASE_ADDRESS 0x08002000
#endif
#ifndef FLASH_SIZE_OVERRIDE
#define FLASH_SIZE_OVERRIDE 0x20000
#endif
#ifndef FLASH_PAGE_SIZE
#define FLASH_PAGE_SIZE 1024
#endif
#ifndef DFU_UPLOAD_AVAILABLE
#define DFU_UPLOAD_AVAILABLE 1
#endif
#ifndef DFU_DOWNLOAD_AVAILABLE
#define DFU_DOWNLOAD_AVAILABLE 1
#endif

#ifndef HAVE_LED
#define HAVE_LED 1
#endif
#ifndef LED_OPEN_DRAIN
#define LED_OPEN_DRAIN 1
#endif
#ifndef LED_GPIO_PORT
#define LED_GPIO_PORT GPIOC
#endif
#ifndef LED_GPIO_PIN
#define LED_GPIO_PIN GPIO13
#endif

#ifndef HAVE_BUTTON
#define HAVE_BUTTON 0
#endif

#ifndef BUTTON_SAMPLE_DELAY_CYCLES
#define BUTTON_SAMPLE_DELAY_CYCLES 1440000
#endif

#ifndef HAVE_USB_PULLUP_CONTROL
#define HAVE_USB_PULLUP_CONTROL 0
#endif

#ifndef USES_GPIOC
#define USES_GPIOC 1
#endif

#endif
28 changes: 28 additions & 0 deletions src/stm32f103/generic/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,47 @@
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED

#ifndef APP_BASE_ADDRESS
#define APP_BASE_ADDRESS 0x08002000
#endif
#ifndef FLASH_SIZE_OVERRIDE
#define FLASH_SIZE_OVERRIDE 0x20000
#endif
#ifndef FLASH_PAGE_SIZE
#define FLASH_PAGE_SIZE 1024
#endif
#ifndef DFU_UPLOAD_AVAILABLE
#define DFU_UPLOAD_AVAILABLE 1
#endif
#ifndef DFU_DOWNLOAD_AVAILABLE
#define DFU_DOWNLOAD_AVAILABLE 1
#endif

#ifndef HAVE_LED
#define HAVE_LED 0
#endif
// #ifndef LED_OPEN_DRAIN
// #define LED_OPEN_DRAIN 0
// #endif
// #ifndef LED_GPIO_PORT
// #define LED_GPIO_PORT GPIOA
// #endif
// #ifndef LED_GPIO_PIN
// #define LED_GPIO_PIN GPIO0
// #endif

#ifndef HAVE_BUTTON
#define HAVE_BUTTON 0
#endif
// #ifndef BUTTON_ACTIVE_HIGH
// #define BUTTON_ACTIVE_HIGH 0
// #endif
// #ifndef BUTTON_GPIO_PORT
// #define BUTTON_GPIO_PORT GPIOA
// #endif
// #ifndef BUTTON_GPIO_PIN
// #define BUTTON_GPIO_PIN GPIO0
// #endif

#ifndef BUTTON_SAMPLE_DELAY_CYCLES
#define BUTTON_SAMPLE_DELAY_CYCLES 1440000
Expand Down
34 changes: 34 additions & 0 deletions src/stm32f103/maplemini/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,65 @@
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED

#ifndef APP_BASE_ADDRESS
#define APP_BASE_ADDRESS 0x08002000
#endif
#ifndef FLASH_PAGE_SIZE
#define FLASH_PAGE_SIZE 1024
#endif
#ifndef DFU_UPLOAD_AVAILABLE
#define DFU_UPLOAD_AVAILABLE 1
#endif
#ifndef DFU_DOWNLOAD_AVAILABLE
#define DFU_DOWNLOAD_AVAILABLE 1
#endif

#ifndef HAVE_LED
#define HAVE_LED 1
#endif
#ifndef LED_GPIO_PORT
#define LED_GPIO_PORT GPIOB
#endif
#ifndef LED_GPIO_PIN
#define LED_GPIO_PIN GPIO1
#endif
#ifndef LED_OPEN_DRAIN
#define LED_OPEN_DRAIN 0
#endif

/* Technically, there is a button on PB8, but the button is
also shorted to BOOT0, so it's not very useful for us to
sample PB8 on boot, since pulling it high will already
trigger the ROM serial bootloader and prevent us from
running anyways. */
#ifndef HAVE_BUTTON
#define HAVE_BUTTON 0
#endif

#ifndef HAVE_USB_PULLUP_CONTROL
#define HAVE_USB_PULLUP_CONTROL 1
#endif
#ifndef USB_PULLUP_GPIO_PORT
#define USB_PULLUP_GPIO_PORT GPIOB
#endif
#ifndef USB_PULLUP_GPIO_PIN
#define USB_PULLUP_GPIO_PIN GPIO9
#endif
#ifndef USB_PULLUP_ACTIVE_HIGH
#define USB_PULLUP_ACTIVE_HIGH 0
#endif
#ifndef USB_PULLUP_OPEN_DRAIN
#define USB_PULLUP_OPEN_DRAIN 1
#endif

#ifndef USES_GPIOA
#define USES_GPIOA 0
#endif
#ifndef USES_GPIOB
#define USES_GPIOB 1
#endif
#ifndef USES_GPIOC
#define USES_GPIOC 0
#endif

#endif
24 changes: 24 additions & 0 deletions src/stm32f103/stlink/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,45 @@
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED

#ifndef APP_BASE_ADDRESS
#define APP_BASE_ADDRESS 0x08002000
#endif
#ifndef FLASH_SIZE_OVERRIDE
#define FLASH_SIZE_OVERRIDE 0x20000
#endif
#ifndef FLASH_PAGE_SIZE
#define FLASH_PAGE_SIZE 1024
#endif
#ifndef DFU_UPLOAD_AVAILABLE
#define DFU_UPLOAD_AVAILABLE 1
#endif
#ifndef DFU_DOWNLOAD_AVAILABLE
#define DFU_DOWNLOAD_AVAILABLE 1
#endif

#ifndef HAVE_LED
#define HAVE_LED 1
#endif
#ifndef LED_GPIO_PORT
#define LED_GPIO_PORT GPIOA
#endif
#ifndef LED_GPIO_PIN
#define LED_GPIO_PIN GPIO9
#endif
#ifndef LED_OPEN_DRAIN
#define LED_OPEN_DRAIN 0
#endif

#ifndef HAVE_BUTTON
#define HAVE_BUTTON 0
#endif

#ifndef HAVE_USB_PULLUP_CONTROL
#define HAVE_USB_PULLUP_CONTROL 0
#endif

#ifndef USES_GPIOA
#define USES_GPIOA 1
#endif

#endif
3 changes: 1 addition & 2 deletions src/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ ifeq ($(TARGET),STM32F103)
endif
ifeq ($(TARGET),BLUEPILL)
TARGET_COMMON_DIR := ./stm32f103
TARGET_SPEC_DIR := ./stm32f103/generic
TARGET_SPEC_DIR := ./stm32f103/bluepill
LDSCRIPT := ./stm32f103/stm32f103x8.ld
ARCH = STM32F1
DEFS += -DHAVE_LED=1 -DLED_GPIO_PORT=GPIOC -DLED_GPIO_PIN=GPIO13 -DLED_OPEN_DRAIN=1 -DUSES_GPIOC=1
endif
ifeq ($(TARGET),MAPLEMINI)
TARGET_COMMON_DIR := ./stm32f103
Expand Down