Boot Linux faster!

Check our new training course

Boot Linux faster!

Check our new training course
and Creative Commons CC-BY-SA
lecture and lab materials

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
:orphan:

.. _nxp_opensda:

NXP OpenSDA
###########

Overview
********

`OpenSDA`_ is a serial and debug adapter that is built into several NXP
evaluation boards. It provides a bridge between your computer (or other USB
host) and the embedded target processor, which can be used for debugging, flash
programming, and serial communication, all over a simple USB cable.

The OpenSDA hardware features a Kinetis K2x microcontroller with an integrated
USB controller. On the software side, it implements a mass storage device
bootloader which offers a quick and easy way to load OpenSDA applications such
as flash programmers, run-control debug interfaces, serial to USB converters,
and more.

Zephyr supports the following debug tools through OpenSDA:

* :ref:`nxp_opensda_pyocd`
* :ref:`nxp_opensda_jlink`

.. _nxp_opensda_firmware:

Program the Firmware
====================

Once you've selected which debug tool you wish to use, you need to program the
associated OpenSDA firmware application to the OpenSDA adapter.

Put the OpenSDA adapter into bootloader mode by holding the reset button while
you power on the board. After you power on the board, release the reset button
and a USB mass storage device called **BOOTLOADER** or **MAINTENANCE** will
enumerate. Copy the OpenSDA firmware application binary to the USB mass storage
device. Power cycle the board, this time without holding the reset button.


.. _nxp_opensda_pyocd:

pyOCD
*****

pyOCD is an Open Source python 2.7 based library for programming and debugging
ARM Cortex-M microcontrollers using CMSIS-DAP.

Host Tools and Firmware
=======================

Follow the instructions in `pyOCD Installation`_ to install the pyOCD flash
tool and GDB server for your host computer.

Select your board in `OpenSDA`_ and download the latest DAPLink firmware
application binary. :ref:`nxp_opensda_firmware` with this application.

Flashing
========

Use the ``make flash`` build target with ``OPENSDA_FW=daplink`` to build your
Zephyr application, invoke the pyOCD flash tool and program your Zephyr
application to flash.

  .. code-block:: console

     $ make OPENSDA_FW=daplink flash
     Using /home/maureen/zephyr/boards/arm/frdm_k64f/frdm_k64f_defconfig as base
     Merging /home/maureen/zephyr/tests/include/test.config
     Merging prj.conf
     #
     # configuration written to .config
     #
     make[1]: Entering directory '/home/maureen/zephyr'
     make[2]: Entering directory '/home/maureen/zephyr/samples/hello_world/outdir/frdm_k64f'
       GEN     ./Makefile
     scripts/kconfig/conf --silentoldconfig Kconfig
       Using /home/maureen/zephyr as source for kernel
       GEN     ./Makefile
       CHK     include/generated/version.h
       UPD     include/generated/version.h
       DTC     dts/arm/frdm_k64f.dts_compiled
       CHK     include/generated/generated_dts_board.h
       UPD     include/generated/generated_dts_board.h
       CHK     misc/generated/configs.c
       UPD     misc/generated/configs.c
       CHK     include/generated/offsets.h
       UPD     include/generated/offsets.h
       CC      lib/libc/minimal/source/stdlib/strtol.o

     <snip>

       CC      kernel/work_q.o
       AR      kernel/lib.a
       CC      src/main.o
       LD      src/built-in.o
       AR      libzephyr.a
       LINK    zephyr.lnk
       IRQ     isr_tables.c
       CC      isr_tables.o
       LINK    zephyr.elf
       BIN     zephyr.bin
     Flashing frdm_k64f
     Flashing Target Device
     INFO:root:DAP SWD MODE initialised
     INFO:root:K64F not in secure state
     INFO:root:ROM table #0 @ 0xe00ff000 cidr=b105100d pidr=4000bb4c4
     INFO:root:[0]<e000e000:SCS-M4 cidr=b105e00d, pidr=4000bb00c, class=14>
     WARNING:root:Invalid coresight component, cidr=0x0
     INFO:root:[1]<e0001000: cidr=0, pidr=0, component invalid>
     INFO:root:[2]<e0002000:FPB cidr=b105e00d, pidr=4002bb003, class=14>
     WARNING:root:Invalid coresight component, cidr=0x1010101
     INFO:root:[3]<e0000000: cidr=1010101, pidr=101010101010101, component invalid>
     WARNING:root:Invalid coresight component, cidr=0x0
     INFO:root:[4]<e0040000: cidr=0, pidr=0, component invalid>
     INFO:root:[5]<e0041000:ETM-M4 cidr=b105900d, pidr=4000bb925, class=9, devtype=13, devid=0>
     INFO:root:[6]<e0042000:ETB cidr=b105900d, pidr=4003bb907, class=9, devtype=21, devid=0>
     INFO:root:[7]<e0043000:CSTF cidr=b105900d, pidr=4001bb908, class=9, devtype=12, devid=28>
     INFO:root:CPU core is Cortex-M4
     INFO:root:FPU present
     INFO:root:6 hardware breakpoints, 4 literal comparators
     INFO:root:4 hardware watchpoints
     [====================] 100%
     INFO:root:Programmed 12288 bytes (3 pages) at 10.57 kB/s
     make[2]: Leaving directory '/home/maureen/zephyr/samples/hello_world/outdir/frdm_k64f'
     make[1]: Leaving directory '/home/maureen/zephyr'


