Keil
STM32L5xx_DFP
STMicroelectronics STM32L5 Series Device Support
https://www.keil.com/pack/
https://github.com/Open-CMSIS-Pack/STM32L5xx_DFP.git
LICENSES
Active development ...
Updated Pack to STM32CubeL5 Firmware Package version V1.4.0 (using HAL Drivers V1.0.4.):
- Added support for ICACHE (LL) component.
- Added extension files for SMBUS (HAL) component.
Package Description (pdsc):
- Added support to STM32L562RETxQ and STM32L562QEIx devices.
- Updated STM32L552 and STM32L562 SVD files (Rev.1.5).
- Updated Documentation.
- Updated schemaVersion (1.7.2).
- Added RAMstart and RAMsize attributes to Flash Algorithm elements.
STM32CubeMX integration:
- Synchronized versions of generated component ::Device:STM32Cube Framework:STM32CubeMX (in gpdsc) and its bootstrap (in pdsc).
- Added support for VREFBUF configuration (FrameworkCubeMX_gpdsc.ftl).
CMSIS-Driver:
- USART: Corrected Flow Control setup.
Updated Pack to STM32CubeL5 Firmware Package version V1.3.1 (using HAL Drivers V1.0.3.)
Added global define USE_HAL_DRIVER to the component ::Device:STM32Cube HAL:Common
Added global define USE_FULL_LL_DRIVER to the component ::Device:STM32Cube LL:Common
CMSIS-Driver:
- SPI:
-- Corrected peripheral resource for CubeMX configuration.
STM32CubeL5 HAL:
- Added Public key accelerator (PKA) HAL component.
Package Description (pdsc):
- Removed stm32l5xx_hal_conf.h from "STM32Cube HAL / Common" component. stm32l5xx_hal_conf.h is generated by STM32CubeMx.
- Adding condition to api and taxonomy to limit to the devices described in this pack.
Flash programming algorithms:
- Added octo SPI algorithm for STM32L562E-DK board.
- Added octo SPI algorithm for STM32L552E-EVAL board.
- Restored original ST octo SPI algorithm.
Updated STM32CubeL5 Firmware Package version to version 1.2.0 (using HAL Drivers V1.0.2)
Board support got moved to dedicated board support pack Keil.STM32l552E-EV_BSP.
Package Description:
- Added capability to launch the Option Byte Loading after a Flash Download.
- Adding STM32CubeMX integration.
Flash programming algorithms:
- Reworked existing algorithms.
- Added OPT algorithm.
SVD files:
- Register NSBOOTADDxR, SECBOOTADD0R are read/write.
CMSIS-Driver:
- Added USART.
- Added SPI.
Initial public version of the STM32L5 device family support pack for the:
STM32L552 and STM32L562 device series.
Based on STM32Cube L5 Firmware Pack version 1.0.0.
use with MDK 5.29 recommended.
ST
Device Support
Device Family Package STMicroelectronics
STM32L5
STM32L5xx
Ultra-low-power STM32L5 MCUs with Arm Cortex-M33 core, MPU, cache, DSP, FPU, TrustZone, 156 DMIPS at 110 MHz.
__var DbgMCU_CR = 0x00000006; // DBGMCU_CR: DBG_STOP, DBG_STANDBY
__var DbgMCU_APB1L_Fz = 0x80E0183F; // DGBMCU_APB1L_FZ: Configure APB1L peripheral freeze behavior
__var DbgMCU_APB1H_Fz = 0x00000062; // DGBMCU_APB1H_FZ: Configure APB1H peripheral freeze behavior
__var DbgMCU_APB2_Fz = 0x00072800; // DGBMCU_APB2_FZ : Configure APB2 peripheral freeze behavior
__var TraceClk_Pin = 0x00040002; // PE2
__var TraceD0_Pin = 0x00020009; // PC9
__var TraceD1_Pin = 0x0002000A; // PC10
__var TraceD2_Pin = 0x00040005; // PE5
__var TraceD3_Pin = 0x0002000C; // PC12
__var DoOptionByteLoading = 0; // Disabled
__var traceSWO = (__traceout & 0x1) != 0; // SWO enabled?
__var traceTPIU = (__traceout & 0x2) != 0; // Synchronous trace port enabled?
Sequence("CheckID");
Sequence("ConfigureTraceSWOClock");
Sequence("ConfigureTraceTPIUClock");
// Replication of Standard Functionality
Write32(0xE000EDF0, 0xA05F0001); // Enable Core Debug via DHCSR
// Device Specific Debug Setup
Write32(0xE0044004, DbgMCU_CR | (Read32(0xE0044004) & 0xF0)); // DBGMCU_CR: Configure MCU Debug
Write32(0xE0044008, DbgMCU_APB1L_Fz); // DBGMCU_APB1_FZ: Configure APB1L Peripheral Freeze Behavior
Write32(0xE004400C, DbgMCU_APB1H_Fz); // DBGMCU_APB1_FZ: Configure APB1H Peripheral Freeze Behavior
Write32(0xE0044010, DbgMCU_APB2_Fz); // DBGMCU_APB1_FZ: Configure APB2 Peripheral Freeze Behavior
__var traceSWO = (__traceout & 0x1) != 0; // SWO (asynchronous) Trace Selected?
__var traceTPIU = (__traceout & 0x2) != 0; // Synchronous trace port enabled?
Sequence("EnableTraceSWO"); // Call SWO Trace Setup
Sequence("EnableTraceTPIU"); // Call TPIU Trace Setup
__var traceSWO = (__traceout & 0x1) != 0; // SWO enabled?
__var traceTPIU = (__traceout & 0x2) != 0; // Synchronous trace port enabled?
Sequence("DisableTraceSWO");
Sequence("DisableTraceTPIU");
__var pidr1 = 0;
__var pidr2 = 0;
__var jep106id = 0;
__var ROMTableBase = 0;
__ap = 0; // AHB-AP
ROMTableBase = ReadAP(0xF8) & ~0x3;
pidr1 = Read32(ROMTableBase + 0x0FE4);
pidr2 = Read32(ROMTableBase + 0x0FE8);
jep106id = ((pidr2 & 0x7) << 4 ) | ((pidr1 >> 4) & 0xF);
Query(0, "Not a genuine ST Device! Abort connection", 1);
Message(2, "Not a genuine ST Device! Abort connection.");
Sequence("ConfigureTraceSWOPin");
Sequence("ConfigureTraceSWOClock");
__var dbgmcu_val = 0; // DBGMCU_CR Value
dbgmcu_val = Read32(0xE0044004) & (~0xF0); // Read DBGMCU_CR and clear trace setup
Write32(0xE0044004, dbgmcu_val); // Write DBGMCU_CR: Trace Settings
Sequence("ConfigureTraceTPIUPins");
Sequence("ConfigureTraceTPIUClock");
__var dbgmcu_val = 0; // DBGMCU_CR Value
dbgmcu_val = Read32(0xE0044004) & (~0xF0); // Read DBGMCU_CR and clear trace setup
Write32(0xE0044004, dbgmcu_val); // Write DBGMCU_CR: Trace Settings
__var dbgmcu_val = 0; // DBGMCU_CR Value
__var dbgmcu_trace_val = 0; // DBGMCU_CR Value
dbgmcu_val = Read32(0xE0044004) & (~0xF0); // Read DBGMCU_CR and clear trace setup
dbgmcu_trace_val = (1 << 5) | (1 << 4); // Trace Port and Clock Enable + Trace I/O Enable + Trace Mode Asynchronous
Write32(0xE0044004, dbgmcu_val | dbgmcu_trace_val); // Write DBGMCU_CR: Trace Settings
__var width = (__traceout & 0x003F0000) >> 16;
__var dbgmcu_val = 0; // DBGMCU_CR Value
__var dbgmcu_trace_val = 0; // DBGMCU_CR Value
dbgmcu_val = Read32(0xE0044004) & (~0xF0); // Read DBGMCU_CR and clear trace setup
dbgmcu_trace_val = (3 << 5) | (1 << 4);
dbgmcu_trace_val = (5 << 5) | (1 << 4);
dbgmcu_trace_val = (7 << 5) | (1 << 4);
Write32(0xE0044004, dbgmcu_val | dbgmcu_trace_val); // Write DBGMCU_CR: Trace Settings
__var pin = 0;
__var port = 0;
__var portAdr = 0;
__var pos = 0;
__var secOffs = 0x00000000;
__var SWO_Pin = 0x00010003; // PB3
secOffs = 0x10000000;
pin = ((SWO_Pin ) & 0x0000FFFF);
port = ((SWO_Pin >> 16) & 0x0000FFFF);
portAdr = 0x42020000 + secOffs + (((SWO_Pin >> 16) & 0x0000FFFF) * 0x400);
pos = pin * 2;
Write32(0x4002104C + secOffs, ((Read32(0x4002104C + secOffs) ) | (1 << port)) ); // RCC_AHB2ENR: IO port clock enable
Write32(portAdr + 0x00, ((Read32(portAdr + 0x00) & ~( 3 << pos)) | (2 << pos )) ); // GPIOx_MODER: Set Mode (Alternate Function)
Write32(portAdr + 0x08, ((Read32(portAdr + 0x08) ) | (3 << pos )) ); // GPIOx_OSPEEDR: Set Speed (Very High Speed)
Write32(portAdr + 0x0C, ((Read32(portAdr + 0x0C) & ~( 3 << pos)) ) ); // GPIOx_PUPDR: Set I/O to no pull-up/pull-down
pos = ((pin ) & 7) * 4;
Write32(portAdr + 0x20, ((Read32(portAdr + 0x20) & ~(15 << pos)) ) ); // GPIOx_AFRL: Alternate Function to AF0
pos = ((pin - 8) & 7) * 4;
Write32(portAdr + 0x24, ((Read32(portAdr + 0x24) & ~(15 << pos)) ) ); // GPIOx_AFRH: Alternate Function to AF0
__var pin = 8;
__var port = 0;
__var portAdr = 0;
__var pos = 0;
__var secOffs = 0x00000000;
__var width = (__traceout & 0x003F0000) >> 16;
secOffs = 0x10000000;
pin = (TraceClk_Pin ) & 0x0000FFFF;
port = (TraceClk_Pin >> 16) & 0x0000FFFF;
portAdr = 0x42020000 + secOffs + (((TraceClk_Pin >> 16) & 0x0000FFFF) * 0x400);
pos = pin * 2;
Write32(0x4002104C + secOffs, ((Read32(0x4002104C + secOffs) ) | (1 << port)) ); // RCC_AHB2ENR: IO port clock enable
Write32(portAdr + 0x00, ((Read32(portAdr + 0x00) & ~( 3 << pos)) | (2 << pos )) ); // GPIOx_MODER: Set Mode (Alternate Function)
Write32(portAdr + 0x08, ((Read32(portAdr + 0x08) ) | (3 << pos )) ); // GPIOx_OSPEEDR: Set Speed (Very High Speed)
Write32(portAdr + 0x0C, ((Read32(portAdr + 0x0C) & ~( 3 << pos)) ) ); // GPIOx_PUPDR: Set I/O to no pull-up/pull-down
pos = ((pin ) & 7) * 4;
Write32(portAdr + 0x20, ((Read32(portAdr + 0x20) & ~(15 << pos)) ) ); // GPIOx_AFRL: Alternate Function to AF0
pos = ((pin - 8) & 7) * 4;
Write32(portAdr + 0x24, ((Read32(portAdr + 0x24) & ~(15 << pos)) ) ); // GPIOx_AFRH: Alternate Function to AF0
pin = (TraceD0_Pin ) & 0x0000FFFF;
port = (TraceD0_Pin >> 16) & 0x0000FFFF;
portAdr = 0x42020000 + secOffs + (((TraceD0_Pin >> 16) & 0x0000FFFF) * 0x400);
pos = pin * 2;
Write32(0x4002104C + secOffs, ((Read32(0x4002104C + secOffs) ) | (1 << port)) ); // RCC_AHB2ENR: IO port clock enable
Write32(portAdr + 0x00, ((Read32(portAdr + 0x00) & ~( 3 << pos)) | (2 << pos )) ); // GPIOx_MODER: Set Mode (Alternate Function)
Write32(portAdr + 0x08, ((Read32(portAdr + 0x08) ) | (3 << pos )) ); // GPIOx_OSPEEDR: Set Speed (Very High Speed)
Write32(portAdr + 0x0C, ((Read32(portAdr + 0x0C) & ~( 3 << pos)) ) ); // GPIOx_PUPDR: Set I/O to no pull-up/pull-down
pos = ((pin ) & 7) * 4;
Write32(portAdr + 0x20, ((Read32(portAdr + 0x20) & ~(15 << pos)) ) ); // GPIOx_AFRL: Alternate Function to AF0
pos = ((pin - 8) & 7) * 4;
Write32(portAdr + 0x24, ((Read32(portAdr + 0x24) & ~(15 << pos)) ) ); // GPIOx_AFRH: Alternate Function to AF0
pin = (TraceD1_Pin ) & 0x0000FFFF;
port = (TraceD1_Pin >> 16) & 0x0000FFFF;
portAdr = 0x42020000 + secOffs + (((TraceD1_Pin >> 16) & 0x0000FFFF) * 0x400);
pos = pin * 2;
Write32(0x4002104C + secOffs, ((Read32(0x4002104C + secOffs) ) | (1 << port)) ); // RCC_AHB2ENR: IO port clock enable
Write32(portAdr + 0x00, ((Read32(portAdr + 0x00) & ~( 3 << pos)) | (2 << pos )) ); // GPIOx_MODER: Set Mode (Alternate Function)
Write32(portAdr + 0x08, ((Read32(portAdr + 0x08) ) | (3 << pos )) ); // GPIOx_OSPEEDR: Set Speed (Very High Speed)
Write32(portAdr + 0x0C, ((Read32(portAdr + 0x0C) & ~( 3 << pos)) ) ); // GPIOx_PUPDR: Set I/O to no pull-up/pull-down
pos = ((pin ) & 7) * 4;
Write32(portAdr + 0x20, ((Read32(portAdr + 0x20) & ~(15 << pos)) ) ); // GPIOx_AFRL: Alternate Function to AF0
pos = ((pin - 8) & 7) * 4;
Write32(portAdr + 0x24, ((Read32(portAdr + 0x24) & ~(15 << pos)) ) ); // GPIOx_AFRH: Alternate Function to AF0
pin = (TraceD2_Pin ) & 0x0000FFFF;
port = (TraceD2_Pin >> 16) & 0x0000FFFF;
portAdr = 0x42020000 + secOffs + (((TraceD2_Pin >> 16) & 0x0000FFFF) * 0x400);
pos = pin * 2;
Write32(0x4002104C + secOffs, ((Read32(0x4002104C + secOffs) ) | (1 << port)) ); // RCC_AHB2ENR: IO port clock enable
Write32(portAdr + 0x00, ((Read32(portAdr + 0x00) & ~( 3 << pos)) | (2 << pos )) ); // GPIOx_MODER: Set Mode (Alternate Function)
Write32(portAdr + 0x08, ((Read32(portAdr + 0x08) ) | (3 << pos )) ); // GPIOx_OSPEEDR: Set Speed (Very High Speed)
Write32(portAdr + 0x0C, ((Read32(portAdr + 0x0C) & ~( 3 << pos)) ) ); // GPIOx_PUPDR: Set I/O to no pull-up/pull-down
pos = ((pin ) & 7) * 4;
Write32(portAdr + 0x20, ((Read32(portAdr + 0x20) & ~(15 << pos)) ) ); // GPIOx_AFRL: Alternate Function to AF0
pos = ((pin - 8) & 7) * 4;
Write32(portAdr + 0x24, ((Read32(portAdr + 0x24) & ~(15 << pos)) ) ); // GPIOx_AFRH: Alternate Function to AF0
pin = (TraceD3_Pin ) & 0x0000FFFF;
port = (TraceD3_Pin >> 16) & 0x0000FFFF;
portAdr = 0x42020000 + secOffs + (((TraceD3_Pin >> 16) & 0x0000FFFF) * 0x400);
pos = pin * 2;
Write32(0x4002104C + secOffs, ((Read32(0x4002104C + secOffs) ) | (1 << port)) ); // RCC_AHB2ENR: IO port clock enable
Write32(portAdr + 0x00, ((Read32(portAdr + 0x00) & ~( 3 << pos)) | (2 << pos )) ); // GPIOx_MODER: Set Mode (Alternate Function)
Write32(portAdr + 0x08, ((Read32(portAdr + 0x08) ) | (3 << pos )) ); // GPIOx_OSPEEDR: Set Speed (Very High Speed)
Write32(portAdr + 0x0C, ((Read32(portAdr + 0x0C) & ~( 3 << pos)) ) ); // GPIOx_PUPDR: Set I/O to no pull-up/pull-down
pos = ((pin ) & 7) * 4;
Write32(portAdr + 0x20, ((Read32(portAdr + 0x20) & ~(15 << pos)) ) ); // GPIOx_AFRL: Alternate Function to AF0
pos = ((pin - 8) & 7) * 4;
Write32(portAdr + 0x24, ((Read32(portAdr + 0x24) & ~(15 << pos)) ) ); // GPIOx_AFRH: Alternate Function to AF0
__var connectionFlash = ( __connection & 0xF ) == 2 ;
__var FLASH_BASE = 0x40022000 ;
__var FLASH_CR = FLASH_BASE + 0x28 ;
__var OBL_LAUNCH_BIT = ( 1 << 27 ) ;
__var LOCK_BIT = ( 1 << 31 ) ;
__var OPTLOCK_BIT = ( 1 << 30 ) ;
__var FLASH_KEYR = FLASH_BASE + 0x08 ;
__var FLASH_KEY1 = 0x45670123 ;
__var FLASH_KEY2 = 0xCDEF89AB ;
__var FLASH_OPTKEYR = FLASH_BASE + 0x10 ;
__var FLASH_OPTKEY1 = 0x08192A3B ;
__var FLASH_OPTKEY2 = 0x4C5D6E7F ;
__var FLASH_CR_Value = 0 ;
__var DoDebugPortStop = 1 ;
__var DP_CTRL_STAT = 0x4 ;
__var DP_SELECT = 0x8 ;
// unlock the FLASH_CR
Write32( FLASH_KEYR, FLASH_KEY1 ) ;
Write32( FLASH_KEYR, FLASH_KEY2 ) ;
// unlock the option byte block
Write32( FLASH_OPTKEYR, FLASH_OPTKEY1 ) ;
Write32( FLASH_OPTKEYR, FLASH_OPTKEY2 ) ;
FLASH_CR_Value = Read32( FLASH_CR ) ;
DoDebugPortStop = 0 ;
__errorcontrol = 1 ;
// write OBL_LAUNCH bit (causes a reset)
Write32( FLASH_CR, FLASH_CR_Value | ( OBL_LAUNCH_BIT ) ) ;
__errorcontrol = 0 ;
// Switch to DP Register Bank 0
WriteDP(DP_SELECT, 0x00000000);
// Power Down Debug port
WriteDP(DP_CTRL_STAT, 0x00000000);
STMicroelectronics STM32L5 Devices
STMicroelectronics STM32L5 Device and CMSIS-CORE
Configuration via STM32CubeMX
#define RTE_DEVICE_CUBE_MX
#define CMSIS_device_header "stm32l5xx.h"
Create a CubeMX basic solution with project
Create a CubeMX TrustZone solution with secure and non-secure projects