Skip to content

Commit

Permalink
Merge pull request #35 from akospasztor/31-gcc
Browse files Browse the repository at this point in the history
Release v1.1.1
  • Loading branch information
akospasztor authored May 27, 2020
2 parents 0372f9f + 6ec46b5 commit 0bde885
Show file tree
Hide file tree
Showing 12 changed files with 65,803 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.vscode/
*.pyc
**/EWARM/*.dep
**/EWARM/settings/
**/EWARM/**/Exe/
**/EWARM/**/List/
**/EWARM/**/Obj/
*.pyc
**/GCC/build/
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Changelog for STM32 Bootloader

## [Unreleased]
- Check checksum of application found on SD card before programming

## 1.1.1
Released: 2020-05-27 | Download: [1.1.1](https://github.com/akospasztor/stm32-bootloader/releases/tag/v1.1.1)
### Added
- GNU Arm Embedded Toolchain support for the STM32L496-Discovery project example
- Automatic source code formatting with clang-format
- Source code format check with CI
### Changed
- Replaced GitHub Actions with Azure Pipelines
### Fixed
- Doxygen warnings are fixed
- READMEs are updated


## 1.1.0
Released: 2019-10-26 | Download: [1.1.0](https://github.com/akospasztor/stm32-bootloader/releases/tag/v1.1.0)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Customizable Bootloader for STM32 microcontrollers. This project includes demons

Each example uses the same bootloader library located in the `lib/stm32-bootloader` folder. The examples are located in the `projects` folder and they come with a separate, dedicated README file with description related to that specific implementation.

Update: the `STM32L496-Discovery` example supports compiling and building the project with the GNU Arm Embedded Toolchain out-of-the-box, in addition to IAR EWARM. Check out the project README for further information.

Please refer to <https://akospasztor.github.io/stm32-bootloader> for complete documentation of the bootloader library source code.

![Build Status](https://dev.azure.com/akospasztor/stm32-bootloader/_apis/build/status/akospasztor.stm32-bootloader?branchName=master)
Expand Down Expand Up @@ -79,7 +81,7 @@ The application image has to be in binary format. If the checksum verification i

__Important notes__:
- In order to perform a successful application jump from the bootloader, the vector table of the application firmware should be relocated. On system reset, the vector table is fixed at address 0x00000000. When creating an application, the microcontroller startup code sets the vector table offset to 0x0000 in the `system_stm32xxxx.c` file by default. This has to be either disabled (the bootloader can be configured to perform the vector table relocation before the jump) or manually set the vector table offset register (VTOR) to the appropriate offset value which is the start address of the application space. For more information, please refer to [[1]](#references).
- The linker settings of the application firmware need to be adjusted from their default settings so that the start address of FLASH reflects the actual start address of the application space.
- The linker settings of the application firmware need to be adjusted from their default settings so that the start address of flash reflects the actual start address of the application space.

## Configuration
The bootloader can be widely configured in the `bootloader.h` file. The file includes detailed comments and descriptions related to the configurable parameters and definitions.
Expand Down
2 changes: 1 addition & 1 deletion lib/stm32-bootloader/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* Private defines -----------------------------------------------------------*/
#define BOOTLOADER_VERSION_MAJOR 1 /*!< Major version */
#define BOOTLOADER_VERSION_MINOR 1 /*!< Minor version */
#define BOOTLOADER_VERSION_PATCH 0 /*!< Patch version */
#define BOOTLOADER_VERSION_PATCH 1 /*!< Patch version */
#define BOOTLOADER_VERSION_RC 0 /*!< Release candidate version */

/* Private typedef -----------------------------------------------------------*/
Expand Down
134 changes: 134 additions & 0 deletions projects/STM32L496-Discovery/GCC/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Configuration ################################################################
# Target name
TARGET = stm32-bootloader
# Debug configuration selector
DEBUG = 1
# Optimization level
OPT = -Og
# Build path
BUILD_DIR = build

# Defines ######################################################################
# Assembly defines
ASM_DEFS =

# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32L496xx

# Includes #####################################################################
# Assembly includes
ASM_INCLUDES =

# C includes
C_INCLUDES = \
-I../include \
-I../../../lib/stm32-bootloader \
-I../../../lib/fatfs \
-I../../../drivers/CMSIS/Include \
-I../../../drivers/CMSIS/Device/ST/STM32L4xx/Include \
-I../../../drivers/STM32L4xx_HAL_Driver/Inc

# Source files #################################################################
# Assembly source files
ASM_SOURCES = \
startup_stm32l496xx.s

# C source files
C_SOURCES = \
$(wildcard ../source/*.c) \
$(wildcard ../../../lib/stm32-bootloader/*.c) \
$(wildcard ../../../lib/fatfs/*.c) \
../../../lib/fatfs/option/unicode.c \
$(wildcard ../../../drivers/STM32L4xx_HAL_Driver/Src/*.c)

# Toolchain ####################################################################
CUSTOMPATH = "C:/Program Files (x86)/GNU Tools ARM Embedded/8 2019-q3-update/bin"
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(CUSTOMPATH)/$(PREFIX)gcc
AS = $(CUSTOMPATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(CUSTOMPATH)/$(PREFIX)objcopy
SZ = $(CUSTOMPATH)/$(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S

# Compiler flags ###############################################################
# CPU
CPU = -mcpu=cortex-m4
# FPU
FPU = -mfpu=fpv4-sp-d16
# Float-abi
FLOAT-ABI = -mfloat-abi=hard
# MCU
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# Create compiler flags
ASFLAGS = $(MCU) $(ASM_DEFS) $(ASM_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

# Generate debug information
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif

# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"

# Linker flags #################################################################
# Linker script
LDSCRIPT = stm32l496xx_flash.ld

# Libraries
LIBS = -lc -lm -lnosys
LIBDIR =

# Create linker flags
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

# Build target #################################################################
# Default: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin

# List of C objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))

# List of ASM objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(ASFLAGS) $< -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $@

$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $@

$(BUILD_DIR):
mkdir $@

# Clean
clean:
-rm -rf $(BUILD_DIR)

# Dependencies
-include $(wildcard $(BUILD_DIR)/*.d)
Loading

0 comments on commit 0bde885

Please sign in to comment.