2022-08-23 15:00:33 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=9" / >
< meta name = "generator" content = "Doxygen 1.8.5" / >
2023-08-31 15:30:31 +00:00
< title > MCUXpresso SDK API Reference Manual: Semihosting< / title >
2022-08-23 15:00:33 +00:00
< link href = "tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "jquery.js" > < / script >
< script type = "text/javascript" src = "dynsections.js" > < / script >
< link href = "navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "resize.js" > < / script >
< script type = "text/javascript" src = "navtree.js" > < / script >
< script type = "text/javascript" >
$(document).ready(initResizable);
$(window).load(resizeHeight);
< / script >
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "search/search.js" > < / script >
< script type = "text/javascript" >
$(document).ready(function() { searchBox.OnSelectItem(0); });
< / script >
< link href = "doxygen.css" rel = "stylesheet" type = "text/css" / >
< link href = "customdoxygen.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
< tr style = "height: 56px;" >
< td id = "projectlogo" > < img alt = "Logo" src = "fs_logo.gif" / > < / td >
< td style = "padding-left: 0.5em;" >
< div id = "projectname" > MCUXpresso SDK API Reference Manual
2024-03-15 14:23:36 +00:00
  < span id = "projectnumber" > Rev 2.15.000< / span >
2022-08-23 15:00:33 +00:00
< / div >
< div id = "projectbrief" > NXP Semiconductors< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
< script type = "text/javascript" >
var searchBox = new SearchBox("searchBox", "search",false,'Search');
< / script >
< div id = "navrow1" class = "tabs" >
< ul class = "tablist" >
< li > < a href = "index.html" > < span > Main  Page< / span > < / a > < / li >
< li > < a href = "pages.html" > < span > Related  Pages< / span > < / a > < / li >
< li > < a href = "modules.html" > < span > API  Reference< / span > < / a > < / li >
< li >
< div id = "MSearchBox" class = "MSearchBoxInactive" >
< span class = "left" >
< img id = "MSearchSelect" src = "search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
< input type = "text" id = "MSearchField" value = "Search" accesskey = "S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
< / span > < span class = "right" >
< a id = "MSearchClose" href = "javascript:searchBox.CloseResultsWindow()" > < img id = "MSearchCloseImg" border = "0" src = "search/close.png" alt = "" / > < / a >
< / span >
< / div >
< / li >
< / ul >
< / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
$(document).ready(function(){initNavTree('a00283.html','');});
< / script >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(0)" > < span class = "SelectionMark" >   < / span > All< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(1)" > < span class = "SelectionMark" >   < / span > Data Structures< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(2)" > < span class = "SelectionMark" >   < / span > Functions< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(3)" > < span class = "SelectionMark" >   < / span > Variables< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(4)" > < span class = "SelectionMark" >   < / span > Typedefs< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(5)" > < span class = "SelectionMark" >   < / span > Enumerations< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(6)" > < span class = "SelectionMark" >   < / span > Enumerator< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(7)" > < span class = "SelectionMark" >   < / span > Groups< / a > < a class = "SelectItem" href = "javascript:void(0)" onclick = "searchBox.OnSelectItem(8)" > < span class = "SelectionMark" >   < / span > Pages< / a > < / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< iframe src = "javascript:void(0)" frameborder = "0"
name="MSearchResults" id="MSearchResults">
< / iframe >
< / div >
< div class = "header" >
< div class = "headertitle" >
2023-08-31 15:30:31 +00:00
< div class = "title" > Semihosting< div class = "ingroups" > < a class = "el" href = "a00281.html" > Debug Console< / a > < / div > < / div > < / div >
2022-08-23 15:00:33 +00:00
< / div > <!-- header -->
< div class = "contents" >
2023-08-31 15:30:31 +00:00
< p > Semihosting is a mechanism for ARM targets to communicate input/output requests from application code to a host computer running a debugger. This mechanism can be used, for example, to enable functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host rather than having a screen and keyboard on the target system.< / p >
< h1 > < a class = "anchor" id = "SemihostingGrps" > < / a >
Guide Semihosting for IAR< / h1 >
< p > < b > NOTE:< / b > After the setting both "printf" and "scanf" are available for debugging, if you want use PRINTF with semihosting, please make sure the SDK_DEBUGCONSOLE is DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN.< / p >
< h2 > Step 1: Setting up the environment< / h2 >
< ol type = "1" >
< li > To set debugger options, choose Project> Options. In the Debugger category, click the Setup tab.< / li >
< li > Select Run to main and click OK. This ensures that the debug session starts by running the main function.< / li >
< li > The project is now ready to be built.< / li >
< / ol >
< h2 > Step 2: Building the project< / h2 >
< ol type = "1" >
< li > Compile and link the project by choosing Project> Make or F7.< / li >
< li > Alternatively, click the Make button on the tool bar. The Make command compiles and links those files that have been modified.< / li >
< / ol >
< h2 > Step 3: Starting semihosting< / h2 >
< ol type = "1" >
< li > Choose "Semihosting_IAR" project -> "Options" -> "Debugger" -> "J-Link/J-Trace".< / li >
< li > Choose tab "J-Link/J-Trace" -> "Connection" tab -> "SWD".< / li >
< li > Choose tab "General Options" -> "Library Configurations", select Semihosted, select Via semihosting. Please Make sure the SDK_DEBUGCONSOLE_UART is not defined in project settings.< / li >
< li > Start the project by choosing Project> Download and Debug.< / li >
< li > Choose View> Terminal I/O to display the output from the I/O operations.< / li >
< / ol >
< h1 > < a class = "anchor" id = "SemihostingKeilGrps" > < / a >
Guide Semihosting for Keil µVision< / h1 >
< p > < b > NOTE:< / b > Semihosting is not support by MDK-ARM, use the retargeting functionality of MDK-ARM instead.< / p >
< h1 > < a class = "anchor" id = "SemihostingGrps9" > < / a >
Guide Semihosting for MCUXpresso IDE< / h1 >
< h2 > Step 1: Setting up the environment< / h2 >
< ol type = "1" >
< li > To set debugger options, choose Project> Properties. select the setting category.< / li >
< li > Select Tool Settings, unfold MCU C Compile.< / li >
< li > Select Preprocessor item.< / li >
< li > Set SDK_DEBUGCONSOLE=0, if set SDK_DEBUGCONSOLE=1, the log will be redirect to the UART.< / li >
< / ol >
< h2 > Step 2: Building the project< / h2 >
< ol type = "1" >
< li > Compile and link the project.< / li >
< / ol >
< h2 > Step 3: Starting semihosting< / h2 >
< ol type = "1" >
< li > Download and debug the project.< / li >
< li > When the project runs successfully, the result can be seen in the Console window.< / li >
< / ol >
< p > Semihosting can also be selected through the "Quick settings" menu in the left bottom window, Quick settings-> SDK Debug Console-> Semihost console.< / p >
< h1 > < a class = "anchor" id = "SemihostingGrps11" > < / a >
Guide Semihosting for ARMGCC< / h1 >
< h2 > Step 1: Setting up the environment< / h2 >
< ol type = "1" >
< li > Turn on "J-LINK GDB Server" -> Select suitable "Target device" -> "OK".< / li >
< li > Turn on "PuTTY". Set up as follows.< ul >
< li > "Host Name (or IP address)" : localhost< / li >
< li > "Port" :2333< / li >
< li > "Connection type" : Telet.< / li >
< li > Click "Open".< / li >
< / ul >
< / li >
< li > Increase "Heap/Stack" for GCC to 0x2000: < / li >
< / ol >
< p > < b > Add to "CMakeLists.txt" < / b > < / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} --defsym=__stack_size__=0x2000")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --defsym=__stack_size__=0x2000")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --defsym=__heap_size__=0x2000")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} --defsym=__heap_size__=0x2000") < / p >
< h2 > Step 2: Building the project< / h2 >
< ol >
< li >
< p class = "startli" > Change "CMakeLists.txt": < / p >
< p > < b > Change < / b > "SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} – specs=nano.specs")" < / p >
< p > < b > to < / b > "SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} – specs=rdimon.specs")"< / p >
< p > < / p >
< p > < b > Replace paragraph < / b > < / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fno-common")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -ffunction-sections")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fdata-sections")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -ffreestanding")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fno-builtin")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -mthumb")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -mapcs")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --gc-sections")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -static")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -z")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker")< / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} muldefs")< / p >
< p > < / p >
< p > < b > To < / b > < / p >
< p > < / p >
< p > SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --specs=rdimon.specs ") < / p >
< p > < / p >
< p > < / p >
< p > < b > Remove < / b > < / p >
< p > target_link_libraries(semihosting_ARMGCC.elf debug nosys)< / p >
< p class = "endli" > < / p >
< / li >
< li >
Run "build_debug.bat" to build project < / li >
< / ol >
< h2 > Step 3: Starting semihosting< / h2 >
< ol type = "1" >
< li > Download the image and set as follows. < div class = "fragment" > < div class = "line" > cd D:\mcu-sdk-2.0-origin\boards\twrk64f120m\driver_examples\semihosting\armgcc\debug< / div >
< div class = "line" > d:< / div >
< div class = "line" > C:\PROGRA~2\GNUTOO~1\4BD65~1.920\bin\arm-none-eabi-gdb.exe< / div >
< div class = "line" > target remote localhost:2331< / div >
< div class = "line" > monitor reset< / div >
< div class = "line" > monitor semihosting enable< / div >
< div class = "line" > monitor semihosting thumbSWI 0xAB< / div >
< div class = "line" > monitor semihosting IOClient 1< / div >
< div class = "line" > monitor flash device = MK64FN1M0xxx12< / div >
< div class = "line" > load semihosting_ARMGCC.elf< / div >
< div class = "line" > monitor reg pc = (0x00000004)< / div >
< div class = "line" > monitor reg sp = (0x00000000)< / div >
< div class = "line" > < span class = "keywordflow" > continue< / span > < / div >
< / div > <!-- fragment --> < / li >
< li > After the setting, press "enter". The PuTTY window now shows the printf() output. < / li >
< / ol >
2022-08-23 15:00:33 +00:00
< / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- HTML footer for doxygen 1.8.5 -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul class = "foot" >
< li class = "footer" > © 2016 NXP Semiconductors. All rights reserved.
< / li >
< / ul >
< / div >
< / body >
< / html >