KW2xD SMAC projects available for KDS?

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

KW2xD SMAC projects available for KDS?

Jump to solution
2,953 Views
calebrust
Contributor III

I'm looking for KDS wireless connectivity projects (specifically ZigBee) to get started with a KW2x chip, but they are all built for IAR.  It seems that there are options to port code from CodeWarrior into KDS, and I can export code from KDS into IAR, but I haven't found a clear path to import IAR projects into KDS.

This Nov 25th post suggests that the connectivity projects will eventually be supported in KDS, so I'm curious about that status?

Re: Beekit for KDS

If anyone knows how to convert or import an IAR project into KDS, that's also an option.  I need some kind of starting point, and I have a usbkw24d512 board, so I was hoping to use the 'Connectivity_Test', located in: Freescale\KW2xD_SMAC\app\ieee_802_15_4\Connectivity_Test\usbkw24d512\build\iar\

Labels (1)
1 Solution
2,044 Views
calebrust
Contributor III

[Update 2]  I got the ieee_802_15_4 Connectivity_Test for the usbkw24d512 to build and run in KDS!! The project is located in:
C:\Freescale\KW2xD_SMAC\app\ieee_802_15_4\Connectivity_Test\usbkw24d512

The steps to build it were lengthy, sorry for the long post.  I basically just started a fresh c project in KDS, and included things as needed to get it all to build.  Most of the post is project settings, but there are a few minor code changes to get it to build/run.  Just to reiterate, I had to do this because the SMAC example projects were all in IAR, and I wanted to use KDS instead.

This process will likely be obsolete when NXP/Freescale releases their SDK v2.0 code for KW2x (expected May, 2016)Introducing Kinetis SDK v2 

---START---

Prerequisites:

Install KDS 3.0.0

Install ARM gcc compiler

Install KSDK v1.2.0

Install KW2xD_SMAC

Jlink(or other debugger) drivers

Project Files & Folders

Start a new C project...

Name it.

Select Empty project

Select Cross ARM GCC

Accept defaults for the rest

Finish.

Copy these folders into your recently created project folder (they’re surprisingly big=199MB)

C:\Freescale\KW2xD_SMAC\app

C:\Freescale\KW2xD_SMAC\boards

C:\Freescale\KW2xD_SMAC\drv

C:\Freescale\KW2xD_SMAC\framework

C:\Freescale\KW2xD_SMAC\ieee_802_15_4

Delete stuff you don’t need out of your project folder.  This might be optional, depending on how mad Eclipse gets.  I deleted everything listed.

\app\ieee_802_15_4\Connectivity_Test\frdmkw24

\app\ieee_802_15_4\Connectivity_Test\twrkw21d256

\app\ieee_802_15_4\Connectivity_Test\twrkw24d512

\app\ieee_802_15_4\Connectivity_Test\usbkw24d512\build\iar

\app\ieee_802_15_4\Low_Power_Demo

\app\ieee_802_15_4\Wireless_Messenger

\app\ieee_802_15_4\Wireless_Uart

\boards\frdmkw24

\boards\twrkw21d256

\boards\twrkw24d512

\framework\LPM

\framework\OSAbstraction\Source\fsl_osa_ext_bm.c

\framework\OSAbstraction\Source\fsl_osa_ext_mqx.c

Refresh the project tree (F5)

Right-click project, select New -> Folder.

Name the folder ‘RTOS’

Add a sub-folder, call it ‘FreeRTOS’

Add another sub-folder, call it ‘Startup’

Import the .c, and .S file(s) from the folders below into the ‘FreeRTOS’ folder

C:\Freescale\KSDK_1.2.0\rtos\FreeRTOS\src\(all)

C:\Freescale\KSDK_1.2.0\rtos\FreeRTOS\port\gcc\(all)

Import the .c, and .S file(s) from the folders below into the ‘Startup’ folder

C:\Freescale\KSDK_1.2.0\platform\devices\startup.c

C:\Freescale\KSDK_1.2.0\platform\devices\MKW24D5\startup\system_MKW24D5.c

