2009-11-12 02:43 AM
Trouble with Hitop and stdperiph_lib
2011-05-17 04:25 AM
Hello everybody,
First off: Sorry to bother you people but I am totally new to ARM and Hitop world and desperately in search of help! The situation: I am supposed to develop a system with the new stm32 microcontroller series. I use Hitop 5.3-CTX for CortexM3 as IDE, which right now I am using to “simulate�, the evaluation board STM3210B-EVAL has already been ordered and should be on its way here… (the microcontroller I will use is the stm32f103vbt6) What I managed so far: I got myself a general understanding of the Hitop IDE and looked at various code examples to get a grip on how to write my program. I also downloaded the “Standard Peripherals Library v3.1.2� and copied the “CMSIS\Core\CM3� files to my project and even got a little test program to run. But the trouble starts here: I want to use the standard library functions, mainly the GPIO ones, like GPIO_StructureInit(). So I tried to copy all the .h and .c files from the current library to my project and also tried to include them in various ways, but I always get compiler error like “undefined reference …� as soon as I want to access the functions defined in the .c files, though I can use the “defines� in the .h files like GPIOA->ODR without any errors. What I need: I asking very kindly if somebody could tell me how I exactly have to include the “Standard Peripherals Library v3.1.2´´ in my project with some directories(?) in Hitop so I don’t have to copy and include the files one by one in my project. I also read something about the makefile (main.ld??) in which you have to edit something to make it work properly? Or do I have to change the “Project Settings� in Hitop, and if yes, in which way? I also don’t understand which files I have to “#include “…� � in the program code so that I can access the functions defined in .c library files. I’ve been trying to figure out this problem for the last few days and I am about to going nuts because I still can’t get it to work. I really hope somebody here can help me or maybe even post a fully functioning Hitop project with the Standard Peripherals Library used within the project. And sorry for my english, I am not a native speaker! Thanks in advance, Jakobi2011-05-17 04:25 AM
Hi Jacobi,
CMSIS, C-Compilers and Doxygen seems really good tools to make software design more difficult. main.ld is not the makefile (what is obviously hidden inside Hitop?) but is the linker file for the GNU linker ld. For the latest HITOP Version there a five diffrent library search paths inside main.ld. All five paths are wrong becouse they changed the version\thumb\thumb2 directory into version\thumb2\ with GCC 4.3.3 installation. This results in a ''cannot find -lgcc'' message and linker tries to link without archive libgcc.a what results in further errors. The only correct library search path is: SEARCH_DIR(''$(ToolDir)\..\lib\gcc\arm-hitex-elf\$(GNU_CORTEX_VERSION)\thumb2'' ) Unfortunately the only Hitop example ''clock'' is not CMSIS compatible and thats why I also struggle with std_lib. See seperate thread - if this compiles I can mail you complete Hitop project. [ This message was edited by: Janvi on 11-10-2009 22:28 ]2011-05-17 04:25 AM
Hello Jacobi,
attached is my Hitop CMSIS project using StdPeriphLib_V3.1.2 with Hitex GCC4.3.3. Make shure you have installed latest Hitop with the GCC compiler option (and not Tasking). For the moment, free download is Hitop 5.31 build 00017. Chain contains unlimited GCC and debugger limitation only occurs if no Tantino cable hardware is found. I used the small file version with 107Mb what seems to be without ARM7 and ARM9 support. If you like to know more what I have changed for success, If you experience more trouble with this example, you can drop me a mail to my forum alias at t-online.de rgds janvi This is my error and warning free ''rebuild all'' command for reference. The shown include path is not used becouse all source files are in project directory. arm-hitex-elf-gcc.exe -c -gdwarf-2 -MD -O0 -trigraphs -mcpu=cortex-m3 -mthumb -Wall -fsigned-char -mlittle-endian -mfpu=vfp -xc -mno-thumb-interwork -mno-tpcs-frame -I..\..\..\Libraries\CMSIS\Core\CM3\ -I..\ -I.\ -o .\objects\main.o .\main.c arm-hitex-elf-as.exe -mcpu=cortex-m3 -gdwarf2 -mthumb -EL -mfpu=vfp -I..\..\..\Libraries\CMSIS\Core\CM3\ -I..\ -I.\ -o .\objects\startup_stm32f10x_md.o .\startup_stm32f10x_md.s arm-hitex-elf-gcc.exe -c -gdwarf-2 -MD -O0 -trigraphs -mcpu=cortex-m3 -mthumb -Wall -fsigned-char -mlittle-endian -mfpu=vfp -xc -mno-thumb-interwork -mno-tpcs-frame -I..\..\..\Libraries\CMSIS\Core\CM3\ -I..\ -I.\ -o .\objects\stm32f10x_gpio.o .\stm32f10x_gpio.c arm-hitex-elf-gcc.exe -c -gdwarf-2 -MD -O0 -trigraphs -mcpu=cortex-m3 -mthumb -Wall -fsigned-char -mlittle-endian -mfpu=vfp -xc -mno-thumb-interwork -mno-tpcs-frame -I..\..\..\Libraries\CMSIS\Core\CM3\ -I..\ -I.\ -o .\objects\stm32f10x_it.o .\stm32f10x_it.c arm-hitex-elf-gcc.exe -c -gdwarf-2 -MD -O0 -trigraphs -mcpu=cortex-m3 -mthumb -Wall -fsigned-char -mlittle-endian -mfpu=vfp -xc -mno-thumb-interwork -mno-tpcs-frame -I..\..\..\Libraries\CMSIS\Core\CM3\ -I..\ -I.\ -o .\objects\stm32f10x_rcc.o .\stm32f10x_rcc.c arm-hitex-elf-ld.exe -T.\main.ld.tmp --cref -t -static -nostartfiles -Map=.\objects\main.map -stats -lc -lgcc -o .\objects\Template.elf arm-hitex-elf-ld: total time in link: 0.046000 arm-hitex-elf-ld: data size 12080332 arm-hitex-elf-ld: mode armelf .\objects\main.o .\objects\startup_stm32f10x_md.o .\objects\stm32f10x_gpio.o .\objects\stm32f10x_it.o .\objects\stm32f10x_rcc.o [ This message was edited by: Janvi on 20-10-2009 16:17 ]2011-05-17 04:25 AM
Hey there Janvi,
good for you that you made it work! The good news is, I also made it work myself after spending endless hours figuring out error messages and trying to resolve them... Sorry for not droping by sooner, but my life is kinda (VERY) busy right now. I will take a look at your project, maybe I still can learn one or two things from it. Btw, how did you manage to make it work with the “-lgcc� command not removed? I only could compile it with removing this from the linker command list. And did you edit the main.ld yourself or did you copy it from somewhere? If you did it yourself, could you kindly explain me what exatly you did. And another thing: I made the whole thing work without removing the “assert...� thing from the conf-file but leaving it right were it was. If you’re still interessted, I could explain my findings to you or upload my project. Anyways, thank you very much for your help! I hope we can both profit from each others findings. Greetings, Jakobi2011-05-17 04:25 AM
The -lgcc switch instructs the linker to use the C runtime from archive libgcc.a You can remove this in the Hitex clock example becouse this example does not use any stdio or other C runtime library. If you remove library you are going to run in further trouble as soon as your project requires string manipulation or other things like math or printf.
Unfortunately, I have to amend my attempt to edit the search path inside linker file as described in my recent post. This attempt removed the linker error from Hitex clock example but does not link the correct library for Keil STM32 Board. The reason is, becouse the only Hitop example project ''clock'' is compiled with the -mfpu=vfp switch in the Hitop project setup. This instructs compiler to use hardware floatingpoint what is not available in the STM32. Becouse the clock example does not use any float numbers, there seems no warning or error in the buildt procedure nor any impact to the clock application. If somebody tries to use the only clock example from Hitex for template of own STM32 project, this fails until the C runtime is used. Even if you remove the -mfpu=vfp switch from compiler, there is no success with runtime library. Probably the clock example was copied from Cortex-A9 or anything else. The only way to use Hitex GCC for the STM32 seems like this: a) - compile your c files with either -msoft-float or -mfloat-abi=soft b) - correct search path in linker file to path: Hitex\GnuToolPackageCortex\arm-hitex-elf\lib\thumb2\soft instead of only Hitex\GnuToolPackageCortex\arm-hitex-elf\lib\thumb2 like described in my recent post. Only this selects STM32 compatible library compiled for ARMv7, Thumb2, little endian, software float. c) - there is another library libc.a what uses diffrent path not found in linker file. To use matching libc for STM32 I copied the complete directory from C:\Programme\Hitex\GnuToolPackageCortex\arm-hitex-elf\lib\thumb2\soft to C:\Programme\Hitex\GnuToolPackageCortex\arm-hitex-elf\lib The default libc after Hitop install for this path seems an interwork compiled libc what is incompatible for the STM32. d) Huraah! As soon as you made anything correct, the result is a success with linking your first example project (within a few weeks) for the new STM32 microcontroller ... By the way - your solution to the assert-param problem would be also interesting. My attempt removed the compile errors but does not really generate appropriate messages in case of wrong parameters. For the moment, the reasons are unknown and I won´t examine this [ This message was edited by: Janvi on 29-10-2009 22:37 ]2011-05-17 04:25 AM
Hey there,
sorry for not replying for so long, I have lot of stuff going on right now. I attached my project, which is fully running in HiSIM, hope it still helps you in some way. And once again the question: Could you please explain to me, what exactly you modified in your main.ld file in order to make it compile/build, and why to had to add/remove/… those statements? Thanks for your answers, Jakobi