DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Unraveling Lombok's Code Design Pitfalls: Exploring Encapsulation Issues
  • Making GDB Suck Less
  • Common Mistakes to Avoid When Writing SQL Code
  • TURN Time Into Value

Trending

  • The Emergence of Cloud-Native Integration Patterns in Modern Enterprises
  • Development of Custom Web Applications Within SAP Business Technology Platform
  • 12 Agile Principles for Successful Agile Development Practices
  • Application Integration for IoT Devices: A Detailed Guide To Unifying Your Ecosystem
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Batch Programming with GDB: Segger J-Link and P&E Multilink

Batch Programming with GDB: Segger J-Link and P&E Multilink

Use the command line to do some efficient batch programming for your firmware boards

Erich Styger user avatar by
Erich Styger
·
Aug. 31, 15 · Tutorial
Like (1)
Save
Tweet
Share
2.73K Views

Join the DZone community and get the full member experience.

Join For Free

I need to program several boards with a firmware: a number too small for serious batch/factory programming, but a number too high for doing this with the debugger. I want this:

  1. Connect the board with the debug probe and power it
  2. Run a script to flash the program and run it
  3. Disconnect and restart step 1.

Need to program a few boards…

Outline

With “Command Line Programming and Debugging with GDB” I have pretty much everything in place. So I only need to combine things into a solution. Because it's different depending on if you're using the P&E Multilink or Segger J-Link, I have covered both methods. I’m using the Eclipse-based Kinetis Design Studio v3.0.0, but a command line gdb installation can be used too.

P&E Multilink

I’m using the following batch file to start the P&E GDB server, followed by starting the gdb client. Change paths accordingly:


REM Start P&E GDB Server with single session
call "cmd /c start C:\Freescale\KDS_3.0.0\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_2.0.8.201504092111\win32\pegdbserver_console.exe -startserver -singlesession -device=Freescale_K6x_K64FN1M0M12"

REM start gdb with script
C:\Freescale\KDS_3.0.0\arm-none-eabi-gdb -x gdbScript.txt

The option -singlesession to the P&E server is a nice feature: it will terminate the server after the session is finished. I’m using the Freescale K64F in the above example, so make sure the -device option matches your target.

The gdb uses the option -x uses this gdb script file:


# gdbscript.txt: script for gdb. Run it with
# gdb -x <commandFile>

# disable confirmation messages (y or no):
set confirm off

# connect to P&E gdb server:
target remote localhost:7224

# reset target:
monitor reset

# load symbols for application (not necessary for flashing only):
# file MyProject/Debug/MyProject.elf

# load application:
load MyProject/Debug/MyProject.elf

# detach from target. As a side effect, this will start it:
detach

# quit gdb:
quit

Segger J-Link

With the Segger J-Link, I need to launch the GDB server first (make sure it's not already running):

c:\Freescale\KDS_3.0.0\segger\JLinkGDBServerCL.exe

SEGGER GDB Server running

In a separate cmd/shell window, I run this script:

c:\Freescale\KDS_3.0.0\toolchain\bin\arm-none-eabi-gdb.exe -x gdbscript.txt

Segger GDB Script

The script has the following content to load the file, run it and then disconnect:


# gdb script
target remote localhost:2331
monitor device MK64FN1M0xxx12
monitor reset
load ./Debug/FRDM-K64F_FreeRTOS_8.2.1.elf
# load symbols, not necessary for flashing only
# file ./Debug/FRDM-K64F_FreeRTOS_8.2.1.elf
monitor go
disconnect
quit

Make sure you update the device and target image/path settings.

The difference with the P&E version is that the Segger J-Link server keeps running. I have not found a way to make that part automated.

Summary

There is no IDE or complicated setup necessary to batch program a set of boards: all that you need are some gdb scripts, and I can program and run one board after each other in a series of boards.

IT Design Debug (command) Session (web analytics) Firmware Command (computing) Integrated development environment

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Unraveling Lombok's Code Design Pitfalls: Exploring Encapsulation Issues
  • Making GDB Suck Less
  • Common Mistakes to Avoid When Writing SQL Code
  • TURN Time Into Value

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: