![](images/stmicroelectronics.png)
STMicroelectronics STM32 CPU Support Package
Warning: This is a legacy package, it has been provided to keep existing projects working and is not recommended for new projects. This package has been replaced by STMicroelectronics STM32 CPU Support Package.
This package contains project templates and system files for the STMicroelectronics STM32.
CrossWorks Version 2 Installation Instructions
- To install this support package
-
- Click the Tools > Package Manager menu option to open the package manager window.
- Right click on the STMicroelectronics STM32 CPU Support Package entry and select Install Selected Packages.
- Click Next to take you to the summary page.
- Click Next to install the package.
- Click Finish to close the package manager window.
- Click the Tools > Show Installed Packages.
- Click on the STMicroelectronics STM32 CPU Support Package link to view the package and its contents.
- To manually install this support package
-
- If you have not done so already, follow the CMSIS 3 Support Package installation instructions.
- Download the file STM32.hzq using your web browser.
- Click the Tools > Manually Install Packages menu option.
- Select the file you have just downloaded to install the package.
- Click the Tools > Show Installed Packages.
- Click on the STMicroelectronics STM32 CPU Support Package link to view the package and its contents.
- To install this support package using other versions
Release Notes
2.28
- Updated SRAM sizes for the STM32F051 memory maps.
- Added EnableTrace("TracePort") support for STM32F1/STM32F3 and STM32L1 devices to STM32_Target.js.
2.27
- Added support for STM32F401xD/STM32F401xE and STM32L152RE.
2.26
- Added support for STM32F07x devices.
- Fixed debugger register display of OSPEEDR for F4xx devices.
- Supplied latest ST CMSIS files for F0xx devices.
- Changed preprocessor defines for STM32F0xx builds to match the latest ST CMSIS files.
- Added ctl_lowest_isr_priority/ctl_highest_isr_priority/ctl_adjust_isr_priority to STM32_ctl.c.
2.25
- Supplied ST CMSIS files for STM32W108xx devices.
- Removed board specific target and sample files - these are now in their own board support packages.
2.24
- Fixed vector names in STM32F0xx.vec, STM32F0xx_LD.vec, STM32F10x_CL.vec, STM32F30x.vec and STMF37x.vec.
- The preprocessor define __TARGET_PROCESSOR_device_name is defined.
2.23
- Added support for STM32F030, STM32F401, STM32F429, STM32F439 and STM32L100 devices.
- Changed startup code to use ST named preprocessor definitions for vector table selection. If you have a project local copy of the startup code you will need to diff and merge.
- Supplied updated versions of ST CMSIS files for STM32F0xx, STM32F4xx and STM32Lxx devices.
2.22
- Added support for STM32L16xx devices.
2.21
- Included STM32F10xxE revision Z in target script device errata work-arounds.
- Registers in NVIC register group have device specific bitfield names.
2.20
- Fixed missing DATA_SRAM memory segment in STM32F4xx memory map files.
- Fixed start address for GPIOD register group in STM32F4xx/STM32F2xx memory map files.
2.19
- Corrected AHB/APB device memory segments in memory map files.
- Peripherals registers in memory map files are now generated from ST CMSIS SVD files.
- Added ctl_sleep and ctl_woken to STM32_ctl.c. These functions can be used in CTL V3 to reduce the timer interrupt frequency when in low power mode.
- Added test10.c to ctl tests. This file is supplied with CTL V3.
- Reduced RAM size to 10K in flash loader for medium density devices.
- Added support for latest STM32L1xxx devices.
2.18
- Fixed Flash Vectors In RAM build for Cortex-M0 devices.
2.17
- Added support for STM32F050 devices that have 0x444 as the DEV_ID.
- Fixed RTC_ISR register display for STM32F2xx, STM32F4xx and STM32L1xx devices.
- Added support for STM32F42x/STM32F43x devices.
2.16
- Memory maps now have peripheral regions to enable Restrict Memory Accesses target project property to work.
- New projects now have the Restrict Memory Accesses target property set.
- New projects now have default stack sizes of 256 bytes.
- Fixed the button support for STM320518-EVAL in the stm32_ctl_board.c.
2.15
- Fixed startup code when VECTORS_IN_RAM defined.
- Added preprocessor define __FPU_PRESENT=1 to STM32F4xx and STM32F3xx Target property group entries.
- Added sample support for ST STM32F3DISCOVERY board.
2.14
- Added support for STM32F3xx devices.
- Added sample support for ST STM3230C-EVAL board.
- Added sample support for ST STM3237C-EVAL board.
- Added support for STM32W devices.
- Added sample support for ST STM32W-RFCKIT-MB950 board.
- Removed from the startup code the disabling of the Cortex-M4F hardware lazy FP save feature for CTL. CTL supplied in CrossWorks for ARM version 2.3 supports the Cortex-M4F hardware lazy FP save feature.
- Removed core CMSIS header files from this package. New projects will reference the include directory $(TargetsDir)/CMSIS_3/CMSIS/Include of the CMSIS-3 package. If you have an existing project then you will have to add $(TargetsDir)/CMSIS_3/CMSIS/Include to the User Include Directories project property.
- Fixed memory map descriptions of STM32F4xx GPIO registers.
2.13
- Added support for STM32F0xx devices.
- Added sample support for ST STM320518-EVAL board.
- Added Device ID support for STM32F4xx that return 0x413 rather than 0x411.
- Removed legacy files targets/STM32F10*.h use stm32f10x.h instead.
- STM32L Flash loader and memory maps support the Data EEPROM.
2.12
- Added support for missing STM32L1 devices.
- Fixed misc problems in memory maps and Target processor references to memory maps.
- ST CMSIS V1.1.0 stm32l1xx.h and system_stm32l1xx.[ch] files supplied.
- ST CMSIS V1.0.0 stm32f4xx.h and system_stm32f4xx.[ch] files supplied.
2.11
- Added sample support for STM32F4DISCOVERY board.
- Added missing ACTRL, CPACR and FPU registers to STM32F4xx memory map files.
- The GCC Target project property is now set to be arm-unknown-eabi for new projects. It is recommended that this is set for existing projects.
- New CTL projects have USE_PROCESS_STACK defined and Process Stack Size project property is set to 128.
- Added CTL VFP samples for STM32F4DISCOVERY and STM3240G-EVAL boards.
- New CTL project includes a STM32_ctl_board.c that uses one of the ST implementations of SystemInit.
- Added support for STM32L151xC/STM32L151xD/STM32L152xC/STM32L152xD/STM32L162xD devices.
- Added sample support for ST STM32L152D-EVAL board.
2.10
- Added GetPartName and MatchPartName functions to the target script. New projects will set the Get Part Name Script and Match Part Name Script project properties to enable part name detection on connect and compatibility on start debugging. This requires CrossWorks for ARM 2.1.2.
- Modified the Reset function in the target script to not use SYSRESETREQ for Revision A STM32F10xx8/STM32F10xxB devices.
- Added support for STM32F4xx devices. This requires CrossWorks for ARM 2.1.2.
- Added sample support for ST STM3240G-EVAL board. This requires CrossWorks for ARM 2.1.2.
- ARM CMSIS V2.00 CM4 core support header files supplied.
2.9
- Support for STM32L-DISCOVERY.
- Corrected base address of SDIO peripheral on STM32F2xx memory maps.
- Corrected FMI peripheral description for STM32F2xx memory maps.
- ST CMSIS v3.5.0 stm32f10x.h and system_stm32f10x.[ch] files supplied.
- ST CMSIS v1.0.0 stm32f2xx.h and system_stm32f2xx.[ch] files supplied.
- Fixed VECTORS_IN_RAM support in STM32_Startup.s when Enable Unused Symbol Removal is set to Yes.
- Added simulator support for STM32F2xx.
- Added support for programming the USER option byte on STM32F2xx devices.
- Added support for STM32F101TB, STM32F217IE and STM32F217IG.
- STM32_ctl.c now implements ctl_set_isr which can be used with RAM based exception vectors.
- Section placement files have thread local storage sections.
- New projects will now use the section placement files from the CrossWorks distribution.
- Added a new placement option Flash Vectors In RAM to allow writeable exception vectors.
2.8
- Supplied missing sample files for STM32VLDISCOVERY.
- Fixed exception vectors for STM32L parts in startup code.
- Fixed CTL systick timer reload.
- Corrected the number of NVIC registers displayed in the registers window for STM32F105/STM32F107/STM32F205/STM32F207 parts.
2.7
- Modified the target reset script to use the SYSRESETREQ bit to implement debug reset.
- Added support for high density STM32F100 devices.
- Added support for STM32F2xx devices.
- Sample support for ST STM3220F-EVAL board.
- ARM CMSIS V2.00 CM3 core support header files supplied.
- ST CMSIS v3.4.0 stm32f10x.h and system_stm32f10x.[ch] files supplied.
- ST CMSIS v1.0.0 stm32l1xx.h and system_stm32l1xx.[ch] files supplied.
- ST CMSIS v0.0.4 stm32f2xx.h and system_stm32f2xx.[ch] files supplied.
- Removed obsolete $(TargetsDir)/STM32/lib/libcmsis$(LibExt)$(LIB) library (CMSIS V2.00 is all in header files). If referenced by existing projects remove references to it in the Linker | Additional Inputs project property.
- Removed $(TargetsDir)/STM32/lib/libst32_v7m_t_le.a library (source code of the files in this library are supplied). If referenced by existing projects remove references to it in the Linker | Additional Inputs project property.
- Target processor selection now defines the appropriate device value for the ST CMSIS header file(s).
2.6
- Section placement property now refers to standard section placement files.
- Fixed VECTORS_IN_RAM support in STM32_Startup.s.
- Added ctl_set_isr to STM32_ctl.c.
- Sample support for ST STM32VLDISCOVERY board.
2.5
- Fixed address of ETH_DMAIER in memory maps and header files.
- Added STM32L device support.
- Added support for STM32F101xF/G and STM32F103xF/G devices.
- Reset script now turns off watchdogs and enables low power mode debugging.
- Reset script has functions that enable the option bytes to be programmed.
- Sample support for ST STM32L152-EVAL board.
- Memory simulator can simulate 4 FSMC Flash/SRAM memories.
2.4
- Added value line device support.
- Flash loader supports flash breakpoints.
- Added Flash Copy To RAM section placement property group.
- Section placement property group now selects the loader to use and as such there is no requirement for Flash/RAM configurations.
- Added start macros to the first sections of the placement files which enables memory to be reserved at the start of the segment by defining the section placement macros.
- New CTL projects now have the STM3210B_EVAL/stm32_ctl_board.c file included.
- CMSIS Version 1.30 supplied.
- CMSIS stm32f10x.h Version 3.3.0 supplied.
- Sample support for ST STM32100B-EVAL board.
- Sample support for IAR STM32F107VC-SK board.
- Samples now use the CMSIS stm32f10x.h rather than the CrossWorks targets/stm32f10x.h.
2.3
- Added missing TIM1 to connectivity line memory maps and header files.
2.2
- Added support for the STM32F103TB.
- Corrected bxCAN and AFIO_MAPR memory map and header definitions for connectivity line devices.
2.1
- The vector table offset register is now always configured to allow the start address of FLASH configuration programs to be moved away from 0x00000000 without modification of startup code.
2.0
- Initial Release.
Documentation
Creating STM32 Projects
To create a new STM32 project
- Select the File > New > New Project menu item.
- Select the appropriate Generic STM32 from the Categories list.
- Select the required project template type from the Templates list.
- Set the required project name and location directory.
- Click OK.
To build and debug an application the runs in Flash memory
- Select the project to work on by using the Project > Set Active Project menu option.
- Select the configuration you require by using the Build > Set Active Build Configuration menu option.
- Right click on the project node in the project explorer and select the Flash placement.
- Build the project by using the Build > Build Project menu option.
- Connect to the appropriate target in the target window.
- Download and start debugging the current project by using Debug > Start Debugging.
To make the application startup from reset
- Right click on the project node in the project explorer and select Properties...
- In the properties window scroll down to the Preprocessor Options section.
- Type STARTUP_FROM_RESET into the Preprocessor Definitions property editor.
STM32 Project Specifics
Target Processor
Once a project has been created you can select different target processors by right clicking on the project node in the project explorer and selecting the Target Processor entry.
Selecting the target processor will specify the memory map that is used for the build and debug. You can view the selected memory map by right clicking on the project node in the project explorer and selecting View Memory Map or View Memory Map (as text).
Selecting the target processor will cause the following preprocessor definitions to be defined when you build the project:
- For F100x4/6 devices STM32F10X_LD_VL.
- For F100x8/B devices STM32F10X_MD_VL.
- For F100xC/D/E devices STM32F10X_HD_VL.
- For F101x4/6, F102x4/6, F103x4/6 devices STM32F10X_LD.
- For F101x8/B, F102x8/B, F103x8/B devices STM32F10X_MD.
- For F101xC/D/E, F102xC/D/E, F103xC/D/E devices STM32F10X_HD.
- For F101xF/G, F103xF/G devices STM32F10X_XL.
- For F105xx and F107xx devices STM32F10X_CL.
- For L1xxx6/8/B devices STM32L1XX_MD.
- For L1xxxC devices STM32L1XX_MDP.
- For L1xxxD devices STM32L1XX_HD.
- For F2xx devices STM32F2XX.
- For F30x devices STM32F30X.
- For F37x devices STM32F37X.
- For F401x devices STM32F401xx.
- For F4xx devices STM32F40_41xxx.
- For F427x and F437x devices STM32F427_437xx.
- For F429x and F439x devices STM32F429_439xx.
- For F030x devices STM32F030.
- For F031x/F050x devices STM32F031.
- For F042x devices STM32F042.
- For F071x/F072x devices STM32F072.
- For W devices the device name.
- For all devices __TARGET_PROCESSOR_device_name.
For devices that have an FPU the preprocessor definition __FPU_PRESENT is defined.
Section Placement
CrossStudio for ARM supports STM32 projects running applications in a number of different memory configurations. You can select the memory configuration you require by right clicking on the project node in the project explorer and selecting the Placement entry.
For STM32 projects the set of placements are:
- Flash application runs in internal Flash memory.
- Flash Vectors In RAM application run in internal Flash memory exception vectors are copied to RAM memory.
- Flash Copy To RAM application starts in internal flash and copies itself to run internal RAM memory.
- RAM application runs internal RAM memory.
Stack and Heap Sizes
The stack and heap sizes are set to be 128 bytes by default when a project is created. This enables projects to run on the smallest of the STM32 processors. It is likely that you will need to change these values when developing applications to run on the larger of the STM32 processors.
Target Startup Code
The startup code STM32_Startup.s is common to all STM32F and STM32L processors. There are a set of preprocessor defines that configure the startup code and are documented in the startup file itself. The startup code calls out to a weak symbol SystemInit with the stack pointer set to the top of RAM. The SystemInit function can be used to set the CPU clock or configure any external memories prior to the C initialisation code as such it cannot access initialised static data.
The startup code declares symoblic names (and weak implementations) for each interrupt service routine, for example the EXTI0_IRQHandler function will be called when this interrupt occurs. If you are porting code that has application specific interrupt service routine names then you can use the preprocessor definitions to rename the symbol for example EXTI0_IRQHandler=MyEXTI0ISR.
Target Reset Script
The reset script STM32_Target.js is used by the debugger to reset the target board.
The reset script will program the DBGMCU register so that the STM32 watchdog timers are stopped when in debug mode and the STM32 lower-power mode debugging is enabled.
The reset script provides some support for programming the USER option byte of the STM32F10x, STM32L and STM32F2xx/STM32F4xx. To use these you should:
- Connect to the appropriate target.
- Use View | Script Console to display the script console.
- In the script console type load("targets/STM32/STM32_Target.js") which should return true on success.
For STM32F10x targets:
- STM32F_EraseOptionBytes() which will erase all of the option bytes - this function must be called first.
- STM32F_Unprotect() to disable read protection - this function should be called unless you want to enable read protection.
- STM32F_SetUSER(b) and pass the desired USER byte value as the argument.
- STM32F_SetData0(b) and pass the desired user Data0 byte value as the argument.
- STM32F_SetData1(b) and pass the desired user Data1 byte value as the argument.
For STM32L targets:
- STM32L_SetUSER(b) and pass the desired USER byte value as the argument.
For STM32F2xx/STM32F4xx targets:
- STM32F2xx_SetUSER(b) and pass the desired USER byte value as the argument.
You should then disconnect the target interface and power cycle the board.
STM32 Internal Flash Loader
The source code to the flash loaders
for the internal Flash of the various devices is provided.STM32L EEPROM Support
The STM32L memory map files and flash loader supports loading the EEPROM which can be used as follows:
extern unsigned eevar __attribute__ ((section(".eeprom"))); unsigned eevar = 12;
Memory Simulator
An STM32 memory simulator is provided that simulates the memories of the various STM32 devices. The memory simulation parameter (which is set by the Target Processor selection) specifies the device name, the size of the internal Flash and RAM memories and then optionally the sizes of 4 FSMC Flash/RAM memories.
CMSIS support
CMSIS header files and source are included as part of the new project setup.
CTL support
The file STM32_ctl.c implements the CTL system timer using the Cortex-M SysTick timer. The timer is configured to interrupt at a 10 millisecond rate and increment the CTL system timer by 10 to give a millisecond timer. The implementation uses the CMSIS SystemFrequency global variable to determine the CPU clock frequency. The CTL samples that are provided in this package have board specific files that implement this variable.
The CTL interrupt support functions ctl_global_interrupts_set, ctl_set_priority, ctl_unmask_isr and ctl_mask_isr are implemented in this file. The Cortex-M3 and Cortex-M4 implementations uses the lowest half of the available NVIC priorities (top bit set in the priority) for CTL interrupts and disables global interrupts by raising t he NVIC basepriority above the highest CTL priority. This enables you to use the upper half of the NVIC priorities for interrupts that do not use CTL and should not be disabled by a CTL interrupt. The functions ctl_lowest_isr_priority, ctl_highest_isr_priority, and ctl_adjust_isr_priority are provided to assist with setting isr priorities.
Known problems
The "Connect With Reset" project property doesn't work with the original ST-LINK and also causes the part name detection to fail on Cortex-M0 devices.