STMicroelectronics STM32 CPU Support Package
This package contains project templates and system files for the STMicroelectronics STM32.
Package Installation Instructions
CrossWorks Version 2.x Installation Instructions
To install this support package using CrossStudio:
- 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.
Alternatively, to manually install this support package:
- 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.
Package Version History
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.
1) 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.
2) 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 compile the project:
- __TARGET_PROCESSOR to be set to the specified processor name.
- For low density value line devices __TARGET_LD_VL and STM32F10X_LD_VL.
- For medium density value line devices __TARGET_MD_VL and STM32F10X_MD_VL.
- For high density value line devices __TARGET_HD_VL and STM32F10X_HD_VL.
- For low density devices __TARGET_LD and STM32F10X_LD.
- For medium density devices __TARGET_MD and STM32F10X_MD.
- For high density devices __TARGET_HD and STM32F10X_HD.
- For XL density devices __TARGET_XL and STM32F10X_XL.
- For connectivity line devices __TARGET_CL and STM32F10X_CL.
- For ULP medium density devices __TARGET_MD_ULP and STM32L1XX_MD.
- For F2xx devices __TARGET_F2XX and STM32F2XX.
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. 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 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 STM32F10x, STM32L and STM32F2xx is provided.
Memory Simulator
An STM32 memory simulator is provided that simulates the memories of the various STM32F10x, STM32L and STM32F2xx 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 library are included as part of the new project setup.
- core_cm3.h general Cortex-M3 CMSIS header file.
- stm32f10x.h STM32F10x specific header file.
- stm32l1xx.h STM32L specific header file.
- stm32f2xx.h STM32F2xx specific header file.
CTL support
The file STM32_ctl.c implements the CTL system timer using the Cortex-M3 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 implementation uses the lowest half of the available NVIC priorities (top bit set in the priority) for CTL interrupts and disables global interrupts by raising the 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.
3) CrossWorks Shared Sample Projects
The following project files are supplied that can be used to run the standard CrossWorks shared samples.
- IAR_STM32F103ZE_SK Shared Samples (click to load project)
- IAR_STM32F107VC_SK Shared Samples (click to load project)
- Keil_MCBSTM32 Shared Samples (click to load project)
- Keil_MCBSTM32E Shared Samples (click to load project)
- ST_STM3210B_EVAL Shared Samples (click to load project)
- ST_STM3210C_EVAL Shared Samples (click to load project)
- ST_STM3210E_EVAL Shared Samples (click to load project)
- ST_STM32100B_EVAL Shared Samples (click to load project)
- ST_STM32L152_EVAL Shared Samples (click to load project)
- ST_STM3210E_EVAL External Flash Loader Solution (click to load project)
- ST_STM32VLDISCOVERY Shared Samples (click to load project)
- ST_STM3220F/G_EVAL Shared Samples (click to load project)
- ST_STM32L_DISCOVERY Shared Samples (click to load project)
- ST_STM3240G_EVAL Shared Samples (click to load project)
- ST_STM32F4DISCOVERY Shared Samples (click to load project)
- ST_STM32L152D_EVAL Shared Samples (click to load project)
4) CTL Sample Projects
The following project files are supplied that can be used to run the standard CrossWorks CTL samples.
- IAR_STM32F103ZE_SK CTL Samples (click to load project)
- IAR_STM32F107VC_SK CTL Samples (click to load project)
- Keil_MCBSTM32 CTL Samples (click to load project)
- Keil_MCBSTM32E CTL Samples (click to load project)
- ST_STM3210B_EVAL CTL Samples (click to load project)
- ST_STM3210C_EVAL CTL Sample (click to load project)
- ST_STM3210E_EVAL CTL Samples (click to load project)
- ST_STM32100B_EVAL CTL Samples (click to load project)
- ST_STM32L152_EVAL CTL Samples (click to load project)
- ST_STM32VLDISCOVERY CTL Samples (click to load project)
- ST_STM3220F/G_EVAL Shared Samples (click to load project)
- ST_STM32L_DISCOVERY CTL Samples (click to load project)
- ST_STM3240G_EVAL CTL Samples (click to load project)
- ST_STM3240G_EVAL CTL VFP Sample (click to load project)
- ST_STM32F4DISCOVERY CTL Samples (click to load project)
- ST_STM32F4DISCOVERY CTL VFP Sample (click to load project)
- ST_STM32L152D_EVAL CTL Samples (click to load project)