Flashing doesn't stick

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

Flashing doesn't stick

Jump to solution
1,376 Views
robertbaruch
Contributor III

So there's this nice Flash button in KDS. When I hit that button and select the Segger Release config, it seems to flash my FRDM-K64F with my project's .elf file, and then run, which is great. However, if I stop gdb and hit the board's reset button, the program doesn't start up again. Likewise, if I flash, disconnect the board, and reconnect, either with USB or with an external power supply, it doesn't start up. I'm sure that I'm missing something conceptually. What do I need to change to get my program to start on boot?

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,095 Views
robertbaruch
Contributor III

Solved!

The 1.3 hello_world program had in the linker settings nosys in the libraries. My 2.0 program had rdimon in the libraries and also -specs=rdimon.specs in the Other Linker settings.

When I changed -specs=rdimon.specs to -specs=nosys.specs, my board properly started the program up even after reset and after USB reconnect. I think this is because rdimon forces the program to wait for a connection from GDB before starting, so of course when I shut down the GDB server, the board couldn't start.

View solution in original post

0 Kudos
10 Replies
1,096 Views
robertbaruch
Contributor III

Solved!

The 1.3 hello_world program had in the linker settings nosys in the libraries. My 2.0 program had rdimon in the libraries and also -specs=rdimon.specs in the Other Linker settings.

When I changed -specs=rdimon.specs to -specs=nosys.specs, my board properly started the program up even after reset and after USB reconnect. I think this is because rdimon forces the program to wait for a connection from GDB before starting, so of course when I shut down the GDB server, the board couldn't start.

0 Kudos
1,095 Views
BlackNight
NXP Employee
NXP Employee

I think the problem is semihosting: are you using printf() in your code? If so and used with semihosting, then this might block and wait for the debugger to take the data. Another reason not to use printf() (Why I don’t like printf() | MCU on Eclipse ) :-(.

Erich

0 Kudos
1,095 Views
robertbaruch
Contributor III

I wasn't using printf. I think what happened was, at one point I tried using semihosting and set up rdimon, but it didn't seem to work so I just took out all the printfs, but left rdimon in. I should have also taken rdimon out.

0 Kudos
1,095 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Rotert,

I use the USB connect the OpenSDA(J26) port of board , then use the j-link to download , when disconnect the usb , then connect it

again, it can work well .

pastedImage_0.png

Please take screenshot about your configuration when debug and the connect of your board . And i recommend

you first test one simple project .

BR

Alice

0 Kudos
1,096 Views
robertbaruch
Contributor III

Here is my debug config. I am also using the J26 port and j-link.

Screenshot debug config.png

Debugging works just fine, but when I unplug the USB and plug it back in, the board does not start the code. I have to download it to the board again.

0 Kudos
1,095 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

Have you install the KSDK, if yes , please test the demo under KSDK :\KSDK_1.3.0\examples\frdmk64f\demo_apps\hello_world\kds

If not , you can create one simple project by yourself .

BR

ALice

0 Kudos
1,095 Views
robertbaruch
Contributor III

Yes, that example works: I'm able to run it, disconnect the USB, reconnect, and the program on the board immediately starts up. Now we need to figure out why it doesn't work with KSDK 2.0.

Here are the differences between the example project and my project for the Debugger and Startup settings. Which would cause the program not to stay on the board?

debugger-settings-diff.png

startup-settings-diff.png

0 Kudos
1,095 Views
BlackNight
NXP Employee
NXP Employee

Hi Robert,

I think your debugger settings are not the problem. I guess it is your project and your sources which cause the problem. Have you still the EzPort enabled/floating. See this thread (FRDM-K64F booting issue when powered from USB port ) or google for "k64f ezport start".

I hope this helps,

Erich

0 Kudos
1,095 Views
robertbaruch
Contributor III

Hi Erich! I think it's something other than EzPort. The startup_MK64F12.S files are not quite identical between the hello world program (which works) and my SDK 2.0 program (which doesn't work). However, just to be sure, I changed the 0xFFFFFFFE word to 0xFFFFFDFE in startup, and that made no difference.

Here is my test program, which differs from the default SDK 2.0 program by not much:

int main(void) {

  /* Init board hardware. */

  BOARD_InitPins();

  BOARD_BootClockRUN();

  // Initialize LED pins

  port_pin_config_t ledConfig = {

    .pullSelect = kPORT_PullDisable,

    .slewRate = kPORT_SlowSlewRate,

    .passiveFilterEnable = kPORT_PassiveFilterDisable,

    .openDrainEnable = kPORT_OpenDrainDisable,

    .driveStrength = kPORT_LowDriveStrength,

    .mux = kPORT_MuxAsGpio,

    .lockRegister = kPORT_UnlockRegister,

  };

  PORT_SetPinConfig(BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, &ledConfig);

  LED_RED_INIT(LOGIC_LED_ON);

  for(;;) { /* Infinite loop to avoid leaving the main function */

    __asm("NOP"); /* something to use as a breakpoint stop while looping */

  }

}

One other symptom that I noticed is that after I start the debugger with my program and the LED is on, if I stop the debugger and then hit the reset button on the board, the program does not restart -- the LED goes out and stays out. With the hello world example, I can stop the debugger and hit reset all day long and it will still restart the program and blink the LED.

0 Kudos
1,095 Views
robertbaruch
Contributor III

