an4287, mqx board support package porting guide -...

43
1 Introduction After the design and evaluation stage of developing a product with MQX has been completed, the user often wants to migrate the application project away from a Freescale evaluation board and to a custom board. Creating a new board support package (BSP) for that end board is the most advisable move. In general, the custom end board will have the same processor as the evaluation board, but will probably have different hardware features than the evaluation board. In terms of how this impacts the BSP, it translates into adding or removing device I/O drivers from the BSP. Chapters 4 and 5 of the MQX Users Guide (MQXUG.pdf) available from https://www.freescale.com give a description of the BSP and PSP folder structure and all the different files that conform to these support packages. They also give a generic list of steps to follow when cloning/creating a new BSP. In summary, creating a new BSP for your custom board involves the following steps: 1. Choosing an existing BSP that is closest to your custom board (same processor, similar hardware features) 2. Create a new BSP that is a cloned copy of the original BSP, and assign it a new name 3. Modify the cloned BSP by adding/removing device I/O drivers, or changing compiler/debugger configurations. Freescale Semiconductor Document Number: AN4287 Application Note Rev. 0, 06/2011 MQX Board Support Package Porting Guide by: Anthony Huereca, Christian Michel-Sendis Microcontroller Solutions Group © 2011 Freescale Semiconductor, Inc. Contents 1 Introduction.......................................................................1 2 CodeWarrior v7.2 BSP Creation.......................................2 3 CodeWarrior 10 BSP Creation........................................15 4 IAR BSP creation............................................................31 5 Conclusion......................................................................42

Upload: vuongnhu

Post on 13-Apr-2018

234 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

1 IntroductionAfter the design and evaluation stage of developing a productwith MQX has been completed, the user often wants tomigrate the application project away from a Freescaleevaluation board and to a custom board. Creating a new boardsupport package (BSP) for that end board is the mostadvisable move.

In general, the custom end board will have the same processoras the evaluation board, but will probably have differenthardware features than the evaluation board. In terms of howthis impacts the BSP, it translates into adding or removingdevice I/O drivers from the BSP.

Chapters 4 and 5 of the MQX Users Guide (MQXUG.pdf)available from https://www.freescale.com give a descriptionof the BSP and PSP folder structure and all the different filesthat conform to these support packages. They also give ageneric list of steps to follow when cloning/creating a newBSP.

In summary, creating a new BSP for your custom boardinvolves the following steps:

1. Choosing an existing BSP that is closest to your customboard (same processor, similar hardware features)

2. Create a new BSP that is a cloned copy of the originalBSP, and assign it a new name

3. Modify the cloned BSP by adding/removing device I/Odrivers, or changing compiler/debugger configurations.

Freescale Semiconductor Document Number: AN4287

Application Note Rev. 0, 06/2011

MQX Board Support PackagePorting Guideby: Anthony Huereca, Christian Michel-Sendis

Microcontroller Solutions Group

© 2011 Freescale Semiconductor, Inc.

Contents

1 Introduction.......................................................................1

2 CodeWarrior v7.2 BSP Creation.......................................2

3 CodeWarrior 10 BSP Creation........................................15

4 IAR BSP creation............................................................31

5 Conclusion......................................................................42

Page 2: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

This application note is intended to be a complement to the MQX User’s guide, by expanding on chapters 4 and 5 andproviding a step by step guidance of how exactly to clone a BSP.

This document illustrates this procedure when using IAR, CodeWarrior v7.2 and CodeWarrior v10.

It also shows how to clone a BSP and a PSP for the K60N512 and MCF52259 tower boards. The procedure is the same forother processors or other boards.

NOTEIn MQX 3.7, the BSP and PSP library files have been split into two separate folders. This application notedescribes the steps to create a new BSP with MQX 3.7. However the same steps will be used with earlierversions of MQX with a small difference that the BSP and PSP library folders are all in the [MQXINSTALLATION]\lib\mqx directory. In MQX 3.7 and later, the libraries are split between the [MQXINSTALLATION]\lib\bsp and [MQX INSTALLATION]\lib\psp directories.

2 CodeWarrior v7.2 BSP CreationThe MQX installation used here is Freescale MQX 3.7. The following sections provide steps to create a MCF52259 BSP.

