LPC488(Cortext MR) FreeRTOS Port Under Crossworks for ARM

paulromero wrote on Monday, April 06, 2015:

Hi Folks:

I suceeded in creating a functional, but incomplete, FreeRTOS port for the LPC4088
in the Crossworks for ARM environment, which was tested on the Embedded Artists
LPC4088-32 Developer’s Kit board.

Most of the incomplete aspects are related to Crossworks system components.
The details follow. Please let me know if you see something which is wrong,
can be automated, or done in a better way. (i.e. Look for TBD for comments
on the incomplete aspects.)

Best Regards,

Paul R.

Platform

Embedded Artists LPC4088-32 Developer’s Kit (Eval. Board.)

Major Component Versions

FreeRTOS: V8.01
Crossworks for ARM: V3.2
LPC Open Library: V2.10 (Xpresso version)

Prerequisite Crossworks Packages

The following are important Crossworks packages and should be downloaded. Note
that this list is not definitive or necessarily complete.

  • Crossworks: ARM CPU Support Package, CMSIS 3 Support Package, Tasking Library Package,
    FreeRTOS Library Package.
  • Embedded Artists: LPC4088 OEM Board Support Package.
  • NXP: LPC1000 CPU Support Package, NXP4300 CPU Support Package.
  • STM: STM32 CPU Support Package, STM32 Discovery Board Support Package.

TBD: Currently, it appears Rowley does not recommend or require a Cortex M4
specific or floating point support package. The STM packages should be replaced
by equivalent NXP packages–but such packages with the requisite FreeRTOS
components may not be currently available. It is believed the LPC1000 CPU
package contains the correct LPC4088 components.

Crossworks Project Properties Configuration

Use the Crossworks GUI to create a project a starting point by selecting
“File->New Project->Executable for LPC OEM EA”. Be sure to select a sensible project
name and project directory. (i.e. For example, $(Home_FreeRTOS)/FreeRTOS_LPC4088)

The following project attributes must be configured as follows:

  • Preprocessor Definitions: CORE_M4
  • ARM FPU Type: FPv4-SP-D16
  • ARM FP ABI Type: Softfp or Hard.

Suggested Overall Code Organization

           $(Home_FreeRTOS_LPC4088)          $(HomeCrossworks)
               |               |                    |
             FreeRTOS       LPC_Open             Packages
                                                    |
                                                  targets

FreeRTOS Source Code Organization

The overall FreeRTOS directory structure will be something like this.
(i.e. The names used are generally suggestions.)

                        $(Home_FreeRTOS)
                               |
                         FreeRTOS_LPC4088
                            |        |
                         Example  Source
                                  |    |
                             include  portable
                                |         |
                               GCC     MemMang
                                |
                             ARM_CM4F

Obtain the FreeRTOS V8.01 source code from the FreeRTOS website or download it from
Crossworks and put it in the “Source” subdirectory. The organization of the FreeRTOS
code should already be the same or very close to directory structure shown above.

TBD: It is believed that threads_CMF4.js script is needed under Crossworks and not
supplied with the generic FreeRTOS source code. Rowley must be consulted to determine
the origin of the file and how to install it.

Put the attached versions of main.c and main_blinky.c in the “Example” subdirectory.
They are slightly modified versions of the source code from the generic FreeRTOS V8.01
and NXP LPC Open V2.10 blinky example for the LPC4088.

In the Crossworks GUI and project, the “Example” directory is labeled as “Source Files”
by default. Make sure it exists and is pointing at “Example” and includes main.c and
main_blinky.c.

Add a “Source” directory to the project with the Crossworks GUI. You should
do this recursively.

Rowley Source Code Organization

The overall directory structure of the Crossworks system software is as follows.
(i.e. These are the currently available generic Crossworks components and
should automatically be installed under the project “System Files” subdirectory
in the Crossworks GUI.)

                          $(Home_CrossWorks)
                                  |
                               packages
                                  |
                               targets
                                  |
    ________________________________________________________
   |                  |                  |                  |
CMSIS_3           EA_LPC4088_OEM        LPC1000             STM32
                     |                  |
                   _____            _________
                  |     |          |         |
                 inc   src      include   LPC407x_8x
                                   |
                                 CMSIS

The following items should be put in EA_LPC4088_OEM. (i.e. There is a directory named
“Systems Files/lpc4088 open bsp” directory in the Crossworks project GUI. Verify
that it points at EA_LPC4088_OEM.)

  • FreeRTOSConfig.h
  • FreeRTOS_board.c

Also, confirm the following definitions in FreeRTOSConfig.h.

#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) )

For timer functionality, add the following definitions.

//
// This must be done to enable timers.
// The timer task should be highest or close to the highest
// priority task. The queue size may need to be configured.
//
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
#define configTIMER_QUEUE_LENGTH 10

TBD: These files are very close to the versions in the STM32F4DISCOVERY subdirectory
supplied by Rowley. It is’t believed currently Rowley has LPC4088 specific versions
of these files. It is likely the generic FreeRTOS release has almost identical
versions for LPC17xx family member or an actual LPC4088 version.

Note that following files under LPC1000 are particularly important.

LPC1000: LPC4078* and LPC407x_8x*
LPC1000/include: LPC4088.h
LPC1000/include/CMSIS: system_407x_8x_177x_8x.* and LPC407x_8x_177x_8x.*

TBD: The LPC1000 and LPC100/CMSIS directories contain as least partially compatible LPC4088
system files. It is believed that they are completely compatible with some LPC17xx family
member. It isn’t known if this is the final or official Rowley solution for LPC4088
functionality.

TBD: STM32 contains the memory map and interrupt vector definition files. As an interim
measure, the STM32F4 versions for the STMF4DISCOVERY board are being used as they are almost
identical to how they are used for for the Cortex M4 on the LPC4088 board. However, there
is probably another more appropriate Rowley directory.

NXP LPC Open Source Code Organization

The overall directory structure of the LPC Open Library is as follows.

                           $(Home_LPC_Open)
                                  |
                          ______________________
                         |                      |
              lpc_board_ea_devkit_4088     lpc_chip_40xx
                  |              |           |    |    |
                 inc            src         inc  libs  src

The entire lpc_board_ea_devkit_4088 and lpc_chip_40xx subdirectories
should be put under $(Home_LPC_Open).

In the file lpc_chip_40xx/src/chip_17xx_40xx.c the variable declaration for
SystemCoreClock and the routine SystemCoreClockUpdate() must be commented
out as they are supplied by the generic Crossworks system files.

Crossworks Configuration

The following paths need to be included in the Crosworks GUI project “User Include Directories”.

$(TargetsDir)/LPC1000/include/CMSIS
$(TargetsDir)/CMSIS_3/CMSIS/Include
$(TargetsDir)/LPC1000/include
$(TargetsDir)/EA_LPC4088_OEM
$(ProjectDir)/FreeRTOS/Source/include
$(ProjectDir)/FreeRTOS/Source/portable/GCC/ARM_CM4F
$(ProjectDir)/LPC_Open/lpc_chip_40xx/inc
$(ProjectDir)/LPC_Open/lpc_board_ea_devkit_4088/inc

TBD: Verify configuration of $(ProjectDir) with Rowley.

The following minimum sizes are recommended:

Heap Size: 8192
Main Stack Size: 512

rtel wrote on Tuesday, April 07, 2015:

Hi - this is quite a long post - does it contain a question? If not, but it is instead posting a port, I would suggest posting to the FreeRTOS Interactive site instead: http://interactive.freertos.org

Regards.