Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner