Getting Started with KDS and mbed

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

Getting Started with KDS and mbed

Jump to solution
2,224 Views
kg1
Contributor II

Further to Getting Started with Kinetis SDK I successfully applied:

C:\FreeScale\KSDK_1.3.0\examples\frdmk64f\demo_apps\i2c_rtos\i2c_rtos_freertos\kds

\\KGPRO\H ntstorage\Store Backed Up\Programming\mbed\Freescale Users Guide 0900766b81468480.pdf

C:\FreeScale\KSDK_1.3.0\doc\Kinetis SDK v.1.3 Demo Applications User's Guide.pdf

Then found: http://frdmtoplay.com/using-mbed-with-kinetis-design-studio/  by bsilvereagle which from the beginners point of view is an excellent article and worked well until the last paragraph. I tried:

https://developer.mbed.org/platforms/FRDM-K64F/
https://developer.mbed.org/handbook/Firmware-FRDM-K64F

Illustrated Step-by-Step Instructions: Updating the Freescale Freedom Board Firmware | MCU on Eclips...

Installed 0226_k20dx128_k64f_0x5000.bin by copy paste to H:\BOOTLOADER

An internal error occurred during: "Launching MBED_A5".
ilg.gnuarmeclipse.debug.gdbjtag.dsf.GnuArmServicesFactory.<init>

(Ljava/lang/String;Ljava/lang/String;)V

http://mcuoneclipse.com/2014/04/27/segger-j-link-firmware-for-opensdav2/

Installed JLink_OpenSDA_V2_2015-10-13.bin by copy paste to H:\BOOTLOADER

Tried to setup new Debug Configuration:
An error has occurred. See error log for more details.
ilg/gnuarmeclipse/debug/gdbjtag/data/CProjectAttributes

Solution: https://community.freescale.com/thread/363937
Installed two plugins (replacements of existing files)

This enabled the use of JLink_OpenSDA_V2_2015-10-13.bin with Test 4 being part of bsilvereagle's article: (only up to line 7 of main())

117970_117970.pngJLinkTest4_1.png

Name : in
Details:{gpio = {pin = PTC16}}
Default:{...}
Decimal:{...}
Hex:{...}
Binary:{...}
Octal:{...}

 

Which blocks in:

void notify_completion(bool success)
{
    printf("{{%s}}" NL "{{%s}}" NL, success ? TEST_ENV_SUCCESS : TEST_ENV_FAILURE, TEST_ENV_END);
    led_blink(LED1, success ? 1.0 : 0.1); //Blocked in this function
}

I would much appreciate guidance for a debugging beginner.

Regards,

Kevin.

Labels (1)
1 Solution
1,347 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kevin,

If you want to use the openOCD debug , you can test first Drag and drop the .bin file(the attachment ) onto the USB drive named BOOTLOADER.Then reinsert the USB to have a try .

(The .bin can used on Windows 7, i check the mebd update the driver , it is the same with Linux, so you can try .)

Firmware FRDM K64F - Handbook | mbed

pastedImage_1.png

Hope it helps

Alice

View solution in original post

0 Kudos
10 Replies
1,347 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Kevin,

Great ! Thank!

Alice

0 Kudos
1,347 Views
kg1
Contributor II

K64F locked up while debugging.

Always try this solution first especially if you are new to KDS and from mbed.org:

Error message from debugger back end:

localhost:3333: The system tried to join a drive to a directory on a joined drive.

(1) Download this file: https://developer.mbed.org/media/uploads/sam_grove/helloworld_k64f.bin

(2) Copy and paste the bin file into your MBED drive: the file loads into your K64F.

(3) Reset your K64F.

(4) This bin file runs ok! Recommence debugging your original program on KDS.

0 Kudos
1,347 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Kevin,

Thank for your explanation in detail !

Alice

0 Kudos
1,346 Views
kg1
Contributor II

Hello Alice,

Yes it works with J-Link openSDA debug. OpenOCD did not work with this project or this one Getting Started with Kinetis SDK . Is it faulty?

Kevin.

0 Kudos
1,348 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kevin,

If you want to use the openOCD debug , you can test first Drag and drop the .bin file(the attachment ) onto the USB drive named BOOTLOADER.Then reinsert the USB to have a try .

(The .bin can used on Windows 7, i check the mebd update the driver , it is the same with Linux, so you can try .)

Firmware FRDM K64F - Handbook | mbed

pastedImage_1.png

Hope it helps

Alice

0 Kudos
1,347 Views
kg1
Contributor II

Hello Alice,

Yes I did get the three firmware packages mixed up. I can now step through this rtos program using OpenOCD:

#include "mbed.h"

#include "test_env.h"

#include "rtos.h"

#include <cstring>

/*

* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and

* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes

* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.

*/

#if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)

#define STACK_SIZE DEFAULT_STACK_SIZE/2

#elif (defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)) && defined(TOOLCHAIN_GCC)

#define STACK_SIZE DEFAULT_STACK_SIZE/2

#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)

#define STACK_SIZE DEFAULT_STACK_SIZE/2

#else

#define STACK_SIZE DEFAULT_STACK_SIZE

#endif

typedef struct {

  char packet[16];

  uint32_t counter;

} mail_t;

Mail<mail_t, 250> mail_in;

Mail<mail_t, 250> mail_out;

void print_char(char c = '*') {

    printf("%c", c);

    fflush(stdout);

}

DigitalOut led1(LED1);

DigitalOut led2(LED2);

void led2_thread1(void const *argument) {

    uint32_t i = 0;

    while (true) {

        i++; // fake data update

        mail_t *mail = mail_in.alloc();

        snprintf(mail->packet, 16, "%-d", i);

        mail->counter = i;

        mail_in.put(mail);

        Thread::wait(1000);

    }

}

void led2_thread2(void const *argument) {

    while (true) {

        osEvent evt = mail_in.get();

        if (evt.status == osEventMail) {

            mail_t *mail = (mail_t*)evt.value.p;

            printf("Text: %s \n\r", mail->packet);

            printf("Number of cycles: %u\n\r", mail->counter);

            mail_in.free(mail);

        }

    }

}

void led2_thread3(void const *argument) {

    while (true) {

        led2 = !led2;

        Thread::wait(1000);

        print_char('$');

    }

}

int main() {

    MBED_HOSTTEST_TIMEOUT(15);

    MBED_HOSTTEST_SELECT(wait_us_auto);

    MBED_HOSTTEST_DESCRIPTION(Basic thread);

    MBED_HOSTTEST_START("RTOS_1");

   Thread thread1(led2_thread1, NULL, osPriorityNormal, STACK_SIZE);

   Thread thread2(led2_thread2, NULL, osPriorityNormal, STACK_SIZE);

   Thread thread3(led2_thread3, NULL, osPriorityNormal, STACK_SIZE);

    while (true) {

        led1 = !led1;

        Thread::wait(500);

    }

}

Thank you for your help.

OpenOCD2.png

0 Kudos
1,347 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kevin,

"An internal error occurred during: "Launching MBED_A5"."- What's the error ?

"Tried to setup new Debug Configuration:" - How do you configure the debug ?

"An error has occurred." -- What's the error ?

About the debug on KDS, i recommend you recommend

KDS_Users_Guide.pdf -> 2.5 Debugging Projects ( the DOC is under "Freescale\KDS_3.0.0\doc")

Hope it helps

Alice

0 Kudos
1,347 Views
kg1
Contributor II

Hello Alice,

Thank you for your reply. In the bsilvereagle's article I am up to here:

"Run code on K64F

Note: I use the Segger J-Link OpenSDA application for debugging. The K64F by default uses OpenOCD. I believe just pressing the 'Debug' icon while the K64F is plugged in should debug the application. I recommend using the Segger J-Link debugging interface. A post will follow on how to do this."

I tried OpenOCD which failed. Hence "I believe just pressing the 'Debug' icon while the K64F is plugged in should debug the application." is not true. Next I installed  Segger J-Link OpenSDA which does debug a simple test program but the program fails the test.

I have decided to restart the test. There are 133 test programs available:

C:\FreeScale\tmp\wsp_kds_3.0.0\mbed\workspace_tools>python project.py -L

[  0] MBED_A1: Basic

[  1] MBED_A2: Semihost file system

[  2] MBED_A3: C++ STL

[  3] MBED_A4: I2C TMP102

[  4] MBED_A5: DigitalIn DigitalOut

[  5] MBED_A6: DigitalInOut

[  6] MBED_A7: InterruptIn

[  7] MBED_A8: Analog

[  8] MBED_A9: Serial Echo at 115200

[  9] MBED_A10: PortOut PortIn

[ 10] MBED_A11: PortInOut

[ 11] MBED_A12: SD File System

[ 12] MBED_A13: I2C MMA7660 accelerometer

[ 13] MBED_A14: I2C Master

[ 14] MBED_A15: I2C Slave

[ 15] MBED_A16: SPI Master

[ 16] MBED_A17: SPI Slave

[ 17] MBED_A18: Interrupt vector relocation

[ 18] MBED_A19: I2C EEPROM read/write test

[ 19] MBED_A20: I2C master/slave test

[ 20] MBED_A21: Call function before main (mbed_main)

[ 21] MBED_A22: SPIFI for LPC4088 (test 1)

[ 22] MBED_A23: SPIFI for LPC4088 (test 2)

[ 23] MBED_A24: Serial echo with RTS/CTS flow control

[ 24] MBED_A25: I2C EEPROM line read/write test

[ 25] MBED_A26: AnalogIn potentiometer test

[ 26] MBED_A27: CAN loopback test

[ 27] MBED_BLINKY: Blinky

[ 28] MBED_BUS: Blinky BUS

[ 29] MBED_BUSOUT: BusOut

[ 30] BENCHMARK_1: Size (c environment)

[ 31] BENCHMARK_2: Size (float math)

[ 32] BENCHMARK_3: Size (printf)

[ 33] BENCHMARK_4: Size (mbed libs)

[ 34] BENCHMARK_5: Size (all)

[ 35] PERF_1: SD Stdio R/W Speed

[ 36] PERF_2: SD FileHandle R/W Speed

[ 37] PERF_3: SD FatFS R/W Speed

[ 38] MBED_1: I2C SRF08

[ 39] MBED_2: stdio

[ 40] MBED_3: PortOut

[ 41] MBED_4: Sleep

[ 42] MBED_5: PWM

[ 43] MBED_6: SW Reset

[ 44] MBED_7: stdio  benchmark

[ 45] MBED_8: SPI

[ 46] MBED_9: Sleep Timeout

[ 47] MBED_10: Hello World

[ 48] MBED_11: Ticker Int

[ 49] MBED_12: C++

[ 50] MBED_13: Heap & Stack

[ 51] MBED_14: Serial Interrupt

[ 52] MBED_15: RPC

[ 53] MBED_16: RTC

[ 54] MBED_17: Serial Interrupt 2

[ 55] MBED_18: Local FS Directory

[ 56] MBED_19: SD FS Directory

[ 57] MBED_20: InterruptIn 2

[ 58] MBED_21: freopen Stream

[ 59] MBED_22: Semihost

[ 60] MBED_23: Ticker Int us

[ 61] MBED_24: Timeout Int us

[ 62] MBED_25: Time us

[ 63] MBED_26: Integer constant division

[ 64] MBED_27: SPI ADXL345

[ 65] MBED_28: Interrupt chaining (InterruptManager)

[ 66] MBED_29: CAN network test

[ 67] MBED_30: CAN network test using interrupts

[ 68] MBED_31: PWM LED test

[ 69] MBED_32: Pin toggling

[ 70] MBED_33: C string operations

[ 71] MBED_34: Ticker Two callbacks

[ 72] MBED_35: SPI C12832 display

[ 73] MBED_36: WFI correct behavior

[ 74] MBED_37: Serial NC RX

