Rearrange MCU namespace so that STM32 is one subtype.

This will allow fitting AT32 alongside, which is an "almost" STM32 clone
with a slightly different and confusing naming scheme.
This commit is contained in:
Keir Fraser
2021-04-27 15:11:16 +01:00
parent fb93abea9e
commit 2809d34c28
35 changed files with 60 additions and 60 deletions
+4 -4
View File
@@ -26,10 +26,10 @@ all: scripts/greaseweazle/version.py
srec_cat bootloader/Bootloader.hex -Intel src/$(PROJ).hex -Intel \
-o $(PROJ)-$(VER).hex -Intel
$(PYTHON) ./scripts/mk_update.py new $(PROJ)-$(VER).upd \
bootloader/Bootloader.bin src/$(PROJ).bin $(stm32)
bootloader/Bootloader.bin src/$(PROJ).bin $(mcu)
blinky:
$(MAKE) debug=y stm32=f1 -C blinky_test -f $(ROOT)/Rules.mk \
$(MAKE) debug=y mcu=stm32f1 -C blinky_test -f $(ROOT)/Rules.mk \
Blinky.elf Blinky.bin Blinky.hex
clean::
@@ -45,7 +45,7 @@ dist:
mkdir -p $(PROJ)-$(VER)/scripts/misc
mkdir -p $(PROJ)-$(VER)/alt
$(MAKE) clean
$(MAKE) stm32=f1 all blinky
$(MAKE) mcu=stm32f1 all blinky
cp -a $(PROJ)-$(VER).hex $(PROJ)-$(VER)/$(PROJ)-F1-$(VER).hex
cp -a $(PROJ)-$(VER).upd $(PROJ)-$(VER)/$(PROJ)-$(VER).upd
cp -a blinky_test/Blinky.hex $(PROJ)-$(VER)/alt/Blinky_Test-$(VER).hex
@@ -60,7 +60,7 @@ dist:
cp -a scripts/misc/*.py $(PROJ)-$(VER)/scripts/misc/
cp -a RELEASE_NOTES $(PROJ)-$(VER)/
$(MAKE) clean
$(MAKE) stm32=f7 all
$(MAKE) mcu=stm32f7 all
cp -a $(PROJ)-$(VER).hex $(PROJ)-$(VER)/$(PROJ)-F7-$(VER).hex
$(PYTHON) ./scripts/mk_update.py cat $(PROJ)-$(VER)/$(PROJ)-$(VER).upd \
$(PROJ)-$(VER)/$(PROJ)-$(VER).upd $(PROJ)-$(VER).upd
+4 -4
View File
@@ -24,11 +24,11 @@ FLAGS += -fno-common -fno-exceptions -fno-strict-aliasing
FLAGS += -mlittle-endian -mthumb -mfloat-abi=soft
FLAGS += -Wno-unused-value -ffunction-sections
ifeq ($(stm32),f1)
FLAGS += -mcpu=cortex-m3 -DSTM32F=1
ifeq ($(mcu),stm32f1)
FLAGS += -mcpu=cortex-m3 -DSTM32F1=1 -DMCU=1
stm32f1=y
else ifeq ($(stm32),f7)
FLAGS += -mcpu=cortex-m7 -DSTM32F=7
else ifeq ($(mcu),stm32f7)
FLAGS += -mcpu=cortex-m7 -DSTM32F7=7 -DMCU=7
stm32f7=y
endif
+1 -1
View File
@@ -1,4 +1,4 @@
RPATH = $(ROOT)/src/f1
RPATH = $(ROOT)/src/mcu/stm32f1
OBJS += stm32.o
OBJS += fpec.o
+2 -2
View File
@@ -1,10 +1,10 @@
#if STM32F == 1
#if MCU == STM32F1
#define FLASH_BASE 0x08000000
#define FLASH_LEN 8K
#elif STM32F == 7
#elif MCU == STM32F7
#define FLASH_BASE 0x08000000
#define FLASH_LEN 16K
+1 -3
View File
@@ -13,9 +13,7 @@ OBJS += util.o
OBJS-$(debug) += console.o
SUBDIRS += usb
SUBDIRS-$(stm32f1) += f1
SUBDIRS-$(stm32f7) += f7
SUBDIRS += mcu usb
.PHONY: $(RPATH)/build_info.c
build_info.o: CFLAGS += -DFW_MAJOR=$(FW_MAJOR) -DFW_MINOR=$(FW_MINOR)
+2
View File
@@ -0,0 +1,2 @@
SUBDIRS-$(stm32f1) += stm32f1
SUBDIRS-$(stm32f7) += stm32f7
@@ -1,4 +1,4 @@
RPATH = $(ROOT)/src/f1
RPATH = $(ROOT)/src/mcu/stm32f1
OBJS += stm32.o
OBJS += fpec.o
@@ -1,4 +1,4 @@
RPATH = $(ROOT)/src/f7
RPATH = $(ROOT)/src/mcu/stm32f7
OBJS += stm32.o
OBJS += fpec.o
+8 -8
View File
@@ -16,14 +16,14 @@
#include <limits.h>
#include "util.h"
#include "stm32/common_regs.h"
#include "stm32/common.h"
#if STM32F == 1
#include "stm32/f1_regs.h"
#include "stm32/f1.h"
#elif STM32F == 7
#include "stm32/f7_regs.h"
#include "stm32/f7.h"
#include "mcu/stm32/common_regs.h"
#include "mcu/stm32/common.h"
#if MCU == STM32F1
#include "mcu/stm32/f1_regs.h"
#include "mcu/stm32/f1.h"
#elif MCU == STM32F7
#include "mcu/stm32/f7_regs.h"
#include "mcu/stm32/f7.h"
#endif
#include "intrinsics.h"
+1 -1
View File
@@ -46,7 +46,7 @@ def mk_cat_entry(dat, hw_model, sig):
def new_upd(argv):
dat = b'GWUP'
hw_model = int(re.match("f(\d)", argv[2]).group(1))
hw_model = int(re.match("\w+f(\d)$", argv[2]).group(1))
with open(argv[1], "rb") as gw_f:
dat += mk_cat_entry(gw_f.read(), hw_model, b'GW')
with open(argv[0], "rb") as bl_f:
+3 -3
View File
@@ -3,9 +3,9 @@ ENTRY(vector_table)
MEMORY
{
FLASH (rx) : ORIGIN = FLASH_BASE, LENGTH = FLASH_LEN
#if STM32F == 1
#if MCU == STM32F1
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
#elif STM32F == 7
#elif MCU == STM32F7
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
EXT_RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 192K
#endif
@@ -51,7 +51,7 @@ SECTIONS
_ebss = .;
} >RAM
#if STM32F == 7
#if MCU == STM32F7
.ext_ram (NOLOAD) : {
. = ALIGN(8);
_ext_ram_start = .;
+2 -2
View File
@@ -1,10 +1,10 @@
#if STM32F == 1
#if MCU == STM32F1
#define FLASH_BASE 0x08002000
#define FLASH_LEN 56K
#elif STM32F == 7
#elif MCU == STM32F7
#define FLASH_BASE 0x08004000
#define FLASH_LEN 48K
+1 -3
View File
@@ -12,9 +12,7 @@ OBJS += floppy.o
OBJS-$(debug) += console.o
SUBDIRS += usb
SUBDIRS-$(stm32f1) += f1
SUBDIRS-$(stm32f7) += f7
SUBDIRS += mcu usb
.PHONY: build_info.c
build_info.o: CFLAGS += -DFW_MAJOR=$(FW_MAJOR) -DFW_MINOR=$(FW_MINOR)
+4 -4
View File
@@ -20,10 +20,10 @@ static void gpio_pull_up_pins(GPIO gpio, uint16_t mask)
}
}
#if STM32F == 1
#include "f1/board.c"
#elif STM32F == 7
#include "f7/board.c"
#if MCU == STM32F1
#include "mcu/stm32f1/board.c"
#elif MCU == STM32F7
#include "mcu/stm32f7/board.c"
#endif
void board_init(void)
+8 -8
View File
@@ -13,9 +13,9 @@
#define BAUD 3000000 /* 3Mbaud */
#endif
#if STM32F == 1
#if MCU == STM32F1
#define PCLK SYSCLK
#elif STM32F == 7
#elif MCU == STM32F7
#define PCLK (APB2_MHZ * 1000000)
#endif
@@ -23,11 +23,11 @@
static void ser_putc(uint8_t c)
{
#if STM32F == 1
#if MCU == STM32F1
while (!(usart1->sr & USART_SR_TXE))
cpu_relax();
usart1->dr = c;
#elif STM32F == 7
#elif MCU == STM32F7
while (!(usart1->isr & USART_ISR_TXE))
cpu_relax();
usart1->tdr = c;
@@ -83,10 +83,10 @@ void console_init(void)
peripheral_clock_delay();
/* Enable TX pin (PA9) for USART output, RX pin (PA10) as input. */
#if STM32F == 1
#if MCU == STM32F1
gpio_configure_pin(gpioa, 9, AFO_pushpull(_10MHz));
gpio_configure_pin(gpioa, 10, GPI_pull_up);
#elif STM32F == 7
#elif MCU == STM32F7
gpio_set_af(gpioa, 9, 7);
gpio_set_af(gpioa, 10, 7);
gpio_configure_pin(gpioa, 9, AFO_pushpull(IOSPD_MED));
@@ -102,9 +102,9 @@ void console_init(void)
* any serial input to cause a crash dump of the stuck context. */
void console_crash_on_input(void)
{
#if STM32F == 1
#if MCU == STM32F1
(void)usart1->dr; /* clear UART_SR_RXNE */
#elif STM32F == 7
#elif MCU == STM32F7
usart1->rqr = USART_RQR_RXFRQ; /* clear ISR_RXNE */
usart1->icr = USART_ICR_ORECF; /* clear ISR_ORE */
#endif
+6 -6
View File
@@ -45,10 +45,10 @@ static const struct gw_delay factory_delay_params = {
.watchdog = 10000
};
#if STM32F == 1
#include "f1/floppy.c"
#elif STM32F == 7
#include "f7/floppy.c"
#if MCU == STM32F1
#include "mcu/stm32f1/floppy.c"
#elif MCU == STM32F7
#include "mcu/stm32f7/floppy.c"
#endif
static struct index {
@@ -356,7 +356,7 @@ struct gw_info gw_info = {
.is_main_firmware = 1,
.max_cmd = CMD_MAX,
.sample_freq = 72000000u,
.hw_model = STM32F
.hw_model = MCU
};
static void watchdog_kick(void)
@@ -1318,7 +1318,7 @@ static void process_command(void)
sink_source_prep(&ssb);
break;
}
#if STM32F == 7
#if MCU == STM32F7
case CMD_SWITCH_FW_MODE: {
uint8_t mode = u_buf[2];
if ((len != 3) || (mode & ~1))
+6 -6
View File
@@ -9,11 +9,11 @@
* See the file COPYING for more details, or visit <http://unlicense.org>.
*/
#if STM32F == 1
#if MCU == STM32F1
/* 8kB-64kB (56kB total) */
#define FIRMWARE_START 0x08002000
#define FIRMWARE_END 0x08010000
#elif STM32F == 7
#elif MCU == STM32F7
/* 16kB-64KB (48kB total) */
#define FIRMWARE_START 0x08004000
#define FIRMWARE_END 0x08010000
@@ -40,7 +40,7 @@ static bool_t upd_strapped;
struct gw_info gw_info = {
.is_main_firmware = 0,
.max_cmd = CMD_MAX,
.hw_model = STM32F
.hw_model = MCU
};
static void blink_init(void)
@@ -159,7 +159,7 @@ static void process_command(void)
update_prep(u_len);
break;
}
#if STM32F == 7
#if MCU == STM32F7
case CMD_SWITCH_FW_MODE: {
uint8_t mode = u_buf[2];
if ((len != 3) || (mode & ~1))
@@ -223,7 +223,7 @@ static void update_process(void)
}
}
#if STM32F == 1
#if MCU == STM32F1
static bool_t enter_bootloader(void)
{
@@ -247,7 +247,7 @@ static bool_t enter_bootloader(void)
return upd_strapped;
}
#elif STM32F == 7
#elif MCU == STM32F7
static bool_t check_update_requested(void)
{
+2
View File
@@ -0,0 +1,2 @@
SUBDIRS-$(stm32f1) += stm32f1
SUBDIRS-$(stm32f7) += stm32f7
+3 -3
View File
@@ -9,12 +9,12 @@
* See the file COPYING for more details, or visit <http://unlicense.org>.
*/
#if STM32F == 1
#if MCU == STM32F1
void IRQ_25(void) __attribute__((alias("IRQ_timer")));
#define TIMER_IRQ 25
#define tim tim1
#define tim_bits 16
#elif STM32F == 7
#elif MCU == STM32F7
void IRQ_50(void) __attribute__((alias("IRQ_timer")));
#define TIMER_IRQ 50
#define tim tim5 /* 32-bit timer */
@@ -114,7 +114,7 @@ void timer_cancel(struct timer *timer)
void timers_init(void)
{
#if STM32F == 7
#if MCU == STM32F7
rcc->apb1enr |= RCC_APB1ENR_TIM5EN;
peripheral_clock_delay();
#endif