2.1 Copy BSP and PSP Projects1. Go to [MQX INSTALLATION]\mqx\build\cwcf72.2. Select the mcp files of the BSP and PSP original projects: In this case, bsp_twrmcf52259.mcp and

psp_twrmcf52259.mcp.3. Copy and Paste these files into this same folder directory.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

2 Freescale Semiconductor, Inc.

Page 3: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 1.4. Rename these files and choose a name relevant to your new board. In this example, these are called as

CUSTOM_BOARD_bsp_mcf52259.mcp and CUSTOM_BOARD_psp_mcf52259.mcp.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 3

Page 4: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 2.

2.2 Copy BSP folder1. Go to [MQX INSTALLATION]\mqx\source\bsp.2. Copy the entire bsp folder of the original BSP, in this case the folder twrmcf52259.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

4 Freescale Semiconductor, Inc.

Page 5: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 3.3. Rename the copied folder to CUSTOM_BOARD_mcf52259:

Figure 4.4. Go into the recently created folder, [MQX INSTALLATION]\mqx\source\bsp\CUSTOM_BOARD_mcf52259 and

locate the twrmcf52259.h header file.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 5

Page 6: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 5.5. Rename it to CUSTOM_BOARD_mcf52259.h

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

6 Freescale Semiconductor, Inc.

Page 7: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 6.

2.3 Copy configuration folder1. Go to [MQX INSTALLATION]\config folder. Copy the folder called “twrmcf52259”, paste it and rename it to

“CUSTOM_BOARD_mcf52259”.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 7

Page 8: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 7.2. Go into the recently created folder:

Figure 8.3. Go into the CWCF72 folder and erase the “build_twrmcf52259_libs_Data” folder, if present. Rename the existing

*.mcp file to “ CUSTOM_BOARD_build_mcf52259.mcp”.

Figure 9.4. Go to [MQX INSTALLATION]\lib and generate a new empty folder with the name of the new BSP

as“CUSTOM_BOARD_mcf52259.cw“.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

8 Freescale Semiconductor, Inc.

Page 9: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 10.5. Inside this newly created folder, create three new empty folders: "mqx", "bsp", and "psp".

Figure 11.

2.4 Edit Batch files1. Now go to [MQX INSTALLATION]\mqx\build\bat.2. In this folder, locate, copy and paste the files bsp_twrmcf52259.bat and psp_twrmcf52259.bat. Rename these files to

“CUSTOM_BOARD_bsp_mcf52259.bat”.

Figure 12.3. Open these recently created bat files in a text editor in order to modify them.4. Open the file CUSTOM_BOARD_psp_mcf52259.bat.5. Locate the line that reads: for %%F in (..\..\..\config\twrmcf52259\*.h) do copy /Y /B ..\..\..

\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF6. Change it to: for %%F in (..\..\..\config\CUSTOM_BOARD_mcf52259\*.h) do copy /Y /B ..\..\..

\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF7. Open the file CUSTOM_BOARD_bsp_mcf52259.bat.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 9

Page 10: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

8. In this file the user will need to modify 10 lines. Like in the previous case, change the name of the bsp folder to the newname. The resulting modified lines are:

for %%F in (..\..\..\config\CUSTOM_BOARD_mcf52259\*.h) do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF

for %%F in (..\..\..\CUSTOM_BOARD_config\twrmcf52259\*.h) do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF

copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intram.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intflash.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\extmram.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.cfg .\dbgcopy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.mem .\dbgcopy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp.h .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp_rev.h .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\CUSTOM_BOARD_mcf52259.h .

With these steps the folder is created and project structure of the new BSP is complete. However, the user still needs togo into the cloned BSP and PSP projects and change some target path and linker output settings.

2.5 Edit PSP CodeWarrior Project Settings1. Open the build_libs. Go to [MQX INSTALLATION]\mqx\build\cwcf72.2. Open the project CUSTOM_BOARD_psp_mcf52259.mcp with CodeWarrior v7.2.3. Open the target settings window by pressing ALT+F7.

Figure 13.4. Change the Output directory so that it points to [MQX INSTALLATION ]\lib\CUSTOM_BOARD_mcf52259.cw\mqx.5. In that same window, click on Access Paths and change the path that points to \config\twrmcf52259 to config

\CUSTOM_BOARD_mcf52259.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

10 Freescale Semiconductor, Inc.

Page 11: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 14.6. Now Click on Linker / BatchRunner Post Linker.7. Make sure the modified psp bat file is selected in the “Batch File” menu. Click on “Choose “ to change the file.

Figure 15.8. Make sure that this step is repeated for each of the targets, that is, Debug and Release target.9. Under CodeWarrior, click on Project→ Reset Project entries, then Project→ Re-search for files. This will update the

access paths and will make CodeWarrior to look for the files from the new access path directory.10. To verify that CodeWarrior is indeed pulling the files from the new directory, open user_config.h file by double

clicking on it and verify that the path is the one corresponding to the \config\CUSTOM_BOARD_mcf5259 directory.

Figure 16.11. Perform the same steps for the BSP project at CUSTOM_BOARD_bsp_mcf52259.mcp.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 11

Page 12: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

2.6 Edit BSP CodeWarrior Project Settings1. Go to [MQX INSTALLATION]\mqx\build\cwcf72.2. Open the project CUSTOM_BOARD_bsp_mcf52259.mcp with CodeWarrior v7.2.3. Open the target settings window by pressing ALT+F7.

Figure 17.4. Change the Output directory so that it points to [MQX INSTALLATION]\lib\CUSTOM_BOARD_mcf52259.cw\bsp.5. In that same window, click on Access Paths and change the paths to the CUSTOM_BOARD directories.

Figure 18.6. Now Click on Linker / BatchRunner Post Linker.7. Make sure the modified psp bat file is selected in the “Batch File” menu. Click on “Choose “ to change the file.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

12 Freescale Semiconductor, Inc.

Page 13: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 19.8. Make sure that this step is repeated for each of the targets, Debug and Release target.9. In CodeWarrior, click on Project ->Reset Project entries, then Project -> Re-search for files. This will update the access

paths and will make CodeWarrior go look for the files from the new access path directory.10. To verify that CodeWarrior is indeed pulling the files from the new directory, open user_config.h file by double

clicking on it and verify that the path is the one corresponding to the \config\CUSTOM_BOARD_mcf5259 directory.11. The user will have to modify one line of code, to reference the header file of our new BSP.12. Under CodeWarrior, open the file “bsp.h” in order to edit it. This file can be found under the “twrmcf52259 BSP files”

group. Inside this file, change the line that reads:

#include <twrmcf52259.h>

to

#include <CUSTOM_BOARD_mcf52259.h>

Figure 20.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 13

Page 14: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

2.7 Modify an application to use the new BSP1. Open an application project for the twrmcf52259.2. Open the target settings window by pressing ALT+F7.3. Click on Access Paths and change the paths to the CUSTOM_BOARD directories.

Figure 21.4. Hit OK to save the settings.5. Under CodeWarrior, click on Project ->Reset Project entries, then Project -> Re-search for files. This will update the

access paths and will make CodeWarrior go look for the files from the new access path directory.6. Some files may be duplicated now. Remove the duplicate files that do not have a dot under the target column. This step

is not necessary however.

CodeWarrior v7.2 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

14 Freescale Semiconductor, Inc.

Page 15: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 22.

2.8 Compile the Project1. Compile the project.2. Once compilation is finished, go to [MQX INSTALLATION ]\lib\CUSTOM_BOARD_mcf52259.cw\mqx.3. Verify that inside this folder the set of files listed in the *.bat file has been copied.

3 CodeWarrior 10 BSP CreationThe MQX installation used here is Freescale MQX 3.7. The user will be creating a new MCF52259 BSP here.

3.1 Copy BSP and PSP Projects1. Go to [MQX INSTALLATION]\mqx\build\cw10.2. Copy and Paste the psp_twrmcf52259 and bsp_twrmcf52259 folders into this same folder directory.3. Rename these folders and choose a name relevant to your new board. In this example, these will be called as

CUSTOM_BOARD_bsp_mcf52259 and CUSTOM_BOARD_psp_mcf52259.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 15

Page 16: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 23.

3.2 Copy BSP folder1. Go to [MQX INSTALLATION]\mqx\build\bsp.2. Copy the entire bsp folder of the original bsp, in this case the folder twrmcf52259. Copy the folder and rename it to

