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

LPC1769 Integration

Posted by jwschmo on October 26, 2016

All,

I've been working to get FreeRTOS integrated with some code on an LPC1769 that is using open source compilers etc and some serious legacy code. Its an odd project where a good chunk of the code is in .CPP files however, its not class based function calls. so with that in mind I started to integrate freertos in, and I'm getting stuck. Now I know that the right way to do this is integrate everything based on the example project, however, I've inherited a significant code base that would be really cumbersome to rewrite for the example project.

SO - I was wondering the following - I have successfully demonstrated to myself that the rtos function call "vTaskStartScheduler" is successfully executing all the way to the assembly code in port.c:

static void prvPortStartFirstTask( void ) { someRedLight(); __asm volatile( " ldr r0, =0xE000ED08 n" /* Use the NVIC offset register to locate the stack. / " ldr r0, [r0] n" " ldr r0, [r0] n" " msr msp, r0 n" / Set the msp back to the start of the stack. / " cpsie i n" / Globally enable interrupts. / " cpsie f n" " dsb n" " isb n" " svc 0 n" / System call to start first task. */ " nop n" ); }

because some Red LED shows up on the board. HOWEVER! after that is called the Task that I'm expecting to start working doesn't crop up. It looks something like this in main.cpp:

extern "C"{

static void someLoopTask( void *pvParameters );

}

#ifndef TEST_MODE int main(void) { initializefunction(); //firmwareLoop(); someRedLight();

xTaskCreate(&someLoopTask,					/* The function that implements the task. */
			"FwLp", 						/* The text name assigned to the task - for debug only as it is not used by the kernel. */
			configMINIMAL_STACK_SIZE+1000, 		/* The size of the stack to allocate to the task. */
			( void * ) NULL, 				/* The parameter passed to the task - just to check the functionality. */
			mainSIG_TASK_PRIORITY, 			/* The priority assigned to the task. */
			NULL );							/* The task handle is not required, so NULL is passed. */


/* Start the tasks and timer running. */	
delay500MS();
someGreenLight();
delay500MS();
vTaskStartScheduler();

someBlueLight();



for (;;) {
}

return 0;

}

extern "C" {

static void someLoopTask( void pvParameters ) { / Remove compiler warning in the case that configASSERT() is not defined. */ someGreenLight(); delay500MS(); ( void ) pvParameters; //someRedLight();

/* Check the task parameter is as expected. */
//configASSERT( ( ( unsigned long ) pvParameters ) == NULL );
for( ;; )
{
	//someLoop();
}

}

}

I've tried a number of iterations - I've looked through the memory mapping (they are different but not incredibly so). I've looked through the support files (I've copied over the pertenant ones). I've played around with the configMINIMALSTACKSIZE constant, I've played around with the extern "C" locationing, and I've played around with the FreeRTOSConfig.h file:

/ FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. All rights reserved

VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

This file is part of the FreeRTOS distribution.

FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.


>>!   NOTE: The modification to the GPL is included to allow you to     !<<
>>!   distribute a combined work that includes FreeRTOS without being   !<<
>>!   obliged to provide the source code for proprietary components     !<<
>>!   outside of the FreeRTOS kernel.                                   !<<


FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  Full license text is available on the following
link: http://www.freertos.org/a00114.html



     FreeRTOS provides completely free yet professionally developed,    
     robust, strictly quality controlled, supported, and cross          
     platform software that is more than just the market leader, it     
     is the industry's de facto standard.                               

     Help yourself get started quickly while simultaneously helping     
     to support the FreeRTOS project by purchasing a FreeRTOS           
     tutorial book, reference manual, or both:                          
     http://www.FreeRTOS.org/Documentation                              



http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
the FAQ page "My application does not run, what could be wrong?".  Have you
defined configASSERT()?

http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.

http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible.  Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.

http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.

http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.

http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.

http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.

1 tab == 4 spaces!

/

#ifndef FREERTOSCONFIGH #define FREERTOSCONFIGH

/ The following #error directive is to remind users that a batch file must be executed prior to this project being built. The batch file cannot be executed from within the IDE! Once it has been executed, re-open or refresh the Eclipse project and remove the #error line below. / //#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above.

#include "LPC17xx.h"

/----------------------------------------------------------- Application specific definitions.

These definitions should be adjusted for your particular hardware and application requirements.

THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. ----------------------------------------------------------/

#define configUSEPREEMPTION 1 #define configUSEIDLEHOOK 0 #define configMAXPRIORITIES ( 5 ) #define configUSETICKHOOK 0 #define configCPUCLOCKHZ ( ( unsigned long ) 100000000 ) #define configTICKRATEHZ ( ( TickTypet ) 1000 ) #define configMINIMALSTACKSIZE ( ( unsigned short ) 80 ) #define configTOTALHEAPSIZE ( ( sizet ) ( 4 1024 ) )//19 **#define configMAXTASKNAMELEN ( 12 ) #define configUSETRACEFACILITY 1 #define configUSE16BITTICKS 0 #define configIDLESHOULDYIELD 0 #define configUSECOROUTINES 0 #define configUSEMUTEXES 1

#define configMAXCOROUTINEPRIORITIES ( 2 )

