Creating MQX 4.0 BSP for K10

Document created by Martin Latal Employee on Mar 14, 2013Last modified by Monica Arvizu on Mar 14, 2013
Version 1Show Document
  • View in full screen mode

Sharing notes taken during creation of MQX 4.0 K10 BSP.

 

These particular notes are for 72 MHz version of K10 (part number K10DX128VLL7), so the baseline BSP for this is twrk20d72m, tested with CodeWarrior IDE. (I believe analogous steps could be taken for other K10 versions as well, just need to select appropriate baseline BSP.)

 

For the K10 BSP, we need to remove USB related code (as there is no USB module on K10) and add #elif into some *mk20.c files such as adc_mk20.c and spi_mk20.c.

 

     1. Add a new unique CPU ID into c:\Freescale\Freescale_MQX_4_0\mqx\source\psp\cortex_m\psp_cpudef.h. For example:

 

#define PSP_CPU_MK10DX128       (PSP_CPU_NUM(PSP_CPU_ARCH_ARM_CORTEX_M4, PSP_CPU_GROUP_KINETIS_K1X, 4))

 

     2. Copy processor header file MK10D7.h from c:\Freescale\CW MCU v10.3\MCU\ProcessorExpert\lib\Kinetis\iofiles\MK10D7.h to c:\Freescale\Freescale_MQX_4_0\mqx\source\psp\cortex_m\cpu\mk10d7.h

 

     3. In the header file: c:\Freescale\Freescale_MQX_4_0\mqx\source\psp\cortex_m\kinetis.h add #include "MK10D7.h" for your processor. For example:

 

#elif   (MQX_CPU == PSP_CPU_MK10DX128)
   #include "MK10D7.h"

 

     4. Use BSP clone tool to clone baseline BSP (twrk20d72m) into a new BSP with a new name such as "board_k10d72m".

 

     5. In user_config.h of the new BSP, c:\Freescale\Freescale_MQX_4_0\config\board_k10d72m\user_config.h change MQX_CPU as it follows:

 

#define MQX_CPU                 PSP_CPU_MK10DX128

 

     6. PSP builds OK. From BSP, we need to remove USB related code in init_gpio.c comment lines 609 and 612 c:\Freescale\Freescale_MQX_4_0\mqx\source\bsp\board_k10d72m\init_gpio.c:

 

/* SIM_SOPT2_REG(SIM_BASE_PTR) |= SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK;*/
/* SIM_SCGC4_REG(SIM_BASE_PTR) |= SIM_SCGC4_USBOTG_MASK;*/

 

     7. In CW IDE, remove USB source code from "bsp_board_k10d72m" build project under "Peripheral IO Drivers".

Remove complete "usb" virtual folder from the BSP build project. Remove "init_usb.c" from "board_k10d72m BSP Files"

 

     8. In BSP source file "spi_mk20.c" c:\Freescale\Freescale_MQX_4_0\mqx\source\io\spi\spi_mk20.c add #elif for k10:

 

#elif (MQX_CPU == PSP_CPU_MK10DX128)
static const pointer dspi_address[] =
{
   (pointer)SPI0_BASE_PTR,
   (pointer)SPI1_BASE_PTR,
};

 

static const uint_32 /*PSP_INTERRUPT_TABLE_INDEX*/ dspi_vectors[][1] =
{
   { INT_SPI0 },
   { INT_SPI1 },
}

 

     9. Similar change need to adc_mk20.c c:\Freescale\Freescale_MQX_4_0\mqx\source\io\adc\kadc\adc_mk20.c:

 

#elif (MQX_CPU == PSP_CPU_MK10DX128)
static const pointer adc_address[] = {
   (pointer)ADC0_BASE_PTR,
   (pointer)ADC1_BASE_PTR
};

 

     10. BSP project builds OK.

 

     11. MFS, RTCS, SHELL projects build OK.

 

     12. If you wish to build an MQX application with this new BSP, don't forget to change the paths to MQX libs and include files in your application project:

 

C compiler "-i" option:

  (for Debug build configuration)

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\psp

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\mfs

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\rtcs

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\shell

    $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp\Generated_Code

 

Linker additional libraries:

  psp.a, bsp.a, mfs.a, rtcs.a, shell.a

 

Linker Library search paths:

  $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp

  $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\psp

  $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\mfs

  $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\rtcs

  $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\shell

 

Path to linker command file:

  $(MQX_ROOT_DIR)\lib\board_k10d72m.cw10\debug\bsp\intflash.lcf

Attachments

    Outcomes