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

Internal FLash with FreeRTOS

Posted by Allure99 on October 10, 2008

Has any one use or have a experience using the embedded flash control (EFC on AT91SAM7x) ?

I manage to run sample basic-internalflash-project from Atmel/ How ever when I try to run it with FreeRTOS, it just crash the RTOS.

Any idea if this possible have EFC running together with FreeRTOS scheduler ?

Thanks.

RE: Internal FLash with FreeRTOS

Posted by woops_ on October 10, 2008
What does the EFC do? Is it to write to the flash memory while the program is running?

RE: Internal FLash with FreeRTOS

Posted by Allure99 on October 23, 2008
yes writing to flash memory while program is running.
I always end up in the

dabort_handler:
b dabort_handler

any idea?


RE: Internal FLash with FreeRTOS

Posted by woops_ on October 23, 2008
Most MCU do not permit writes to flash where the program is executing.

RE: Internal FLash with FreeRTOS

Posted by Çağlar Akyüz on October 23, 2008
How do yo disable your interrupts?
Where do you replace(ram or flash) your flash routines or how?

Caglar

RE: Internal FLash with FreeRTOS

Posted by Allure99 on October 23, 2008
Hi Chaalar,


Thanks for your reply.

1) i am using the portDISABLE_INTERRUPTS(); (not sure it is appropriate)

2) use (.fast) to put into the SRAM as below:

e_FLASH_Result Flash_Command(e_FLASH_Cmd cmd, const int page)__attribute__ ((section (".fast")));

//*****************************************************************************
// Function: Flash_Command
//
// Description:
// Perform a flash command on the specified page number.
// This function does not take a data as a parameter - eg. flash write buffer must be
// setup already if required.
//
// Parameters:
// - cmd : flash command to perform,
// - page : page number.
//
// Return Value:
// - e_FLASH_Result
//
//*****************************************************************************

e_FLASH_Result Flash_Command(e_FLASH_Cmd cmd, const int page)
{

e_FLASH_Result ret_val = FLASH_FAIL;
unsigned int fcr_val = 0x0; //Value to be placed in MC_FCR.
unsigned int fsr_val; //FSR reg content.
AT91S_EFC *pEfc; //pointer to EFC.

pEfc = AT91C_BASE_EFC0; // Base address of EFC0 registers.

switch(cmd)
{
case FLASH_LOCK_PAGE:// Lock a page.

fcr_val = (0x5A << 24) | (page << 8) | 0x2;
break;

case FLASH_UNLOCK_PAGE:// Unlock a page.

fcr_val = (0x5A << 24) | (page << 8) | 0x4;
break;

case FLASH_ERASE_PAGE:// Erase a page of data - write all zeroes (not 0xff)!
case FLASH_WRITE_PAGE:// Write data to a page (which should be unlocked already).

fcr_val = (0x5A << 24) | (page << 8) | 0x1;
break;

default:

return ret_val;
break;
}

// Disable interrupts
portDISABLE_INTERRUPTS();

//AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;

// Wait for flash to be ready.
do
{
fsr_val = pEfc->EFC_FSR;
}
while ((fsr_val & AT91C_MC_FRDY) == 0);

// Now send command.
pEfc->EFC_FCR = fcr_val;

// Wait for flash to be ready.
do
{
fsr_val = pEfc->EFC_FSR;
}
while ((fsr_val & AT91C_MC_FRDY) == 0);

//Check for errors and return.
if((fsr_val = pEfc->EFC_FSR) & (AT91C_MC_PROGE | AT91C_MC_LOCKE))
{
return ret_val; // Error shown in PROGE or LOCKE bits.
}
// Restore interrupts
portENABLE_INTERRUPTS();

return FLASH_OK;
}




RE: Internal FLash with FreeRTOS

Posted by Çağlar Akyüz on October 23, 2008
1) I don't know how is your linker script, but there is no .fast section in mine(default FreeRTOS linker script) I don't know
if linker throws error or silently discards wrong section qualifiers. So I would suggest you to be sure that your function is
in ram. ( Either check your linker script or map file)
2) It seems that you do not touch value of MC_FMR register in your flash routines. However, it must be set to a reasonable
for a safe flash programming. As far as I remember, for writing to flash and for re-programming NVM bits you have to
use two different FMR settings. In your case the default may be ok, but again I would suggest a check. This can be also
change according to your startup file. So one working with Atmel example may not work with FreeRTOS.
3) Last but not the least, you're returning from your programming routine with interrupts disabled if something goes wrong
with the programming. I think this is the problem you have at the moment.

Regards,
Caglar


[ 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