<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Esden&#39;s Blog - libopenstm32</title>
      <link>https://esden.net</link>
      <description>This is Piotr Esden-Tempski&#39;s personal blog</description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://esden.net/categories/libopenstm32/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Mon, 29 Dec 2014 00:00:00 +0000</lastBuildDate>
      <item>
          <title>Black Magic Discovery</title>
          <pubDate>Mon, 29 Dec 2014 00:00:00 +0000</pubDate>
          <author>Esden</author>
          <link>https://esden.net/blog/2014-12-29-black-magic-discovery/</link>
          <guid>https://esden.net/blog/2014-12-29-black-magic-discovery/</guid>
          <description xml:base="https://esden.net/blog/2014-12-29-black-magic-discovery/">&lt;p&gt;Hey everyone!&lt;/p&gt;
&lt;p&gt;Today I had to fix another STM32F4 Discovery board. By fixing I mean replacing the STLink firmware with Black Magic Probe firmware. I do that on a semi regular basis but as I have not done it in a long time I did not remember the process anymore. Obviously this calls for a blog post with some step by step instructions on how to do it, so that I have a reference in the future. Also you might find it useful yourself.&lt;/p&gt;
&lt;p&gt;First of all let&#39;s explain what we are trying to do. The objective is to replace the STLink SWD (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; title=&quot;Serial Wire Debug Wiki page&quot; href=&quot;https://en.wikipedia.org/wiki/Joint_Test_Action_Group#Serial_Wire_Debug&quot;&gt;Serial Wire Debug&lt;/a&gt;) firmware with Black Magic Probe firmware.  The board is setup by default to use a smaller chip to run the STLink firmware to talk to the main stm32.  We need to change the smaller chips firmware.  The initial adjustments to the board are needed to be able to access the programming pins of the smaller chip and replace it&#39;s contents to Black Magic Probe firmware so that we can use GDB (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; title=&quot;GNU DeBugger website&quot; href=&quot;https://www.gnu.org/software/gdb/&quot;&gt;GNU DeBugger&lt;/a&gt;) to program and debug the board instead of the very unstable and unreliable proprietary STLink protocol. The adjustments needed to access the small chips programming pins need to be reversed once the firmware is changed to Black Magic Probe firmware, resulting with an stm32 f4 discovery board with Black Magic Probe firmware ready to use.&lt;/p&gt;
&lt;p&gt;For the &quot;Fixing&quot; process I use a genuine Black magic probe, I have one of those very early ones with a 0.1&quot; header that is very useful in this particular case. You can also use a Black Magic Probe Mini with a PCB adapter, make an adapter cable or you can use another Discovery board that has already been &quot;fixed&quot;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First step is to change the two solder jumpers on the bottom of the discovery board.&lt;/p&gt;
&lt;p&gt;[caption id=&quot;attachment_503&quot; align=&quot;alignnone&quot; width=&quot;510&quot;]&lt;a href=&quot;/wp-content/uploads/2014/12/STM32F4-discovery-bottom.jpeg&quot;&gt;&lt;img src=&quot;https://esden.net/blog/2014-12-29-black-magic-discovery/images/STM32F4-discovery-bottom.jpeg&quot; alt=&quot;Jumper modification for SWD programming.&quot; /&gt;&lt;/a&gt; Jumper modification for SWD programming.[/caption]&lt;/p&gt;
&lt;p&gt;Remove the 0Ohm resistor/jumpers marked with red circles, and close the jumpers marked with blue circles.&lt;/p&gt;
&lt;p&gt;Note: The easiest way to do that is to use a soldering tip, add a bunch more solder over the resistor and swipe them of. After that is done use solder wick to make sure there is no short on the &quot;red&quot; jumper. You can discard the 0Ohm resistors. It is much easier to just add a small blob of solder to close the &quot;blue&quot; jumpers, it is easy to remove them later in the process by just using some solder wick.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Remove the SWD and slave MCU jumpers as indicated by the red circles in the photo.&lt;/p&gt;
&lt;p&gt;[caption id=&quot;attachment_507&quot; align=&quot;alignnone&quot; width=&quot;576&quot;]&lt;a href=&quot;/wp-content/uploads/2014/12/IMG_1109.jpg&quot;&gt;&lt;img src=&quot;https://esden.net/blog/2014-12-29-black-magic-discovery/images/IMG_1109.jpg&quot; alt=&quot;STM32F4 Discovery board Jumpers for updating the programmer chip firmware&quot; /&gt;&lt;/a&gt; STM32F4 Discovery board Jumpers for updating the programmer chip firmware[/caption]&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Attach jumper wires to the Black Magic Probe header.&lt;/p&gt;
&lt;p&gt;[caption id=&quot;attachment_509&quot; align=&quot;alignnone&quot; width=&quot;576&quot;]&lt;a href=&quot;/wp-content/uploads/2014/12/IMG_1110.jpg&quot;&gt;&lt;img src=&quot;https://esden.net/blog/2014-12-29-black-magic-discovery/images/IMG_1110.jpg&quot; alt=&quot;Black Magic Probe Serial Wire Debug connections for Discovery board &amp;quot;fixing&amp;quot;&quot; /&gt;&lt;/a&gt; Black Magic Probe Serial Wire Debug connections for Discovery board &quot;fixing&quot;[/caption]&lt;/p&gt;
&lt;p&gt;Standard JTAG/SWD 20Pin 0.1&quot; header&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Black wire - Pin 14 (GND)&lt;/li&gt;
&lt;li&gt;Orange wire - Pin 9 (TCLK/SWCLK)&lt;/li&gt;
&lt;li&gt;Yellow wire - Pin 8 (TMS/SWDIO)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In case you are trying to figure out which pins these are on a standard ARM Cortex 10Pin 0.05&quot; header. Here you go:&lt;/p&gt;
&lt;p&gt;Standard JTAG/SWD Cortex 10Pin 0.1&quot; header&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Black wire - Pin 3, 5 or 9 (GND)&lt;/li&gt;
&lt;li&gt;Orange wire - Pin 4 (TCLK/SWCLK)&lt;/li&gt;
&lt;li&gt;Yellow wire - Pin 2 (TMS/SWDIO)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Attach the Black Magic Probe to the discovery board.&lt;/p&gt;
&lt;p&gt;[caption id=&quot;attachment_510&quot; align=&quot;alignnone&quot; width=&quot;576&quot;]&lt;a href=&quot;/wp-content/uploads/2014/12/IMG_1113.jpg&quot;&gt;&lt;img src=&quot;https://esden.net/blog/2014-12-29-black-magic-discovery/images/IMG_1113.jpg&quot; alt=&quot;STM32F4 Discovery board Serial Wire Debug connection for &amp;quot;fixing&amp;quot; the on board programmer firmware&quot; /&gt;&lt;/a&gt; STM32F4 Discovery board Serial Wire Debug connection for &quot;fixing&quot; the on board programmer firmware[/caption]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Black wire (GND) - Pin 3 of the SWD (CN2) header&lt;/li&gt;
&lt;li&gt;Orange wire (SWCLK) - Pin 2 of the ST-LINK/DISCOVERY (CN3) header&lt;/li&gt;
&lt;li&gt;Yellow wire (SWDIO) - Pin 4 of the ST-LINK/DISCOVERY (CN3) header&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now you can connect the discovery board and the Black Magic probe to your computer via USB. The order should not matter, but usually I tend to connect the usb wires to the laptop before connecting the SWD wires between the two devices, just to make sure we don&#39;t have some strange current loop that powers one or the other via IO pins, which might be problematic.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now we turn our attention to the software. You can obviously do these steps before you wire everything up but this is the order I followed.&lt;/p&gt;
&lt;p&gt;The process requires a few dependencies that you should install using either apt on Linux or homebrew or macports on OS X:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;pyserial&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In my case I use OS X and homebrew so I needed to run the following two commands:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;brew install python pip install pyserial&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Download and make the an arm gcc compiler &quot;findable&quot;. I recommend using &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://launchpad.net/gcc-arm-embedded&quot;&gt;GCC ARM Embedded&lt;/a&gt; as it is maintained by the ARM developers themselves and they seem to generally know what they are doing. :)&lt;/p&gt;
&lt;p&gt;So download it from here: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://launchpad.net/gcc-arm-embedded&quot;&gt;https://launchpad.net/gcc-arm-embedded&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then unpack it into your home directory:&lt;/p&gt;
&lt;p&gt;[code language=&quot;text&quot; gutter=&quot;false&quot;] cd ~ tar xfvj ~/Downloads/gcc-arm-none-eabi-replace this with the version-mac.tar.bz2 [/code]&lt;/p&gt;
&lt;p&gt;Then you should add the binary directory of the newly unpacked compiler package to your system. Obviously to do this you add the directory to your PATH environment variable. If you don&#39;t know what that is you should learn a bit more about your &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://www.linfo.org/path_env_var.html&quot;&gt;Unix/Linux basics&lt;/a&gt;. :)&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;export PATH=~/gcc-arm-none-eabi-someversion/bin:$PATH&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To make this addition persistent you can also add that to your &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/&quot;&gt;.profile, .bash_profile or .zprofile&lt;/a&gt; depending on the shell and setup you use.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Download blackmagic firmware source code. You can get it at &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/blacksphere/blackmagic&quot;&gt;https://github.com/blacksphere/blackmagic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The easiest way is to clone the github repository, look for the small window at the center right of the github page for the git repository url. If you have a github account choose the ssh url but if you refuse to do so then you can go with the https one too. :)&lt;/p&gt;
&lt;p&gt;If you did not learn about &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://git-scm.com/&quot;&gt;GIT&lt;/a&gt; and &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://github.com&quot;&gt;GitHub&lt;/a&gt; yet this is the perfect time to take a break from all of this here and come back after you have &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://help.github.com/categories/bootcamp/&quot;&gt;caught up on your homework&lt;/a&gt;. :D&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git clone git@github.com:blacksphere/blackmagic.git&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 9&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&#39;s build the firmware. This consists of three steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Fetch the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://www.libopencm3.org/wiki/Main_Page&quot;&gt;libopencm3&lt;/a&gt; &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://git-scm.com/book/en/v2/Git-Tools-Submodules&quot;&gt;submodule&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Build from the toplevel so libopencm3 is built&lt;/li&gt;
&lt;li&gt;Build the blackmagic firmware for the stlink&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd blackspheregit submodule initgit submodule updatemakecd srcmake cleanmake PROBE_HOST=stlink&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 10&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We can finally connect to the hardware we wired up before and erase the pesky stlink firmware. When the discovery boards ship, the firmware is read and write protected on the STLink chip. So to be able to overwrite the firmware we will have to unlock the chip. Thanks to Gareth there is a small python script that can do that for us. You just have to call the following command inside the src directory of the blackmagic repository and it should be able to remove the write protection:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;../scripts/hexprog.py -s -d /dev/cu.usbmodemSOMESERIAL1 -r blackmagic.bin&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the case you are on Linux you can leave out the -d device parameter. For reference the -s parameter tells hexprog to use Serial Wire Debug instead of JTAG and -r tells it to unlock and erase the target chip.&lt;/p&gt;
&lt;p&gt;If you skip any of those two parameters it will not work for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 11&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Flash the bootloader. We are getting very close. To upload the blackmagic bootloader you use arm-none-eabi-gdb.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;arm-none-eabi-gdb blackmagic_dfutarget extended_remote /dev/usbmodemSOMESERIAL1monitor swdp_scanattach 1loadexit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This sequence of commands attaches to the virtual gdb server that is provided by the Black Magic Probe on it&#39;s virtual serial port 1. (The second serial port is the USB to serial interface located on the back of the BMPM) We then tell the monitor (this is the BMP) to scan using Serial Wire Debug as our protocol. Next we attach to the virtual process number 1. (As we are on the embedded systems there usually should only ever be 1 process unless you run an RTOS) We load the firmware from the elf file that we passed on to gdb earlier and exit GDB.&lt;/p&gt;
&lt;p&gt;Simple right? :D (Believe me that is definitely simpler than setting up and making OpenOCD work with Eclipse)&lt;/p&gt;
&lt;p&gt;Tip: To make things easier for the future you can add the following to your .gdbinit file:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set target-async onset confirm offset history saveset mem inaccessible-by-default offtar ext /dev/cu.usbmodemSOMESERIAL1mon versionmon swdp_scan#mon jtag_scan att 1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note: On Linux the cu.usbmodem device name will be /dev/ttyACM0 instead.&lt;/p&gt;
&lt;p&gt;After setting up the .gdbinit file the upload process becomes quite a bit shorter:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;arm-none-eabi-gdb blackmagicloadexit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 12&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Upload the black magic firmware itself. Here you have two options. Either you can use the same process as before using GDB or you can use the now uploaded DFU bootloader to upload the Black Magic Probe firmware payload. Using GDB you would run the following:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;arm-none-eabi-gdb blackmagictarget extended_remote /dev/cu.usbmodemSOMESERIAL1monitor swdp_scanattach 1loadexit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively you can upload the firmware using a DFU script. Before you do that though you should disconnect the genuine Black Magic Probe from your computer as you want to make sure the script flashes the Discovery board and not your BMP. To do that you will need to install python libusb as an additional dependency. But having done that you can then run the following to upload the firmware:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;./scripts/stm32_mem.py blackmagic.bin&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 13&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Put everything back together. Now you just have to do four things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Disconnect your Black Magic Probe and Discovery board from your computer as well as each other.&lt;/li&gt;
&lt;li&gt;Remove the solder blobs you have added on the back of the board.&lt;/li&gt;
&lt;li&gt;Add solder blobs to where you removed the resistors at the very beginning.&lt;/li&gt;
&lt;li&gt;Put the jumpers back to where they were on the front of the Discovery board.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You are pretty much done now. If everything went well you should have your &quot;fixed&quot; discovery board. Follow to the one additional step below to test that.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 14&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Plug in your Discovery board into your computer. The dual color led next to the USB connector should be solid Green. If it is blinking Green it means the bootloader is running and the board is expecting to be flashed with the firmware. This can happen if you still have the power jumper disconnected that provides power to the &quot;slave&quot; STM32F4 chip. This is actually very useful if you want to upgrade the Black Magic Probe firmware on your discovery board. :D&lt;/p&gt;
&lt;p&gt;Additionally if everything went well if you are on Mac OS X a /dev/cu.usbmodemSOMESERIAL1 and /dev/cu.usbmodemSOMESERIAL3 should appear. If you are on linux you should be able to find ttyACM0 and ttyACM1 in the /dev directory.&lt;/p&gt;
&lt;p&gt;I hope this write up is useful for you and the future me. :) I am planning to write another blog post on how to build and upload an example firmware onto the slave processor. So hold on to your hats! :)&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;
Esden&lt;/p&gt;
&lt;p&gt;P.S. Big thanks to Jack Ziesing for proofreading and introductory paragraph and sparking the work on this article. It is a great help! :)&lt;/p&gt;
</description>
      </item>
      <item>
          <title>libopencm3 Discovery</title>
          <pubDate>Mon, 29 Dec 2014 00:00:00 +0000</pubDate>
          <author>Esden</author>
          <link>https://esden.net/blog/2014-12-29-libopencm3-discovery/</link>
          <guid>https://esden.net/blog/2014-12-29-libopencm3-discovery/</guid>
          <description xml:base="https://esden.net/blog/2014-12-29-libopencm3-discovery/">&lt;p&gt;Hi everyone,&lt;/p&gt;
