dave:嵌入式设备通过semihost机制输出调试信息到调试主机

版权声明:博客地址:blog.csdn.net/x356982611,未经允许不得转载,不得转载,不得转载 https://blog.csdn.net/x356982611/article/details/81713760

简介

semihost 是arm的一种机制,把运行设备的输入输出请求传递给运行调试器的主机,利用这种机制,可以使用主机的屏幕和键盘,而不用在嵌入式目标系统上使用屏幕和键盘。可以使用此机制启用C库中的函数,例如printf()和scanf()

下面的例子是printf打印到调试窗口,工具为DAVEv4,其他版本的可能不一样些

  1. 新建工程
    这里写图片描述

  2. 新建调试配置,使能Semihosting
    这里写图片描述

  3. 打开semihost输出窗口
    这里写图片描述

  4. 修改工程属性中的 “C/c++ Build” - “ARM-GCC C Linker” -” miscellaneous”-“Other flags” 选项
    -specs=rdimon.specs

这里写图片描述

  1. 添加初始化代码
/*
 * main.c
 *
 *  Created on: 2018 Aug 16 09:51:30
 *  Author: ink
 */



#include <xmc_common.h>
#include <stdio.h>

/**

 * @brief main() - Application entry point
 *
 * <b>Details of function</b><br>
 * This routine is the application entry point. It is invoked by the device startup code. 
 */
extern void initialise_monitor_handles(void);

int main(void)
{

    initialise_monitor_handles();

  /* Placeholder for user application code. The while loop below can be replaced with user application code. */
  while(1U)
  {
      printf("semihost:output to console\n");
  }
}
  1. 调试运行,printf就能输出到semihost console窗口
    这里写图片描述

示例工程

https://download.csdn.net/download/x356982611/10607743

引用

https://www.infineonforums.com/threads/3489-DAVE-TIP-of-the-day-Semihosting-in-DAVEv4?tdsourcetag=s_pctim_aiomsg
https://blog.csdn.net/x356982611/article/details/81713760

猜你喜欢

转载自blog.csdn.net/x356982611/article/details/81713760