Align stm32f3 port with stm32f4
This commit is contained in:
parent
c0234a4579
commit
84c0fd7a09
7 changed files with 90 additions and 58 deletions
|
|
@ -1,61 +1,17 @@
|
|||
UF2_FAMILY_ID = 0x6b846188
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
ST_HAL_DRIVER = lib/st/stm32f3xx_hal_driver
|
||||
ST_CMSIS = lib/st/cmsis_device_f3
|
||||
CMSIS_5 = lib/CMSIS_5
|
||||
|
||||
# List of git submodules that is included as part of the UF2 version
|
||||
GIT_SUBMODULES = st/cmsis_device_f3 st/stm32f3xx_hal_driver tinyusb
|
||||
|
||||
include ../make.mk
|
||||
|
||||
# Port Compiler Flags
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-nostdlib -nostartfiles \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
|
||||
|
||||
# suppress warning caused by vendor mcu driver
|
||||
CFLAGS += -Wno-error=cast-align -Wno-error=unused-parameter
|
||||
|
||||
LD_FILES ?= $(PORT_DIR)/linker/STM32F303VCTx_FLASH.ld
|
||||
|
||||
# Port source
|
||||
PORT_SRC_C += \
|
||||
$(addprefix $(CURRENT_PATH)/, $(wildcard *.c)) \
|
||||
$(ST_CMSIS)/Source/Templates/system_stm32f3xx.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_cortex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_rcc.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_rcc_ex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_gpio.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_flash.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_flash_ex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_uart.c
|
||||
|
||||
SRC_C += \
|
||||
$(PORT_SRC_C) \
|
||||
lib/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
|
||||
|
||||
# Port include
|
||||
INC += \
|
||||
$(TOP)/$(CMSIS_5)/CMSIS/Core/Include \
|
||||
$(TOP)/$(ST_CMSIS)/Include \
|
||||
$(TOP)/$(ST_HAL_DRIVER)/Inc
|
||||
|
||||
include port.mk
|
||||
include ../rules.mk
|
||||
|
||||
# flash target ROM bootloader
|
||||
# flash using ROM bootloader
|
||||
flash-dfu-util: $(BUILD)/$(OUTNAME).bin
|
||||
dfu-util -R -a 0 --dfuse-address 0x08000000 -D $<
|
||||
|
||||
#-------------- Self-update --------------
|
||||
#------------------------------------------
|
||||
# Self-update
|
||||
#------------------------------------------
|
||||
|
||||
self-update:
|
||||
@echo "not implemented yet"
|
||||
|
|
|
|||
19
ports/stm32f3/README.md
Normal file
19
ports/stm32f3/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# TinyUF2 for STM32F3
|
||||
|
||||
TinyUF2 reserved 16KB therefore application should start at `0x08004000`
|
||||
|
||||
To create a UF2 image from a .bin file, either use family option `STM32F3` or its magic number as follows:
|
||||
|
||||
From hex
|
||||
|
||||
```
|
||||
uf2conv.py -c -f 0x6b846188 firmware.hex
|
||||
uf2conv.py -c -f STM32F3 firmware.hex
|
||||
```
|
||||
|
||||
From bin
|
||||
|
||||
```
|
||||
uf2conv.py -c -b 0x08004000 -f STM32F3 firmware.bin
|
||||
uf2conv.py -c -b 0x08004000 -f 0x6b846188 firmware.bin
|
||||
```
|
||||
|
|
@ -23,7 +23,10 @@
|
|||
*/
|
||||
|
||||
#include "board_api.h"
|
||||
#include "tusb.h" // for logging
|
||||
|
||||
#ifndef BUILD_NO_TINYUSB
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
#define FLASH_CACHE_SIZE 512
|
||||
#define FLASH_CACHE_INVALID_ADDR 0xffffffff
|
||||
|
|
@ -85,7 +88,7 @@ void flash_write(uint32_t dst, const uint8_t *src, int len)
|
|||
|
||||
if (sector == 0)
|
||||
{
|
||||
TU_LOG1("invalid sector\r\n");
|
||||
TUF2_LOG1("invalid sector\r\n");
|
||||
}
|
||||
|
||||
HAL_FLASH_Unlock();
|
||||
|
|
@ -94,7 +97,7 @@ void flash_write(uint32_t dst, const uint8_t *src, int len)
|
|||
{
|
||||
uint32_t SectorError = 0;
|
||||
|
||||
TU_LOG1("Erase: %08lX size = %lu\n", addr, size);
|
||||
TUF2_LOG1("Erase: %08lX size = %lu\n", addr, size);
|
||||
|
||||
FLASH_EraseInitTypeDef EraseInit;
|
||||
EraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
|
|
@ -106,7 +109,7 @@ void flash_write(uint32_t dst, const uint8_t *src, int len)
|
|||
|
||||
if (SectorError != 0xFFFFFFFF)
|
||||
{
|
||||
TU_LOG1("failed to erase!\r\n");
|
||||
TUF2_LOG1("failed to erase!\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,9 +119,10 @@ void flash_write(uint32_t dst, const uint8_t *src, int len)
|
|||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, dst + i, (uint64_t) data);
|
||||
}
|
||||
|
||||
// verify contents
|
||||
if (memcmp((void*)dst, src, len) != 0)
|
||||
{
|
||||
TU_LOG1("failed to write\r\n");
|
||||
TUF2_LOG1("Failed to write\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@
|
|||
|
||||
#include "board_api.h"
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
#ifndef BUILD_NO_TINYUSB
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
|
|
@ -160,6 +163,7 @@ void board_app_jump(void)
|
|||
#if defined(UART_DEV) && CFG_TUSB_DEBUG
|
||||
HAL_UART_DeInit(&UartHandle);
|
||||
HAL_GPIO_DeInit(UART_GPIO_PORT, UART_TX_PIN | UART_RX_PIN);
|
||||
UART_CLOCK_DISABLE();
|
||||
#endif
|
||||
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12 | GPIO_PIN_11);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#ifndef BOARD_FLASH_APP_START
|
||||
#define BOARD_FLASH_APP_START 0x08004000
|
||||
#endif
|
||||
|
||||
#define BOARD_RAM_START 0x20000000
|
||||
#define BOARD_RAM_SIZE 0x9FFF
|
||||
|
||||
|
|
|
|||
47
ports/stm32f3/port.mk
Normal file
47
ports/stm32f3/port.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
UF2_FAMILY_ID = 0x6b846188
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
ST_HAL_DRIVER = lib/st/stm32f3xx_hal_driver
|
||||
ST_CMSIS = lib/st/cmsis_device_f3
|
||||
CMSIS_5 = lib/CMSIS_5
|
||||
|
||||
# Port Compiler Flags
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-nostdlib -nostartfiles \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
|
||||
|
||||
# suppress warning caused by vendor mcu driver
|
||||
CFLAGS += -Wno-error=cast-align -Wno-error=unused-parameter
|
||||
|
||||
# default linker file
|
||||
LD_FILES ?= $(PORT_DIR)/linker/STM32F303VCTx_FLASH.ld
|
||||
|
||||
# Port source
|
||||
SRC_C += \
|
||||
ports/stm32f3/boards.c \
|
||||
ports/stm32f3/board_flash.c \
|
||||
$(ST_CMSIS)/Source/Templates/system_stm32f3xx.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_cortex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_rcc.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_rcc_ex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_gpio.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_flash.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_flash_ex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_uart.c
|
||||
|
||||
ifndef BUILD_NO_TINYUSB
|
||||
SRC_C += lib/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
|
||||
endif
|
||||
|
||||
# Port include
|
||||
INC += \
|
||||
$(TOP)/$(CMSIS_5)/CMSIS/Core/Include \
|
||||
$(TOP)/$(ST_CMSIS)/Include \
|
||||
$(TOP)/$(ST_HAL_DRIVER)/Inc
|
||||
|
|
@ -34,9 +34,8 @@
|
|||
// COMMON CONFIGURATION
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// defined by board.mk
|
||||
#ifndef CFG_TUSB_MCU
|
||||
#error CFG_TUSB_MCU must be defined
|
||||
#error CFG_TUSB_MCU must be defined in board.mk
|
||||
#endif
|
||||
|
||||
// RHPort number used for device can be defined by board.mk, default to port 0
|
||||
|
|
@ -51,8 +50,10 @@
|
|||
// This example doesn't use an RTOS
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
|
||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
||||
// #define CFG_TUSB_DEBUG 0
|
||||
// can be defined by compiler in DEBUG build
|
||||
#ifndef CFG_TUSB_DEBUG
|
||||
#define CFG_TUSB_DEBUG 0
|
||||
#endif
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||
|
|
|
|||
Loading…
Reference in a new issue