cancel
Showing results for 
Search instead for 
Did you mean: 

GNU ARM compile problem, FLASH_KEY

pgregson1
Associate III
Posted on November 17, 2013 at 19:06

Hello,

I am using GNU ARM gcc version 4.7.4 to compile a simple LED flasher using STM32_USB-FS-Device_Lib_V4.0.0.  I am getting the following error:

-I/AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries//AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/inc -o build/stm32f10x_flash.o /AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c

/AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c: In function 'FLASH_Unlock':

/AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c:323:17: error: 'FLASH_KEY1' undeclared (first use in this function)

/AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c:323:17: note: each undeclared identifier is reported only once for each function it appears in

/AddIns/Development/STMicro/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c:324:17: error: 'FLASH_KEY2' undeclared (first use in this function)

and many more copies of ''FLASH_KEY'' errors.

My code compiles and runs fine with the STM32F10x_StdPeriph_Lib_V3.5.0 on the Olimex STM32_P103 board.

I  used grep -lr to try to find where this is defined without success.  Can anyone explain the problem to me and suggest a solution, please?

Thanks and Best regards,

Peter

3 REPLIES 3
Posted on November 17, 2013 at 22:30

You -I path doesn't look quite right.

The include path for the defines are in :

STM32_USB-FS-Device_Lib_V4.0.0\Libraries\CMSIS\Device\ST\STM32F10x\Include\stm32f10x.h
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pgregson1
Associate III
Posted on November 18, 2013 at 04:15

Hello,

In answer to clive1, I copied stm32f10x.h to my application's include directory.  That is why the first entry in the list of includes is -Iinc, so that the compiler finds the copy before it finds the one in the distribution.  I did this because there are application-dependent settings in the file, such as selection of the device, the clock, the USE_STDPERIPH_DRIVER flag, etc.  This way I can be developing a number of projects on different processors simultaneously.

I suppose that I could have used command-line defines instead.  That might be better, in fact, because it would allow me to change them inside the makefile.

I have found a way around the original problem, that of FLASH_KEY compiler errors, by just removing stm32f10x_flash.c from the sources at STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_Std_Periph_Driver/src.

This is not a good work-around.  It does allow me to continue developing the current project and it may provide someone more knowledgable some more information as to the nature of my problem.  The fact that the compile is successful and that the compiled code runs properly on the Olimex STM32_P103 board indicates that my problem is not related to my path.

Best regards,

Peter

Posted on November 18, 2013 at 05:03

it may provide someone more knowledgable some more information as to the nature of my problem

Maybe they have ESP too, but your excerpted include paths seem neither valid or complete. The probability remains that it's reading the wrong file in preference to the correct one, or the warning is simply omitted. If grep truly can't find the instance I found, then you might want to review the state of the unpacked library. The absence or presence only matters to the linker if the functions are actually used elsewhere in your code, otherwise dead code elimination simply removes them from the equation. One solution, as you have observed, is to cherry pick which library files are needed by the application.

USE_STDPERIPH_DRIVER, STM32F10X_MD, USE_STM3210B_EVAL
..\inc;
..\..\..\Libraries\CMSIS\Device\ST\STM32F10x\Include;
..\..\..\Libraries\STM32_USB-FS-Device_Driver\inc;
..\..\..\Libraries\STM32F10x_StdPeriph_Driver\inc;
..\..\..\Utilities\STM32_EVAL;
..\..\..\Utilities\STM32_EVAL\Common;
..\..\..\Utilities\STM32_EVAL\STM3210B_EVAL

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..