CUSTOM_BOARD_mcf52259:

Figure 24.3. Go into the recently created folder, [MQX INSTALLATION]\mqx\source\bsp\CUSTOM_BOARD_mcf52259 and

locate the twrmcf52259.h header file.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

16 Freescale Semiconductor, Inc.

Page 17: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 25.4. Rename it to CUSTOM_BOARD_mcf52259.h

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 17

Page 18: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 26.

3.3 Copy the configuration folder1. Go to [MQX INSTALLATION ]\config folder. Copy the folder called “twrmcf52259”, paste it and rename it to

“CUSTOM_BOARD_mcf52259”.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

18 Freescale Semiconductor, Inc.

Page 19: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 27.2. Go into the recently created folder:

Figure 28.3. In this folder you can see a “CW” folder for every CodeWarrior version that supports this BSP. Erase the folder of the

CodeWarrior versions you are not using. CodeWarrior v10 is used here, so, erase both folders “CWCF71” and“CWCF72”.

4. The above folders contain projects in the classic CodeWarrior interface to build all MQX libraries in a single click.This approach is not the same in CodeWarrior v10, so here, the config folder will basically only be used to store the“user_config.h” file. For this example the user can erase the CWCF71 and CWCF72 folders:

NOTETo re-build all MQX libraries in a single click in CodeWarrior v10, one approachto do that is to create a special workspace exclusively to host all MQX librariesbuild projects. The user can then build them all by selecting the option “Build allprojects in the workspace”.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 19

Page 20: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 29.5. Go to [MQX INSTALLATION ]\lib and generate a new empty folder with the name of the new BSP. Namely,

“CUSTOM_BOARD_mcf52259.cw10 “.

Figure 30.6. Inside this newly created folder, create three new empty folders: "mqx", "bsp" and "psp".

Figure 31.

3.4 Edit Batch files1. Now go to [MQX INSTALLATION]\mqx\build\bat.2. In this folder, locate, copy and paste the files bsp_twrmcf52259.bat and psp_twrmcf52259.bat. Rename these files to

“CUSTOM_BOARD_bsp_mcf52259.bat”.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

20 Freescale Semiconductor, Inc.

Page 21: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 32.3. Open these recently created bat files in a text editor in order to modify them.4. Open the file CUSTOM_BOARD_psp_mcf52259.bat.5. Locate the line that reads: for %%F in (..\..\..\config\twrmcf52259\*.h) do copy /Y /B ..\..\..

\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF6. Change it to: for %%F in (..\..\..\config\CUSTOM_BOARD_mcf52259\*.h) do copy /Y /B ..\..\..

\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF7. Open the file CUSTOM_BOARD_bsp_mcf52259.bat.8. In this file the user will need to modify 10 lines. Like in the previous case, change the name of the bsp folder to the new

name. The resulting modified lines are:

for %%F in (..\..\..\config\CUSTOM_BOARD_mcf52259\*.h) do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF

for %%F in (..\..\..\CUSTOM_BOARD_config\twrmcf52259\*.h) do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF

copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intram.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intflash.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\extmram.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.cfg .\dbgcopy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.mem .\dbgcopy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp.h .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp_rev.h .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\CUSTOM_BOARD_mcf52259.h .

With these steps the folder is created and project structure of the new BSP is complete. However, the user still needs togo into the cloned BSP and PSP projects and change some target path and linker output settings.

3.5 Modify BSP projectNow the next step is to modify the BSP project that was copied earlier, so that all path references in that project point to thenew BSP files.

1. Go to: [MQX INSTALLATION]\mqx\build\cw10\CUSTOM_BOARD_bsp_twrmcf52259.2. Open the *.project file in CodeWarrior v10.1 by dragging it and dropping it in the CodeWarrior 10.1 IDE.3. Once the BSP project is opened, start by cleaning the project from all eventual past object code by clicking on Project

→ Clean.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 21

Page 22: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 33.4. Now, in the CodeWarrior Projects window, go to the twrmcf52259 BSP Files group, expand it, and select all files

within that group. Right click and select “Delete”. This is done so as to replace those files with the files from the newBSP.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

22 Freescale Semiconductor, Inc.

