How Do We Debug in Embedded System

  In short, for bare metal embedded development, we highly recommend solutions that can be used on all major platforms (Windows, macOS and GNU/Linux), with hardware probes that implement the SWD protocol and support tracing via the SWO pin. The preferred probes that match the above requirements are J-Link EDU/J-Link, from SEGGER.

Overview

  Although it varies a lot depending on personal skills and experience, debugging can be one of the most time consuming activities during software development, and any solutions intended to address it are welcome.

Generally there are two approaches:

  • manually stepping through the code to check the program flow and inspect various status variables
  • letting the program run and automatically collect various tracing messages (like the traditional printf() calls) and/or execution events (enter/exit interrupt handlers, memory location change, etc)

  To be noted that these approaches are not exclusive, but complement each other, since they better serve different purposes, and have specific advantages and disadvantages.

Manual stepping

  Manually stepping through the code is great for debugging a standalone linear piece of code, to check if the implementation of an algorithm is correct, to detect off-by-one errors (accessing past the size of an array or collection). It is also useful to get an initial understanding of the functionality of a piece of code written by someone else. Its main drawback is severely distorting the time behaviour of the debugged code, which, if the debugged device is interacting with other external devices, will most likely trigger timeouts. For complex code, with multiple iterations and multiple processes, it is quite tedious, requiring a lot of manual interactions with the debugger to reach the desired point in time, especially when the sessions are expected to be restarted often.

  The manual stepping approach generally requires a generic debugger and a specific method to connect it to the application to be debugged. The GNU toolchains provide a standard gdb command line tool to interact with the debugged application, and Eclipse provides various plug-ins to integrate the command line tool into the IDE.

  The recommended way to connect gdb, running on the development machine, to the application, running on an embedded device, is to use a gdb server.

  If the debugged application is a GNU/Linux ARM application, running on an embedded device like BeagleBone or Raspberry, the gdb server must be first installed and started on it, then the gdb client needs to be instructed to connect via tcp/ip to it and start the debug session.

  If the debugged application runs on a bare metal device, then it is necessary to use a physical probe, to load the device memory and to assist during the debugging session. The standard way is to use a JTAG or SWD probe, paired with a custom gdb server, able to talk to it on one side, and to accept the standard gdb commands on the other side.

Using trace messages

  Collecting tracing messages and events, when used wisely, can be a valuable source of information regarding the flow of a complex application, with multiple interacting threads, being especially useful when the debug sessions are restarted often. Once the trace messages are added, the dynamic life of various threads/handlers can be seen with a simple view of the trace log.

  In addition to classical printf() messages that need to be manually inserted in the code, for embedded applications, modern ARM cores, including those in the Cortex-M families, provide special support for collecting hardware events, like accurate timestamps when an interrupt handler was entered/exited, when a memory location was accessed, and more.

  Recognising the importance of these methods, the designers of the ARM families added special support, like the SWO (Serial Wire Output) pin in Cortex-M processors, or even more elaborate interfaces for larger ARM processors.

GDB

  The tool used by GNU ARM Eclipse plug-ins for debugging is the ARM version of GDB, the venerable GNU debugging tool.

This Article is From: GUN ARM Eclipse

时间: 2024-10-18 14:57:07

How Do We Debug in Embedded System的相关文章

嵌入式(Embedded System)笔记 —— Cortex-M3 Introduction and Basics(上)

随着课内的学习,我想把每节课所学记录下来,以作查阅.以饲读者.由于我所上的是英文班课程,因此我将把关键术语的英文给出,甚至有些内容直接使用英文. 本次所介绍内容是关于Cortex-M3的基础内容. ------------------------------------------------------------------------------------------------------------------------------------------------ 1.什么是嵌

Embedded System.

Soc ( System on Chip) Soc is an integrated circuit (IC) that integrates all components of a computer or otherelectronic system into a single chip. It may contain digital, analog, mixed-signal, and often radio-frequency functions—all on a single chips

微软职位内部推荐-SW Engineer II for Embedded System

微软近期Open的职位: Do you have a passion for embedded devices and services? &nbsp Does the following make you excited: Internet of Things, Industrial, Home Automation and Next Generation of Embedded OS based on Windows 10? &nbsp If so, you need not look

嵌入式(Embedded System)笔记 —— Cortex-M3 Introduction and Basics(下)

随着课内的学习,我想把每节课所学记录下来,以作查阅.以饲读者.由于我所上的是英文班课程,因此我将把关键术语的英文给出,甚至有些内容直接使用英文. 本次所介绍内容仍是关于Cortex-M3的基础内容,相对上一篇来说,介绍的内容更加具体和细致了. --------------------------------------------------------------------------------------------------------------------------------

CSYE 7374: IoT Embedded System

CSYE 7374: IoT Embedded SystemsAssignment 2Due on 2/5/201) Given the following C update function, what does the FSM look like ? Assume push andpop are input pure signals and the return value of the function is a pure output signal calledoutput. In ad

debugging requires the debug connect session system privilege.

通过pl/sql调试存储过程时报错 很明显是当前用户权限不足.那就为它补足权限.

Single-stack real-time operating system for embedded systems

A real time operating system (RTOS) for embedded controllers having limited memory includes a continuations library, a wide range of macros that hide continuation point management, nested blocking functions, and a communications stack. The RTOS execu

System.Diagnostics.Debug和System.Diagnostics.Trace

在 .net 类库中有一个 system.diagnostics 命名空间,该命名空间提供了一些与系统进程.事件日志.和性能计数器进行交互的类库.当中包括了两个对开发人员而言十分有用的类——debug类和 trace类.本文介绍了这两个类的一些基本用途,旨在提高广大开发人员的开发效率. 使用debug类来帮助调试 调试程序对每个程序员来说是家常便饭.可是我们会经常遇到一些情况让我们头疼,例如: 当我们在开发一个界面控件的时候,简单的设断点会增加paint事件的响应次数,而造成的环境参数改变. 断

C# 的两种debug 方法

第一种:需要把调试方法改成debug代码用 #if DEBUG 包裹 using System; using System.Collections.Generic; using System.Text; using System.IO; namespace SplitPackage { public static class EnvConfig { static EnvConfig() { #if DEBUG ToolsPath = @"D:\workspace\shopstyle\tool&q