Topic : undefined reference to `FLASH_ProgramWord'

Forum : ARM

Original Post
Post Information Post
December 22, 2009 - 4:33am
Guest

Hi!
I have a problem building the application, appears undefined reference to `FLASH_ProgramWord', 'FLASH_Unlock', FLASH_ErasePage. I dont understand why if i defined as #define _FLASH_PROG in stm32f10x_conf.h.
It is missing something?

#define FLASH_PAGE_SIZE ((u16)0x800)
#define StartAddr ((u32)0x08040000)
#define EndAddr ((u32)0x08065800)

typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;

u32 EraseCounter = 0x00, Address = 0x00;
u32 Data = 0xF0F0F0F0;
u32 NbrOfPage = 0x00;

volatile FLASH_Status FLASHStatus;
volatile TestStatus MemoryProgramStatus;

int main(void)
{
FLASHStatus = FLASH_COMPLETE;
MemoryProgramStatus = PASSED;

.....

/* Unlock the Flash Program Erase controller */
FLASH_Unlock();

/* Define the number of page to be erased */
NbrOfPage = (EndAddr - StartAddr) / FLASH_PAGE_SIZE;

/* Clear All pending flags */
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);

/* Erase the FLASH pages */
for(EraseCounter = 0; (EraseCounter < NbrOfPage) && (FLASHStatus == FLASH_COMPLETE); EraseCounter++)
{
FLASHStatus = FLASH_ErasePage(StartAddr + (FLASH_PAGE_SIZE * EraseCounter));
}

/* FLASH Word program of data 0xF0F0F0F0 at addresses defined by StartAddr and EndAddr*/
Address = StartAddr;

while((Address < EndAddr) && (FLASHStatus == FLASH_COMPLETE))
{
FLASHStatus = FLASH_ProgramWord(Address, Data);
Address = Address + 4;
}

/* Check the corectness of written data */
Address = StartAddr;

while((Address < EndAddr) && (MemoryProgramStatus != FAILED))
{
if((*(vu32*) Address) != Data)
{
MemoryProgramStatus = FAILED;
}
Address = Address + 4;
}

while(1)
{}

}

Replies
Post Information Post
+1
0
-1
December 22, 2009 - 9:33am
Guest

Hi

Here are some suggestions:
- Verify your are not using a precompiled version of the library
- Verify which version of the library you use
- Verify the file you modify is the one taken in account by the project (rename it and see if build fails)

Regards
Matloub

+1
0
-1
December 22, 2009 - 4:47pm
Guest

Hi!
Thanks for your time...
My library version is 2.0.2. Its is quite strange because ride7 builds tha apllication successefully if i add the file stm32f10x_flash.c to the project. But running the r-link programming, he program the flash and
when in run mode and enters the code for write flash data it apears the message 'lost communication with target!'
If I run step by step the r-link makes the program works fine and writes the correct data in to flash memory.

Other thing, I try to define the functions like extern Flash_Unlock(); and the compiler returns failed and 2 definitions of
function FLASH_Unlock, one in main.c (my) the other in stm32f10x_flash.c. If remove my definition the compiler returns undefined reference to FLASH_Unlock. I can send you the code if you need.
Thanks again.
My complements...

+1
0
-1
December 23, 2009 - 9:18am
Guest

Hi

Here is what I can suggest:

- Make sure you using the last version of our tools Ride7 and RKit-ARM from (http://www.mcu-raisonance.com/mcu_downloads.html)

- Try to convert your project to latest library (you can refer to ST documentation for that)
Make sure you copy sources and your header files you use in your project in specific folder
Refer to the example Reva\STM32F103_MemsToLCD

- If you still have issues you can send me that project letting me know how to reproduce the probelm
I will try to find if the issue comes from our software, from ST library or from your side.

Regards
Matloub

+1
0
-1
January 2, 2010 - 5:15am
Guest

hi,
i have faced similar problem.
it seems that compiler is unable to find the source file for flash routines/
or it uses the a precompiled copy of the same!

i have added the flash routines in my project as a work around for the problem!

but there must be some actual explanation for why this is happening.

and a solution for the same.

regards
microp1

+1
0
-1
January 5, 2010 - 3:30am
Guest

I agree with you.
I solve the problem by adding the stm32f10x_flash.c, i dont understand how, but the compiler accepts without problems.
This strategy, i dont like too much, seems like we are cheating the compiler...
Some thing is wrong, I dont know what! I dont believe this procedure is the correct thing, and changing to the new library i think that dont have anything to do. I remove Ride7, and install last version, problem persists.

+1
0
-1
July 13, 2010 - 11:21am
Guest

I had the same problem. After investigating I found that the STM32F10x_thumb.lib library had been built without all the flash stuff.

In C:\Progra~1\Raison~1\Ride\Lib\ARM\STM32F~1\project\stm32f10x_conf.h the line "#define _FLASH_PROG" was commented out. Simply uncomment and rebuild the STM32F10x_thumb.rprj project. Then rebuild your own project (obviously linking the newly built STM32F10x_thumb.lib library).