[Cryptech-Commits] [sw/stm32] 05/06: Only the HSM project needs the RTOS; most of the test projects can use the STM32 HAL code directly.
git at cryptech.is
git at cryptech.is
Mon Jun 13 20:55:46 UTC 2016
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch master
in repository sw/stm32.
commit a5850b450733141f320a817c523b85dff49f52eb
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Mon Jun 13 15:49:09 2016 -0400
Only the HSM project needs the RTOS; most of the test projects can use the STM32 HAL code directly.
---
Makefile | 24 +++++++++++-----------
.../TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S | 9 ++------
...up_stm32f429xx.S => startup_stm32f429xx_rtos.S} | 0
.../TARGET_CRYPTECH_ALPHA/stm32f4xx_it.c | 6 ++++--
.../TARGET_CRYPTECH_ALPHA/stm32f4xx_it_rtos.c | 17 +++++++++++++--
projects/bootloader/Makefile | 4 +---
projects/cli-test/Makefile | 20 +++++++++++++++++-
projects/hsm/Makefile | 21 +++++++++++++++++--
projects/rtos-test/Makefile | 4 ++++
stm-init.h | 3 ---
10 files changed, 76 insertions(+), 32 deletions(-)
diff --git a/Makefile b/Makefile
index b96ea64..51461c1 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,7 @@ export TOPLEVEL = $(shell pwd)
# define board: dev-bridge or alpha
BOARD = TARGET_CRYPTECH_ALPHA
+#BOARD = TARGET_CRYPTECH_DEV_BRIDGE
# Location of the Libraries folder from the STM32F4 Standard Peripheral Library
export LIBS_DIR = $(TOPLEVEL)/libraries
@@ -43,7 +44,7 @@ export LIBTFM_DIR = $(LIBS_DIR)/thirdparty/libtfm
export LIBHAL_DIR = $(LIBS_DIR)/libhal
export LIBCLI_DIR = $(LIBS_DIR)/libcli
-export LIBS = $(MBED_DIR)/libstmf4.a $(RTOS_DIR)/librtos.a
+export LIBS = $(MBED_DIR)/libstmf4.a
# linker script
export LDSCRIPT = $(BOARD_DIR)/TOOLCHAIN_GCC_ARM/STM32F429BI.ld
@@ -87,15 +88,14 @@ CFLAGS += -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F429xx
CFLAGS += -D__CORTEX_M4 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_STM32F429ZI -DTOOLCHAIN_GCC -D__FPU_PRESENT=1 -D$(BOARD)
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
CFLAGS += -std=c99
-CFLAGS += -I $(TOPLEVEL)
-CFLAGS += -I $(MBED_DIR)/api
-CFLAGS += -I $(MBED_DIR)/rtos/rtos
-CFLAGS += -I $(MBED_DIR)/rtos/rtx/TARGET_CORTEX_M
-CFLAGS += -I $(MBED_DIR)/targets/cmsis
-CFLAGS += -I $(MBED_DIR)/targets/cmsis/TARGET_STM/TARGET_STM32F4
-CFLAGS += -I $(MBED_DIR)/targets/cmsis/TARGET_STM/TARGET_STM32F4/$(BOARD)
-CFLAGS += -I $(MBED_DIR)/targets/hal/TARGET_STM/TARGET_STM32F4
-CFLAGS += -I $(MBED_DIR)/targets/hal/TARGET_STM/TARGET_STM32F4/$(BOARD)
+CFLAGS += -I$(TOPLEVEL)
+CFLAGS += -I$(MBED_DIR)/api
+CFLAGS += -I$(MBED_DIR)/targets/cmsis
+CFLAGS += -I$(MBED_DIR)/targets/cmsis/TARGET_STM/TARGET_STM32F4
+CFLAGS += -I$(MBED_DIR)/targets/cmsis/TARGET_STM/TARGET_STM32F4/$(BOARD)
+CFLAGS += -I$(MBED_DIR)/targets/hal/TARGET_STM/TARGET_STM32F4
+CFLAGS += -I$(MBED_DIR)/targets/hal/TARGET_STM/TARGET_STM32F4/$(BOARD)
+CFLAGS += -DHAL_RSA_USE_MODEXP=0
export CFLAGS
%.o : %.c
@@ -121,7 +121,7 @@ cli-test: $(BOARD_OBJS) $(LIBS) $(LIBCLI_DIR)/libcli.a
$(RTOS_DIR)/librtos.a:
$(MAKE) -C $(RTOS_DIR)
-rtos-test: $(RTOS_OBJS) $(LIBS)
+rtos-test: $(RTOS_OBJS) $(LIBS) $(RTOS_DIR)/librtos.a
$(MAKE) -C projects/rtos-test
$(LIBTFM_DIR)/libtfm.a:
@@ -136,7 +136,7 @@ $(LIBCLI_DIR)/libcli.a:
libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a
$(MAKE) -C projects/libhal-test
-hsm: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a
+hsm: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a $(RTOS_DIR)/librtos.a
$(MAKE) -C projects/hsm
bootloader: $(BOARD_OBJS) $(LIBS)
diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S
index c431df8..7b4f6ff 100644
--- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S
+++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S
@@ -110,14 +110,9 @@ LoopFillZerobss:
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */
- //bl __libc_init_array
+ bl __libc_init_array
/* Call the application's entry point.*/
- //bl main
- // Calling the crt0 'cold-start' entry point. There __libc_init_array is called
- // and when existing hardware_init_hook() and software_init_hook() before
- // starting main(). software_init_hook() is available and has to be called due
- // to initializsation when using rtos.
- bl _start
+ bl main
bx lr
.size Reset_Handler, .-Reset_Handler
diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx_rtos.S
similarity index 100%
copy from libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S
copy to libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/TOOLCHAIN_GCC_ARM/startup_stm32f429xx_rtos.S
diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it.c
index 7c30228..7b8e97f 100644
--- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it.c
+++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it.c
@@ -65,6 +65,10 @@ void NMI_Handler(void)
*/
void HardFault_Handler(void)
{
+#ifdef HAL_GPIO_MODULE_ENABLED
+ //HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_SET);
+#endif
/* Go to infinite loop when Hard Fault exception occurs */
while (1) { ; }
}
@@ -103,7 +107,6 @@ void UsageFault_Handler(void)
}
-#if 0 /* already defined in libraries/mbed/rtos/ */
/**
* @brief This function handles SVCall exception.
* @param None
@@ -140,7 +143,6 @@ void SysTick_Handler(void)
{
HAL_IncTick();
}
-#endif
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
diff --git a/projects/bootloader/stm32f4xx_it.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it_rtos.c
similarity index 94%
rename from projects/bootloader/stm32f4xx_it.c
rename to libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it_rtos.c
index 7aed16b..1118db2 100644
--- a/projects/bootloader/stm32f4xx_it.c
+++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_it_rtos.c
@@ -37,6 +37,8 @@
******************************************************************************
*/
+#include "cmsis_os.h"
+
#include "stm-init.h"
#include "stm-uart.h"
@@ -65,6 +67,10 @@ void NMI_Handler(void)
*/
void HardFault_Handler(void)
{
+#ifdef HAL_GPIO_MODULE_ENABLED
+ //HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_SET);
+#endif
/* Go to infinite loop when Hard Fault exception occurs */
while (1) { ; }
}
@@ -103,6 +109,7 @@ void UsageFault_Handler(void)
}
+#if 0 /* already defined in libraries/mbed/rtos/ */
/**
* @brief This function handles SVCall exception.
* @param None
@@ -139,6 +146,7 @@ void SysTick_Handler(void)
{
HAL_IncTick();
}
+#endif
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
@@ -178,7 +186,7 @@ void USART1_IRQHandler(void)
* @brief This function handles UART interrupt request.
* @param None
* @retval None
- * @Note HAL_UART_IRQHandler will call HAL_UART_RxCpltCallback in main.c.
+ * @Note HAL_UART_IRQHandler will call HAL_UART_RxCpltCallback below.
*/
void USART2_IRQHandler(void)
{
@@ -206,7 +214,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
__weak void HAL_UART1_RxCpltCallback(UART_HandleTypeDef *huart)
{
/* NOTE: This function Should not be modified, when the callback is needed,
- the HAL_UART_TxCpltCallback could be implemented in the user file
+ the HAL_UART_RxCpltCallback could be implemented in the user file
*/
}
@@ -217,4 +225,9 @@ __weak void HAL_UART2_RxCpltCallback(UART_HandleTypeDef *huart)
*/
}
+void HAL_Delay(__IO uint32_t Delay)
+{
+ osDelay(Delay);
+}
+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/projects/bootloader/Makefile b/projects/bootloader/Makefile
index fe75849..a63d29c 100644
--- a/projects/bootloader/Makefile
+++ b/projects/bootloader/Makefile
@@ -10,9 +10,7 @@ BOARD_OBJS = \
$(BOARD_DIR)/system_stm32f4xx.o \
$(BOARD_DIR)/stm32f4xx_hal_msp.o \
./startup_stm32f429xx.o \
- ./stm32f4xx_it.o
-
-LIBS = $(MBED_DIR)/libstmf4.a
+ $(BOARD_DIR)/stm32f4xx_it.o
all: $(PROG:=.elf)
diff --git a/projects/cli-test/Makefile b/projects/cli-test/Makefile
index acf2720..e043566 100644
--- a/projects/cli-test/Makefile
+++ b/projects/cli-test/Makefile
@@ -2,8 +2,26 @@ TEST = cli-test
OBJS = crc32.o test_sdram.o mgmt-cli.o mgmt-dfu.c mgmt-fpga.c mgmt-misc.c mgmt-show.c mgmt-test.c
+BOARD_OBJS = \
+ $(TOPLEVEL)/stm-init.o \
+ $(TOPLEVEL)/stm-fmc.o \
+ $(TOPLEVEL)/stm-uart.o \
+ $(TOPLEVEL)/syscalls.o \
+ $(TOPLEVEL)/stm-rtc.o \
+ $(TOPLEVEL)/spiflash_n25q128.o \
+ $(TOPLEVEL)/stm-fpgacfg.o \
+ $(TOPLEVEL)/stm-keystore.o \
+ $(TOPLEVEL)/stm-sdram.o \
+ $(TOPLEVEL)/stm-flash.o \
+ $(BOARD_DIR)/TOOLCHAIN_GCC_ARM/startup_stm32f429xx_rtos.o \
+ $(BOARD_DIR)/system_stm32f4xx.o \
+ $(BOARD_DIR)/stm32f4xx_hal_msp.o \
+ $(BOARD_DIR)/stm32f4xx_it_rtos.o
+
CFLAGS += -I$(LIBCLI_DIR)
-LIBS += $(LIBCLI_DIR)/libcli.a
+CFLAGS += -I$(RTOS_DIR)/rtos -I$(RTOS_DIR)/rtx/TARGET_CORTEX_M
+
+LIBS += $(LIBCLI_DIR)/libcli.a $(RTOS_DIR)/librtos.a
all: $(TEST:=.elf)
diff --git a/projects/hsm/Makefile b/projects/hsm/Makefile
index d8fd1f9..1ee5323 100644
--- a/projects/hsm/Makefile
+++ b/projects/hsm/Makefile
@@ -3,9 +3,26 @@ PROJ = hsm
# objs in addition to $(PROJ).o
OBJS =
-CFLAGS += -I $(LIBHAL_DIR)
+BOARD_OBJS = \
+ $(TOPLEVEL)/stm-init.o \
+ $(TOPLEVEL)/stm-fmc.o \
+ $(TOPLEVEL)/stm-uart.o \
+ $(TOPLEVEL)/syscalls.o \
+ $(TOPLEVEL)/stm-rtc.o \
+ $(TOPLEVEL)/spiflash_n25q128.o \
+ $(TOPLEVEL)/stm-fpgacfg.o \
+ $(TOPLEVEL)/stm-keystore.o \
+ $(TOPLEVEL)/stm-sdram.o \
+ $(TOPLEVEL)/stm-flash.o \
+ $(BOARD_DIR)/TOOLCHAIN_GCC_ARM/startup_stm32f429xx_rtos.o \
+ $(BOARD_DIR)/system_stm32f4xx.o \
+ $(BOARD_DIR)/stm32f4xx_hal_msp.o \
+ $(BOARD_DIR)/stm32f4xx_it_rtos.o
-LIBS += $(LIBHAL_DIR)/libhal.a $(LIBTFM_DIR)/libtfm.a
+CFLAGS += -I$(LIBHAL_DIR)
+CFLAGS += -I$(RTOS_DIR)/rtos -I$(RTOS_DIR)/rtx/TARGET_CORTEX_M
+
+LIBS += $(LIBHAL_DIR)/libhal.a $(LIBTFM_DIR)/libtfm.a $(RTOS_DIR)/librtos.a
all: $(PROJ:=.elf)
diff --git a/projects/rtos-test/Makefile b/projects/rtos-test/Makefile
index dd2cab5..9e58a41 100644
--- a/projects/rtos-test/Makefile
+++ b/projects/rtos-test/Makefile
@@ -1,5 +1,9 @@
TEST = thread-test semaphore-test mutex-test
+CFLAGS += -I$(RTOS_DIR)/rtos -I$(RTOS_DIR)/rtx/TARGET_CORTEX_M
+
+LIBS += $(RTOS_DIR)/librtos.a
+
all: $(TEST:=.elf)
%.elf: %.o $(BOARD_OBJS) $(LIBS)
diff --git a/stm-init.h b/stm-init.h
index dd19311..252485d 100644
--- a/stm-init.h
+++ b/stm-init.h
@@ -35,7 +35,6 @@
#ifndef __STM_INIT_H
#define __STM_INIT_H
-#include "cmsis_os.h"
#include "stm32f4xx_hal.h"
/* Macros used to make GPIO pin setup (in stm-init.c) easier */
@@ -60,6 +59,4 @@
extern void stm_init(void);
extern void Error_Handler(void);
-#define HAL_Delay osDelay
-
#endif /* __STM_INIT_H */
More information about the Commits
mailing list