en.radzio.dxp.pl |
|
Main menu Tutorials Code library for LCD
ATMEL AVR microcontrollers STMicro ST7 microcontrollers Projects Software
|
Programming STM32VLDISCOVERY with open source toolchain However the Keil uVision is good choice for beginners and it is very easy for use, that have some restrictions. Maximum otuput size is 32KiB, and still it is a commercial compiler. There are some more or less "open" build environments that do not have restricted maximum build size output and are available for free. One of them is Sourcery CodeBench Lite, known before as Codesourcery G++ Lite. This is free version of paid CodeBench environment,. In free version there is no IDE, only command-line toolchain. So let's use one of most popular IDE for programing : Eclipse IDE. Eclipse is also used as editor in commercial edition of CodeBench (and more of other commercial toolchains for ARM). In conenction with Sourcery CodeBench and GNU ARM Eclipse Plugin makes free and easy to use environment for creating software for STM32 (and other) microcontrollers with ARM core.
Important words about debugging Installing Sourcery CodeBench Installing Eclipse Installing GNU ARM Eclipse Plugin
Creating project with GNU ARM Eclipse Plugin Now we are ready to add to project device support files from CMSIS library. Download archive and exctract from CMSIS folder following files : stm32f10x.h, system_stm32f10x.c, system_stm32f10x.h and startup_stm32f10x_md_vl.s (from arm-gcc subfolder). You can download only required files from here, but I do not quarantee that files are up to date with files supplied by STMicroelectronics on thier website. Copy files into folder with project, and refresh projec tree [step 11]. Now, try build project. There are some errors [step 12]. We must define from which group of STM32 microcontrollers we are used. On STM32VLDISCOVERY is mounted microcontroller from Medium Density Value Line group (MD_VL). So open properties window [step13], expand C/C++ build tree and select "Settings" section [step 14]. On tab 'Tool settings' select the 'Preprocessor' section in ARM Sourcery Windows GCC C compiler [step 15]. Click on the icon with white sheet and green plus sign in 'Defined symblos' section and type STM32F10X_MD_VL in dialog window [step 16]. After you click 'OK' button, defined symbol should be present on list [step 17]. Now try build application again. There should be no errors, but one warning [step 18]. We missed one important file - script for the linker. Linker script contains informations about location of application sections in microcontroller memory. Download linker script for STM32VLDISCOVERY : stm32vldiscovery.ld and save it in project directory. Now open again project properties window and go to 'General' settings for linker and specify location of linker script [step 19]. Now try build application again. There should be no errors and warnings [step 20]. Switch to 'Console' tab [step 21]. You should see informations about used space in sections : text, data and bss [step 22]. In 'text' section are stored code of application. In section data are stored variables initialized with value different than zero. In section bss are stored variables uninitialized (initialized with value zero). Now expand "Debug" folder on project tree [step 23]. Look for files with *.o extension. This file should be exist for each source file (*.c and *.s). But there is no *.o file for startup_stm32f10x_md_vl.s! Compiler is case-sensitive and assembler source files should have upper case extension *.S. So, change extension of startup file and rebuild application again. Look again into 'Debug' folder [step 24]. Now in folder is present startup_stm32f10x_md_vl.o file, so everything is fine. Now, copy into main.c file code form lesson 1 and build application [step 25]. Output code size is about two times bigger than output code this same example compiled by Keil uVision. Open project properties window and go to 'Optimization' section of compiler settings [step 26] and select option "Optimize size" [step27]. Rebuild application, now code size should be smaller [step 28]. Programming flash memory
|
(c) Radosław Kwiecień |