Debugging
=========

Use the ``make debug`` build target with ``OPENSDA_FW=daplink`` to build your
Zephyr application, invoke the pyOCD GDB server, attach a GDB client, and
program your Zephyr application to flash. It will leave you at a gdb prompt.

  .. code-block:: console

     $ make OPENSDA_FW=daplink debug
     Using /home/maureen/zephyr/boards/arm/frdm_k64f/frdm_k64f_defconfig as base
     Merging /home/maureen/zephyr/tests/include/test.config
     Merging prj.conf
     #
     # configuration written to .config
     #
     make[1]: Entering directory '/home/maureen/zephyr'
     make[2]: Entering directory '/home/maureen/zephyr/samples/hello_world/outdir/frdm_k64f'
       GEN     ./Makefile
     scripts/kconfig/conf --silentoldconfig Kconfig
       Using /home/maureen/zephyr as source for kernel
       GEN     ./Makefile
       CHK     include/generated/version.h
       UPD     include/generated/version.h
       DTC     dts/arm/frdm_k64f.dts_compiled
       CHK     include/generated/generated_dts_board.h
       UPD     include/generated/generated_dts_board.h
       CHK     misc/generated/configs.c
       UPD     misc/generated/configs.c
       CHK     include/generated/offsets.h
       UPD     include/generated/offsets.h
       CC      lib/libc/minimal/source/stdlib/strtol.o

     <snip>

       CC      kernel/work_q.o
       AR      kernel/lib.a
       CC      src/main.o
       LD      src/built-in.o
       AR      libzephyr.a
       LINK    zephyr.lnk
       IRQ     isr_tables.c
       CC      isr_tables.o
       LINK    zephyr.elf
       BIN     zephyr.bin
     pyOCD GDB server running on port 3333
     GNU gdb (GDB) 7.11.0.20160511-git
     Copyright (C) 2016 Free Software Foundation, Inc.
     License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
     This is free software: you are free to change and redistribute it.
     There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
     and "show warranty" for details.
     This GDB was configured as "--host=x86_64-pokysdk-linux --target=arm-zephyr-eabi".
     Type "show configuration" for configuration details.
     For bug reporting instructions, please see:
     <http://www.gnu.org/software/gdb/bugs/>.
     Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.
     For help, type "help".
     Type "apropos word" to search for commands related to "word"...
     Reading symbols from /home/maureen/zephyr/samples/hello_world/outdir/frdm_k64f/zephyr.elf...done.
     INFO:root:DAP SWD MODE initialised
     INFO:root:K64F not in secure state
     INFO:root:ROM table #0 @ 0xe00ff000 cidr=b105100d pidr=4000bb4c4
     INFO:root:[0]<e000e000:SCS-M4 cidr=b105e00d, pidr=4000bb00c, class=14>
     WARNING:root:Invalid coresight component, cidr=0x0
     INFO:root:[1]<e0001000: cidr=0, pidr=0, component invalid>
     INFO:root:[2]<e0002000:FPB cidr=b105e00d, pidr=4002bb003, class=14>
     WARNING:root:Invalid coresight component, cidr=0x1010101
     INFO:root:[3]<e0000000: cidr=1010101, pidr=101010101010101, component invalid>
     WARNING:root:Invalid coresight component, cidr=0x0
     INFO:root:[4]<e0040000: cidr=0, pidr=0, component invalid>
     INFO:root:[5]<e0041000:ETM-M4 cidr=b105900d, pidr=4000bb925, class=9, devtype=13, devid=0>
     INFO:root:[6]<e0042000:ETB cidr=b105900d, pidr=4003bb907, class=9, devtype=21, devid=0>
     INFO:root:[7]<e0043000:CSTF cidr=b105900d, pidr=4001bb908, class=9, devtype=12, devid=28>
     INFO:root:CPU core is Cortex-M4
     INFO:root:FPU present
     INFO:root:6 hardware breakpoints, 4 literal comparators
     INFO:root:4 hardware watchpoints
     INFO:root:Telnet: server started on port 4444
     INFO:root:GDB server started at port:3333
     Remote debugging using :3333
     INFO:root:One client connected!
     k_cpu_idle () at /home/maureen/zephyr/arch/arm/core/cpu_idle.S:135
     135		bx lr
     Loading section text, size 0x233e lma 0x0
     Loading section devconfig, size 0xa8 lma 0x2340
     Loading section rodata, size 0x5d4 lma 0x23e8
     Loading section datas, size 0x14 lma 0x29bc
     Loading section initlevel, size 0xa8 lma 0x29d0
     [====================] 100%
     INFO:root:Programmed 45056 bytes (3 pages) at 38.21 kB/s
     Start address 0x1b64, load size 10870
     Transfer rate: 9 KB/sec, 1207 bytes/write.
     (gdb)