&lt;p&gt;As promised in the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://esden.net/2014/12/11/black-magic-discovery/&quot;&gt;previous post&lt;/a&gt;. Here is a short write up how to download, compile and upload your first example program using libopencm3 and a STM32F4 discovery board.&lt;/p&gt;
&lt;p&gt;Very similar process will apply to any other evaluation boards that employ an STM32 microcontroller and Black Magic Probe JTAG/SWD programmer. Like for example Lisa/M, Lisa/MX, Lisa/S, Apogee and so on.&lt;/p&gt;
&lt;h2 id=&quot;step-1&quot;&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;If you did not already do that, download and install GCC ARM Embedded. You might have already done it if you were &quot;fixing&quot; your Discovery board.&lt;/p&gt;
&lt;p&gt;You can download the compiler from here: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://launchpad.net/gcc-arm-embedded&quot;&gt;https://launchpad.net/gcc-arm-embedded&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Unpack it into your home directory:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd ~&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar xfvj ~/Downloads/gcc-arm-none-eabi-replace this with the version-mac.tar.bz2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should add the binary directory of the newly unpacked compiler package to your system. Obviously to do this you add the directory to your PATH environment variable. If you don&#39;t know what that is you should learn a bit more about your &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://www.linfo.org/path_env_var.html&quot;&gt;Unix/Linux basics&lt;/a&gt;. :)&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;export PATH=~/gcc-arm-none-eabi-someversion/bin:$PATH&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To make this addition persistent you can also add that to your &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/&quot;&gt;.profile, .bash_profile or .zprofile&lt;/a&gt; depending on the shell and setup you use.&lt;/p&gt;
&lt;h2 id=&quot;step-2&quot;&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Download libopencm3-examples. You can find this repository at &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/libopencm3/libopencm3-examples&quot;&gt;https://github.com/libopencm3/libopencm3-examples&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git clone git@github.com:libopencm3/libopencm3-examples.git&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;step-3&quot;&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Build the libopencm3 examples. The repository contains libopencm3 as a submodule so you will have to initialize and update the submodule before you can compile the library itself as well as all the different examples.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd libopencm3-examples&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git submodule init&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git submodule update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;make&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will take a bit as there is a lot of examples included in that repository. In the past the examples were part of the main library itself but there became so many of them that we had to split it off. Otherwise the build and clone process just took too long.&lt;/p&gt;
&lt;h2 id=&quot;step-4&quot;&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Prepare your environment. To make your life easier you should set up your .gdbinit configuration file. This will make the firmware upload and debug process so much easier. Just add the following lines to the .gdbinit file:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set target-async on&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set confirm off&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set history save&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set mem inaccessible-by-default off&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar ext /dev/cu.usbmodemSOMESERIAL1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mon version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mon swdp_scan&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#mon jtag_scan&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;att 1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note: On linux the cu.usbmodemSOMESERIAL1 becomes ttyACM0.&lt;/p&gt;
&lt;p&gt;For reference here is the breakdown of what the commands inside of the .gdbinit file mean:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;set target-async on&lt;/em&gt;: Enable &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://www-zeuthen.desy.de/dv/documentation/unixguide/infohtml/gdb/Background-Execution.html&quot;&gt;background execution commands&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;set confirm off&lt;/em&gt;: This disables the really annoying &quot;are you sure&quot; questions. :)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;set history save&lt;/em&gt;: This forces GDB to save the command history.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;set mem inaccessible-by-default off&lt;/em&gt;: This is one of the most important commands here. Very often when you are trying to debug your code on a microcontroller you have to read the content of memory mapped registers. If you don&#39;t set this option the debugger will prevent you from doing so as it has no idea that this memory is actually accessible. On a PC having the option on makes total sense but on a microcontroller it is mostly a burden.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;tar ext /dev/cu.usbmodemSOMESERIAL1&lt;/em&gt;: tell gdb to connect to Black Magic Probe&lt;/li&gt;
&lt;li&gt;&lt;em&gt;mon version&lt;/em&gt;: Print version of the Black Magic Probe.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;mon swdp_scan&lt;/em&gt;: Scan for devices using SWD protocol.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;att 1&lt;/em&gt;: Attach to the first process. On a microcontroller you will have only one process...&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;step-4-1&quot;&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Upload fancyblink example. The simplest example for the STM32F4 Discovery board is the fancyblink example. It is also very easy to upload. As long as your Discovery board is &quot;fixed&quot; and uses the BMP firmware.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd examples/stm32/f4/stm32f4-discovery/fancyblink&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;arm-none-eabi-gdb fancyblink.elf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;load&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;run&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the LEDs on the Discovery board should be blinking. You can interrupt the execution of the program by pressing &lt;Ctrl&gt;-C. You can continue the execution by running cont.&lt;/p&gt;
&lt;p&gt;Here is a short reference of GDB commands that you might find useful when playing around with code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; load -&amp;gt; load the binary from the provided elf file. (Note: it detects if the elf file changed on the hard disk and loads a new one if available. So you don&#39;t have to quit GDB every time when you recompile your code)&lt;/li&gt;
&lt;li&gt;run -&amp;gt; start the execution of your firmware&lt;/li&gt;
&lt;li&gt;backtrace -&amp;gt; print the call stack trace of the current line of code being executed&lt;/li&gt;
&lt;li&gt;make -&amp;gt; runs make command in the directory you started gdb. Very useful if you want to update the binary you are running really quick.&lt;/li&gt;
&lt;li&gt;break filename:lineno -&amp;gt; you can add a breakpoint inside your code. GDB will stop the execution of the program as soon as the line is hit by the firmware.&lt;/li&gt;
&lt;li&gt;step -&amp;gt; execute one single line of code and return back to the command line&lt;/li&gt;
&lt;li&gt;next -&amp;gt; same as step but it does not enter into the functions called and skips them. Useful if you want to step over functions you know take forever and you are not interested in what they are actually doing. :)&lt;/li&gt;
&lt;li&gt;print variablename -&amp;gt; print the content of a variable&lt;/li&gt;
&lt;li&gt;print/x variablename -&amp;gt; print the content of a variable as HEX&lt;/li&gt;
&lt;li&gt;list -&amp;gt; prints the context of the line being executed at the very moment&lt;/li&gt;
&lt;li&gt;kill -&amp;gt; if used in a GDB script it will reset the MCU and exit GDB. Very useful as last command of a GDB script.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope this will be helpful for you.&lt;/p&gt;
&lt;p&gt;Cheers, Esden&lt;/p&gt;
&lt;p&gt;P.S. Big thanks to Jack Ziesing for proofreading and introductory paragraph and sparking the work on this article. It is a great help! :)&lt;/p&gt;
</description>
      </item>
      <item>
          <title>Open-Source and Open-Hardware Multicopter platform</title>
          <pubDate>Fri, 24 Jul 2009 00:00:00 +0000</pubDate>
          <author>Esden</author>
          <link>https://esden.net/blog/2009-07-24-open-source-and-open-hardware-multicopter-platform/</link>
          <guid>https://esden.net/blog/2009-07-24-open-source-and-open-hardware-multicopter-platform/</guid>
          <description xml:base="https://esden.net/blog/2009-07-24-open-source-and-open-hardware-multicopter-platform/">&lt;p&gt;Over the last two weeks many things happened. I found out that there is a really open-source and open-hardware quadrocopter project in the wild. It is called booz and is part of the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://paparazzi.enac.fr/wiki/Main_Page&quot;&gt;paparazzi&lt;/a&gt; project. Code and schematics just as board layouts are under the GPLv2 or later license. That is really awesome news.&lt;/p&gt;