Page 23: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 34.5. Once these files are deleted, select again the twrmcf52259 group, right click and select “Add Files”.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 23

Page 24: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 35.6. Now in the window that opens, browse to the location of the new BSP folder [MQX INSTALLATION]\mqx\source

\bsp\CUSTOM_BOARD_mcf52259.7. Select all files within that folder and click on “Open”.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

24 Freescale Semiconductor, Inc.

Page 25: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 36.8. Another window will pop-up. Select “Create links for each file and directory” and then click “OK”.

Figure 37.9. Repeat the same process to add the files inside the “cw” folder present at [MQX INSTALLATION]\mqx\source\bsp

\CUSTOM_BOARD_mcf52259\cw.10. In this directory, select the files “boot.c” and “cw.c”. Click "OK" and follow the same process.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 25

Page 26: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 38.

3.6 Modify the Config Files1. Now change the files inside the “twrmcf52259 User Config” Folder. In this case, there’s only one file: “user_config.h”.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

26 Freescale Semiconductor, Inc.

Page 27: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

2. Repeat the same steps as before, delete the present “user_config.h” file and replace it by the file present in the newfolder, namely: [MQX INSTALLATION]\config\CUSTOM_BOARD_mcf52259\user_config.

3.7 Modify the Project SettingsNow all files have been changed with the ones from the new BSP. We still need to change the system paths in the projectsettings.

1. In order to do this, go to Project→ Properties. Click on “C/C++ General”→ “Paths and Symbols”.2. Here you will find a window that allows you to modify the paths where assembler files and C/C++ files are searched.

There are three paths that need to be changed.a. Change \mqx\source\bsp\twrmcf52259 to : \mqx\source\bsp\CUSTOM_BOARD_mcf52259.b. Change \mqx\source\bsp\twrmcf52259\cw to : \mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw.c. Change \config\twrmcf52259 to \config\CUSTOM_BOARD_mcf52259.

The user may change these paths by clicking on the “Edit” button.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 27

Page 28: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 39.3. Then go to 'C/C++ Build'->Settings. In the Tool Chain tab, click on ColdFire Compiler->Input.4. Under "User Path" and "User Recursive Path" modify the settings to point to the new BSP by clicking on the edit

button while the path is highlighted.

Figure 40.5. Do the same steps as above under ColdFire Assembler->Input6. In that same window, click now on the left column in C/C++ Build →Settings, then on the tab labeled “Build Steps”.7. Next, we will change the path to the .bat file that we modified earlier.8. Change the text inside the “ Command” field so that it reads : "${ProjDirPath}\..\..\bat

\bsp_CUSTOM_BOARD_mcf52259.bat" "${MQX_PATH}\lib\CUSTOM_BOARD_mcf52259.cw10\mqx".

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

28 Freescale Semiconductor, Inc.

Page 29: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 41.9. Finally modify the output directory on the Build Artifact tab, so that the compiled library is put into the new library

folder.

Figure 42.

3.8 Modify the Header File1. After the project settings are modified, the user will modify one line of code, to refer the header file of the new BSP.2. Under CodeWarrior, open the file “bsp.h” in order to edit it. This file can be found under the “twrmcf52259 BSP files”

group. Inside this file, change the line that reads:

#include <twrmcf52259.h> to #include <CUSTOM_BOARD_mcf52259.h>

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 29

Page 30: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 43.

This concludes the necessary changes to have all paths pointing to the new BSP. At this point, the new BSP should be able tocompile with no mistakes. This concludes the cloning of the BSP project.

3.9 Use the new library in the projectNow that the new BSP library has been created for the customer board, the MQX project needs to know how to use it.

1. Compile the new BSP if you have not done so already.2. Then open up an MQX project in CW10.3. Right click on the project name, and select Properties.4. Go to the C/C++ Build->Settings->ColdFire Linker page, and edit the Link Command File to look in the new BSP

directory.

Figure 44.5. Then modify the Library search path to look for the new BSP directory by clicking on the edit icon.

CodeWarrior 10 BSP Creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

30 Freescale Semiconductor, Inc.

Page 31: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 45.6. Do the same procedure for the ColdFire Compiler and ColdFire Assembler pages.7. Hit “OK” to save changes.8. Then go to the MQX Libraries folder and remove the library files for your target project.

Figure 46.9. Then right click on the MQX libraries folder and select “Add”->Files.

10. Go to [MQX INSTALLATION] \lib\CUSTOM_BOARD_mcf52259.cw10\bsp.11. Select bsp_twrmcf52259_d.a file and hit Open.12. Select “Create links for each files and directories” in the pop-up dialog box.

Figure 47.13. Now compile the project, and it will use the new BSP.

NOTEThe rest of the libraries will use the twrmcf52259 settings. If you wish to use the entirenew BSP, repeat the above steps with each MQX library.

4 IAR BSP creationThe MQX installation used here is Freescale MQX 3.7. The user will be creating a new K60N512 BSP here.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 31

Page 32: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

4.1 Copy BSP and PSP Projects1. Go to [MQX INSTALLATION]\mqx\build\iar\.2. Select the .ewp files of the BSP and PSP original projects.

See the files circled in red below:

Figure 48.3. Copy and Paste these files into this same folder directory rename these files with a name relevant to your new board. In

this example we choose to call them CUSTOM_BOARD_bsp_twrk60n512 andCUSTOM_BOARD_psp_twrk60n512A.

Figure 49.

4.2 Copy BSP Folder1. Go to [MQX INSTALLATION ]\mqx\source\bsp.2. Copy the entire bsp folder for the original board. In this case, it is twrk60n512 folder.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

32 Freescale Semiconductor, Inc.

Page 33: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 50.3. Paste the folder in the same directory, and name it CUSTOM_BOARD_twrk60n512.

Figure 51.4. Go into the newly created folder, [MQX INSTALLATION]\mqx\source\bsp\CUSTOM_BOARD_twrk60n512 and

locate the twrk60n512.h header file.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 33

Page 34: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 52.5. Rename it to CUSTOM_BOARD_twrk60n512.h

Figure 53.

4.3 Copy configuration folder1. Go to [MQX INSTALLATION]\config folder. Copy the folder called “twrk60n512”, paste it and rename it to

“CUSTOM_BOARD_ twrk60n512”.

Figure 54.2. Go inside the new folder you just created, and go into the IAR folder. Then open the build_libs.eww file in a text

editor, and change the lines for the BSP and PSP project names to match the new BSP name.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

34 Freescale Semiconductor, Inc.

Page 35: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 55.3. Save the file.

4.4 Edit Batch files1. Go to [MQX INSTALLATION]\mqx\build\bat.2. In this folder, locate, copy and paste the files bsp_twrk60n512.bat and psp_twrk60n512.bat. Rename these files to

“CUSTOM_BOARD_bsp_ twrk60n512.bat” and “CUSTOM_BOARD_psp_ twrk60n512.bat”, respectively.

Figure 56.3. Open the file CUSTOM_BOARD_bsp_twrk60n512.bat in a text editor.4. In this file you will need to modify 7 lines. The modification consists of changing the name of the twrk60n512 bsp

folder to the new name.5. The resulting modified lines are:

for

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 35

Page 36: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

%%F in (..\..\..\config\CUSTOM_BOARD_twrk60n512\*.h) do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF

copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\intram.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\intflash.lcf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\dbg\twrk60n512.mem .\dbgcopy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\dbg\init_kinetis.tcl .\dbg

copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\iar\ram.icf .copy /Y ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\iar\intflash.icf

6. Open the file CUSTOM_BOARD_psp_ twrk60n512.bat in a text editor.7. Locate the line that reads: for %%F in (..\..\..\config\twrk60n512\*.h) do copy /Y /B

and change it to for %%F in (..\..\..\config\CUSTOM_BOARD_twrk60n512\*.h) do copy /Y /B

Figure 57.8. The above steps completes creating the folder and project structure of the new BSP. The user still needs to go into the

cloned projects, and change some target path and linker output settings.

4.5 Edit IAR Project settingsThe next few sections will configure the MQX library projects for IAR to point to the new BSP. The user will need to do thesteps for both the Debug and Release versions of the library to fully port the BSP. The user may only do the Debug projects ifso desired however.

1. Open the build_libs.eww workspace in the new config directory [MQX INSTALLATION]\config\CUSTOM_BOARD_twrk60n512\iar\build_libs.eww.