C:\Freescale\KSDK_1.2.0\platform\devices\MKW24D5\startup\gcc\startup_MKW24D5.S

Refresh the project tree (F5)

In the end, the structure should look like this:

KDS_Connectivity_Test_DirStructure.png

Project Properties

Open the project properties (Alt+Enter)

Properties -> C/C++ Build -> Behavior -> Build settings

Un-check "Stop on first build error"

Properties -> C/C++ Build -> Environment -> Environment variables to set

Add...

Name: PROJECT_LOC

Value: <your project location> e.g. C:\Users\crust\workspace.kds\Connectivity_Test_usbkw24

Properties -> C/C++ Build -> Settings -> Tool Settings:

Target Processor -> ARM family

cortex-m4

Target Processor -> Float ABI

Library (soft)

Warnings

Check "Enable all common warnings (-Wall)

Cross ARM GNU Assembler -> Preprocessor -> Defined symbols (-D)

Add...

DEBUG

Cross ARM GNU Assembler -> Includes -> Include paths (-I)

Add...

${KSDK_PATH}\rtos\FreeRTOS\config\KW24D5\gcc

Cross ARM C Compiler -> Preprocessor -> Defined symbols (-D)

Add… (or just paste the whole list all at once)

_DEBUG=1

CPU_MKW24D512VHA5

USB_KW24D512

CLOCK_SETUP=4

FSL_RTOS_FREE_RTOS

gSerialMgrUseUSB_c=1

gSerialMgrUseUart_c=1

gFsciIncluded_c=0

gSmacSupported=1

"PoolsDetails_c=_block_size_ 64 _number_of_blocks_ 10 _eol_ _block_size_ 128 _number_of_blocks_ 2 _eol_ _block_size_ 256 _number_of_blocks_ 10 _eol_"

gKBD_KeysCount_c=1

gLEDsOnTargetBoardCnt_c=2

gEepromType_d=gEepromDevice_InternalFlash_c

Cross ARM C Compiler -> Includes -> Include paths (-I)

Add… (paste)

${PROJECT_LOC}\app\ieee_802_15_4\Connectivity_Test\common

${PROJECT_LOC}\boards\usbkw24d512

${PROJECT_LOC}\drv\Portable\LED\Interface

${PROJECT_LOC}\drv\Portable\Keyboard\Interface

${PROJECT_LOC}\drv\Portable\GPIO_IrqAdapter

${PROJECT_LOC}\drv\Portable\TMR_Adapter\

${PROJECT_LOC}\drv\Portable\SPI_Adapter\

${PROJECT_LOC}\drv\Portable\USB_VirtualCom\

${PROJECT_LOC}\framework\Common

${PROJECT_LOC}\framework\OSAbstraction\Interface

${PROJECT_LOC}\framework\Utils\Lists

${PROJECT_LOC}\framework\Utils\FunctionLib

${PROJECT_LOC}\framework\Utils\SecLib

${PROJECT_LOC}\framework\Utils\ModuleInfo

${PROJECT_LOC}\framework\RNG\Interface

${PROJECT_LOC}\framework\Panic\Interface

${PROJECT_LOC}\framework\SerialManager\Interface

${PROJECT_LOC}\framework\MemManager\Interface

${PROJECT_LOC}\framework\TimersManager\Interface

${PROJECT_LOC}\framework\TimersManager\Source

${PROJECT_LOC}\framework\Messaging\Interface

${PROJECT_LOC}\ieee_802_15_4\Source\Phy\Interface

${PROJECT_LOC}\ieee_802_15_4\Source\Phy\Source\MCR20A\MCR20Drv

${PROJECT_LOC}\ieee_802_15_4\Source\Phy\Source\XcvrSPI

${PROJECT_LOC}\ieee_802_15_4\Source\SMAC\Interface

${PROJECT_LOC}\ieee_802_15_4\Source\SMAC\Generic

${PROJECT_LOC}\ieee_802_15_4\Source\SMAC\Source

${PROJECT_LOC}\app\ieee_802_15_4\Connectivity_Test\usbkw24d512\Source

${KSDK_PATH}\platform\CMSIS\Include

${KSDK_PATH}\platform\devices\

${KSDK_PATH}\platform\devices\MKW24D5\include

${KSDK_PATH}\platform\devices\MKW24D5\startup

${KSDK_PATH}\platform\osa\inc

${KSDK_PATH}\platform\drivers\src\flash\C90TFS\drvsrc\include

${KSDK_PATH}\platform\drivers\inc

${KSDK_PATH}\platform\drivers\src\mmcau\asm-cm4

${KSDK_PATH}\platform\hal\inc

${KSDK_PATH}\platform\system\inc

${KSDK_PATH}\platform\system\src\clock\MKW24D5

${KSDK_PATH}\platform\utilities\inc

${KSDK_PATH}\rtos\FreeRTOS\port\gcc

${KSDK_PATH}\rtos\FreeRTOS\config\KW24D5\gcc

${KSDK_PATH}\rtos\FreeRTOS\include

${KSDK_PATH}\rtos\FreeRTOS\src

${KSDK_PATH}\usb\adapter\sources

${KSDK_PATH}\usb\adapter\sources\sdk

${KSDK_PATH}\usb\usb_core\include

${KSDK_PATH}\usb\usb_core\device\include

${KSDK_PATH}\usb\usb_core\device\include\usbkw24d512

${KSDK_PATH}\usb\usb_core\device\sources\classes\include

${KSDK_PATH}\usb\usb_core\device\sources\classes\include\config

${KSDK_PATH}\usb\usb_core\device\sources\classes\cdc

Cross ARM C Compiler -> Optimization -> Language standard

GNU ISO C99

Cross ARM C Linker -> General -> Script files (-T)

Add...

“${KSDK_PATH}\platform\devices\MKW24D5\linker\gcc\MKW24D512xxx5_flash.ld”

Cross ARM C Linker -> General

Un-Check "Remove unused sections (-Xlinker --gc-sections)"  [at least until you know it’s building okay]

Cross ARM C Linker -> Libraries -> Libraries (-I)

Add...

m

g

gcc

nosys

Cross ARM C Linker -> Libraries -> Library search path (-L)

Add...

“${KSDK_PATH}\platform\devices\MKW24D5\linker\gcc”

Cross ARM C Linker -> Miscellaneous -> Other Objects

${KSDK_PATH}\usb\usb_core\device\build\kds\usbd_sdk_usbkw24d512_freertos\debug\libusbd_freertos.a

${KSDK_PATH}\lib\ksdk_freertos_lib\kds\KW24D5\debug\libksdk_platform_freertos.a

${KSDK_PATH}\platform\drivers\src\mmcau\asm-cm4\lib_mmcau.a

Cross ARM C Linker -> Miscellaneous -> Other linker flags

-Xlinker --defsym=__ram_vector_table__=1  --specs=nano.specs  -Xlinker --defsym=__heap_size__=0x2C00

Click Apply

Click OK

Comment Stuff Out

I couldn’t get it to build without any changes, but there are only 2 offending code segments that seem to be unused, so I commented them out.

comment-out the AES_128_CCM function, located in:

\framework\Utils\SecLib\SecLib.c

/*

uint8_t AES_128_CCM(uint8_t* pInput,

                    uint32_t inputLen,

                    uint8_t* pAuthData,

                    uint32_t authDataLen,

                    uint8_t* pInitVector,

                    uint8_t* pCounter,

                    uint8_t* pKey,

                    uint8_t* pOutput,

                    uint8_t* pCbcMac,

                    uint8_t flags)

{

#if FSL_FEATURE_SOC_LTC_COUNT

        return LTC_AES128_CCM(pInput, inputLen, pAuthData, authDataLen, pInitVector, pCounter, pKey, pOutput, pCbcMac, flags);

#else

        return sw_AES128_CCM(pInput, inputLen, pAuthData, authDataLen, pInitVector, pCounter, pKey, pOutput, pCbcMac, flags);

#endif

}*/ //Commented per KDS build instead of IAR

...as far as I can tell this function isn’t used, and I don’t know where to find the w_AES128_CCM() function.

comment-out vPortEndScheduler(), located in

\RTOS\FreeRTOS\tasks.c

It’s inside the vTaskEndScheduler(void) function:

void vTaskEndScheduler( void )

{

        /* Stop the scheduler interrupts and call the portable scheduler end

        routine so the original ISRs can be restored if necessary.  The port

        layer must ensure interrupts enable     bit is left in the correct state. */

        portDISABLE_INTERRUPTS();

        xSchedulerRunning = pdFALSE;

        //vPortEndScheduler(); //Commented per KDS build instead of IAR

}

...Things shouldn’t really call the vTaskEndScheduler function...right?  I think it would stop the RTOS, so we don’t really need this.

Importing Dependency Projects

Import ksdk_freertos_lib_KW24D5 project

C:\Freescale\KSDK_1.2.0\lib\ksdk_freertos_lib\kds\KW24D5

Import usbd_sdk_usbkw24d512_freertos project

C:\Freescale\KSDK_1.2.0\usb\usb_core\device\build\kds\usbd_sdk_usbkw24d512_freertos

Build both projects.

Build the Connectivity_Test project

Finally ready to actually build the Connectivity_Test project in KDS. Yay!

Click Build.

With print size enabled.png

When you build (if it works), the size will be 143k

If you go back to Cross ARM C Linker -> General

And check the box to remove unused sections (-Xlinker --gc-sections), the code is smaller (93k).

With print size enabled2.png

When this project is compiled in IAR, it’s 83k, so only ~10k smaller, which is good because I read somewhere that IAR has much better optimization than gcc, but I guess it's not a huge difference.

With print size enabled3-iar.png

Fixing runtime errors

For unknown reasons the compiler malloc() function starts out at memory area(0x20000000), instead of (0x1FFFB000), so it runs out of memory(I think), and the program gets stuck in the default ISR.

DefaultISR:

    b  DefaultISR

There are probably better ways to fix this, but I just changed the memory management scheme to alloc/free.  (FreeRTOSConfig.h)

#define configFRTOS_MEMORY_SCHEME                 2

This change gets the example to run (or should).  For me, everything worked after this!! 

--END--

A different post I read stated that it wasn't possible to build the SMAC app examples in KDS because they relied on library .a files which were only built in IAR, but it seems to me that the full Mac and Phy source is included in the KW2xD_SMAC download, which is why I attempted this process in the first place.

View solution in original post

8 Replies
2,045 Views
calebrust
Contributor III

[Update 2]  I got the ieee_802_15_4 Connectivity_Test for the usbkw24d512 to build and run in KDS!! The project is located in:
C:\Freescale\KW2xD_SMAC\app\ieee_802_15_4\Connectivity_Test\usbkw24d512

The steps to build it were lengthy, sorry for the long post.  I basically just started a fresh c project in KDS, and included things as needed to get it all to build.  Most of the post is project settings, but there are a few minor code changes to get it to build/run.  Just to reiterate, I had to do this because the SMAC example projects were all in IAR, and I wanted to use KDS instead.

This process will likely be obsolete when NXP/Freescale releases their SDK v2.0 code for KW2x (expected May, 2016)Introducing Kinetis SDK v2 

---START---

Prerequisites:

Install KDS 3.0.0

Install ARM gcc compiler

Install KSDK v1.2.0

Install KW2xD_SMAC

Jlink(or other debugger) drivers

Project Files & Folders

Start a new C project...

Name it.

Select Empty project

Select Cross ARM GCC

Accept defaults for the rest

Finish.

Copy these folders into your recently created project folder (they’re surprisingly big=199MB)

C:\Freescale\KW2xD_SMAC\app

C:\Freescale\KW2xD_SMAC\boards

C:\Freescale\KW2xD_SMAC\drv

C:\Freescale\KW2xD_SMAC\framework

C:\Freescale\KW2xD_SMAC\ieee_802_15_4

