AN4287, MQX Board Support Package Porting Guide - Freescale ...

86 downloads 407 Views 1MB Size Report
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 ...
Freescale Semiconductor Application Note

Document Number: AN4287 Rev. 0, 06/2011

MQX Board Support Package Porting Guide by:

Anthony Huereca, Christian Michel-Sendis Microcontroller Solutions Group

Contents

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. © 2011 Freescale Semiconductor, Inc.

1

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

2

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

3

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

4

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

5

Conclusion......................................................................42

CodeWarrior v7.2 BSP Creation

This application note is intended to be a complement to the MQX User’s guide, by expanding on chapters 4 and 5 and providing 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 for other processors or other boards. NOTE In MQX 3.7, the BSP and PSP library files have been split into two separate folders. This application note describes the steps to create a new BSP with MQX 3.7. However the same steps will be used with earlier versions of MQX with a small difference that the BSP and PSP library folders are all in the [MQX INSTALLATION]\lib\mqx directory. In MQX 3.7 and later, the libraries are split between the [MQX INSTALLATION]\lib\bsp and [MQX INSTALLATION]\lib\psp directories.

2 CodeWarrior v7.2 BSP Creation The 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 Projects 1. 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.

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

Freescale Semiconductor, Inc.

CodeWarrior v7.2 BSP Creation

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.

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

3

CodeWarrior v7.2 BSP Creation

Figure 2.

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

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

Freescale Semiconductor, Inc.

CodeWarrior v7.2 BSP Creation

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.

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

5

CodeWarrior v7.2 BSP Creation

Figure 5. 5. Rename it to CUSTOM_BOARD_mcf52259.h

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

Freescale Semiconductor, Inc.

CodeWarrior v7.2 BSP Creation

Figure 6.

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

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

7

CodeWarrior v7.2 BSP Creation

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“. MQX Board Support Package Porting Guide, Rev. 0, 06/2011 8

Freescale Semiconductor, Inc.

CodeWarrior v7.2 BSP Creation

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

Figure 11.

2.4 Edit Batch files 1. 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%%~xF

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

7. Open the file CUSTOM_BOARD_bsp_mcf52259.bat.

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

9

CodeWarrior v7.2 BSP Creation

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) \source\include\dontchg.h + %%F ..\%%~nF%%~xF

do copy /Y /B ..\..\..\mqx

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

/Y /Y /Y /Y /Y /Y /Y /Y

do copy /Y /B ..\..\..\mqx

..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intram.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intflash.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\extmram.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.cfg .\dbg ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.mem .\dbg ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp.h . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp_rev.h . ..\..\..\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 to go into the cloned BSP and PSP projects and change some target path and linker output settings.

2.5 Edit PSP CodeWarrior Project Settings 1. 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.

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

Freescale Semiconductor, Inc.

CodeWarrior v7.2 BSP Creation

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.

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

11

CodeWarrior v7.2 BSP Creation

2.6 Edit BSP CodeWarrior Project Settings 1. 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. MQX Board Support Package Porting Guide, Rev. 0, 06/2011 12

Freescale Semiconductor, Inc.

CodeWarrior v7.2 BSP Creation

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

to #include

Figure 20. MQX Board Support Package Porting Guide, Rev. 0, 06/2011 Freescale Semiconductor, Inc.

13

CodeWarrior v7.2 BSP Creation

2.7 Modify an application to use the new BSP 1. 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.

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

Figure 22.

2.8 Compile the Project 1. 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 Creation The 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 Projects 1. 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.

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

15

CodeWarrior 10 BSP Creation

Figure 23.

3.2 Copy BSP folder 1. 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.

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

Figure 25. 4. Rename it to CUSTOM_BOARD_mcf52259.h

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

17

CodeWarrior 10 BSP Creation

Figure 26.

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

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

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: NOTE To re-build all MQX libraries in a single click in CodeWarrior v10, one approach to do that is to create a special workspace exclusively to host all MQX libraries build projects. The user can then build them all by selecting the option “Build all projects in the workspace”.

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

