<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eclipse Archives - Digital Me</title>
	<atom:link href="https://ba0sh1.com/tag/eclipse/feed/" rel="self" type="application/rss+xml" />
	<link>https://ba0sh1.com/tag/eclipse/</link>
	<description>Electronics, Computers at leisure time</description>
	<lastBuildDate>Sat, 25 May 2013 03:10:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.6</generator>
	<item>
		<title>Opensource STM32 development</title>
		<link>https://ba0sh1.com/2013/05/25/opensource-stm32-development/</link>
					<comments>https://ba0sh1.com/2013/05/25/opensource-stm32-development/#comments</comments>
		
		<dc:creator><![CDATA[Baoshi]]></dc:creator>
		<pubDate>Sat, 25 May 2013 03:10:06 +0000</pubDate>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[STM32]]></category>
		<guid isPermaLink="false">https://www.ba0sh1.com/?p=636</guid>

					<description><![CDATA[<p>In an upcoming project I need a micro controller that operates: 1x 16-bit DAC (SPI); 1x 24-bit ADC (SPI); 1x 8-bit parallel LCD; 1x rotary encoder; 1x PWM fan; 1x fan tachometer; 1x...</p>
<p>The post <a href="https://ba0sh1.com/2013/05/25/opensource-stm32-development/">Opensource STM32 development</a> appeared first on <a href="https://ba0sh1.com">Digital Me</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In an upcoming project I need a micro controller that operates: 1x 16-bit DAC (SPI); 1x 24-bit ADC (SPI); 1x 8-bit parallel LCD; 1x rotary encoder; 1x PWM fan; 1x fan tachometer; 1x temperature sensor (DS18B20); 2x analog switches; 1x uplink UART; 4x push buttons, and some voltage monitoring for various power rails. To my estimation these peripherals require about 40 pins. Considering the additional clock, power and programming/debug lines, the minimal pin count I&#8217;m going for is 64. So I went to element 14 parametric search to look for a suitable chip.</p>
<p><span id="more-636"></span>While lacking of choice is not always a real engineering problem, having too many choices is usually  more troublesome. My filtering for 64-100 pin devices resulted in 1638 devices from 17 manufactures&#8230; After <del>much</del> 1 second consideration I <del>finally</del> quickly made a decision. The winner is &#8212; STM32 ARM Cortex-M series. At the price point comparable to Microchip or Atmel&#8217;s 8-bit processor, I can jump onto 32-bit ARM development, how &#8220;IN&#8221; it is!</p>
<p>But the road that follows is not as smooth as I had imagined. STmicroelectronics has labelled themselves to be a &#8220;Hardware&#8221; manufacture so that they can excuse themselves from providing a usable compiler. While they do offer downloads of development tools from reputable vendors such as IAR or Keil, those tools are either &#8220;crippled&#8221; edition or time limited ware. I then spend several days looking for a guide to setup free or opensource ARM development tool-chain. There are quite a number of good resources online, for example, <a title="Tutorial: Setting-up ARM Cortex-M3 Development Enviroment using Codesourcery Toolchain, Eclipse, and Segger J-Link Debugger" href="http://deneb.homedns.org/things/?p=113" target="_blank" rel="noopener">here</a>, <a title="Setting up the GCC ARM Toolchain" href="http://hertaville.com/2012/05/28/gcc-arm-toolchain-stm32f0discovery/" target="_blank" rel="noopener">here</a> and <a title="Learning Eclipse &amp; ARM" href="https://sites.google.com/site/learningeclipsearm/2-software-installation" target="_blank" rel="noopener">here</a>. I&#8217;m not going to write &#8220;Yet Another &#8230;&#8221;, just document my approaches here, for note taking purposes.</p>
<h3>Mini-TOC</h3>
<ol>
<li><span style="line-height:13px;"><a href="#developmentplatform">Development Platform</a></span></li>
<li><a href="#commandlinetools">Command Line Tools</a></li>
<li><a href="#projectfolder">Project Folder</a></li>
<li><a href="#projecttemplate">Project Template</a></li>
<li><a href="#eclipseide">Eclipse IDE</a></li>
<li><a href="#importstm32project">Import STM32 Project</a></li>
<li><a href="#debuggingineclipse">Debugging in Eclipse</a></li>
<li><a href="#eclipseplugins">Eclipse Plugins</a></li>
<li><a href="#attachments">Downloads</a></li>
</ol>
<p><a name="developmentplatform"></a></p>
<h3>Development Platform</h3>
<p>My toolchain installation is on Windows 7. I have test it on both 32-bit and 64-bit editions. I have no plan to do development on Linux or Mac OSX yet, mainly because my other EDA tools are only available in Windows.<br />
<a name="commandlinetools"></a></p>
<h3>Command Line Tools</h3>
<p>Compiling program from the command line is probably the best experience to understand the compiler tools and the interaction among them. Most online resources recommend <a title="Sourcery G++ Lite" href="http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/" target="_blank" rel="noopener">Sourcery G++ Lite</a> as the compiler. I did try this and it works great. However Sourcery is not fully open source and I do not like the fact that you have to signup at Mentor to download it. I use the <a title="GCC ARM" href="https://launchpad.net/gcc-arm-embedded" target="_blank" rel="noopener">GNU tools for ARM</a>, because:</p>
<ol>
<li>It is fully open-source.</li>
<li>It is actively maintained by ARM employees.</li>
<li>It contains hardware float support (which is available on STM32F4) so more future-proof.</li>
</ol>
<p>I download the Windows ZIP package and extract it to C:Appsarmgcc. (C:Apps is the folder where I usually keep programs that do not need to be installed). I also add C:Appsarmgccbin to the user PATH.</p>
<p><del>GNU make utilities are also required. I download the Yagarto Tools package from <a title="Yagarto Tools" href="http://www.yagarto.de/download/yagarto/yagarto-tools-20121018-setup.exe">here</a>. GNU make from <a title="Make for Windows" href="http://gnuwin32.sourceforge.net/packages/make.htm" target="_blank" rel="noopener">here</a> is also usable but I found the one inside Yagarto Tools has better compatibility with many &#8220;Linux only&#8221; Makefiles.</del> GNU Make utility is required. Win32 version with supporting files is <a title="here" href="https://ba0sh1com.files.wordpress.com/2020/09/2c1c9-make.zip" target="_blank" rel="noopener">here</a>. I extract all the files to C:Appsbin and add the same to user PATH.</p>
<p>To verify the installation, open a Command Prompt and try these two commands:</p>
<ol>
<li><span style="line-height:13px;">arm-none-eabi-gcc -v</span></li>
<li>make -v
<p><figure id="attachment_641" aria-describedby="caption-attachment-641" style="width: 406px" class="wp-caption aligncenter"><a href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/38876-gccnmake.png" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" class="thumbnail  wp-image-641  " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/38876-gccnmake.png" alt="gcc and make" width="406" height="349" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/38876-gccnmake.png 677w, https://ba0sh1.com/wp-content/uploads/2013/05/38876-gccnmake-300x258.png 300w" sizes="(max-width: 406px) 100vw, 406px" /></a><figcaption id="caption-attachment-641" class="wp-caption-text">gcc and make</figcaption></figure></li>
</ol>
<p>I have heard some &#8220;make&#8221; utilities which maybe installed by other software such as the WinAVR or Delphi can conflict with the GNU make, so make sure &#8220;make -v&#8221; gives correct version information as &#8220;GNU make 3.81&#8221;. Otherwise just rename the make.exe to something else such as &#8220;gmake.exe&#8221;.</p>
<p><a name="projectfolder"></a></p>
<h3>Project Folder</h3>
<p>Many development tools, e.g.,  Arduino, MPLab, Atmel Studio, Altium Designer, etc, store user files in its own &#8220;workspace&#8221; or &#8220;project&#8221; folder. By default the folders are created under Windows user profile, but I prefer to move them to a central location to ease backup and sync. My central location is &#8220;D:workspace&#8221;. For STM32 I created a &#8220;D:workspaceSTM32&#8221; where I put all STM32 related files.<br />
ST Standard Peripheral Library is required for development. I downloaded the STM32F10x flavour and put it under d:workspaceSTM32STM32F10x_StdPeriph_Lib_V3.5.0</p>
<p><a name="projecttemplate"></a></p>
<h3><strong>Project Template</strong></h3>
<p>I tried several STM32 project templates available on the Internet, and finally I decided to make my own. The reason I do not like some templates are:</p>
<ol>
<li><span style="line-height:13px;">Some templates copy files from ST peripheral library to their own folder. This is only good if ST frequently modify their library interface, or you want to modify ST source code. I would rather keep ST library files in their original location and reference them from my Makefile.</span></li>
<li>Some templates compile all ST peripheral library files into one library archive (.a file). It is pretty wasteful if only part of the library are used. I choose to reference only the used ST library files.</li>
<li>Some template organize the Makefile into separate sub-makefiles and include them in the final one. It is good for large project. At currently I would rather use a monolithic Makefile to make life easier.</li>
</ol>
<p>As I have yet to learn how to create a GitHub account, my project template is attached <a href="#attachments">below</a>.<br />
Explanation for some snippets of the Makefile:</p>
<p>[code firstline=&#8221;10&#8243;]<br />
######################################<br />
# building variables<br />
######################################<br />
# debug build?<br />
DEBUG = 1<br />
# build for debug in ram?<br />
RAMBUILD = 0<br />
# optimization<br />
OPT = -O0<br />
[/code]</p>
<p>Here I set the variables controlling the build process:</p>
<ul>
<li>DEBUG is a general debugging switch. If defined as 0, no debug symbol is generated in the final .elf file.</li>
<li>RAMBUILD sets where the code is executed. If RAMBUILD = 0, the code is set to execute from Flash (starts from 0x08000000). Otherwise if RAMBUILD = 1, the code is executed from RAM (from 0x20000000). RAMBUILD selects the correct link script and interrupt vector table. It is always preferable to debug in RAM as the on-chip flash has a limited re-write cycle. The compiler will generate an error if RAM is not enough to host the complete program.</li>
<li>OPT is the optimization switch. Sometimes if RAM is not enough for debugging, use -Os to reduce program size.</li>
</ul>
<p>[code firstline=&#8221;20&#8243;]<br />
#######################################<br />
# paths<br />
#######################################<br />
# source path<br />
VPATH = src startup<br />
# firmware library path<br />
PERIPHLIBPATH = ../../STM32F10x_StdPeriph_Lib_V3.5.0/Libraries<br />
VPATH += $(PERIPHLIBPATH)/CMSIS/CM3/CoreSupport<br />
VPATH += $(PERIPHLIBPATH)/CMSIS/CM3/DeviceSupport/ST/STM32F10x<br />
VPATH += $(PERIPHLIBPATH)/STM32F10x_StdPeriph_Driver/src<br />
# Build path<br />
BUILD_DIR = build<br />
[/code]</p>
<p>Here various paths are listed, including the project source code (src and startup), ST peripheral library path and building path (BUILD_DIR). Source codes are located using VPATH directive.</p>
<p>[code firstline=&#8221;33&#8243;]<br />
# #####################################<br />
# source<br />
# #####################################<br />
SRCS =<br />
  main.c<br />
  stm32f10x_it.c<br />
  system_stm32f10x.c</p>
<p>SRCSASM =<br />
  startup_stm32f10x_hd.s</p>
<p># #####################################<br />
# firmware library<br />
# #####################################<br />
PERIPHLIB_SOURCES =<br />
  core_cm3.c<br />
  stm32f10x_gpio.c<br />
  stm32f10x_rcc.c<br />
[/code]</p>
<p>I list all the used source files here. system_stm32f10x.c and stm32f10x_it.c are copied from ST peripheral library. These two files always need modification to suit specific application. Startup code startup_stm32f10x_hd.s is from Attolic TrueStudio.</p>
<p>[code firstline=&#8221;87&#8243;]<br />
#######################################<br />
# LDFLAGS<br />
#######################################<br />
# link script<br />
ifeq ($(RAMBUILD), 1)<br />
LDSCRIPT = linker/STM32F103VE_ram.ld<br />
else<br />
LDSCRIPT = linker/STM32F103VE_flash.ld<br />
endif<br />
[/code]</p>
<p>These are the link scripts obtained from Atollic TrueStudio and ST peripheral library.<br />
More startup files and link scripts for other STM32 devices are linked at the <a href="#attachments">end</a> of the article.</p>
<p>To compile the project simply type &#8220;make&#8221; within the project root folder. The Makefile features auto generated dependencies so I do not need to clean the project all the time. At the end of the building process the size of each section is displayed.</p>
<figure id="attachment_672" aria-describedby="caption-attachment-672" style="width: 406px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/b7151-stm32-make.png" target="_blank" rel="noopener"><img decoding="async" class=" wp-image-672 " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/b7151-stm32-make.png" alt="Make a project" width="406" height="205" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/b7151-stm32-make.png 677w, https://ba0sh1.com/wp-content/uploads/2013/05/b7151-stm32-make-300x152.png 300w" sizes="(max-width: 406px) 100vw, 406px" /></a><figcaption id="caption-attachment-672" class="wp-caption-text">Make a project</figcaption></figure>
<p><a name="eclipseide"></a></p>
<h3>Eclipse IDE</h3>
<p>Although building program from the command line is probably the best experience to understand the compiler, sticking to the command line only is definitely the stupidest idea (except for some &#8220;cool effect&#8221; in front of young players). Eclipse is one the the greatest free IDE so I decided to use it.<br />
However Eclipse has become bloatware these days. The current binary package of &#8220;Eclipse IDE for C/C++ Developers&#8221; is about 130MB, which contains a lot of plugins, such as &#8220;Visual C++ support&#8221;, that I do not need at all. And you do not have an option to uninstall it! So I choose the bare metal way. Download the &#8220;Platform Runtime Binary&#8221; package from Eclipse archive (currently version 3.8.2 <a title="Eclipse archive" href="http://archive.eclipse.org/eclipse/downloads/drops/R-3.8.2-201301310800/">here</a>). It weights 53MB. Extraction the package to C:Appseclipse-stm32, run eclipse.exe. When workspace location is asked, give &#8220;D:workspaceSTM32eclipse&#8221;</p>
<figure id="attachment_675" aria-describedby="caption-attachment-675" style="width: 378px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/28cfc-eclipse-workspace-location.png" target="_blank" rel="noopener"><img decoding="async" class=" wp-image-675   " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/28cfc-eclipse-workspace-location.png" alt="Eclipse workspace location" width="378" height="175" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/28cfc-eclipse-workspace-location.png 630w, https://ba0sh1.com/wp-content/uploads/2013/05/28cfc-eclipse-workspace-location-300x139.png 300w" sizes="(max-width: 378px) 100vw, 378px" /></a><figcaption id="caption-attachment-675" class="wp-caption-text">Eclipse workspace location</figcaption></figure>
<p>For the next step, choose &#8220;Help&#8221;-&gt;&#8221;Install New Software&#8230;&#8221;, click the &#8220;Add&#8230;&#8221; button and type in Eclipse CDT site as the picture below (The current settings is for Eclispe 3.8 &#8220;Juno&#8221;):</p>
<figure id="attachment_676" aria-describedby="caption-attachment-676" style="width: 235px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/48c3f-eclipse-cdt-site.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-676 " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/48c3f-eclipse-cdt-site.png" alt="Eclipse CDT site" width="235" height="108" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/48c3f-eclipse-cdt-site.png 392w, https://ba0sh1.com/wp-content/uploads/2013/05/48c3f-eclipse-cdt-site-300x138.png 300w" sizes="auto, (max-width: 235px) 100vw, 235px" /></a><figcaption id="caption-attachment-676" class="wp-caption-text">Eclipse CDT site</figcaption></figure>
<p>Then select &#8220;Work with:&#8221; CDT and check these packages:</p>
<figure id="attachment_677" aria-describedby="caption-attachment-677" style="width: 443px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/52afa-eclipse-cdt-packages.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-677 " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/52afa-eclipse-cdt-packages.png" alt="Eclipse CDT packages" width="443" height="416" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/52afa-eclipse-cdt-packages.png 739w, https://ba0sh1.com/wp-content/uploads/2013/05/52afa-eclipse-cdt-packages-300x282.png 300w" sizes="auto, (max-width: 443px) 100vw, 443px" /></a><figcaption id="caption-attachment-677" class="wp-caption-text">Eclipse CDT packages</figcaption></figure>
<p>Click &#8220;Next&#8221;, accept some license nags and a clean bare-metal Eclipse C/C++ development environment is up.</p>
<p><a name="importstm32project"></a></p>
<h3>Import STM32 Project</h3>
<p>Start Eclipse, choose &#8220;File&#8221;-&gt;&#8221;New&#8221;-&gt;&#8221;Makefile Project with Existing Code&#8221;, enter as follows:</p>
<figure id="attachment_681" aria-describedby="caption-attachment-681" style="width: 315px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/d3588-eclipse-new-project.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-681 " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/d3588-eclipse-new-project.png" alt="Eclipse new project setting" width="315" height="328" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/d3588-eclipse-new-project.png 525w, https://ba0sh1.com/wp-content/uploads/2013/05/d3588-eclipse-new-project-288x300.png 288w" sizes="auto, (max-width: 315px) 100vw, 315px" /></a><figcaption id="caption-attachment-681" class="wp-caption-text">Eclipse new project setting</figcaption></figure>
<p>The project &#8220;Blank&#8221; is created. A small red cross is displayed at the folder icon. This is because the Eclipse indexer is not able to find all the definitions and prototypes. To fix this, right click the project folder and select &#8220;Properties&#8221;, in the popup window, select &#8220;C/C++ Build-&gt;Discovery Options&#8221;, change &#8220;Complier invocation command&#8221; to &#8220;arm-none-eabi-gcc&#8221;.</p>
<figure id="attachment_683" aria-describedby="caption-attachment-683" style="width: 611px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/b96f4-eclipse-discovery.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-683 " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/b96f4-eclipse-discovery.png" alt="Eclipse discovery options" width="611" height="461" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/b96f4-eclipse-discovery.png 1018w, https://ba0sh1.com/wp-content/uploads/2013/05/b96f4-eclipse-discovery-300x226.png 300w, https://ba0sh1.com/wp-content/uploads/2013/05/b96f4-eclipse-discovery-768x579.png 768w" sizes="auto, (max-width: 611px) 100vw, 611px" /></a><figcaption id="caption-attachment-683" class="wp-caption-text">Eclipse discovery options</figcaption></figure>
<p>Close the Properties window, do a rebuild inside Eclipse (which takes a while as compare to build from command line because Eclipse is scanning into building process). When finished, a &#8220;Includes&#8221; folder will appear in the project folder. The red cross should go away and all the symbols in the source code shall be able to resolve. (If not, right click project folder, &#8220;Index&#8221;-&gt;&#8221;Rebuild&#8221;)</p>
<figure id="attachment_684" aria-describedby="caption-attachment-684" style="width: 238px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/98a4f-eclipse-project-folder.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-684 " title="Eclipse project folder" src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/98a4f-eclipse-project-folder.png" alt="Eclipse project folder" width="238" height="211" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/98a4f-eclipse-project-folder.png 396w, https://ba0sh1.com/wp-content/uploads/2013/05/98a4f-eclipse-project-folder-300x266.png 300w" sizes="auto, (max-width: 238px) 100vw, 238px" /></a><figcaption id="caption-attachment-684" class="wp-caption-text">Eclipse project folder</figcaption></figure>
<p><a name="debuggingineclipse"></a></p>
<h3>Debugging in Eclipse</h3>
<p>Programming and Debugging STM32 using UART is possible but clumsy. I&#8217;m lucky enough to have a SEGGER J-Link debugger so everything becomes easy. To start program and debug in Eclipse, right click the project, select &#8220;Debug As&#8221;-&gt;&#8221;Debug Configurations&#8230;&#8221;,  select &#8220;GDB Hardware Debugging&#8221; and press &#8220;New Launch Configuration&#8221; button, set the parameters at &#8220;Main&#8221; tab as follows</p>
<figure id="attachment_703" aria-describedby="caption-attachment-703" style="width: 505px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/4d7b1-eclipse-debug-main-flash.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-703  " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/4d7b1-eclipse-debug-main-flash.png" alt="Eclipse Flash debug configuration (Main)" width="505" height="421" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/4d7b1-eclipse-debug-main-flash.png 842w, https://ba0sh1.com/wp-content/uploads/2013/05/4d7b1-eclipse-debug-main-flash-300x250.png 300w, https://ba0sh1.com/wp-content/uploads/2013/05/4d7b1-eclipse-debug-main-flash-768x640.png 768w" sizes="auto, (max-width: 505px) 100vw, 505px" /></a><figcaption id="caption-attachment-703" class="wp-caption-text">Eclipse Flash debug configuration (Main)</figcaption></figure>
<p>The debug configuration name is &#8220;Debug Blank Flash&#8221;, meaning we&#8217;re debugging using on-board Dlash. Make sure &#8220;Using Standard GDB Hardware Debugging Launcher&#8221; is selected at the bottom. For the &#8220;Debugger&#8221; tab, the following settings are used</p>
<figure id="attachment_704" aria-describedby="caption-attachment-704" style="width: 505px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/72417-eclipse-debug-debugger-flash.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-704  " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/72417-eclipse-debug-debugger-flash.png" alt="Eclipse Flash debug configuration (Debugger)" width="505" height="421" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/72417-eclipse-debug-debugger-flash.png 842w, https://ba0sh1.com/wp-content/uploads/2013/05/72417-eclipse-debug-debugger-flash-300x250.png 300w, https://ba0sh1.com/wp-content/uploads/2013/05/72417-eclipse-debug-debugger-flash-768x640.png 768w" sizes="auto, (max-width: 505px) 100vw, 505px" /></a><figcaption id="caption-attachment-704" class="wp-caption-text">Eclipse Flash debug configuration (Debugger)</figcaption></figure>
<p>BTW I&#8217;ll be using SEGGER GDB Server so the &#8220;Port number&#8221; is 2331. There are other GDB servers such as OpenOCD, but since I&#8217;m developing under Windows I&#8217;d rather use original SEGGER software.</p>
<p>The &#8220;Startup&#8221; tab is below</p>
<figure id="attachment_702" aria-describedby="caption-attachment-702" style="width: 505px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/57ca8-eclipse-debug-startup-flash.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-702  " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/57ca8-eclipse-debug-startup-flash.png" alt="Eclipse Flash debug configuration (Startup)" width="505" height="528" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/57ca8-eclipse-debug-startup-flash.png 842w, https://ba0sh1.com/wp-content/uploads/2013/05/57ca8-eclipse-debug-startup-flash-287x300.png 287w, https://ba0sh1.com/wp-content/uploads/2013/05/57ca8-eclipse-debug-startup-flash-768x803.png 768w" sizes="auto, (max-width: 505px) 100vw, 505px" /></a><figcaption id="caption-attachment-702" class="wp-caption-text">Eclipse Flash debug configuration (Startup)</figcaption></figure>
<p>Code inside the two editors are:</p>
<p>[code language=&#8221;text&#8221;]<br />
monitor speed 30<br />
monitor endian little<br />
monitor reset<br />
monitor speed auto<br />
set remote memory-write-packet-size 1024<br />
set remote memory-write-packet-size fixed<br />
monitor flash download = 1<br />
monitor flash device = STM32F103RC<br />
[/code]</p>
<p>and</p>
<p>[code language=&#8221;text&#8221;]<br />
tbreak main<br />
monitor reset 0<br />
continue<br />
[/code]</p>
<p>For the &#8220;Initialize Command&#8221; part, my development board has a STM32F103RCT6 so the &#8220;flash device&#8221; is set to STM32F103RC.<br />
For the &#8220;Run Commands&#8221; part, take note I&#8217;ve inserted a &#8220;monitor reset 0&#8221;. I found this is necessary to debug RTOSs such as Chibios (wonder why).</p>
<p>Most of the time it is more convenient to debug inside RAM, provided that the chip has enough RAM for the program. To build a program for RAM debugging, set &#8220;RAMBUILD=1&#8221; in the Makefile.</p>
<p>A separate debug configuration is necessary for RAM debugging. Simply duplicate a configuration from the previous Flash debugger and configure the &#8220;Startup&#8221; tab as follows</p>
<figure id="attachment_709" aria-describedby="caption-attachment-709" style="width: 505px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/7aed2-eclipse-debug-startup-ram.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" wp-image-709 " src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2013/05/7aed2-eclipse-debug-startup-ram.png" alt="Eclipse RAM debug configuration (Startup)" width="505" height="528" srcset="https://ba0sh1.com/wp-content/uploads/2013/05/7aed2-eclipse-debug-startup-ram.png 842w, https://ba0sh1.com/wp-content/uploads/2013/05/7aed2-eclipse-debug-startup-ram-287x300.png 287w, https://ba0sh1.com/wp-content/uploads/2013/05/7aed2-eclipse-debug-startup-ram-768x803.png 768w" sizes="auto, (max-width: 505px) 100vw, 505px" /></a><figcaption id="caption-attachment-709" class="wp-caption-text">Eclipse RAM debug configuration (Startup)</figcaption></figure>
<p>Similarly the codes are</p>
<p>[code language=&#8221;text&#8221;]<br />
monitor speed 30<br />
monitor endian little<br />
monitor reset<br />
monitor speed auto<br />
monitor writeu32 0xE000ED08 = 0x20000000<br />
[/code]</p>
<p>and</p>
<p>[code language=&#8221;text&#8221;]<br />
tbreak main<br />
monitor reset 0<br />
monitor reg r13 = (0x20000000)<br />
monitor reg pc = (0x20000004)<br />
continue<br />
[/code]</p>
<p>The debug configurations can be added to &#8220;Favourite&#8221; menu for easy launching. But before launching, start &#8220;SEGGER J-Link GDB Server&#8221;.</p>
<p><em>Make sure the &#8220;BOOT0&#8221; and &#8220;BOOT1&#8221; pin on STM32 are correctly configured when choosing debugging from RAM or Flash.</em><br />
<a name="eclipseplugins"></a></p>
<h3>Eclipse Plugins</h3>
<p>There&#8217;s a lot of STM32 Eclipse plugins that make life easier. The plugins I use:</p>
<ol>
<li><a title="EmbSysRegView" href="http://embsysregview.sourceforge.net/">EmbSysRegView</a>  It shows ARM Cortex registers during debug section. Probably the most useful plugin.</li>
<li><a title="StateViewer" href="http://www.highintegritysystems.com/down-loads/stateviewer-plug-in/">StateViewer </a> It displays important information (Tasks, Queues, Timers) is the program uses FreeRTOS. It is a free plugin but the website asks for your information (which I don&#8217;t like). For simplicity the Eclipse software site is &#8220;<a href="http://www.highintegritysystems.com/StateViewer/">http://www.highintegritysystems.com/StateViewer/</a>&#8220;</li>
</ol>
<p>Plugin I do not use:</p>
<ol>
<li><a style="line-height:13px;" title="GNU ARM Eclipse Plug-in" href="http://sourceforge.net/projects/gnuarmeclipse/" target="_blank" rel="noopener">GNU ARM Eclipse Plug-in</a><span style="line-height:13px;"> This plugin automates ARM development under Eclipse. It uses Eclipse managed build system so user do not need to write a Makefile. The reason I do not use this plugin is because it obscures the building process while I like to have everything in proper control.</span></li>
<li><a title="Zylin Embedded CDT" href="http://opensource.zylin.com/embeddedcdt.html" target="_blank" rel="noopener">Zylin Embedded CDT</a> This plugin provides easier settings for hardware GDB. However I do not feel the CDT build-in GDB integration is harder to configure.</li>
<li><a title="ST MicroXplorer" href="http://www.st.com/web/en/catalog/tools/PF251717" target="_blank" rel="noopener">ST MicroXplorer</a> MicroXplorer is a visual tool for planning and configure STM32 mcu pins. It also generates configuration code automatically. MicroXplorer is distributed as a standalone utility and a Eclipse plugin. The Eclipse plugin seems to slow down Eclipse startup significantly. I use the standalone version.</li>
</ol>
<p><a name="attachments"></a></p>
<h3>Downloads</h3>
<p>[attachments size=small docid=&#8221;656,662,661&#8243;]</p>
<p>The post <a href="https://ba0sh1.com/2013/05/25/opensource-stm32-development/">Opensource STM32 development</a> appeared first on <a href="https://ba0sh1.com">Digital Me</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://ba0sh1.com/2013/05/25/opensource-stm32-development/feed/</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
	</channel>
</rss>