2. Right click on the BSP project and select Options.3. Go to the General Options category, and select the Output tab. Modify the Executables/libraries dialog box to point to

our new customer board folder:

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

36 Freescale Semiconductor, Inc.

Page 37: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 58.4. Go to the C/C++ Compiler category and select the Preprocessor tab. Change the lines that originally pointed to the

twrk60n512 folders to the CUSTOM_BOARD_twrk60n512 folders.

Figure 59.5. Do the same thing on the Assembler->Preprocessor tab.6. In the Build Actions category, change the Post-build command line to point to the custom BSP: "$PROJ_DIR$\..\bat

\CUSTOM_BOARD_bsp_twrk60n512.bat" "$PROJ_DIR$\..\..\..\lib\CUSTOM_BOARD_twrk60n512.iar\bsp\CUSTOM_BOARD_bsp_twrk60n512_d.a" IAR.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 37

Page 38: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 60.7. Finally on the Library Builder page, modify the output file to use the new custom BSP's. The line should be:

$PROJ_DIR$\..\..\..\lib\CUSTOM_BOARD_twrk60n512.iar\bsp\CUSTOM_BOARD_bsp_twrk60n512_d.a8. Perform the same steps as with the PSP project. Note that there is only one line to modify in the C/C++ Compiler and

Assembler library paths for the PSP library.

Figure 61.9. Hit “OK” to save the changes.

4.6 Add BSP and PSP files1. Now modify the files inside the BSP and PSP projects.2. Inside the BSP project, remove all the files under the folder twrk60n512 BSP files:

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

38 Freescale Semiconductor, Inc.

Page 39: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 62.3. Then right click on the folder name and go to Add->Add Files.

Figure 63.4. Add all the files in the BSP folder at [MQX INSTALLATION]\mqx\source\bsp\CUSTOM_BOARD_twrk60n512.5. Also add the kernel_data.s file in the [MQX INSTALLATION] \mqx\source\bsp\CUSTOM_BOARD_twrk60n512\iar

directory.6. Open the file bsp.h, which can be found under the “twrk60n512 BSP Files” folder in the project, and replace

#include<twrk60n512.h;

with #include<CUSTOM_BOARD_twrk60n512.h;

7. Then remove user_config.h file under the twrk60n612 User Config folder.8. Replace it with the user_config.h file found at [MQX INSTALLAITON]\config

\CUSTOM_BOARD_twrk60n512\user_config.h9. Finally compile the BSP and PSP libraries, and verify the compiled libraries and header files are at [MQX

INSTALLATION]\lib\CUSTOM_BOARD_twrk60n512 and [MQX INSTALLATION]\lib\CUSTOM_BOARD_twrk60n512\psp.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 39

Page 40: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

4.7 Modify the other librariesUsing the steps as above, the user can also create custom versions of each of the other MQX libraries, so that the USB librarycan be edited for the board without affecting the default demo board. However, since the BSP is the key library that changesbetween different boards, this is not necessary.

4.8 Use the new library in the projectNow that the new BSP library has been created for the customer board, the MQX project needs to know how to use it.

1. Compile the new BSP, if you have not done so already.2. Then open up an MQX project like the K60 Quick Start Demo, which will be used in this example.3. Right click on the project name, and select Options.4. Go to the C/C++ Compiler setting and then the Preprocessor tab, and change the first four lines to point to the new BSP

directory.

Figure 64.5. Do the same procedure in the Assembler category on the Preprocessor tab.6. Hit “OK” to save changes.7. Then go to the MQX Libraries folder and remove the library files for your target project. By default, that would be the

Debug project, so remove the bsp_twrk60n512_d.a file and psp_twrk60n512_d.a files.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

40 Freescale Semiconductor, Inc.

Page 41: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

Figure 65.8. Then right click on the MQX libraries folder and select “Add”->Files.9. Go to [MQX INSTALLATION] \lib\CUSTOM_BOARD_twrk60n512.iar\bsp.

10. Under “Files of type:” select “All Files (*.*)” .

Figure 66.11. Select CUSTOM_BOARD_bsp_twrk60n512_d.a file and click Open.12. Then go to the [MQX INSTALLATION]\lib\CUSTOM_BOARD_twrk60n512\psp folder to add the

