Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

STM32 EEPROM emulation fail with optimization

Posted by Lawrence Song on March 3, 2010
I am using the Code Sourcery G++ Lite gcc compiler with the optimization flag set to optimize size (Os). Unfortunately this made the application unable to read or write to flash using EEPROM emulation. I tried to optimize with only a level one without success. This narrows down the flags to the list below:
          -fauto-inc-dec 
-fcprop-registers
-fdce
-fdefer-pop
-fdelayed-branch
-fdse
-fguess-branch-probability
-fif-conversion2
-fif-conversion
-fipa-pure-const
-fipa-reference
-fmerge-constants
-fsplit-wide-types
-ftree-builtin-call-dce
-ftree-ccp
-ftree-ch
-ftree-copyrename
-ftree-dce
-ftree-dominator-opts
-ftree-dse
-ftree-forwprop
-ftree-fre
-ftree-phiprop
-ftree-sra
-ftree-pta
-ftree-ter
-funit-at-a-time


Could one or more of these optimization flags cause EEPROM emulation to fail?

RE: STM32 EEPROM emulation fail with optimization

Posted by Richard on March 3, 2010
Well you could try adding in the optimisation flags one at a time until you start to get the problem again, but generally the route cause of this type of problem is something in the code being compiled, be it a volatile qualifier that is mising or something similar. Likewise it could be something not quite right in the compiler, but I would go through the code with a fine tooth comb first. These things can often be quite subtle.

Regards.

RE: STM32 EEPROM emulation fail with optimization

Posted by Lawrence Song on March 8, 2010
Yes it is a problem with the loop counter after optimization. I have setup a loop that counts the number of seconds. Once that counter reaches a certain size data is stored into EEPROM and the value resets. EEPROM works after the loop is diabled. Unfortunately declaring a variable volatile only means that the value of the variable is retrieved from SRAM instead of directly accessing it from the registers by the MCU. Does anyone have solved this problem before?

Another thing that puzzles me is that after I get rid of a variable I do not use anymore in the header file STM32fx_it.c (the STM-32 peripheral library's interrupt handler source file) with the optmization flag set to Os, the controller throws a Hard Fault Exception near the very beginning. Of course Make Clean was the first thing I did. I searched (and grepped) for any occurrances where the variable might be used without luck. The problem is gone when I declare the variable again. What is weird is that I do not even have to give the variable the same as the one I removed! It seems that as long there is A variable the firmware is happy. (All other variables are extern in the file). Has anyone have encountered something similar before?


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists