I have been able to sucessfully compile simple BLINK program and flash my custom board (Kinetis MKL03Z8VFG4R) with Jlink inside MCUXpresso v10.2.0 using command:
////////////////////////////////
// command to be executed...
////////////////////////////////
"C:\Program Files (x86)\SEGGER\JLink_V632b\JLink.exe" -if SWD -speed auto -commanderscript "C:/[my_path]/MCUXpressoIDE_10.2.0_759/workspace/gpio_led_output_test/script.jlink" -device MKL03Z8xxx4 -SelectEmuBySN [jlink_serial_number]////////////////////////////////
// script.jlink
////////////////////////////////
ExitOnError 1
r
h
loadfile "C:\[my_path]/\MCUXpressoIDE_10.2.0_759\workspace/gpio_led_output_test/Release/gpio_led_output_test.hex"
qc////////////////////////////////
// command to use in a script
////////////////////////////////
set MCUX_WORKSPACE_LOC=C:/[my_path]/MCUXpressoIDE_10.2.0_759/workspace
set MCUX_JLINK="C:/Program Files (x86)/SEGGER/JLink_V632b/""%MCUX_JLINK%/JLink.exe" -if SWD -speed auto -commanderscript "%MCUX_WORKSPACE_LOC%/gpio_led_output_test/script.jlink" -device MKL03Z8xxx4 -SelectEmuBySN [jlink_serial_number]
Operation was sucessfull, in console I can see this output:
Executing flash operation 'Program' (Program executable into flash gpio_led_output_test.axf) - Mon Jun 25 10:37:04 CEST 2018
Checking MCU info...
Scanning for targets...
Executing flash action...
SEGGER J-Link Commander V6.32b (Compiled May 8 2018 18:26:51)
DLL version V6.32b, compiled May 8 2018 18:26:33
J-Link Command File read successfully.
Processing script file...
J-Link Commander will now exit on Error
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link ARM-OB STM32 compiled Aug 22 2012 19:52:04
Hardware version: V7.00
License(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTref=3.300V
Target connection not established yet but required for command.
Device "MKL03Z8XXX4" selected.
Connecting to target via SWD
InitTarget()
Found SW-DP with ID 0x0BC11477
AP map detection skipped. Manually configured AP map found.
AP[0]: AHB-AP (IDR: Not set)
AP[1]: CUSTOM-AP (IDR: Not set)
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xF0002000
CPUID register: 0x410CC601. Implementer code: 0x41 (ARM)
Found Cortex-M0 r0p1, Little endian.
FPUnit: 2 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ F0002000
ROMTbl[0][0]: F0000000, CID: B105900D, PID: 001BB932 MTB-M0+
ROMTbl[0][1]: F0001000, CID: B105900D, PID: 0008E000 MTBDWT
ROMTbl[0][2]: E00FF000, CID: B105100D, PID: 000BB4C0 ROM Table
ROMTbl[1] @ E00FF000
ROMTbl[1][0]: E000E000, CID: B105E00D, PID: 000BB008 SCS
ROMTbl[1][1]: E0001000, CID: B105E00D, PID: 000BB00A DWT
ROMTbl[1][2]: E0002000, CID: B105E00D, PID: 000BB00B FPB
Cortex-M0 identified.
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
PC = 1C0000C0, CycleCnt = 00000000
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 1C001CA0, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000
SP(R13)= 20000218, MSP= 20000218, PSP= FFFFFFFC, R14(LR) = 1C0015F9
XPSR = 61000000: APSR = nZCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
FPU regs: FPU not enabled / not implemented on connected CPU.
Downloading file [C:\[my_path]\MCUXpressoIDE_10.2.0_759\workspace/gpio_led_output_test/Release/gpio_led_output_test.hex]...
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (1024 bytes)
J-Link: Flash download: Total time needed: 0.232s (Prepare: 0.046s, Compare: 0.089s, Erase: 0.019s, Program: 0.046s, Verify: 0.016s, Restore: 0.014s)
O.K.
Script processing completed.
I can then debug my custom board (I see printed characters from my PRINTF() function in JlLink GDB Server console), but my firmware runs only when in debug session. In source I have set internal LIRC clock (2Mhz) and I have only 1 configuration, ie. BOARD_BootClockRUN(), which I pressume should start CPU in "normal" mode.
Why is my board not starting if I only apply power lines to it? Is it depend on any project options: I used default project options, ie. "SDK Debug Console: Semihost", "Redlib (semihost-nf)", etc.)?
Edit:
I have also tried to set (Quick Settings-->SDB Debug Console) to "UART console" (as suggested in MCUXpresso IDE and Semihosting), but its not working either. My Preprocessor Defined Symbols are as below:
__REDLIB__
CPU_MKL03Z8VFK4
CPU_MKL03Z8VFK4_cm0plus
CR_INTEGER_PRINTF
PRINTF_FLOAT_ENABLE=0
__MCUXPRESSO
__USE_CMSIS
DEBUG
SDK_DEBUGCONSOLE=1
Using MCUXpresso Config Tools I have manually set UART0 line (is this a problem?). I tried even with different combinations of directives (NDEBUG, SDK_DEBUGCONSOLE 1/0), but CPU does not start running.
My PINs initialization routine is:
void BOARD_InitPins(void)
{
CLOCK_EnableClock(kCLOCK_PortA);
CLOCK_EnableClock(kCLOCK_PortB);gpio_pin_config_t LED_GREEN_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};GPIO_PinInit(BOARD_INITPINS_LED_GREEN_GPIO, BOARD_INITPINS_LED_GREEN_PIN, &LED_GREEN_config);
gpio_pin_config_t LED_RED_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};GPIO_PinInit(BOARD_INITPINS_LED_RED_GPIO, BOARD_INITPINS_LED_RED_PIN, &LED_RED_config);
PORT_SetPinMux(BOARD_INITPINS_LED_GREEN_PORT, BOARD_INITPINS_LED_GREEN_PIN, kPORT_MuxAsGpio);
PORT_SetPinMux(BOARD_INITPINS_LED_RED_PORT, BOARD_INITPINS_LED_RED_PIN, kPORT_MuxAsGpio);/* PORTB1 (pin 9) is configured as LPUART0_RX */
PORT_SetPinMux(BOARD_INITPINS_UART_RX_PORT, BOARD_INITPINS_UART_RX_PIN, kPORT_MuxAlt3);/* PORTB2 (pin 10) is configured as LPUART0_TX */
PORT_SetPinMux(BOARD_INITPINS_UART_TX_PORT, BOARD_INITPINS_UART_TX_PIN, kPORT_MuxAlt3);/* PORTB3 (pin 11) is configured as I2C0_SCL */
PORT_SetPinMux(BOARD_INITPINS_SCL_PORT, BOARD_INITPINS_SCL_PIN, kPORT_MuxAlt2);/* PORTB4 (pin 12) is configured as I2C0_SDA */
PORT_SetPinMux(BOARD_INITPINS_SDA_PORT, BOARD_INITPINS_SDA_PIN, kPORT_MuxAlt2);SIM->SOPT5 = ((SIM->SOPT5 &
/* Mask bits to zero which are setting */
(~(SIM_SOPT5_LPUART0RXSRC_MASK)))/* LPUART0 Receive Data Source Select: LPUART_RX pin. */
| SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX));
}
Hi,
Please probe the KL03 RESET pin status without debugger with power up.
And you can just toggle a led to check if your application code works without debugger.
Please let us know the KL03 RESET pin status during power up.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------