19

CodeWarrior 10 BSP Creation

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 files 1. 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”.

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

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%%~xF

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

7. 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) \source\include\dontchg.h + %%F ..\%%~nF%%~xF

do copy /Y /B ..\..\..\mqx

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

/Y /Y /Y /Y /Y /Y /Y /Y

do copy /Y /B ..\..\..\mqx

..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intram.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\intflash.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\extmram.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.cfg .\dbg ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\cw\dbg\twrmcf52259.mem .\dbg ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp.h . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_mcf52259\bsp_rev.h . ..\..\..\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 to go into the cloned BSP and PSP projects and change some target path and linker output settings.

3.5 Modify BSP project Now the next step is to modify the BSP project that was copied earlier, so that all path references in that project point to the new 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.

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

21

CodeWarrior 10 BSP Creation

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 new BSP.

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

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

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

23

CodeWarrior 10 BSP Creation

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”.

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

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.

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

25

CodeWarrior 10 BSP Creation

Figure 38.

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

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

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

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

3.7 Modify the Project Settings Now all files have been changed with the ones from the new BSP. We still need to change the system paths in the project settings. 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.

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

27

CodeWarrior 10 BSP Creation

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. 6. 7. 8.

Do the same steps as above under ColdFire Assembler->Input In that same window, click now on the left column in C/C++ Build →Settings, then on the tab labeled “Build Steps”. Next, we will change the path to the .bat file that we modified earlier. 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". MQX Board Support Package Porting Guide, Rev. 0, 06/2011

28

Freescale Semiconductor, Inc.

CodeWarrior 10 BSP Creation

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 File 1. 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 to #include

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

29

CodeWarrior 10 BSP Creation

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 to compile with no mistakes. This concludes the cloning of the BSP project.

3.9 Use the new library in the project Now 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.

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

Freescale Semiconductor, Inc.

IAR BSP creation

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. 10. 11. 12.

Then right click on the MQX libraries folder and select “Add”->Files. Go to [MQX INSTALLATION] \lib\CUSTOM_BOARD_mcf52259.cw10\bsp. Select bsp_twrmcf52259_d.a file and hit Open. 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. NOTE The rest of the libraries will use the twrmcf52259 settings. If you wish to use the entire new BSP, repeat the above steps with each MQX library.

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

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

31

IAR BSP creation

4.1 Copy BSP and PSP Projects 1. 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 and CUSTOM_BOARD_psp_twrk60n512A.

Figure 49.

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

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

Freescale Semiconductor, Inc.

IAR BSP creation

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.

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

33

IAR BSP creation

Figure 52. 5. Rename it to CUSTOM_BOARD_twrk60n512.h

Figure 53.

4.3 Copy configuration folder 1. 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.

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

Freescale Semiconductor, Inc.

IAR BSP creation

Figure 55. 3. Save the file.

4.4 Edit Batch files 1. 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 MQX Board Support Package Porting Guide, Rev. 0, 06/2011 Freescale Semiconductor, Inc.

35

IAR BSP creation %%F in (..\..\..\config\CUSTOM_BOARD_twrk60n512\*.h) \include\dontchg.h + %%F ..\%%~nF%%~xF copy copy copy copy

/Y /Y /Y /Y

do copy /Y /B ..\..\..\mqx\source

..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\intram.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\intflash.lcf . ..\..\..\mqx\source\bsp\CUSTOM_BOARD_twrk60n512\cw\dbg\twrk60n512.mem .\dbg ..\..\..\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 settings The next few sections will configure the MQX library projects for IAR to point to the new BSP. The user will need to do the steps for both the Debug and Release versions of the library to fully port the BSP. The user may only do the Debug projects if so 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:

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

Freescale Semiconductor, Inc.

IAR BSP creation

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.

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

37

IAR BSP creation

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.a 8. 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 files 1. 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:

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

Freescale Semiconductor, Inc.

IAR BSP creation

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

Suggest Documents