#define configUSECOUNTINGSEMAPHORES 0 #define configUSEALTERNATIVEAPI 0 #define configCHECKFORSTACKOVERFLOW 2 #define configUSERECURSIVEMUTEXES 0 #define configQUEUEREGISTRYSIZE 5 #define configGENERATERUNTIMESTATS 0

/ Set the following definitions to 1 to include the API function, or zero to exclude the API function. /

#define INCLUDEvTaskPrioritySet 1 #define INCLUDEuxTaskPriorityGet 1 #define INCLUDEvTaskDelete 1 #define INCLUDEvTaskCleanUpResources 0 #define INCLUDEvTaskSuspend 1 #define INCLUDEvTaskDelayUntil 1 **#define INCLUDEvTaskDelay 1 #define INCLUDEuxTaskGetStackHighWaterMark 0

/ This demo makes use of one or more example stats formatting functions. These format the raw data provided by the uxTaskGetSystemState() function in to human readable ASCII form. See the notes in the implementation of vTaskList() within FreeRTOS/Source/tasks.c for limitations. / //#define configUSESTATSFORMATTINGFUNCTIONS 1

/----------------------------------------------------------- Ethernet configuration. -----------------------------------------------------------/

/ MAC address configuration. / #define configMACADDR0 0x00 **#define configMACADDR1 0x12 **#define configMACADDR2 0x13 **#define configMACADDR3 0x10 **#define configMACADDR4 0x15 **#define configMACADDR5 0x11

/ IP address configuration. / #define configIPADDR0 192 **#define configIPADDR1 168 #define configIPADDR2 0 **#define configIPADDR3 201

/ Netmask configuration. / #define configNETMASK0 255 **#define configNETMASK1 255 **#define configNETMASK2 255 **#define configNETMASK3 0

/ Use the system definition, if there is one / #ifdef NVICPRIOBITS #define configPRIOBITS NVICPRIOBITS #else #define configPRIOBITS 5 / 32 priority levels / #endif

/ The lowest priority. / #define configKERNELINTERRUPTPRIORITY ( 31 << (8 - configPRIOBITS) ) / Priority 5, or 160 as only the top three bits are implemented. / / !!!! configMAXSYSCALLINTERRUPTPRIORITY must not be set to zero !!!! See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. / #define configMAXSYSCALLINTERRUPTPRIORITY ( 5 << (8 - configPRIOBITS) )

/ Priorities passed to NVICSetPriority() do not require shifting as the function does the shifting itself. Note these priorities need to be equal to or lower than configMAXSYSCALLINTERRUPTPRIORITY - therefore the numeric value needs to be equal to or greater than 5 (on the Cortex-M3 the lower the numeric value the higher the interrupt priority). / #define configEMACINTERRUPTPRIORITY 5 **#define configUSBINTERRUPTPRIORITY 6

/----------------------------------------------------------- Macros required to setup the timer for the run time stats. -----------------------------------------------------------/ //extern void vConfigureTimerForRunTimeStats( void ); //#define portCONFIGURETIMERFORRUNTIMESTATS() vConfigureTimerForRunTimeStats() //#define portGETRUNTIMECOUNTERVALUE() LPCTIM0->TC

#endif / FREERTOSCONFIGH /


However, at this point I'm a bit lost - I can't get it to call the task nor blink the light please Obi-Wan you're my only hope.....Should I look at the ISR information? I'll note that a blue tooth stack is being setup before this stuff is getting called, but this software disables interrupts so I figured it would be ok.....


LPC1769 Integration

Posted by edwards3 on October 26, 2016

Do you have the FreeRTOS interrupts installed? See answer 1 here http://www.freertos.org/FAQHelp.html If yes do you hit the FreeRTOS SVC handler vPortSVCHandler() in port.c? (put a break point in it to see)


LPC1769 Integration

Posted by jwschmo on October 29, 2016

Cool - I added the following three lines to FreeRTOSConfig.h:

#define vPortSVCHandler SVCHandler **#define xPortPendSVHandler PendSVHandler #define xPortSysTickHandler SysTick_Handler

However now I'm getting the following compile error:

build/BOARD/libs/freertos/portable/GCC/ARMCM3/port.o:port.c:(.text.SysTickHandler+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [build/BOARD/firmware-BOARD.elf] Error 1

Fatal error: local() encountered an error (return code 2)

In the code I'm trying to integrate with there is a timer.cpp that has the following code:

unsigned int SYSTEMTICKCOUNT;

extern "C" {

void SysTickHandler() { ++SYSTEMTICK_COUNT; }

}

If I comment out that code so that the other function can compile correctly (which it will compile if I comment out the above lines) then the processor doesn't do anything - additionally I moved the "systemTickCount" over to the other function call as well :(.

Thoughts?


LPC1769 Integration

Posted by rtel on October 30, 2016

So the code you are integrating with already defines a SysTickHandler(). Is the SYSTEMTICKCOUNT variable it increments used anywhere? If not, you can just comment out the previous handler. If it is then you could increment SYSTEMTICK_COUNT from the FreeRTOS tick hook function. Not if you do that though it will only start incrementing after the scheduler has been started.


[ 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