<?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>STM32Cube Archives - Digital Me</title>
	<atom:link href="https://ba0sh1.com/tag/stm32cube/feed/" rel="self" type="application/rss+xml" />
	<link>https://ba0sh1.com/tag/stm32cube/</link>
	<description>Electronics, Computers at leisure time</description>
	<lastBuildDate>Sun, 22 Feb 2015 18:15:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
	<item>
		<title>STM32CubeMX GCC Makefile project</title>
		<link>https://ba0sh1.com/2015/02/23/stm32cubemx-gcc-makefile/</link>
					<comments>https://ba0sh1.com/2015/02/23/stm32cubemx-gcc-makefile/#comments</comments>
		
		<dc:creator><![CDATA[Baoshi]]></dc:creator>
		<pubDate>Sun, 22 Feb 2015 18:15:48 +0000</pubDate>
				<category><![CDATA[Project]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[Makefile]]></category>
		<category><![CDATA[STM32]]></category>
		<category><![CDATA[STM32Cube]]></category>
		<category><![CDATA[STM32CubeMX]]></category>
		<guid isPermaLink="false">https://www.ba0sh1.com/?p=1062</guid>

					<description><![CDATA[<p>Writing peripheral initialization code is probably the most tedious work in embedded development. It always successfully stops me from starting a new project. I believe engineers at STMicroelectronics share the same pain. Therefore...</p>
<p>The post <a rel="nofollow" href="https://ba0sh1.com/2015/02/23/stm32cubemx-gcc-makefile/">STM32CubeMX GCC Makefile project</a> appeared first on <a rel="nofollow" href="https://ba0sh1.com">Digital Me</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Writing peripheral initialization code is probably the most tedious work in embedded development. It always successfully stops me from starting a new project. I believe engineers at STMicroelectronics share the same pain. Therefore they created <a title="STM32Cube" href="http://www.st.com/stm32cube" target="_blank" rel="noopener">STM32Cube</a> firmware and STM32CubeMX graphical configuration tool, which turns numerous key strokes and page flips into just a few mouse clicks. STM32CubeMX is free software, but the initialization code it generates require compiler tools carrying hefty price tags, IARARM, Keil ARM-MDK, and Atollic TrueSTUDIO, to name the few. Fair enough these compilers do offer free editions with limited functionality. But I still prefer unrestricted, free tool that is easily scale-able for my current and future projects. Just like the GNU Make and ARM GCC toolchain I described in <a title="Opensource STM32 development" href="https://www.ba0sh1.com/opensource-stm32-development/" target="_blank" rel="noopener">Opensource STM32 development</a>.</p>
<p><span id="more-1062"></span></p>
<h2><span style="color:#ff0000;">UPDATE</span></h2>
<p><span style="color:#ff0000;">Always get update from https://github.com/baoshi/CubeMX2Makefile The code is now based on SW4STM32 project output. Thanks various contributors to make this possible.</span></p>
<p>Deprived off electronics lab back in Singapore, a Chinese new year holiday here in Shanghai home is perfect for some software projects. I have little exposure with Python but after two days of Googling (through VPN) and copy/paste, a crude CubeMX2Makefile utility is ready, available at https://github.com/baoshi/CubeMX2Makefile (OOP aficionados please forgive my spaghetti styled code. It works is it?)</p>
<p>As the name suggests, the program converts STM32CubeMX project into a GNU Makefile. Here is a mini-HOWTO:</p>
<ol>
<ol>
<li>Create a STM32CubeMX project, configure pins, peripherals and MiddleWare, then edit project settings as follows: <span style="color:#ff0000;">(choose SW4STM32 instead of TrueStudio in the picture below)</span>
<figure id="attachment_1065" aria-describedby="caption-attachment-1065" style="width: 600px" class="wp-caption aligncenter"><a class="thumbnail" href="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2015/02/897a8-stm32cubemx_project_setting.png" target="_blank" rel="noopener"><img decoding="async" class="wp-image-1065" src="http://blog.ba0sh1.com/wordpress/wp-content/uploads/2015/02/897a8-stm32cubemx_project_setting.png?w=1024&#038;h=512" alt="STM32CubeMX project settings" width="600" height="300" srcset="https://ba0sh1.com/wp-content/uploads/2015/02/897a8-stm32cubemx_project_setting.png 1220w, https://ba0sh1.com/wp-content/uploads/2015/02/897a8-stm32cubemx_project_setting-300x150.png 300w, https://ba0sh1.com/wp-content/uploads/2015/02/897a8-stm32cubemx_project_setting-1024x512.png 1024w, https://ba0sh1.com/wp-content/uploads/2015/02/897a8-stm32cubemx_project_setting-768x384.png 768w" sizes="(max-width: 600px) 100vw, 600px" /></a><figcaption id="caption-attachment-1065" class="wp-caption-text">STM32CubeMX project settings</figcaption></figure>
<p>Make sure the Tool/IDE selection is TrueSTUDIO 4.3.1 (as of STM32CubeMX 4.6.0), and note down the &#8220;Toolchain Folder Location&#8221;. I found it necessary to empty the old &#8220;Toolchain Folder&#8221; before each code generation, otherwise the project file just keep growing regardless of settings (this could be a bug in STM32CubeMX). See <a href="#update">update</a> below.</li>
<li>Download the project from the Github repo below, extract files to a folder, say &#8220;C:CubeMX2Makefile&#8221;. Install Python 2.7 Win32 from www.python.org
<p>[code light=&#8221;true&#8221;]<br />
c:CubeMX2Makefile&gt;dir /b<br />
.gitattributes<br />
.gitignore<br />
CubeMX2Makefile.py<br />
CubeMX2Makefile.tpl<br />
readme.md<br />
[/code]</p>
</li>
<li>From command prompt, execute CubeMX2Makefile.py, e.g,
<p>[code light=&#8221;true&#8221;]<br />
c:CubeMX2Makefile&gt;CubeMX2Makefile.py R:411ProjTestF4<br />
File created: R:411ProjTestF4Makefile<br />
[/code]</p>
</li>
<li>Cd into &#8220;Toolchain Folder Locaiton&#8221;, make project, i.e.,
<p>[code light=&#8221;true&#8221;]<br />
R:411ProjTestF4&gt;make<br />
&#8230;<br />
arm-none-eabi-size build/TestF4.elf<br />
 text data bss dec hex filename<br />
 5876 12 1056 6944 1b20 build/TestF4.elf<br />
arm-none-eabi-objcopy -O ihex build/TestF4.elf build/TestF4.hex<br />
[/code]</p>
<p>Refer to <a title="Command line tools" href="https://www.ba0sh1.com/opensource-stm32-development/#commandlinetools" target="_blank" rel="noopener">blog</a> and below links for ARM GCC and make utility installation. It will be much easier to import the Makefile project into Eclipse CDT for code editing and debugging.</li>
</ol>
</ol>
<h3>Useful links</h3>
<p>CubeMX2Makefile: <a title="https://github.com/baoshi/CubeMX2Makefile" href="https://github.com/baoshi/CubeMX2Makefile" target="_blank" rel="noopener">https://github.com/baoshi/CubeMX2Makefile</a></p>
<p>STM32Cube: <a title="http://www.st.com/stm32cube" href="http://www.st.com/stm32cube" target="_blank" rel="noopener">http://www.st.com/stm32cube</a></p>
<p>ARM GCC: <a title="https://launchpad.net/gcc-arm-embedded" href="https://launchpad.net/gcc-arm-embedded" target="_blank" rel="noopener">https://launchpad.net/gcc-arm-embedded</a></p>
<p>My packaged GNU Make for Win32: <a title="GNU Make Win32" href="https://ba0sh1com.files.wordpress.com/2020/09/2c1c9-make.zip" target="_blank" rel="noopener">https://ba0sh1com.files.wordpress.com/2020/09/2c1c9-make.zip</a></p>
<p><a name="update"></a></p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://ba0sh1.com/2015/02/23/stm32cubemx-gcc-makefile/">STM32CubeMX GCC Makefile project</a> appeared first on <a rel="nofollow" href="https://ba0sh1.com">Digital Me</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://ba0sh1.com/2015/02/23/stm32cubemx-gcc-makefile/feed/</wfw:commentRss>
			<slash:comments>36</slash:comments>
		
		
			</item>
	</channel>
</rss>
