From 5582afbe037d78edbf1748f1574ac260384d5642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Sundstr=C3=B6m?= Date: Mon, 9 Feb 2026 15:10:25 +0100 Subject: [PATCH] misc: Support for STM32401CD Blackpill as debug probe --- cross-file/blackpill-f401cd.ini | 24 ++++++++++++++ meson_options.txt | 1 + src/platforms/blackpill-f401cd/README.md | 4 +++ src/platforms/blackpill-f401cd/platform.h | 31 +++++++++++++++++++ .../common/blackpill-f4/blackpill-f401cd.ld | 30 ++++++++++++++++++ src/platforms/meson.build | 1 + 6 files changed, 91 insertions(+) create mode 100644 cross-file/blackpill-f401cd.ini create mode 100644 src/platforms/blackpill-f401cd/README.md create mode 100644 src/platforms/blackpill-f401cd/platform.h create mode 100644 src/platforms/common/blackpill-f4/blackpill-f401cd.ld diff --git a/cross-file/blackpill-f401cd.ini b/cross-file/blackpill-f401cd.ini new file mode 100644 index 00000000000..bc286c80245 --- /dev/null +++ b/cross-file/blackpill-f401cd.ini @@ -0,0 +1,24 @@ +# This a cross-file for the blackpill-f401cd probe, providing sane default options for it. + +[binaries] +c = 'arm-none-eabi-gcc' +cpp = 'arm-none-eabi-g++' +ld = 'arm-none-eabi-gcc' +ar = 'arm-none-eabi-ar' +nm = 'arm-none-eabi-nm' +strip = 'arm-none-eabi-strip' +objcopy = 'arm-none-eabi-objcopy' +objdump = 'arm-none-eabi-objdump' +size = 'arm-none-eabi-size' + +[host_machine] +system = 'bare-metal' +cpu_family = 'arm' +cpu = 'arm' +endian = 'little' + +[project options] +probe = 'blackpill-f401cd' +targets = 'cortexar,cortexm,riscv32,riscv64,apollo3,at32f4,ch32,ch579,efm,gd32,hc32,lpc,mm32,nrf,nxp,puya,renesas,rp,sam,stm,ti,xilinx' +rtt_support = true +bmd_bootloader = true diff --git a/meson_options.txt b/meson_options.txt index 9129524f380..b54a2440c18 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,6 +5,7 @@ option( '', '96b_carbon', 'blackpill-f401cc', + 'blackpill-f401cd', 'blackpill-f401ce', 'blackpill-f411ce', 'bluepill', diff --git a/src/platforms/blackpill-f401cd/README.md b/src/platforms/blackpill-f401cd/README.md new file mode 100644 index 00000000000..fa4e2106eb8 --- /dev/null +++ b/src/platforms/blackpill-f401cd/README.md @@ -0,0 +1,4 @@ +This platform supports the Black Pill F401CD, with STM32F401CD. + +Detailed information about this platform can be found found in the [readme of the common blackpill-f4 code](./../common/blackpill-f4/README.md). + diff --git a/src/platforms/blackpill-f401cd/platform.h b/src/platforms/blackpill-f401cd/platform.h new file mode 100644 index 00000000000..34c767c3dbc --- /dev/null +++ b/src/platforms/blackpill-f401cd/platform.h @@ -0,0 +1,31 @@ +/* + * This file is part of the Black Magic Debug project. + * + * Copyright (C) 2011 Black Sphere Technologies Ltd. + * Written by Gareth McMullin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* This file provides the platform specific declarations for the blackpill-f401cd implementation. */ + +#ifndef PLATFORMS_BLACKPILL_F401CD_PLATFORM_H +#define PLATFORMS_BLACKPILL_F401CD_PLATFORM_H + +#define PLATFORM_IDENT "(BlackPill-F401CD) " +#define PLATFORM_CLOCK_FREQ RCC_CLOCK_3V3_84MHZ + +#include "blackpill-f4.h" + +#endif /* PLATFORMS_BLACKPILL_F401CD_PLATFORM_H */ diff --git a/src/platforms/common/blackpill-f4/blackpill-f401cd.ld b/src/platforms/common/blackpill-f4/blackpill-f401cd.ld new file mode 100644 index 00000000000..ea032a38af9 --- /dev/null +++ b/src/platforms/common/blackpill-f4/blackpill-f401cd.ld @@ -0,0 +1,30 @@ +/* + * This file is part of the libopenstm32 project. + * + * Copyright (C) 2010 Thomas Otto + * Copyright (C) 2024 1BitSquared + * Modified by Rachel Mant + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* Define memory regions. */ +MEMORY +{ + rom (rx) : ORIGIN = 0x08000000, LENGTH = 384K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K +} + +/* Include the platform common linker script. */ +INCLUDE ../blackmagic.ld diff --git a/src/platforms/meson.build b/src/platforms/meson.build index 5232c208ca8..3e4e6210127 100644 --- a/src/platforms/meson.build +++ b/src/platforms/meson.build @@ -44,6 +44,7 @@ subdir('common/tm4c') # This is used to allow multiple probes share the same source code probe_alias_map = { 'blackpill-f401cc': 'common/blackpill-f4', + 'blackpill-f401cd': 'common/blackpill-f4', 'blackpill-f401ce': 'common/blackpill-f4', 'blackpill-f411ce': 'common/blackpill-f4', 'bluepill': 'stlink',