Delete stuff you don’t need out of your project folder.  This might be optional, depending on how mad Eclipse gets.  I deleted everything listed.

\app\ieee_802_15_4\Connectivity_Test\frdmkw24

\app\ieee_802_15_4\Connectivity_Test\twrkw21d256

\app\ieee_802_15_4\Connectivity_Test\twrkw24d512

\app\ieee_802_15_4\Connectivity_Test\usbkw24d512\build\iar

\app\ieee_802_15_4\Low_Power_Demo

\app\ieee_802_15_4\Wireless_Messenger

\app\ieee_802_15_4\Wireless_Uart

\boards\frdmkw24

\boards\twrkw21d256

\boards\twrkw24d512

\framework\LPM

\framework\OSAbstraction\Source\fsl_osa_ext_bm.c

\framework\OSAbstraction\Source\fsl_osa_ext_mqx.c

Refresh the project tree (F5)

Right-click project, select New -> Folder.

Name the folder ‘RTOS’

Add a sub-folder, call it ‘FreeRTOS’

Add another sub-folder, call it ‘Startup’

Import the .c, and .S file(s) from the folders below into the ‘FreeRTOS’ folder

C:\Freescale\KSDK_1.2.0\rtos\FreeRTOS\src\(all)

C:\Freescale\KSDK_1.2.0\rtos\FreeRTOS\port\gcc\(all)

Import the .c, and .S file(s) from the folders below into the ‘Startup’ folder

C:\Freescale\KSDK_1.2.0\platform\devices\startup.c

C:\Freescale\KSDK_1.2.0\platform\devices\MKW24D5\startup\system_MKW24D5.c

C:\Freescale\KSDK_1.2.0\platform\devices\MKW24D5\startup\gcc\startup_MKW24D5.S

Refresh the project tree (F5)

In the end, the structure should look like this:

KDS_Connectivity_Test_DirStructure.png

Project Properties

Open the project properties (Alt+Enter)

Properties -> C/C++ Build -> Behavior -> Build settings

Un-check "Stop on first build error"

Properties -> C/C++ Build -> Environment -> Environment variables to set

Add...

Name: PROJECT_LOC

Value: <your project location> e.g. C:\Users\crust\workspace.kds\Connectivity_Test_usbkw24

Properties -> C/C++ Build -> Settings -> Tool Settings:

Target Processor -> ARM family

cortex-m4

Target Processor -> Float ABI

Library (soft)

Warnings

Check "Enable all common warnings (-Wall)

Cross ARM GNU Assembler -> Preprocessor -> Defined symbols (-D)

Add...

DEBUG

Cross ARM GNU Assembler -> Includes -> Include paths (-I)

Add...

${KSDK_PATH}\rtos\FreeRTOS\config\KW24D5\gcc

Cross ARM C Compiler -> Preprocessor -> Defined symbols (-D)

Add… (or just paste the whole list all at once)

_DEBUG=1

CPU_MKW24D512VHA5

USB_KW24D512

CLOCK_SETUP=4

FSL_RTOS_FREE_RTOS

gSerialMgrUseUSB_c=1

gSerialMgrUseUart_c=1

gFsciIncluded_c=0

gSmacSupported=1

"PoolsDetails_c=_block_size_ 64 _number_of_blocks_ 10 _eol_ _block_size_ 128 _number_of_blocks_ 2 _eol_ _block_size_ 256 _number_of_blocks_ 10 _eol_"

gKBD_KeysCount_c=1

gLEDsOnTargetBoardCnt_c=2

gEepromType_d=gEepromDevice_InternalFlash_c

Cross ARM C Compiler -> Includes -> Include paths (-I)

Add… (paste)

${PROJECT_LOC}\app\ieee_802_15_4\Connectivity_Test\common

${PROJECT_LOC}\boards\usbkw24d512

${PROJECT_LOC}\drv\Portable\LED\Interface

${PROJECT_LOC}\drv\Portable\Keyboard\Interface

${PROJECT_LOC}\drv\Portable\GPIO_IrqAdapter

