Port MQX4.0 application to MQX4.1 gcc building

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Port MQX4.0 application to MQX4.1 gcc building

878 Views
yifangguo-b4310
NXP Employee
NXP Employee

We know,  MQX4.0.0 project  use Freescale tool chains(ARM Toolchain) to compile it. In Properties->C/C++ Build->Tool Chain Editorit looks like this

1.png

But when build MQX4.1.0 libraryCode Warrior10.x  use GCC compiler tool chains(ARM Ltd Windows GCC) to build.

4.png

So,   your application should use gcc too. The porting is something about how to deal with  the application codes  conforming to GCC syntax. Let’s   use cw10.6 IDE for example.

Step 1.Create a new MQX4.1.0 application,

5.png

When finished, gcc tool chain is selected as default.

Step 2. Add your project source file to the new MQX4.1 project.  You’d better new a virtual Folder,

6.png

Add the source files and link to them,

7.png

TIPS:  The *.c file which need compiled , will must be  added in the CodeWarrior Projects view window.

The *.h file, is not must. But it’s path should be set in Properties->C/C++ General->Paths and Symbols->Includes->GNU C for building search.

The  *.a library is not must added in view windows, but it’s full path should be added in Properties->C/C++ Build->Setings->ARM Ltd Windows GCC Linker->Miscellaneous.

Step 3.  After add all source files, now, build the project.  There will be a lot of compile error,  next step, to  fix them.

1.       (1) Add “#include <psptypes_legacy.h>” in the project's .c or .h

If your compiler report this type is not defined error,

8.png

In the MQX 4.1.0 lib code, the standard C99 integer and boolean types (from stdlib.h and stdbool.h) are used instead of the proprietary MQX types. When porting the application to the MQX version 4.1.0, compilation issues could occur.

The psptypes_legacy.h header file is available and contains the definition of the MQX legacy types. This file can be included in the MQX application to overcome most of the compilation problems caused by the change of types. To avoid potential problems, adopt the C99 types in your application

2.      (2) Define symbol _EWL_99 to 1

If your compiler report bool type is unknown type,

9.png

Legacy MQX custom integer types were replaced by the Standard C99 set (int_32 -> int32_t, boolean -> bool, etc). In Properties->C/C++ General->Paths and Symbols->Symbols, add _EWL_C99 macro, value 1.

10.png

3.       (3) Byte  alignment packed syntax error

ARM Toolchain use key word “__packed”, but compile failed in GCC compiler.

11.png

In GCC compiler, use key word “__attribute_((packed))” to set one byte alignment.

12.png

4.       (4) Embedded assembly language in C program.

If your code embed some assembly language in c program, in FSL ARM Toolchain, support this syntax, but gcc build it failed,

13.png

You should modify to this syntax,
14.png

5.       (5) GCC compiler Macro __GNUC__

If you need macro to control your code by compiler,  __GNUC__ can use  for GCC tool chain and __CWCC__ can use for FSL ARM Toolchain.
15.png

6.       (6) Link the external library

If your application project include a external library, this library should be compiled by GCC tool chain too.

Note, the Float ABI is consistent in the project and the library that selected one as need.

16.png

7.       (7) Link script

FSL  ARM Toolchain use   *. lcf(e.g. intflash_sramdata.lcf)as link script,  but GCC tool chain  use    *.ld(e.g intflash_sramdata.ld). Select it in a available path,(e.g. MQX_ROOT_DIR/ lib/twrk70f120m.cw10gcc/debug/bsp/ intflash_sramdata.ld)

17.png

8.       (8) When debug the project, it can’t find initial script.

If debug the project, download failed, prompt look like this,

18.png

It mean the target initialize script can’t find, you should fill an available path in

Debug As->Debug Configurations->Target settings/Connection->Edit->Target->Edit->Initialization, ${PROJDIRPATH}/lib/twrk70f120m.cw10gcc/dbg/init_kinetis.tcl.

19.png

If prompt that can’t open memory configuration file, like this,

20.png

It mean the memory configure script can’t find, you should fill an available path in

Debug As->Debug Configurations->Target settings/Connection->Edit->Target->Edit->Memory, ${PROJDIRPATH}/lib/twrk70f120m.cw10gcc/dbg/twrk70f120m.mem

21.png

1 Reply

425 Views
dyun
Contributor I

Shouldn't you be defining "_EWL_C99" to 1 instead of "_EWL_99" as you indicated in step 3.2?

0 Kudos
Reply