CUSTOM_BOARD_psp_twrk60n512_d.a file.

IAR BSP creation

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

Freescale Semiconductor, Inc. 41

Page 42: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

13. Now compile the project, and it will use the new BSP.

5 ConclusionCreating a new Board Support Package for your customized board is a common and useful activity. This application noteguides you through the process of creating a new BSP and using it for CodeWarrior 10, CodeWarrior v7.2, and IAR. Thetechniques given in this document can apply to any other MQX board support package, and will give you a betterunderstanding of the role that MQX libraries play when developing your application. For the latest MQX version anddocumentation, refer to: https://www.freescale.com/mqx.

Conclusion

MQX Board Support Package Porting Guide, Rev. 0, 06/2011

42 Freescale Semiconductor, Inc.

Page 43: AN4287, MQX Board Support Package Porting Guide - …cache.freescale.com/files/32bit/doc/app_note/AN4287.pdf · This application note is intended to be a complement to the MQX User’s

How to Reach Us:

Home Page:www.freescale.com

Web Support:http://www.freescale.com/support

USA/Europe or Locations Not Listed:Freescale SemiconductorTechnical Information Center, EL5162100 East Elliot RoadTempe, Arizona 85284+1-800-521-6274 or +1-480-768-2130www.freescale.com/support

Europe, Middle East, and Africa:Freescale Halbleiter Deutschland GmbHTechnical Information CenterSchatzbogen 781829 Muenchen, Germany+44 1296 380 456 (English)+46 8 52200080 (English)+49 89 92103 559 (German)+33 1 69 35 48 48 (French)www.freescale.com/support

Japan:Freescale Semiconductor Japan Ltd.HeadquartersARCO Tower 15F1-8-1, Shimo-Meguro, Meguro-ku,Tokyo 153-0064Japan0120 191014 or +81 3 5437 [email protected]

Asia/Pacific:Freescale Semiconductor China Ltd.Exchange Building 23FNo. 118 Jianguo RoadChaoyang DistrictBeijing 100022China+86 10 5879 [email protected]

For Literature Requests Only:Freescale Semiconductor Literature Distribution Center1-800-441-2447 or +1-303-675-2140Fax: [email protected]

Document Number: AN4287Rev. 0, 06/2011

Information in this document is provided solely to enable system and softwareimplementers to use Freescale Semiconductors products. There are no express or impliedcopyright licenses granted hereunder to design or fabricate any integrated circuits orintegrated circuits based on the information in this document.

Freescale Semiconductor reserves the right to make changes without further notice to anyproducts herein. Freescale Semiconductor makes no warranty, representation, orguarantee regarding the suitability of its products for any particular purpose, nor doesFreescale Semiconductor assume any liability arising out of the application or use of anyproduct or circuit, and specifically disclaims any liability, including without limitationconsequential or incidental damages. "Typical" parameters that may be provided inFreescale Semiconductor data sheets and/or specifications can and do vary in differentapplications and actual performance may vary over time. All operating parameters,including "Typicals", must be validated for each customer application by customer'stechnical experts. Freescale Semiconductor does not convey any license under its patentrights nor the rights of others. Freescale Semiconductor products are not designed,intended, or authorized for use as components in systems intended for surgical implantinto the body, or other applications intended to support or sustain life, or for any otherapplication in which failure of the Freescale Semiconductor product could create asituation where personal injury or death may occur. Should Buyer purchase or useFreescale Semiconductor products for any such unintended or unauthorized application,Buyer shall indemnify Freescale Semiconductor and its officers, employees, subsidiaries,affiliates, and distributors harmless against all claims, costs, damages, and expenses, andreasonable attorney fees arising out of, directly or indirectly, any claim of personal injuryor death associated with such unintended or unauthorized use, even if such claims allegesthat Freescale Semiconductor was negligent regarding the design or manufacture ofthe part.

RoHS-compliant and/or Pb-free versions of Freescale products have the functionality andelectrical characteristics as their non-RoHS-complaint and/or non-Pb-free counterparts.For further information, see http://www.freescale.com or contact your Freescalesales representative.

For information on Freescale's Environmental Products program, go tohttp://www.freescale.com/epp.

Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.All other product or service names are the property of their respective owners.

© 2011 Freescale Semiconductor, Inc.