gdb -- FreeScale / NXP Kinetis Tower K64F120M (Arch Linux)

来源:互联网 发布:2016老男孩python十期 编辑:程序博客网 时间:2024/06/05 15:00
origin: http://nuttx.org/doku.php?id=wiki:getting-started:kinetis-twr-k64f120m&s[]=debug&s[]=jlink

Here we will try to set up a functional Nuttx environment on a TWR-K64F120M Tower evaluation board, combined with the TWR-SER for Ethernet access on Arch Linux OS.

This may be applicable to other Linux distributions as well.

We will install the required software components, configure the board with the following configurations:

  • nsh: uses the main board only. nsh prompt will be available on OpenSDA serial bridge. SDHC card is automounted in /mnt/sdcard
  • netnsh: uses main board coupled with TWR-SER board. nsh prompt will be available on both OpenSDA serial bridge and Ethernet
Installing the ARM tool chain

See “Getting Started with NuttX – Nucleo STM32F303 (Arch Linux)” page for instructions.

Install Nuttx
$ mkdir twr-k64f120m; cd twr-k64f120m$ git clone https://bitbucket.org/nuttx/nuttx$ git clone https://bitbucket.org/nuttx/apps$ cd nuttx$ cd tools$ ./configure.sh twr-k64f120m/nsh  or$ ./configure.sh twr-k64f120m/netnsh

Now compile Nuttx (output truncated):

$ make...LD: nuttxmake[1]: Leaving directory '/home/myhome/projets/twr-k64f120m/nuttx/arch/arm/src'CP: nuttx.hex

One can see the firmware nuttx.hex has been successfully generated.

Flash &debug with JLInk OpenSDA and gdb

Should you not have a JTAG probe, JLink is kindly providing a proprietary OpenSDA V2 firmware which will allow to flash anddebug with JLink software trhoug the USB link,while still keeping the serial bridge feature.

So please install this firwmare on your tower kit. See https://www.segger.com/opensda.html for instructions

The JLink software is available on Arch AUR: jlink-software-and-documentation. Please install it.

In the nuttx directory, you may prepare a .gdbinit file with:

target remote localhost:2331monitor reset

It will allow gdb to automatically connect to the JLink server.

udev rules:

JLink package comes with a 99-jlink.rules already installed in /etc/udev/rules.d, so nothing special should be done her.

Make sure your OpenSDA serial is recognized properly. Plug your TWR-K64F120M to the USB connector (Power/OpenSDA Mini-USB).

Check that your board is detected properly:

ls -l /dev/ttyA*crw-rw-rw- 1 root uucp 166, 0 25 oct.  08:11 /dev/ttyACM0

let's try to connect to OpenSDA

While your TWR-K64F120M is connected with the USB cable, start JLink server:

$ JLinkGDBServer -device MK64FN1M0xxx12 -if SWD -speed 4000 -endian little -vdSEGGER J-Link GDB Server V5.12 Command Line VersionJLinkARM.dll V5.12 (DLL compiled Mar 30 2016 17:29:06)-----GDB Server start settings-----GDBInit file:                  noneGDB Server Listening port:     2331SWO raw output listening port: 2332Terminal I/O port:             2333Accept remote connection:      yesGenerate logfile:              offVerify download:               onInit regs on start:            offSilent mode:                   offSingle run mode:               offTarget connection timeout:     0 ms------J-Link related settings------J-Link Host interface:         USBJ-Link script:                 noneJ-Link settings file:          none------Target related settings------Target device:                 MK64FN1M0xxx12Target interface:              SWDTarget interface speed:        4000kHzTarget endian:                 littleConnecting to J-Link...J-Link is connected.Firmware: J-Link OpenSDA compiled Jan  4 2017 16:04:51Hardware: V1.00S/N: 621000000Checking target voltage...Target voltage: 3.30 VListening on TCP/IP port 2331Connecting to target...Connected to targetWaiting for GDB connection...

So far so good, in an other dedicated terminal session (cd in nuttx before), start gdb. It should automatically connect toJLink server:

$ arm-none-eabi-gdb nuttxGNU gdb (GDB) 7.12.1Copyright (C) 2017 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-pc-linux-gnu --target=arm-none-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 nuttx...done.__start () at chip/kinetis_start.c:273273{Resetting target(gdb)

Now load the firmware into the TWR-K64F120M MCU. In gdb type:

(gdb) loadLoading section .vectors, size 0x198 lma 0x0Loading section .cfmprotect, size 0x10 lma 0x400Loading section .text, size 0x32079 lma 0x800Loading section .ARM.exidx, size 0x8 lma 0x3287cLoading section .data, size 0x1dc lma 0x32884Loading section .ramfunc, size 0x6c lma 0x32a60Start address 0xb3c, load size 205937Transfer rate: 40222 KB/sec, 11440 bytes/write.(gdb) 

Run the code. In gdb type:

(gdb) mon resetResetting target(gdb) cContinuing.

The Green LED should be ON on the TWR-K64F120M board. Orange and Red leds should flash faintly according to IRQ and SIGNAL activity.

To stop the code, press Ctlrl+C

For more information on openSDA: www.nxp.com/pages/opensda-serial-and-debug-adapter:OPENSDAand for GNU gdb:https://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_toc.html

GNU Make doc may be also valuable: https://www.gnu.org/software/make/manual/make.html

Connect to the OpenSDA serial console

Open a new terminal and run the minterm:

$ miniterm.py --filter direct /dev/ttyACM0 115200miniterm.py /dev/ttyACM0 115200--- Miniterm on /dev/ttyACM0  115200,8,N,1 ------ Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

Press the RESET button on the TWR-K64120M board, one should see the following in the terminal window:

__start: Reset status: 00:00Mounting procfs to /procSuccessfully bound SDHC to the MMC/SD driverfat_checkbootrecord: ERROR: Signature: aa55 FS sectorsize: 0 HW sectorsize: 512NuttShell (NSH)nsh> 

At this stage the SD card (if any) should be automatically mounted on /mnt/sdcard

Congratulation ! You are started with Nuttx !

Navigation
  • Home
  • Downloads
  • Documentation
  • Forum
  • Wiki
  • Links
Print/export
  • Download as PDF
  • Printable version
Toolbox
  • What links here
  • Recent changes
  • Media Manager
  • Site index
  • Permanent link
  • Cite this page

原创粉丝点击