.. _nxp_opensda_jlink:

Segger J-Link
*************

Segger offers firmware running on the OpenSDA platform which makes OpenSDA
compatible to J-Link Lite, allowing users to take advantage of most J-Link
features like the ultra fast flash download and debugging speed or the
free-to-use GDB Server, by using a low-cost OpenSDA platform for developing on
evaluation boards.

Host Tools and Firmware
=======================

Download and install the `Segger J-Link Software and Documentation Pack`_ to
get the J-Link GDB server for your host computer.

Select your board in `OpenSDA`_ and download the Segger J-Link firmware
application binary. :ref:`nxp_opensda_firmware` with this application.

Flashing
========

The Segger J-Link firmware does not support command line flashing, therefore
the ``make flash`` build target is not supported.

Debugging
=========

Use the ``make debug`` build target with ``OPENSDA_FW=jlink`` to build your
Zephyr application, invoke the J-Link GDB server, attach a GDB client, and
program your Zephyr application to flash. It will leave you at a gdb prompt.

  .. code-block:: console

     $ make OPENSDA_FW=jlink debug
     Using /home/maureen/zephyr/boards/arm/frdm_k64f/frdm_k64f_defconfig as base
     Merging /home/maureen/zephyr/tests/include/test.config
     Merging prj.conf
     #
     # configuration written to .config
     #
     make[1]: Entering directory '/home/maureen/zephyr'
     make[2]: Entering directory '/home/maureen/zephyr/samples/hello_world/outdir/frdm_k64f'
       GEN     ./Makefile
     scripts/kconfig/conf --silentoldconfig Kconfig
       Using /home/maureen/zephyr as source for kernel
       GEN     ./Makefile
       CHK     include/generated/version.h
       UPD     include/generated/version.h
       DTC     dts/arm/frdm_k64f.dts_compiled
       CHK     include/generated/generated_dts_board.h
       UPD     include/generated/generated_dts_board.h
       CHK     misc/generated/configs.c
       UPD     misc/generated/configs.c
       CHK     include/generated/offsets.h
       UPD     include/generated/offsets.h
       CC      lib/libc/minimal/source/stdlib/strtol.o

     <snip>

       CC      kernel/work_q.o
       AR      kernel/lib.a
       CC      src/main.o
       LD      src/built-in.o
       AR      libzephyr.a
       LINK    zephyr.lnk
       IRQ     isr_tables.c
       CC      isr_tables.o
       LINK    zephyr.elf
       BIN     zephyr.bin
     JLink GDB server running on port 2331
     SEGGER J-Link GDB Server V6.14b Command Line Version

     JLinkARM.dll V6.14b (DLL compiled Mar  9 2017 08:48:20)

     -----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:               on
     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:                 MK64FN1M0xxx12
     Target interface:              SWD
     Target interface speed:        1000kHz
     Target endian:                 little

     Connecting to J-Link...
     GNU gdb (GDB) 7.11.0.20160511-git
     Copyright (C) 2016 Free Software Foundation, Inc.
     License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
     This is free software: you are free to change and redistribute it.
     There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
     and "show warranty" for details.
     This GDB was configured as "--host=x86_64-pokysdk-linux --target=arm-zephyr-eabi".
     Type "show configuration" for configuration details.
     For bug reporting instructions, please see:
     <http://www.gnu.org/software/gdb/bugs/>.
     Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.
     For help, type "help".
     Type "apropos word" to search for commands related to "word"...
     Reading symbols from /home/maureen/zephyr/samples/hello_world/outdir/frdm_k64f/zephyr.elf...done.
     J-Link is connected.
     Firmware: J-Link OpenSDA 2 compiled Feb 28 2017 19:27:57
     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...Remote debugging using :2331
     Connected to 127.0.0.1
     Reading all registers
     Read 4 bytes @ address 0x00001A04 (Data = 0xBF004770)
     Read 2 bytes @ address 0x000019FC (Data = 0x4040)
     Read 2 bytes @ address 0x000019FE (Data = 0xF380)
     Read 2 bytes @ address 0x00001A00 (Data = 0x8811)
     Read 2 bytes @ address 0x00001A02 (Data = 0xBF30)
     k_cpu_idle () at /home/maureen/zephyr/arch/arm/core/cpu_idle.S:135
     135		bx lr
     Halting target CPU...
     ...Target halted (PC = 0x00001A04)
     Loading section text, size 0x233e lma 0x0
     Downloading 4096 bytes @ address 0x00000000
     Downloading 4096 bytes @ address 0x00001000
     Downloading 830 bytes @ address 0x00002000
     Loading section devconfig, size 0xa8 lma 0x2340
     Downloading 168 bytes @ address 0x00002340
     Loading section rodata, size 0x5d4 lma 0x23e8
     Downloading 1492 bytes @ address 0x000023E8
     Loading section datas, size 0x14 lma 0x29bc
     Downloading 20 bytes @ address 0x000029BC
     Loading section initlevel, size 0xa8 lma 0x29d0
     Downloading 168 bytes @ address 0x000029D0
     Start address 0x1b64, load size 10870
     Writing register (PC = 0x641b0000)
     Transfer rate: 5307 KB/sec, 1552 bytes/write.
     Read 4 bytes @ address 0x00001B64 (Data = 0xF3802010)
     Resetting target
     Resetting target
     (gdb)


Console
=======

If you configured your Zephyr application to use a UART console (most boards
enable this by default), open a serial terminal (minicom, putty, etc.) with the
following settings:

   - Speed: 115200
   - Data: 8 bits
   - Parity: None
   - Stop bits: 1

If you configured your Zephyr application to use `Segger RTT`_ console instead,
open telnet:

  .. code-block:: console

     $ telnet localhost 19021
     Trying 127.0.0.1...
     Connected to localhost.
     Escape character is '^]'.
     SEGGER J-Link V6.14b - Real time terminal output
     J-Link OpenSDA 2 compiled Feb 28 2017 19:27:57 V1.0, SN=621000000
     Process: JLinkGDBServer


.. _OpenSDA:
   http://www.nxp.com/opensda

.. _Segger J-Link OpenSDA:
   https://www.segger.com/opensda.html

.. _Segger J-Link Software and Documentation Pack:
   https://www.segger.com/downloads/jlink

.. _Segger RTT:
    https://www.segger.com/jlink-rtt.html

.. _pyOCD Installation:
   https://github.com/mbedmicro/pyOCD#installation