[ 75] MBED_38: Serial NC TX

[ 76] CMSIS_RTOS_1: Basic

[ 77] CMSIS_RTOS_2: Mutex

[ 78] CMSIS_RTOS_3: Semaphore

[ 79] CMSIS_RTOS_4: Signals

[ 80] CMSIS_RTOS_5: Queue

[ 81] CMSIS_RTOS_6: Mail

[ 82] CMSIS_RTOS_7: Timer

[ 83] CMSIS_RTOS_8: ISR

[ 84] RTOS_1: Basic thread

[ 85] RTOS_2: Mutex resource lock

[ 86] RTOS_3: Semaphore resource lock

[ 87] RTOS_4: Signals messaging

[ 88] RTOS_5: Queue messaging

[ 89] RTOS_6: Mail messaging

[ 90] RTOS_7: Timer

[ 91] RTOS_8: ISR (Queue)

[ 92] RTOS_9: SD File write-read

[ 93] NET_1: TCP client hello world

[ 94] NET_2: NIST Internet Time Service

[ 95] NET_3: TCP echo server

[ 96] NET_4: TCP echo client

[ 97] NET_5: UDP echo server

[ 98] NET_6: UDP echo client

[ 99] NET_7: HTTP client hello world

[100] NET_8: NTP client

[101] NET_9: Multicast Send

[102] NET_10: Multicast Receive

[103] NET_11: Broadcast Send

[104] NET_12: Broadcast Receive

[105] NET_13: TCP client echo loop

[106] NET_14: UDP PHY/Data link layer

[107] UB_1: u-blox USB modem: HTTP client

[108] UB_2: u-blox USB modem: SMS test

[109] USB_1: Mouse

[110] USB_2: Keyboard

[111] USB_3: Mouse_Keyboard

[112] USB_4: Serial Port

[113] USB_5: Generic HID

[114] USB_6: MIDI

[115] USB_7: AUDIO

[116] CMSIS_DSP_1: FIR

[117] DSP_1: FIR

[118] KL25Z_1: LPTMR

[119] KL25Z_2: PIT

[120] KL25Z_3: TSI Touch Sensor

[121] KL25Z_4: RTC

[122] KL25Z_5: MMA8451Q accelerometer

[123] EXAMPLE_1: /dev/null

[124] EXAMPLE_2: FS + RTOS

[125] UT_1: Basic

[126] UT_2: Semihost file system

[127] UT_3: General tests

[128] UT_BUSIO: BusIn BusOut

[129] UT_I2C_EEPROM_ASYNCH: I2C Asynch eeprom

[130] UT_SERIAL_ASYNCH: Asynch serial test (req 2 serial peripherals)

[131] UT_SPI_ASYNCH: Asynch spi test

[132] UT_LP_TICKER: Low power ticker test

[133] DTCT_1: Simple detect test

====================================================================================

I will try test number 84 and will include all source code including the mbed libraries:

PS C:\FreeScale\tmp\wsp_kds_3.0.0\mbed> python workspace_tools/project.py -m K64F -i kds -p 84

...

Copy: Timer.cpp
Copy: TimerEvent.cpp
Copy: librtos.a
Copy: librtx.a
Copy: K64FN1M0xxx12.ld
Copy: main.cpp

Successful exports:
  * K64F::kds   C:\FreeScale\tmp\wsp_kds_3.0.0\mbed\build\export\RTOS_1_kds_K64F.zip
====================================================================================

Next I completed the debug configurations:

rtos3.png

rtos4.png

rtos5.png

Here are the main screens of KDS:

rtos1.png

rtos2.png

This time I immediately clicked Resume at the break point and it worked!

Cheers,

Kevin.

0 Kudos
1,347 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kevin,

Does you PC is Linux system ?

- If you want use the openOCD to debug , first you need copy the "k20dx128_k64f_if_mbed.bin" to the bootloader.

- At the J-Link openSDA debug , i see you said "This time I immediately clicked Resume at the break point and it worked!" ,

so you have not problem , right ?

BR

Alice

0 Kudos