&lt;p&gt;This project is intended for research and universities so the boards are using BGA parts that are difficult to solder for a mere mortal, and there is some lack in documentation. That is why some other people and me started a project called &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://openmulticopter.org&quot;&gt;openmulticopter&lt;/a&gt;. The basic idea is to create and maintain a completely open-source quadrocopter/multicopter platform for everyone. As a multicopter does not consist only of the control electronics but also contains parts like remote control receiver, brushless motor controllers, a frame, and so on, we tried to combine many open-source parts that are already out there. Just take a look into the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://openmulticopter.org&quot;&gt;wiki&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;Some highlights of open-source components that we have chosen so far are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://svn.savannah.gnu.org/viewvc/paparazzi3/trunk/sw/airborne/booz/?root=paparazzi&quot;&gt;booz&lt;/a&gt; (the core of the platform)&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://libopenstm32.sourceforge.net&quot;&gt;libopenstm32&lt;/a&gt; (firmware library for STM32 microcontrollers)&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://rcos-wiki.codingmonkey.de/index.php/RCOPEN24&quot;&gt;RCOPEN24&lt;/a&gt; (a 2.4GHz remote control system)&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://open-bldc.org/&quot;&gt;open-bldc&lt;/a&gt; (brushless motor controllers)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We also formulated a &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://openmulticopter.org/wiki/Mission_statement&quot;&gt;mission statement&lt;/a&gt; that can be found in the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://openmulticopter.org/&quot;&gt;openmulticopter wiki&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There is still a lot of work in front of us, but I am really happy with the progress we are making. If you are interested in contributing just drop into the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://webchat.freenode.net/?channels=#openmulticopter&quot;&gt;#openmulticopter&lt;/a&gt; IRC channel on Freenode, or write an email to the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http://openmulticopter.org/cgi-bin/mailman/listinfo/openmulticopter&quot;&gt;mailing list&lt;/a&gt;.&lt;/p&gt;
</description>
      </item>
    </channel>
</rss>
