mirror of https://github.com/wolfSSL/wolfBoot.git
Minor cleanups. Add the required Cube HAL to app Makefile.
parent
17a3d5c476
commit
ff28cec38a
14
arch.mk
14
arch.mk
|
@ -78,11 +78,6 @@ ifeq ($(ARCH),ARM)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET),stm32l4)
|
|
||||||
ARCH_FLASH_OFFSET=0x08000000
|
|
||||||
SPI_TARGET=stm32
|
|
||||||
endif
|
|
||||||
|
|
||||||
## Cortex-M CPU
|
## Cortex-M CPU
|
||||||
ifeq ($(CORTEX_M33),1)
|
ifeq ($(CORTEX_M33),1)
|
||||||
CFLAGS+=-mcpu=cortex-m33
|
CFLAGS+=-mcpu=cortex-m33
|
||||||
|
@ -274,11 +269,14 @@ endif
|
||||||
|
|
||||||
ifeq ($(TARGET),stm32l4)
|
ifeq ($(TARGET),stm32l4)
|
||||||
SPI_TARGET=stm32
|
SPI_TARGET=stm32
|
||||||
|
ARCH_FLASH_OFFSET=0x08000000
|
||||||
OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.o
|
OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.o
|
||||||
OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.o
|
OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.o
|
||||||
CFLAGS+=-DSTM32L4A6xx -DUSE_HAL_DRIVER -I$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Inc/ \
|
CFLAGS+=-DSTM32L4A6xx -DUSE_HAL_DRIVER -Isrc -Ihal \
|
||||||
-Isrc -I$(STM32CUBE)/Drivers/BSP/STM32L4xx_Nucleo_144/ -I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ \
|
-I$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Inc/ \
|
||||||
-I$(STM32CUBE)/Drivers/CMSIS/Include/
|
-I$(STM32CUBE)/Drivers/BSP/STM32L4xx_Nucleo_144/ \
|
||||||
|
-I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ \
|
||||||
|
-I$(STM32CUBE)/Drivers/CMSIS/Include/
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
|
CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
|
||||||
|
|
|
@ -27,14 +27,9 @@
|
||||||
#define DMB() asm volatile ("dmb")
|
#define DMB() asm volatile ("dmb")
|
||||||
|
|
||||||
/*** RCC ***/
|
/*** RCC ***/
|
||||||
|
|
||||||
#define RCC_PRESCALER_DIV_NONE 0
|
#define RCC_PRESCALER_DIV_NONE 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint32_t Address = 0, PAGEError = 0;
|
static uint32_t Address = 0, PAGEError = 0;
|
||||||
|
|
||||||
|
|
||||||
static FLASH_EraseInitTypeDef EraseInitStruct;
|
static FLASH_EraseInitTypeDef EraseInitStruct;
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,7 +122,7 @@ int RAMFUNCTION hal_flash_erase(uint32_t address,int len)
|
||||||
|
|
||||||
static void RAMFUNCTION flash_set_waitstates(int waitstates)
|
static void RAMFUNCTION flash_set_waitstates(int waitstates)
|
||||||
{
|
{
|
||||||
FLASH->ACR |= waitstates | FLASH_ACR_DCEN | FLASH_ACR_ICEN;
|
FLASH->ACR |= (waitstates | FLASH_ACR_DCEN | FLASH_ACR_ICEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RAMFUNCTION void flash_wait_complete(void)
|
static RAMFUNCTION void flash_wait_complete(void)
|
||||||
|
@ -141,7 +136,7 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
uint32_t *dst;
|
uint32_t *dst;
|
||||||
uint32_t reg;
|
uint32_t reg;
|
||||||
int ret=-1;
|
int ret = -1;
|
||||||
|
|
||||||
hal_flash_clear_errors();
|
hal_flash_clear_errors();
|
||||||
reg = FLASH->CR & (~FLASH_CR_FSTPG);
|
reg = FLASH->CR & (~FLASH_CR_FSTPG);
|
||||||
|
@ -166,10 +161,10 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||||
}
|
}
|
||||||
if ((FLASH->SR &FLASH_SR_PROGERR)!= FLASH_SR_PROGERR) {
|
if ((FLASH->SR &FLASH_SR_PROGERR)!= FLASH_SR_PROGERR) {
|
||||||
ret=0;
|
ret=0;
|
||||||
}
|
}
|
||||||
if ((FLASH->SR & FLASH_SR_EOP) == FLASH_SR_EOP) {
|
if ((FLASH->SR & FLASH_SR_EOP) == FLASH_SR_EOP) {
|
||||||
FLASH->SR |= FLASH_SR_EOP;
|
FLASH->SR |= FLASH_SR_EOP;
|
||||||
}
|
}
|
||||||
FLASH->CR &= ~FLASH_CR_PG;
|
FLASH->CR &= ~FLASH_CR_PG;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -178,10 +173,12 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||||
static void clock_pll_off(void)
|
static void clock_pll_off(void)
|
||||||
{
|
{
|
||||||
uint32_t reg32;
|
uint32_t reg32;
|
||||||
|
|
||||||
/* Enable internal multi-speed oscillator. */
|
/* Enable internal multi-speed oscillator. */
|
||||||
RCC->CR |= RCC_CR_HSION;
|
RCC->CR |= RCC_CR_HSION;
|
||||||
DMB();
|
DMB();
|
||||||
while ((RCC->CR & RCC_CR_HSIRDY) == 0) {};
|
while ((RCC->CR & RCC_CR_HSIRDY) == 0) {};
|
||||||
|
|
||||||
/* Select HSI as SYSCLK source. */
|
/* Select HSI as SYSCLK source. */
|
||||||
reg32 = RCC->CFGR;
|
reg32 = RCC->CFGR;
|
||||||
reg32 &= ~((1 << 1) | (1 << 0));
|
reg32 &= ~((1 << 1) | (1 << 0));
|
||||||
|
@ -201,6 +198,7 @@ static void clockconfig(int powersave)
|
||||||
|
|
||||||
/* Enable Power controller */
|
/* Enable Power controller */
|
||||||
RCC->APB1ENR1 |= RCC_APB1ENR1_PWREN;
|
RCC->APB1ENR1 |= RCC_APB1ENR1_PWREN;
|
||||||
|
|
||||||
/* Select clock parameters */
|
/* Select clock parameters */
|
||||||
/*cpu_freq=16000000;*/
|
/*cpu_freq=16000000;*/
|
||||||
hpre= RCC_PRESCALER_DIV_NONE;
|
hpre= RCC_PRESCALER_DIV_NONE;
|
||||||
|
@ -208,17 +206,19 @@ static void clockconfig(int powersave)
|
||||||
ppre2=RCC_PRESCALER_DIV_NONE;
|
ppre2=RCC_PRESCALER_DIV_NONE;
|
||||||
flash_waitstates = 3;
|
flash_waitstates = 3;
|
||||||
flash_set_waitstates(flash_waitstates);
|
flash_set_waitstates(flash_waitstates);
|
||||||
|
|
||||||
/* Enable internal high-speed oscillator. */
|
/* Enable internal high-speed oscillator. */
|
||||||
RCC->CR |=RCC_CR_HSION;
|
RCC->CR |=RCC_CR_HSION;
|
||||||
DMB();
|
DMB();
|
||||||
while ((RCC->CR & RCC_CR_HSIRDY)==0);
|
while ((RCC->CR & RCC_CR_HSIRDY)==0);
|
||||||
|
|
||||||
/* select HSI as SYSCLK source*/
|
/* select HSI as SYSCLK source*/
|
||||||
reg32 = RCC->CFGR;
|
reg32 = RCC->CFGR;
|
||||||
reg32 &= ~((1 << 1) | (1 << 0));
|
reg32 &= ~((1 << 1) | (1 << 0));
|
||||||
RCC->CFGR = (reg32 | RCC_CFGR_SW_HSI);
|
RCC->CFGR = (reg32 | RCC_CFGR_SW_HSI);
|
||||||
DMB();
|
DMB();
|
||||||
/* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
||||||
*/
|
/* Set prescalers for AHB, ADC, ABP1, ABP2 */
|
||||||
reg32 = RCC->CFGR;
|
reg32 = RCC->CFGR;
|
||||||
reg32 &= ~(0xF0);
|
reg32 &= ~(0xF0);
|
||||||
RCC->CFGR = (reg32 | (hpre << 4));
|
RCC->CFGR = (reg32 | (hpre << 4));
|
||||||
|
|
|
@ -1,9 +1,33 @@
|
||||||
|
/* stm32-4xx_hal_conf.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfBoot.
|
||||||
|
*
|
||||||
|
* wolfBoot 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 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfBoot 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __STM32L4xx_HAL_CONF_H
|
#ifndef __STM32L4xx_HAL_CONF_H
|
||||||
#define __STM32L4xx_HAL_CONF_H
|
#define __STM32L4xx_HAL_CONF_H
|
||||||
|
|
||||||
#define HAL_MODULE_ENABLED
|
#define HAL_MODULE_ENABLED
|
||||||
#define HAL_FLASH_MODULE_ENABLED
|
#define HAL_FLASH_MODULE_ENABLED
|
||||||
#define HAL_RCC_MODULE_ENABLED
|
#define HAL_RCC_MODULE_ENABLED
|
||||||
|
|
||||||
#include "stm32l4xx_hal_flash.h"
|
#include "stm32l4xx_hal_flash.h"
|
||||||
#include "stm32l4xx_hal_rcc.h"
|
#include "stm32l4xx_hal_rcc.h"
|
||||||
#define assert_param(expr) ((void)0U)
|
#define assert_param(expr) ((void)0U)
|
||||||
|
|
||||||
#endif /* __STM32L4xx_HAL_CONF_H */
|
#endif /* __STM32L4xx_HAL_CONF_H */
|
||||||
|
|
|
@ -79,6 +79,16 @@ ifeq ($(TARGET),stm32h7)
|
||||||
LSCRIPT_TEMPLATE=ARM-stm32h7.ld
|
LSCRIPT_TEMPLATE=ARM-stm32h7.ld
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET),stm32l4)
|
||||||
|
APP_OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.o
|
||||||
|
APP_OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.o
|
||||||
|
CFLAGS+=-DSTM32L4A6xx -DUSE_HAL_DRIVER -Isrc -Ihal \
|
||||||
|
-I$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Inc/ \
|
||||||
|
-I$(STM32CUBE)/Drivers/BSP/STM32L4xx_Nucleo_144/ \
|
||||||
|
-I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ \
|
||||||
|
-I$(STM32CUBE)/Drivers/CMSIS/Include/
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET),stm32l5)
|
ifeq ($(TARGET),stm32l5)
|
||||||
ifeq ($(TZEN),1)
|
ifeq ($(TZEN),1)
|
||||||
LSCRIPT_TEMPLATE=ARM-stm32l5-ns.ld
|
LSCRIPT_TEMPLATE=ARM-stm32l5-ns.ld
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
/* app_stm32l4.c
|
||||||
|
*
|
||||||
|
* Test bare-metal boot-led-on application
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfBoot.
|
||||||
|
*
|
||||||
|
* wolfBoot 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 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfBoot 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "wolfboot/wolfboot.h"
|
#include "wolfboot/wolfboot.h"
|
||||||
|
@ -10,17 +34,19 @@ void main(void)
|
||||||
hal_init();
|
hal_init();
|
||||||
boot_led_on();
|
boot_led_on();
|
||||||
boot_version = wolfBoot_current_firmware_version();
|
boot_version = wolfBoot_current_firmware_version();
|
||||||
if(boot_version == 1) {
|
if (boot_version == 1) {
|
||||||
/* Turn on Blue LED */
|
/* Turn on Blue LED */
|
||||||
boot_led_on();
|
boot_led_on();
|
||||||
wolfBoot_update_trigger();
|
wolfBoot_update_trigger();
|
||||||
} else if(boot_version >= 2) {
|
} else if (boot_version >= 2) {
|
||||||
/* Turn on Red LED */
|
/* Turn on Red LED */
|
||||||
led_on();
|
led_on();
|
||||||
wolfBoot_success();
|
wolfBoot_success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for reboot */
|
/* Wait for reboot */
|
||||||
while(1) {
|
while(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PLATFORM_stm32l4 */
|
#endif /* PLATFORM_stm32l4 */
|
||||||
|
|
|
@ -180,7 +180,7 @@ void boot_led_off(void)
|
||||||
#endif /* PLATFORM_stm32wb */
|
#endif /* PLATFORM_stm32wb */
|
||||||
|
|
||||||
#ifdef PLATFORM_stm32l4
|
#ifdef PLATFORM_stm32l4
|
||||||
#define AHB2_CLOCK_ER (*(volatile uint32_t *)(0x4002104C)) // RCC_AHB2ENR
|
#define AHB2_CLOCK_ER (*(volatile uint32_t *)(0x4002104C)) /* RCC_AHB2ENR */
|
||||||
#define GPIOB_AHB2_CLOCK_ER (1 << 1)
|
#define GPIOB_AHB2_CLOCK_ER (1 << 1)
|
||||||
|
|
||||||
#define GPIOB_BASE 0x48000400
|
#define GPIOB_BASE 0x48000400
|
||||||
|
|
Loading…
Reference in New Issue