${PROJECT_LOC}\drv\Portable\TMR_Adapter\

${PROJECT_LOC}\drv\Portable\SPI_Adapter\

${PROJECT_LOC}\drv\Portable\USB_VirtualCom\

${PROJECT_LOC}\framework\Common

${PROJECT_LOC}\framework\OSAbstraction\Interface

${PROJECT_LOC}\framework\Utils\Lists

${PROJECT_LOC}\framework\Utils\FunctionLib

${PROJECT_LOC}\framework\Utils\SecLib

${PROJECT_LOC}\framework\Utils\ModuleInfo

${PROJECT_LOC}\framework\RNG\Interface

${PROJECT_LOC}\framework\Panic\Interface

${PROJECT_LOC}\framework\SerialManager\Interface

${PROJECT_LOC}\framework\MemManager\Interface

${PROJECT_LOC}\framework\TimersManager\Interface

${PROJECT_LOC}\framework\TimersManager\Source

${PROJECT_LOC}\framework\Messaging\Interface

${PROJECT_LOC}\ieee_802_15_4\Source\Phy\Interface

${PROJECT_LOC}\ieee_802_15_4\Source\Phy\Source\MCR20A\MCR20Drv

${PROJECT_LOC}\ieee_802_15_4\Source\Phy\Source\XcvrSPI

${PROJECT_LOC}\ieee_802_15_4\Source\SMAC\Interface

${PROJECT_LOC}\ieee_802_15_4\Source\SMAC\Generic

${PROJECT_LOC}\ieee_802_15_4\Source\SMAC\Source

${PROJECT_LOC}\app\ieee_802_15_4\Connectivity_Test\usbkw24d512\Source

${KSDK_PATH}\platform\CMSIS\Include

${KSDK_PATH}\platform\devices\

${KSDK_PATH}\platform\devices\MKW24D5\include

${KSDK_PATH}\platform\devices\MKW24D5\startup

${KSDK_PATH}\platform\osa\inc

${KSDK_PATH}\platform\drivers\src\flash\C90TFS\drvsrc\include

${KSDK_PATH}\platform\drivers\inc

${KSDK_PATH}\platform\drivers\src\mmcau\asm-cm4

${KSDK_PATH}\platform\hal\inc

${KSDK_PATH}\platform\system\inc

${KSDK_PATH}\platform\system\src\clock\MKW24D5

${KSDK_PATH}\platform\utilities\inc

${KSDK_PATH}\rtos\FreeRTOS\port\gcc

${KSDK_PATH}\rtos\FreeRTOS\config\KW24D5\gcc

${KSDK_PATH}\rtos\FreeRTOS\include

${KSDK_PATH}\rtos\FreeRTOS\src

${KSDK_PATH}\usb\adapter\sources

${KSDK_PATH}\usb\adapter\sources\sdk

${KSDK_PATH}\usb\usb_core\include

${KSDK_PATH}\usb\usb_core\device\include

${KSDK_PATH}\usb\usb_core\device\include\usbkw24d512

${KSDK_PATH}\usb\usb_core\device\sources\classes\include

${KSDK_PATH}\usb\usb_core\device\sources\classes\include\config

${KSDK_PATH}\usb\usb_core\device\sources\classes\cdc

Cross ARM C Compiler -> Optimization -> Language standard

GNU ISO C99

Cross ARM C Linker -> General -> Script files (-T)

Add...

“${KSDK_PATH}\platform\devices\MKW24D5\linker\gcc\MKW24D512xxx5_flash.ld”

Cross ARM C Linker -> General

Un-Check "Remove unused sections (-Xlinker --gc-sections)"  [at least until you know it’s building okay]

Cross ARM C Linker -> Libraries -> Libraries (-I)

Add...

m

g

gcc

nosys

Cross ARM C Linker -> Libraries -> Library search path (-L)

Add...

“${KSDK_PATH}\platform\devices\MKW24D5\linker\gcc”

Cross ARM C Linker -> Miscellaneous -> Other Objects

