mirror of https://github.com/FOME-Tech/fome-fw.git
boards no longer need specific openblt files
This commit is contained in:
parent
f75aa47a9e
commit
5e1ec57bfa
|
@ -1,40 +0,0 @@
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Collect project files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
# Collect all application files in the current directory and its subdirectories, but
|
|
||||||
# exclude flash-layout.c as this one is directly included in a source file, when used.
|
|
||||||
PROJ_FILES += $(filter-out $(OPENBLT_BOARD_DIR)/flash_layout.c, $(call rwildcard, $(OPENBLT_BOARD_DIR), *.c *.h *.s))
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Options for toolchain binaries |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
ifeq ($(PROJECT_CPU),ARCH_STM32F4)
|
|
||||||
BRDFLAGS = -DSTM32F429xx
|
|
||||||
else ifeq ($(PROJECT_CPU),ARCH_STM32F7)
|
|
||||||
#TODO: check what CPU is on proteus f7
|
|
||||||
BRDFLAGS = -DSTM32F767xx
|
|
||||||
else ifeq ($(PROJECT_CPU),ARCH_STM32H7)
|
|
||||||
#TODO: check what CPU is on proteus h7
|
|
||||||
BRDFLAGS = -DSTM32H743xx
|
|
||||||
endif
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Specify library files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
LIBS =
|
|
||||||
|
|
||||||
# We use HSI (internal) on proteus. We define HSE (external) only to have compiler happy.
|
|
||||||
BRDFLAGS += -DHSE_VALUE=8000000
|
|
||||||
|
|
||||||
# hellen144
|
|
||||||
BRDFLAGS += -DSTATUS_LED_PORT=GPIOG -DSTATUS_LED_PIN=GPIO_PIN_0
|
|
||||||
|
|
||||||
# Frequency of the external crystal oscillator
|
|
||||||
BRDFLAGS += -DBOOT_CPU_XTAL_SPEED_KHZ=8000
|
|
||||||
BRDFLAGS += -DBOOT_CPU_SYSTEM_SPEED_KHZ=168000
|
|
||||||
# Select the desired UART peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_RS232_CHANNEL_INDEX=2
|
|
||||||
# \brief Select the desired CAN peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_CAN_CHANNEL_INDEX=0
|
|
||||||
|
|
||||||
PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/main_internal_osc.c
|
|
|
@ -1,296 +0,0 @@
|
||||||
/************************************************************************************//**
|
|
||||||
* \brief Bootloader application source file.
|
|
||||||
* \internal
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* C O P Y R I G H T
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) 2021 by Feaser http://www.feaser.com All rights reserved
|
|
||||||
*
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* L I C E N S E
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* This file is part of OpenBLT. OpenBLT 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 3 of the License, or (at your option) any later
|
|
||||||
* version.
|
|
||||||
*
|
|
||||||
* OpenBLT 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 have received a copy of the GNU General Public License along with OpenBLT. It
|
|
||||||
* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
|
|
||||||
*
|
|
||||||
* \endinternal
|
|
||||||
****************************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************************
|
|
||||||
* Include files
|
|
||||||
****************************************************************************************/
|
|
||||||
#include "boot.h" /* bootloader generic header */
|
|
||||||
#ifdef STM32F429xx
|
|
||||||
#include "stm32f4xx.h" /* STM32 CPU and HAL header */
|
|
||||||
#endif
|
|
||||||
#ifdef STM32F767xx
|
|
||||||
#include "stm32f7xx.h" /* STM32 CPU and HAL header */
|
|
||||||
#endif
|
|
||||||
#ifdef STM32H743xx
|
|
||||||
#include "stm32h7xx.h" /* STM32 CPU and HAL header */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************
|
|
||||||
* Function prototypes
|
|
||||||
****************************************************************************************/
|
|
||||||
static void Init(void);
|
|
||||||
static void SystemClock_Config(void);
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief This is the entry point for the bootloader application and is called
|
|
||||||
** by the reset interrupt vector after the C-startup routines executed.
|
|
||||||
** \return Program return code.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
/* initialize the microcontroller */
|
|
||||||
Init();
|
|
||||||
/* initialize the bootloader */
|
|
||||||
BootInit();
|
|
||||||
|
|
||||||
/* start the infinite program loop */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
/* run the bootloader task */
|
|
||||||
BootTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* program should never get here */
|
|
||||||
return 0;
|
|
||||||
} /*** end of main ***/
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief Interrupt service routine of the timer.
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
void SysTick_Handler(void)
|
|
||||||
{
|
|
||||||
/* Increment the tick counter. */
|
|
||||||
HAL_IncTick();
|
|
||||||
/* Invoke the system tick handler. */
|
|
||||||
HAL_SYSTICK_IRQHandler();
|
|
||||||
} /*** end of TimerISRHandler ***/
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief Initializes the microcontroller.
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
static void Init(void)
|
|
||||||
{
|
|
||||||
/* HAL library initialization */
|
|
||||||
HAL_Init();
|
|
||||||
/* configure system clock */
|
|
||||||
SystemClock_Config();
|
|
||||||
} /*** end of Init ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief System Clock Configuration. This code was created by CubeMX and configures
|
|
||||||
** the system clock to match the configuration in the bootloader's
|
|
||||||
** configuration (blt_conf.h), specifically the macros:
|
|
||||||
** BOOT_CPU_SYSTEM_SPEED_KHZ and BOOT_CPU_XTAL_SPEED_KHZ.
|
|
||||||
** Note that the Lower Layer drivers were selected in CubeMX for the RCC
|
|
||||||
** subsystem.
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
static void SystemClock_Config(void)
|
|
||||||
{
|
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
|
||||||
|
|
||||||
/* Configure the main internal regulator output voltage. */
|
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
|
||||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
||||||
|
|
||||||
/* Initializes the RCC Oscillators according to the specified parameters
|
|
||||||
* in the RCC_OscInitTypeDef structure.
|
|
||||||
*/
|
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
||||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
|
||||||
RCC_OscInitStruct.PLL.PLLM = 8;
|
|
||||||
RCC_OscInitStruct.PLL.PLLN = 336;
|
|
||||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
|
||||||
RCC_OscInitStruct.PLL.PLLQ = 7;
|
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Clock configuration incorrect or hardware failure. Hang the system to prevent
|
|
||||||
* damage.
|
|
||||||
*/
|
|
||||||
ASSERT_RT(BLT_FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initializes the CPU, AHB and APB buses clocks. */
|
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
|
||||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Clock configuration incorrect or hardware failure. Hang the system to prevent
|
|
||||||
* damage.
|
|
||||||
*/
|
|
||||||
ASSERT_RT(BLT_FALSE);
|
|
||||||
}
|
|
||||||
} /*** end of SystemClock_Config ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief Initializes the Global MSP. This function is called from HAL_Init()
|
|
||||||
** function to perform system level initialization (GPIOs, clock, DMA,
|
|
||||||
** interrupt).
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
void HAL_MspInit(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
|
||||||
|
|
||||||
/* Power and SYSCFG clock enable. */
|
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
/* GPIO ports clock enable. */
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* Configure PE3 pin for the LED. */
|
|
||||||
GPIO_InitStruct.Pin = STATUS_LED_PIN;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(STATUS_LED_PORT, &GPIO_InitStruct);
|
|
||||||
HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Configure GPIO pin for (optional) backdoor entry input. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (BOOT_COM_RS232_ENABLE > 0)
|
|
||||||
/* UART TX and RX GPIO pin configuration. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* UART clock enable. */
|
|
||||||
__HAL_RCC_USART3_CLK_ENABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
|
||||||
/* CAN TX and RX GPIO pin configuration. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_12;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF9_CAN2;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* CAN clock enable. */
|
|
||||||
/* CAN1 clock needs to be enabled for CAN2 operation */
|
|
||||||
__HAL_RCC_CAN1_CLK_ENABLE();
|
|
||||||
__HAL_RCC_CAN2_CLK_ENABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (BOOT_COM_USB_ENABLE > 0)
|
|
||||||
/* USB pin configuration. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* USB clock enable. */
|
|
||||||
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
|
||||||
#endif
|
|
||||||
} /*** end of HAL_MspInit ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief DeInitializes the Global MSP. This function is called from HAL_DeInit()
|
|
||||||
** function to perform system level de-initialization (GPIOs, clock, DMA,
|
|
||||||
** interrupt).
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
void HAL_MspDeInit(void)
|
|
||||||
{
|
|
||||||
/* Reset the RCC clock configuration to the default reset state. */
|
|
||||||
HAL_RCC_DeInit();
|
|
||||||
|
|
||||||
/* Reset GPIO pin for the LED to turn it off. */
|
|
||||||
HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(STATUS_LED_PORT, STATUS_LED_PIN);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_13);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (BOOT_COM_USB_ENABLE > 0)
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11);
|
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12);
|
|
||||||
/* USB clock disable. */
|
|
||||||
__HAL_RCC_USB_OTG_FS_CLK_DISABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12);
|
|
||||||
/* CAN clock disable. */
|
|
||||||
__HAL_RCC_CAN2_CLK_DISABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (BOOT_COM_RS232_ENABLE > 0)
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10);
|
|
||||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_11);
|
|
||||||
/* UART clock disable. */
|
|
||||||
__HAL_RCC_USART3_CLK_DISABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* GPIO ports clock disable. */
|
|
||||||
__HAL_RCC_GPIOH_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOE_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOD_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOC_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOA_CLK_DISABLE();
|
|
||||||
|
|
||||||
/* SYSCFG and PWR clock disable. */
|
|
||||||
__HAL_RCC_PWR_CLK_DISABLE();
|
|
||||||
__HAL_RCC_SYSCFG_CLK_DISABLE();
|
|
||||||
} /*** end of HAL_MspDeInit ***/
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************** end of main.c *************************************/
|
|
|
@ -1,28 +0,0 @@
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Collect project files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
# Collect all application files in the current directory and its subdirectories, but
|
|
||||||
# exclude flash-layout.c as this one is directly included in a source file, when used.
|
|
||||||
PROJ_FILES += $(filter-out $(OPENBLT_BOARD_DIR)/flash_layout.c, $(call rwildcard, $(OPENBLT_BOARD_DIR), *.c *.h *.s))
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Options for toolchain binaries |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
BRDFLAGS = -DSTM32F429xx
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Specify library files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
LIBS =
|
|
||||||
|
|
||||||
BRDFLAGS += -DHSE_VALUE=8000000
|
|
||||||
|
|
||||||
BRDFLAGS += -DSTATUS_LED_PORT=GPIOE -DSTATUS_LED_PIN=GPIO_PIN_3
|
|
||||||
|
|
||||||
# Frequency of the external crystal oscillator
|
|
||||||
BRDFLAGS += -DBOOT_CPU_XTAL_SPEED_KHZ=8000
|
|
||||||
BRDFLAGS += -DBOOT_CPU_SYSTEM_SPEED_KHZ=168000
|
|
||||||
# Select the desired UART peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_RS232_CHANNEL_INDEX=2
|
|
||||||
# \brief Select the desired CAN peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_CAN_CHANNEL_INDEX=1
|
|
|
@ -1,5 +0,0 @@
|
||||||
# This board uses bootloader
|
|
||||||
USE_BOOTLOADER = yes
|
|
||||||
|
|
||||||
# include Prometheus bootloader code
|
|
||||||
BOOTLOADERINC = $(PROJECT_DIR)/bootloader/prometheus/$(PROMETHEUS_BOARD)
|
|
|
@ -1,37 +0,0 @@
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Collect project files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
# Collect all application files in the current directory and its subdirectories, but
|
|
||||||
# exclude flash-layout.c as this one is directly included in a source file, when used.
|
|
||||||
PROJ_FILES += $(filter-out $(OPENBLT_BOARD_DIR)/flash_layout.c, $(call rwildcard, $(OPENBLT_BOARD_DIR), *.c *.h *.s))
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Options for toolchain binaries |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
ifeq ($(PROJECT_CPU),ARCH_STM32F4)
|
|
||||||
BRDFLAGS = -DSTM32F429xx
|
|
||||||
else ifeq ($(PROJECT_CPU),ARCH_STM32F7)
|
|
||||||
BRDFLAGS = -DSTM32F767xx
|
|
||||||
else ifeq ($(PROJECT_CPU),ARCH_STM32H7)
|
|
||||||
BRDFLAGS = -DSTM32H743xx
|
|
||||||
endif
|
|
||||||
|
|
||||||
# We use HSI (internal) on proteus. We define HSE (external) only to have compiler happy.
|
|
||||||
BRDFLAGS += -DHSE_VALUE=8000000
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Specify library files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
LIBS =
|
|
||||||
|
|
||||||
BRDFLAGS += -DSTATUS_LED_PORT=GPIOE -DSTATUS_LED_PIN=GPIO_PIN_3
|
|
||||||
|
|
||||||
# Frequency of the external crystal oscillator
|
|
||||||
BRDFLAGS += -DBOOT_CPU_XTAL_SPEED_KHZ=8000
|
|
||||||
BRDFLAGS += -DBOOT_CPU_SYSTEM_SPEED_KHZ=168000
|
|
||||||
# Select the desired UART peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_RS232_CHANNEL_INDEX=2
|
|
||||||
# \brief Select the desired CAN peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_CAN_CHANNEL_INDEX=0
|
|
||||||
|
|
||||||
PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/main_internal_osc.c
|
|
|
@ -4,12 +4,6 @@ BOARDCPPSRC = $(BOARD_DIR)/board_configuration.cpp
|
||||||
# Required include directories
|
# Required include directories
|
||||||
BOARDINC += $(BOARD_DIR)/config/controllers/algo
|
BOARDINC += $(BOARD_DIR)/config/controllers/algo
|
||||||
|
|
||||||
# Override LD script
|
|
||||||
ifeq ($(USE_BOOTLOADER),yes)
|
|
||||||
# include Prometheus bootloader code
|
|
||||||
BOOTLOADERINC = $(PROJECT_DIR)/bootloader/subaru_eg33
|
|
||||||
endif
|
|
||||||
|
|
||||||
#LED
|
#LED
|
||||||
DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::G7
|
DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::G7
|
||||||
|
|
||||||
|
|
|
@ -1,270 +0,0 @@
|
||||||
/************************************************************************************//**
|
|
||||||
* \brief Bootloader application source file.
|
|
||||||
* \internal
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* C O P Y R I G H T
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) 2021 by Feaser http://www.feaser.com All rights reserved
|
|
||||||
*
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* L I C E N S E
|
|
||||||
*----------------------------------------------------------------------------------------
|
|
||||||
* This file is part of OpenBLT. OpenBLT 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 3 of the License, or (at your option) any later
|
|
||||||
* version.
|
|
||||||
*
|
|
||||||
* OpenBLT 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 have received a copy of the GNU General Public License along with OpenBLT. It
|
|
||||||
* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
|
|
||||||
*
|
|
||||||
* \endinternal
|
|
||||||
****************************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************************
|
|
||||||
* Include files
|
|
||||||
****************************************************************************************/
|
|
||||||
#include "boot.h" /* bootloader generic header */
|
|
||||||
#ifdef STM32F429xx
|
|
||||||
#include "stm32f4xx.h" /* STM32 CPU and HAL header */
|
|
||||||
#endif
|
|
||||||
#ifdef STM32F767xx
|
|
||||||
#include "stm32f7xx.h" /* STM32 CPU and HAL header */
|
|
||||||
#endif
|
|
||||||
#ifdef STM32H743xx
|
|
||||||
#include "stm32h7xx.h" /* STM32 CPU and HAL header */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************
|
|
||||||
* Function prototypes
|
|
||||||
****************************************************************************************/
|
|
||||||
static void Init(void);
|
|
||||||
static void SystemClock_Config(void);
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief This is the entry point for the bootloader application and is called
|
|
||||||
** by the reset interrupt vector after the C-startup routines executed.
|
|
||||||
** \return Program return code.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
/* initialize the microcontroller */
|
|
||||||
Init();
|
|
||||||
/* initialize the bootloader */
|
|
||||||
BootInit();
|
|
||||||
|
|
||||||
/* start the infinite program loop */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
/* run the bootloader task */
|
|
||||||
BootTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* program should never get here */
|
|
||||||
return 0;
|
|
||||||
} /*** end of main ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief Initializes the microcontroller.
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
static void Init(void)
|
|
||||||
{
|
|
||||||
/* HAL library initialization */
|
|
||||||
HAL_Init();
|
|
||||||
/* configure system clock */
|
|
||||||
SystemClock_Config();
|
|
||||||
} /*** end of Init ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief System Clock Configuration. This code was created by CubeMX and configures
|
|
||||||
** the system clock to match the configuration in the bootloader's
|
|
||||||
** configuration (blt_conf.h), specifically the macros:
|
|
||||||
** BOOT_CPU_SYSTEM_SPEED_KHZ and BOOT_CPU_XTAL_SPEED_KHZ.
|
|
||||||
** Note that the Lower Layer drivers were selected in CubeMX for the RCC
|
|
||||||
** subsystem.
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
static void SystemClock_Config(void)
|
|
||||||
{
|
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
|
||||||
|
|
||||||
/* Configure the main internal regulator output voltage. */
|
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
|
||||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
||||||
|
|
||||||
/* Initializes the CPU, AHB and APB busses clocks. */
|
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
||||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
|
||||||
RCC_OscInitStruct.PLL.PLLM = 25;
|
|
||||||
RCC_OscInitStruct.PLL.PLLN = 432;
|
|
||||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
|
||||||
RCC_OscInitStruct.PLL.PLLQ = 2;
|
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Clock configuration incorrect or hardware failure. Hang the system to prevent
|
|
||||||
* damage.
|
|
||||||
*/
|
|
||||||
ASSERT_RT(BLT_FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Activate the Over-Drive mode. */
|
|
||||||
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Clock overdrive hardware failure. Hang the system to prevent damage.
|
|
||||||
*/
|
|
||||||
ASSERT_RT(BLT_FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initializes the CPU, AHB and APB busses clocks. */
|
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
|
|
||||||
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Clock configuration incorrect or hardware failure. Hang the system to prevent
|
|
||||||
* damage.
|
|
||||||
*/
|
|
||||||
ASSERT_RT(BLT_FALSE);
|
|
||||||
}
|
|
||||||
} /*** end of SystemClock_Config ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief Initializes the Global MSP. This function is called from HAL_Init()
|
|
||||||
** function to perform system level initialization (GPIOs, clock, DMA,
|
|
||||||
** interrupt).
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
void HAL_MspInit(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
|
||||||
|
|
||||||
/* Power and SYSCFG clock enable. */
|
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
/* GPIO ports clock enable. */
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
|
||||||
|
|
||||||
#if (BOOT_COM_RS232_ENABLE > 0)
|
|
||||||
/* UART clock enable. */
|
|
||||||
__HAL_RCC_USART1_CLK_ENABLE();
|
|
||||||
#endif
|
|
||||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
|
||||||
/* CAN clock enable. */
|
|
||||||
__HAL_RCC_CAN1_CLK_ENABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Configure GPIO pin for the Red LED. */
|
|
||||||
GPIO_InitStruct.Pin = STATUS_LED_PIN;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(STATUS_LED_PORT, &GPIO_InitStruct);
|
|
||||||
HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Configure GPIO pin for (optional) backdoor entry input. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
#endif
|
|
||||||
#if (BOOT_COM_RS232_ENABLE > 0)
|
|
||||||
/* UART TX and RX GPIO pin configuration. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
#endif
|
|
||||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
|
||||||
/* CAN enable pin */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
||||||
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_0, GPIO_PIN_SET);
|
|
||||||
/* CAN TX and RX GPIO pin configuration. */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
|
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /*** end of HAL_MspInit ***/
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************//**
|
|
||||||
** \brief DeInitializes the Global MSP. This function is called from HAL_DeInit()
|
|
||||||
** function to perform system level de-initialization (GPIOs, clock, DMA,
|
|
||||||
** interrupt).
|
|
||||||
** \return none.
|
|
||||||
**
|
|
||||||
****************************************************************************************/
|
|
||||||
void HAL_MspDeInit(void)
|
|
||||||
{
|
|
||||||
/* Reset the RCC clock configuration to the default reset state. */
|
|
||||||
HAL_RCC_DeInit();
|
|
||||||
|
|
||||||
/* Reset GPIO pin for the LED to turn it off. */
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
|
|
||||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_13);
|
|
||||||
|
|
||||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0);
|
|
||||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_1);
|
|
||||||
/* CAN clock disable. */
|
|
||||||
__HAL_RCC_CAN1_CLK_DISABLE();
|
|
||||||
#endif
|
|
||||||
#if (BOOT_COM_RS232_ENABLE > 0)
|
|
||||||
/* Deinit used GPIOs. */
|
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9);
|
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_10);
|
|
||||||
/* UART clock disable. */
|
|
||||||
__HAL_RCC_USART1_CLK_DISABLE();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* GPIO ports clock disable. */
|
|
||||||
__HAL_RCC_GPIOG_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOD_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOC_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_DISABLE();
|
|
||||||
__HAL_RCC_GPIOA_CLK_DISABLE();
|
|
||||||
|
|
||||||
/* SYSCFG and PWR clock disable. */
|
|
||||||
__HAL_RCC_PWR_CLK_DISABLE();
|
|
||||||
__HAL_RCC_SYSCFG_CLK_DISABLE();
|
|
||||||
} /*** end of HAL_MspDeInit ***/
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************** end of main.c *************************************/
|
|
|
@ -1,25 +0,0 @@
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Collect project files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
# Collect all application files in the current directory and its subdirectories, but
|
|
||||||
# exclude flash-layout.c as this one is directly included in a source file, when used.
|
|
||||||
PROJ_FILES += $(filter-out $(OPENBLT_BOARD_DIR)/flash_layout.c, $(call rwildcard, $(OPENBLT_BOARD_DIR), *.c *.h *.s))
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Specific options for toolchain binaries |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
BRDFLAGS = -DSTM32F767xx -DHSE_VALUE=25000000
|
|
||||||
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
#| Specify library files |
|
|
||||||
#|--------------------------------------------------------------------------------------|
|
|
||||||
LIBS =
|
|
||||||
|
|
||||||
BRDFLAGS += -DSTATUS_LED_PORT=GPIOG -DSTATUS_LED_PIN=GPIO_PIN_8
|
|
||||||
|
|
||||||
# Frequency of the external crystal oscillator
|
|
||||||
BRDFLAGS += -DBOOT_CPU_XTAL_SPEED_KHZ=25000
|
|
||||||
BRDFLAGS += -DBOOT_CPU_SYSTEM_SPEED_KHZ=216000
|
|
||||||
BRDFLAGS += -DBOOT_COM_RS232_CHANNEL_INDEX=0
|
|
||||||
# \brief Select the desired CAN peripheral as a zero based index.
|
|
||||||
BRDFLAGS += -DBOOT_COM_CAN_CHANNEL_INDEX=0
|
|
Loading…
Reference in New Issue