AnsweredAssumed Answered

Why do I get "ERROR: Failed to prepare for programming" when flashing?

Question asked by Don Turner on Jul 15, 2016
Latest reply on Jul 22, 2016 by Don Turner

I have a new Freescale FRDM-K22F board. I'm unable to load any programs onto it.

 

When I attempt to load the program I get the following error message from JLinkGDBServer: ERROR: Failed to prepare for programming

 

Here's my working environment:

 

Host OS: Mac OS X 10.11.5 El Capitan

Toolchain: GNU ARM (gcc-arm-none-eabi-4_8-2014q3)

Firmware: SEGGER OpenSDA 2.1 generic firmware from https://www.segger.com/downloads/jlink/OpenSDA_V2_1.bin

JLink: V5.12i Command Line Version from https://www.segger.com/downloads/jlink/JLink_MacOSX_V512i.pkg

 

Here's what happens when I attempt to load the hello_world example:

 

1. Start JLinkGDBServer from Terminal

 

./JLinkGDBServer -select USB -device MK22FN512xxx12 -if SWD -speed 1000

 

SEGGER J-Link GDB Server V5.12i Command Line Version

JLinkARM.dll V5.12i (DLL compiled Jul  5 2016 19:02:37)

-----GDB Server start settings-----

GDBInit file:                  none

GDB Server Listening port:     2331

SWO raw output listening port: 2332

Terminal I/O port:             2333

Accept remote connection:      yes

Generate logfile:              off

Verify download:               off

Init regs on start:            off

Silent mode:                   off

Single run mode:               off

Target connection timeout:     0 ms

------J-Link related settings------

J-Link Host interface:         USB

J-Link script:                 none

J-Link settings file:          none

------Target related settings------

Target device:                 MK22FN512xxx12

Target interface:              SWD

Target interface speed:        1000kHz

Target endian:                 little

 

Connecting to J-Link...

J-Link is connected.

Firmware: J-Link OpenSDA 2 compiled Jul 12 2016 12:33:05

Hardware: V1.00

S/N: 621000000

Checking target voltage...

Target voltage: 3.30 V

Listening on TCP/IP port 2331

Connecting to target...Connected to target

Waiting for GDB connection...

 

2. Run GDB and load hello_world

 

arm-none-eabi-gdb hello_world.elf

(gdb) target remote localhost:2331

 

<JLink output>

Reading all registers

WARNING: Failed to read memory @ address 0xFFFFFFFE

 

(gdb) load

 

<JLink output>

Downloading 1024 bytes @ address 0x00000000

Downloading 16 bytes @ address 0x00000400

Downloading 16096 bytes @ address 0x00000410

Downloading 4080 bytes @ address 0x000042F0

Downloading 8 bytes @ address 0x000052E0

Downloading 4 bytes @ address 0x000052E8

Downloading 4 bytes @ address 0x000052EC

Downloading 164 bytes @ address 0x000052F0

ERROR: Failed to prepare for programming.

Failed to execute RAMCode for RAM check!

Writing register (PC = 0x000004d8)

 

I have tried various other firmwares and the beta version of JLink, as well as various combinations of `monitor halt` and `monitor reset` but I am still unable to load any programs onto the K22F board. Can anyone help?

Outcomes