Skip to content

Instantly share code, notes, and snippets.

@RickKimball
Last active January 28, 2018 22:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RickKimball/71a388efd58ac0d3a0e1a272ecf4e095 to your computer and use it in GitHub Desktop.
Save RickKimball/71a388efd58ac0d3a0e1a272ecf4e095 to your computer and use it in GitHub Desktop.
stm32duino Makefile for adding custom boards.

This gist provides a way to maintain a custom set of boards that work with stm32duino. Two new boards are added, 'Maple Mini Custom' and 'Blue Pill'. I wanted a stable configuration that isn't changing without me doing the changes. The default boards.txt seem to be subject to everyone's flight of fancy. Using a boards.custom file, I know it won't change.

The maple mini board adds the ability to run without a bootloader. This give you back full access to the entire flash and ram. It also adds 3 new upload options, Serial, BMP, and STLink while retaining the pin mapping of the maple mini variant.

The Blue Pill board provides a stable configuration for a "bluepill" board that is really the stm32f103c generic variant.

To use this extract the files in this gist into ~/Arduino/hardware/STM32F1. Using the Makefile provided, a file called boards.custom is appended to the github boards.txt file after pulling the latest boards.txt from the stm32duino github repo.

# stop the Arduino IDE
$ make clean all
# start the Arduino IDE, you should see 2 new boards "Maple Mini Custom" and "Blue Pill"
# Custom STM32 Boards
#
# boards:
# maple_mini - adds a no_bootloader option along upload via with Serial,BMP,STLINK
# bluepill - stm32f103c8 generic board allows you to customize to your desires
# defaults to 128k,
#
maple_mini.name=Maple Mini Custom
maple_mini.build.board=MAPLE_MINI_
maple_mini.vid.0=0x1EAF
maple_mini.pid.0=0x0004
maple_mini.build.core=maple
maple_mini.build.cpu_flags=-DMCU_STM32F103CB -DSERIAL_USB
maple_mini.build.variant=maple_mini
maple_mini.upload.usbID=1EAF:0003
maple_mini.upload.use_1200bps_touch=false
maple_mini.upload.file_type=bin
maple_mini.upload.auto_reset=true
maple_mini.menu.bootloader_version.none=No Bootloader (20K RAM, 128K Flash)
maple_mini.menu.bootloader_version.none.build.ldscript=ld/no_bootloader.ld
maple_mini.menu.bootloader_version.none.build.vect=VECT_TAB_ADDR=0x8000000
maple_mini.menu.bootloader_version.none.upload.maximum_data_size=20480
maple_mini.menu.bootloader_version.none.upload.maximum_size=131072
#-- CPU Clock frequency
maple_mini.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
maple_mini.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
maple_mini.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
maple_mini.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
maple_mini.menu.upload_method.serialMethod=Serial
maple_mini.menu.upload_method.serialMethod.upload.protocol=maple_serial
maple_mini.menu.upload_method.serialMethod.upload.tool=serial_upload
maple_mini.menu.upload_method.serialMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG -DSERIAL_USB
maple_mini.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
maple_mini.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
maple_mini.menu.upload_method.BMPMethod.upload.tool=bmp_upload
maple_mini.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG -DSERIAL_USB
maple_mini.menu.upload_method.STLinkMethod=STLink
maple_mini.menu.upload_method.STLinkMethod.upload.protocol=STLink
maple_mini.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
maple_mini.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG -DSERIAL_USB
###################### Blue Pill stm32f103c8t6 ########################################
bluepill.name=Blue Pill
bluepill.vid.0=0x1EAF
bluepill.pid.0=0x0004
bluepill.build.variant=generic_stm32f103c
bluepill.build.vect=VECT_TAB_ADDR=0x8000000
bluepill.build.core=maple
bluepill.build.board=GENERIC_STM32F103C
bluepill.upload.use_1200bps_touch=false
bluepill.upload.file_type=bin
bluepill.upload.auto_reset=true
bluepill.menu.device_variant.STM32F103CB=bluepill (20k RAM. 128k Flash)
bluepill.menu.device_variant.STM32F103CB.build.cpu_flags=-DMCU_STM32F103CB
bluepill.menu.device_variant.STM32F103CB.build.ldscript=ld/jtag.ld
bluepill.menu.device_variant.STM32F103CB.upload.maximum_data_size=20480
bluepill.menu.device_variant.STM32F103CB.upload.maximum_size=131072
#---------------------------- UPLOAD METHODS ---------------------------
bluepill.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
bluepill.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
bluepill.menu.upload_method.BMPMethod.upload.tool=bmp_upload
bluepill.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
bluepill.menu.upload_method.jlinkMethod=JLink
bluepill.menu.upload_method.jlinkMethod.upload.protocol=jlink
bluepill.menu.upload_method.jlinkMethod.upload.tool=jlink_upload
bluepill.menu.upload_method.jlinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG -DSERIAL_USB -DGENERIC_BOOTLOADER
bluepill.menu.upload_method.serialMethod=Serial
bluepill.menu.upload_method.serialMethod.upload.protocol=maple_serial
bluepill.menu.upload_method.serialMethod.upload.tool=serial_upload
bluepill.menu.upload_method.serialMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
bluepill.menu.upload_method.STLinkMethod=STLink
bluepill.menu.upload_method.STLinkMethod.upload.protocol=STLink
bluepill.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
bluepill.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
#-- CPU Clock frequency
bluepill.menu.cpu_speed.speed_72mhz=72MHz
bluepill.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
bluepill.menu.cpu_speed.speed_48mhz=48MHz
bluepill.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
# EOF
# STM32F1/Makefile - provide a way to use a custom boards.txt
#
#
.phony: all checkout clean
all: boards.txt
checkout:
git checkout boards.txt
boards.txt:
git show HEAD:STM32F1/boards.txt >/tmp/boards.txt; cat /tmp/boards.txt boards.custom >boards.txt
clean:
rm -f boards.txt
@lacklustrlabs
Copy link

You can skip the Makefile if you just rename boards.custom to boards.local.txt.
The downside is that you will not have that stable configuration you wanted.

But thanks for this, this is just what I needed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment