Guide for working with MQX in MCUXpresso

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

Guide for working with MQX in MCUXpresso

1,532 Views
m4l490n
Contributor V

Introduction and Assumptions

  I'm creating this little tutorial because I haven't been able to find anything better for doing this. I will explain how I work with MQX using MCUXpresso, it's not perfect, but it's a start. If anyone has a better way please comment or create a guide and link it here.

  This is kind of a hybrid approach. Since the code you may be working on constantly is your application, there is not much need to do this for the kernel, bsp, psp, and other libraries but similar steps can be done in case you want to work with those in MCUXpresso as well.

  For this little guide, I'm working in Linux and the GNU ARM compiler, also, I'll be using MQX V4.1.1. I'll be building the kernel, bsp, psp, and other libraries from the command line as explained in the documentation and creating MCUXpresso project to work with the application, in this case, the "hello" example found in MQX_4_1_1_LINUX_GA/mqx/examples/hello.

  For these steps I'm assuming the FRDM-K64 board and that you have the MQX_4_1_1_LINUX_GA folder in the "home" directory. I also have flashed the Segger JLink OpenSDA debugger to the FRDM board so debugging is with JLink instead of whatever comes in the board out of the box. If you want to do that, follow the OpenSDA / OpenSDA V2 Firmware guide.

Redirect STDIO to the Debugger

  Before starting, if you don't want to search where is UART0 (defined as TTYA in MQX) on the board and connect a USB-to-Serial converter to it, you can do the following modifications to the file "user_config.h" to have printf be redirected to the debugger. The file is located in MQX_4_1_1_LINUX_GA/config/frdmk64f.

Change #define BSPCFG_ENABLE_TTYA 1 for #define BSPCFG_ENABLE_TTYA 0

Change #define BSPCFG_ENABLE_IODEBUG 0 for #define BSPCFG_ENABLE_IODEBUG 1

Add #define BSP_DEFAULT_IO_CHANNEL   "iodebug:" anywhere in the file.

Create and debug MQX in MCUXpresso

1. Navigate to the folder where the mqx libraries should be built

         cd MQX_4_1_1_LINUX_GA/build/frdmk64f/make

2. Run the build script

         ./build_gcc_arm.sh

That will create a folder called "lib" inside MQX_4_1_1_LINUX_GA that in turn contains a folder called frdmk64f.gcc_arm where the "debug" and "release" folders are placed which will contain the necessary libraries built for the FRDM-K64 board.

3. Create a new C project in eclipse with file>New>Makefile Project with existing code using the code found in MQX_4_1_1_LINUX_GA/mqx/examples/hello and name it "hello":

pastedImage_7.png

4. Once the project is created do a right-click>Properties and go to the C/C++ Build section. There, in the "Builder Settings" tab put the following:

pastedImage_8.png

Build command: TOOL=gcc_arm CONFIG=debug LOAD=intflash

Build directory: ${workspace_loc:/hello/build/make/hello_frdmk64f}

5. Now in the Behavior tab put "build" instead of "all" for the Build (Incremental build).

pastedImage_10.png

That's the only change in this tab

6. Build the project.

That will create a folder called "intflash_debug" inside the "build/make/hello_frdmk64f/gcc_arm" with the generated .elf file.

7. Create a new build configuration:

pastedImage_8.png

C/C++ Application: build/make/hello_frdmk64f/gcc_arm/intflash_debug/hello_frdmk64f.elf

8. Debug

Labels (1)
Tags (2)
0 Kudos
Reply
1 Reply

1,334 Views
danielchen
NXP TechSupport
NXP TechSupport

Thanks for your sharing, it is very useful to other customers. I shared your post to MQX space.

Regards

Daniel

0 Kudos
Reply