2025-11-24 6:46 AM
I am trying to convert the G491re openbootloader example to the F413 mcu. I take it that everything that needs to changed is in the openbootloader_conf.h file.
I believe I have the correct map configuration as shown below, but I am confused as how I figure out how to define the parameters at lines 74 and beyond. Are those just command codes? Also, how does the bootloader know there is only 1 bank instead of 2 like in the example?
/**
******************************************************************************
* @file openbootloader_conf.h
* @author MCD Application Team
* @brief Contains Open Bootloader configuration
******************************************************************************
* @attention
*
* Copyright (c) 2019 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef OPENBOOTLOADER_CONF_H
#define OPENBOOTLOADER_CONF_H
/* Includes ------------------------------------------------------------------*/
#include "platform.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* -------------------------------- Device ID ------------------------------- */
//devide ID for F413 is 0x463
#define DEVICE_ID_MSB 0x04 /* MSB byte of device ID */
#define DEVICE_ID_LSB 0x63 /* LSB byte of device ID */
/* -------------------------- Definitions for Memories ---------------------- */
//This F413 has 1.5MB
#define FLASH_START_ADDRESS FLASH_BASE
#define FLASH_END_ADDRESS (FLASH_BASE + (1500 * 1024))
// This F413 has 256kb (SRAM1) + 64kb (SRAM2)
#define RAM_START_ADDRESS SRAM_BASE
#define RAM_END_ADDRESS (SRAM_BASE + (320 * 1024)) /* Size of SRAM1 + SRAM2 (80 + 16) */
//F413 has a different starting area than G4
// 0x1FFFC000 to 0x1FFFC00F
#define OB1_START_ADDRESS 0x1FFFC000U /* Option bytes 1 registers address */
#define OB1_END_ADDRESS (OB1_START_ADDRESS + 16) /* Option bytes 1 end address (48 bytes) */
//F413 only has 1 Bank so this is not needed
//#define OB2_START_ADDRESS 0x1FFFF800U /* Option bytes 2 registers address */
//#define OB2_END_ADDRESS (OB2_START_ADDRESS + 48) /* Option bytes 2 end address (48 bytes) */
//F413 has a different starting area than G4
#define OTP_START_ADDRESS 0x1FFF7800 /* OTP registers address */
#define OTP_END_ADDRESS (OTP_START_ADDRESS + 1024) /* OTP end address (1024 bytes) */
/*F413 has the same starting System Memory address as the G4
But it has ia different ending address.
The F413 address size is 77FF (in hex), which is 30 * 1024*/
#define ICP1_START_ADDRESS 0x1FFF0000 /* System memory registers address */
#define ICP1_END_ADDRESS (ICP1_START_ADDRESS + (30 * 1024)) /* System memory registers end address */
//F413 only has 1 memory bank so this is not needed
//#define ICP2_START_ADDRESS 0x1FFF8000 /* System memory registers address */
//#define ICP2_END_ADDRESS (ICP2_START_ADDRESS + (28 * 1024)) /* System memory registers end address */
#define OPENBL_RAM_SIZE 0x00003000U /* RAM used by the Open Bootloader */
#define RDP_LEVEL_0 OB_RDP_LEVEL_0
#define RDP_LEVEL_1 OB_RDP_LEVEL_1
#define RDP_LEVEL_2 OB_RDP_LEVEL_2
#define AREA_ERROR 0x0U /* Error Address Area */
#define FLASH_AREA 0x1U /* Flash Address Area */
#define RAM_AREA 0x2U /* RAM Address area */
#define OB_AREA 0x3U /* Option bytes Address area */
#define OTP_AREA 0x4U /* OTP Address area */
#define ICP_AREA 0x5U /* System memory area */
#define FLASH_ERASE_ALL 0xFFFF
#define FLASH_BANK1_ERASE 0xFFFE
#define FLASH_BANK2_ERASE 0xFFFD
#define INTERFACES_SUPPORTED 5U
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#endif /* OPENBOOTLOADER_CONF_H */