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

LPC 1758 1768 IAP (In Application Programming

Posted by Maarten Roest on March 28, 2011
I am using FreeRTOS, and it needs to load variables from Flash before starting tasks.

The main entry code for FreeRTOS looks as follows:

int main(void)
{
/* Call SystemCoreClockUpdate such that SystemCoreClock holds correct
* value.
*/
SystemCoreClockUpdate();

__disable_irq();
// This stores variables to flash, then reads them using IAP, so far so good...
SaveDefaultValues();
LoadAllValues();
__enable_irq();

// Every module has at least the following tasks running:

xQ_MODBUS_UART_S = xQueueCreate( QS_MODBUS_UART_S, sizeof(Q_MESSAGE));

vMBPInit( );
vTaskStartScheduler( );

return 0 ;
}

For testing, the code first saves the default values to flash, (Bank 15 at 0x0000F000)
The strange thing is, when stepping through the code, all flash functions are executed successfully.
If I look in the Flash Memory at the specified location, it shows the correct values, and after reading from flash the correct values reside in RAM.

So far so good,

BUT: When the vTaskStartScheduler is called, the tasks should start running, but they never enter running state.

When I suspend the code, it always resides in:


static void prvCheckTasksWaitingTermination( void )
{
#if ( INCLUDE_vTaskDelete == 1 )
{
portBASE_TYPE xListIsEmpty;

/* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
too often in the idle task. */
if( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0 )
{
vTaskSuspendAll();
xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
xTaskResumeAll();

if( !xListIsEmpty )
{
tskTCB *pxTCB;

portENTER_CRITICAL();
{
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) );
vListRemove( &( pxTCB->xGenericListItem ) );
--uxCurrentNumberOfTasks;
--uxTasksDeleted;
}
portEXIT_CRITICAL();

prvDeleteTCB( pxTCB );
}
}
}
#endif
}

The value of uxTasksDeleted = 0.
The code never leaves this function, so it seems the scheduler cannot function properly anymore.

When I remove the Flash related code from the startup code (SaveDefaultValues and LoadAllValues), the system starts normally with tasks running as they should.


Is it possible using IAP changes something in the system state, preventing FreeRTOS to schedule normally ?
Is there some information on how to use IAP in combination with FreeRTOS ?

According to Code Red (the programming environment is theirs) it should reserve 32 bytes from the start of RAM in order to properly use the IAP functions.
I have enabled the GUI setting in Code Red for this.

However, perhaps there is something else I need to do (in FreeRTOS settings??) to reserve those bytes...

Any help is appreciated,

RE: LPC 1758 1768 IAP (In Application Programming

Posted by Dave on March 28, 2011
I have never used IAP, but it does sound like it is causing data corruption somewhere. Your IAP routines are called between the RAM being initialized by the C start code, and the kernel being used, so I would guess that something initialized in the start code is clobbered by the IAP code. It is just a guess.


[ 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