I've also noticed that the download procedure is slightly different between the hello world example and the SDK 2.0 version.

The hello_world (1.3) version:

Target interface speed set to 30 kHz

Resetting target

Halting target CPU...

...Target halted (PC = 0x00000540)

R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000

R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000

R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000

R12= 00000000, R13= 20030000, MSP= 20030000, PSP= 00000000

R14(LR) = FFFFFFFF, R15(PC) = 00000540

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Reading all registers

Select auto target interface speed (1429 kHz)

Flash breakpoints enabled

Semi-hosting enabled (Handle on BKPT)

Wrong client mask. Semihosting I/O not changed.

Failed to disable SWO.

Failed to enable SWO. Could not determine a suitable SWO speed!

Downloading 1024 bytes @ address 0x00000000 - Verified OK

Downloading 16 bytes @ address 0x00000400 - Verified OK

Downloading 16096 bytes @ address 0x00000410 - Verified OK

Downloading 1596 bytes @ address 0x000042F0 - Verified OK

Downloading 8 bytes @ address 0x0000492C - Verified OK

Downloading 4 bytes @ address 0x00004934 - Verified OK

Downloading 4 bytes @ address 0x00004938 - Verified OK

Downloading 116 bytes @ address 0x0000493C - Verified OK

Writing register (PC = 0x000004d8)

Read 4 bytes @ address 0x000004D8 (Data = 0xF000B672)

Resetting target

Halting target CPU...

...Target halted (PC = 0x000004D8)

Read 2 bytes @ address 0x000011FA (Data = 0x2300)

Read 2 bytes @ address 0x000011FA (Data = 0x2300)

Read 2 bytes @ address 0x000011FA (Data = 0x2300)

R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000

R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000

R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000

R12= 00000000, R13= 20030000, MSP= 20030000, PSP= 00000000

R14(LR) = FFFFFFFF, R15(PC) = 000004D8

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Reading all registers

Read 4 bytes @ address 0x000004D8 (Data = 0xF000B672)

Setting breakpoint @ address 0x000011FA, Size = 2, BPHandle = 0x0001

Starting target CPU...

...Breakpoint reached @ address 0x000011FA

Reading all registers

Removing breakpoint @ address 0x000011FA, Size = 2

Read 4 bytes @ address 0x000011FA (Data = 0x60FB2300)

Reading 64 bytes @ address 0x2002FFC0

Starting target CPU...

The 2.0 version:

Target interface speed set to 1000 kHz

Resetting target

Halting target CPU...

...Target halted (PC = 0x000004D8)

R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000

R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000

R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000

R12= 00000000, R13= 20030000, MSP= 20030000, PSP= 00000000

R14(LR) = FFFFFFFF, R15(PC) = 000004D8

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Reading all registers

Select auto target interface speed (1429 kHz)

Flash breakpoints enabled

Semi-hosting enabled (Handle on BKPT)

Wrong client mask. Semihosting I/O not changed.

Failed to disable SWO.

Failed to enable SWO. Could not determine a suitable SWO speed!

Downloading 1024 bytes @ address 0x00000000 - Verified OK

Downloading 16 bytes @ address 0x00000400 - Verified OK

Downloading 16112 bytes @ address 0x00000410 - Verified OK

Downloading 13712 bytes @ address 0x00004300 - Verified OK

Downloading 8 bytes @ address 0x00007890 - Verified OK

Downloading 4 bytes @ address 0x00007898 - Verified OK

Downloading 4 bytes @ address 0x0000789C - Verified OK

Downloading 392 bytes @ address 0x000078A0 - Verified OK

Comparing flash  [....................] Done.

Erasing flash    [....................] Done.

Programming flash [....................] Done.

Verifying flash  [....................] Done.

Writing register (PC = 0x00000540)

Read 4 bytes @ address 0x00000540 (Data = 0x4809B672)

Read 2 bytes @ address 0x000024DA (Data = 0xF002)

Read 2 bytes @ address 0x000024DA (Data = 0xF002)

Resetting target

Halting target CPU...

...Target halted (PC = 0x00000540)

Read 2 bytes @ address 0x000024DA (Data = 0xF002)

Read 2 bytes @ address 0x000024DA (Data = 0xF002)

Read 2 bytes @ address 0x000024DA (Data = 0xF002)

R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000

R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000

R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000

R12= 00000000, R13= 20030000, MSP= 20030000, PSP= 00000000

R14(LR) = FFFFFFFF, R15(PC) = 00000540

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Reading all registers

Read 4 bytes @ address 0x00000540 (Data = 0x4809B672)

Setting breakpoint @ address 0x000024DA, Size = 2, BPHandle = 0x0001

Starting target CPU...

Comparing flash  [....................] Done.

Erasing flash    [....................] Done.

Programming flash [....................] Done.

Verifying flash  [....................] Done.

...Breakpoint reached @ address 0x000024DA

Reading all registers

Removing breakpoint @ address 0x000024DA, Size = 2

Read 4 bytes @ address 0x000024DA (Data = 0xFE77F002)

Reading 64 bytes @ address 0x2002FFC0

Starting target CPU...

Note that in the 2.0 version there's some flash stuff going on (comparing, erasing, programming, verifying) where in 1.3 that isn't done. Could that have something to do with the problem?

0 Kudos