${KSDK_PATH}\usb\usb_core\device\build\kds\usbd_sdk_usbkw24d512_freertos\debug\libusbd_freertos.a

${KSDK_PATH}\lib\ksdk_freertos_lib\kds\KW24D5\debug\libksdk_platform_freertos.a

${KSDK_PATH}\platform\drivers\src\mmcau\asm-cm4\lib_mmcau.a

Cross ARM C Linker -> Miscellaneous -> Other linker flags

-Xlinker --defsym=__ram_vector_table__=1  --specs=nano.specs  -Xlinker --defsym=__heap_size__=0x2C00

Click Apply

Click OK

Comment Stuff Out

I couldn’t get it to build without any changes, but there are only 2 offending code segments that seem to be unused, so I commented them out.

comment-out the AES_128_CCM function, located in:

\framework\Utils\SecLib\SecLib.c

/*

uint8_t AES_128_CCM(uint8_t* pInput,

                    uint32_t inputLen,

                    uint8_t* pAuthData,

                    uint32_t authDataLen,

                    uint8_t* pInitVector,

                    uint8_t* pCounter,

                    uint8_t* pKey,

                    uint8_t* pOutput,

                    uint8_t* pCbcMac,

                    uint8_t flags)

{

#if FSL_FEATURE_SOC_LTC_COUNT

        return LTC_AES128_CCM(pInput, inputLen, pAuthData, authDataLen, pInitVector, pCounter, pKey, pOutput, pCbcMac, flags);

#else

        return sw_AES128_CCM(pInput, inputLen, pAuthData, authDataLen, pInitVector, pCounter, pKey, pOutput, pCbcMac, flags);

#endif

}*/ //Commented per KDS build instead of IAR

...as far as I can tell this function isn’t used, and I don’t know where to find the w_AES128_CCM() function.

comment-out vPortEndScheduler(), located in

\RTOS\FreeRTOS\tasks.c

It’s inside the vTaskEndScheduler(void) function:

void vTaskEndScheduler( void )

{

        /* Stop the scheduler interrupts and call the portable scheduler end

        routine so the original ISRs can be restored if necessary.  The port

        layer must ensure interrupts enable     bit is left in the correct state. */

        portDISABLE_INTERRUPTS();

        xSchedulerRunning = pdFALSE;

        //vPortEndScheduler(); //Commented per KDS build instead of IAR

}

...Things shouldn’t really call the vTaskEndScheduler function...right?  I think it would stop the RTOS, so we don’t really need this.

Importing Dependency Projects

Import ksdk_freertos_lib_KW24D5 project

C:\Freescale\KSDK_1.2.0\lib\ksdk_freertos_lib\kds\KW24D5

Import usbd_sdk_usbkw24d512_freertos project

C:\Freescale\KSDK_1.2.0\usb\usb_core\device\build\kds\usbd_sdk_usbkw24d512_freertos

Build both projects.

Build the Connectivity_Test project

Finally ready to actually build the Connectivity_Test project in KDS. Yay!

Click Build.

With print size enabled.png

When you build (if it works), the size will be 143k

If you go back to Cross ARM C Linker -> General

And check the box to remove unused sections (-Xlinker --gc-sections), the code is smaller (93k).

With print size enabled2.png

When this project is compiled in IAR, it’s 83k, so only ~10k smaller, which is good because I read somewhere that IAR has much better optimization than gcc, but I guess it's not a huge difference.

With print size enabled3-iar.png

Fixing runtime errors

For unknown reasons the compiler malloc() function starts out at memory area(0x20000000), instead of (0x1FFFB000), so it runs out of memory(I think), and the program gets stuck in the default ISR.

DefaultISR:

    b  DefaultISR

There are probably better ways to fix this, but I just changed the memory management scheme to alloc/free.  (FreeRTOSConfig.h)

#define configFRTOS_MEMORY_SCHEME                 2

This change gets the example to run (or should).  For me, everything worked after this!! 

--END--

A different post I read stated that it wasn't possible to build the SMAC app examples in KDS because they relied on library .a files which were only built in IAR, but it seems to me that the full Mac and Phy source is included in the KW2xD_SMAC download, which is why I attempted this process in the first place.

2,043 Views
EarlOrlando
Senior Contributor II

Hello,

Unfortunately, there is not information available about it yet. As you can see in the post in the link below, there is no way to support our stacks in KDS by now.

How can I obtain 802.15.4 protocol stack gcc library or source for MCR20A and KW2x?

However, I have attached the compiled connectivity test for the usbkw24d512 which I think will be useful for you.

Best regards,

Earl Ramírez.

0 Kudos
2,043 Views
calebrust
Contributor III

Thanks for the .srec file, it might be useful for some preliminary testing.  Unfortunately, I still need source code for the 802.15.4 stack to use in KDS.

From this thread:

How can I obtain 802.15.4 protocol stack gcc library or source for MCR20A and KW2x?

"I think that migrate the code and have complete compatibility will be impossible."

Are you saying that there's no 802.15.4 source code, or at least no way to compile the source code for the KW2x with Kinetis Design Studio & gcc?

In this thread

MCR20A source migration from IAR to KDS

Sunil Singh disagrees, saying:

"We used  KDS 3.0 and KSDK 1.2.

We did't link \ieee_802_15_4\Lib\Freescale_802.15.4_MAC_06_M4_IAR.a  and  it is not required."

I'd like to do what Sunil Singh did, and integrate the 802.15.4 stack into my codebase, but I'm new to this and I haven't gotten it to compile. I've spent hours adding include paths, and expanding the source tree, but still haven't finished. 

1. Eclipse only reports the first include that prevents the build, so I have to include 1 file/directory per attempt

2. Eclipse parses the files and returns errors on every included header file that it can't find, even if the functions aren't called/used. (so I might be including files I don't technically need)

0 Kudos
2,043 Views
EarlOrlando
Senior Contributor II

Hello,

I am sorry but the 802.15.4 stack is only delivered as library.

This stack without the Kinetis SDK support is not supported on KDS, but in CodeWarrior, so you could give a try in exporting the BeeKit projects from CodeWarrior into KDS.

If you are interested in the 802.15.4 stack with the Kinetis SDK support your only option is IAR.

If you only need to enable your board without the stack, you could use any Kinetis SDK supported IDE. I think that this is the case that Sunil Singh is talking about.

Best regards,

Earl.

0 Kudos
2,043 Views
calebrust
Contributor III

"If you only need to enable your board without the stack, you could use any Kinetis SDK supported IDE"

Enable my board without the stack, meaning without ZigBee (802.15.4)?

0 Kudos
2,043 Views
EarlOrlando
Senior Contributor II

Hello,

I mean without the NXP 802.15.4 Stack, i.e. only the MCU and its peripherals as any non-KW Kinetis Device. You are able to use the radio which internally is connected through a SPI instance. Honestly, I don't think that this is a suitable solution.

About the second post, honestly I haven't tried to do what you are doing but the MAC applications include a series of drivers which can be helpful to you.

pastedImage_0.png

Best regards,

Earl.

0 Kudos
2,043 Views
calebrust
Contributor III

I was able to create a demo project in BeeKit("MAC Packet Error Rate Demo End Device"), and then 'Export Solution' to CodeWarrior.  The export process creates a few files, some of which I believe are compiled binaries.

Next, I imported the project into Kinetis Design Studio by meticulously following the online guide:
How to build BeeKit exported CodeWarrior 10.6 projects using KDS

After following the steps in that guide, the project did build successfully. :smileyhappy:  I haven't tried to incorporate anything from Processor Expert, or the Kinetis SDK yet, or integrate any other functionality, but at least I have a code base in KDS that might be able to transmit data via the MCR20A and KW2x.  No idea if I can use freeRTOS at this point.

0 Kudos
2,044 Views
calebrust
Contributor III

[Update] It was a dead end to build the project in BeeKit and import it into KDS because the OS BeeKit generates code for is something Freescale made up, and one requirement for this project is to use FreeRTOS.

0 Kudos