<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nickray</title>
    <description>The latest articles on DEV Community by nickray (@nickray).</description>
    <link>https://dev.to/nickray</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F109581%2F42daf336-dd61-4e79-8cf7-b854f8d61747.jpeg</url>
      <title>DEV Community: nickray</title>
      <link>https://dev.to/nickray</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nickray"/>
    <language>en</language>
    <item>
      <title>Turning RobotDyn Black Pill into a Black Magic Probe</title>
      <dc:creator>nickray</dc:creator>
      <pubDate>Tue, 18 Dec 2018 01:53:03 +0000</pubDate>
      <link>https://dev.to/nickray/turning-robotdyn-black-pill-into-a-black-magic-probe-j80</link>
      <guid>https://dev.to/nickray/turning-robotdyn-black-pill-into-a-black-magic-probe-j80</guid>
      <description>&lt;p&gt;&lt;code&gt;Actual date: 2018-12-18&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Today, my package from RobotDyn arrived, containing too many things, among them several STM32 ARM Mini Systems (aka "Black Pills"). They look great, cost $2.99, and don't have &lt;a href="http://wiki.stm32duino.com/index.php?title=RobotDyn_Black_Pill"&gt;the resistor problem&lt;/a&gt; most "Blue Pills" have. Since they are F103 boards, I will be able to test &lt;code&gt;mvirkunnen&lt;/code&gt;'s &lt;a href="https://github.com/mvirkkunen/stm32f103xx-usb"&gt;stm32f103-usb&lt;/a&gt; implementation, and eventually, hopefully, manage to implement the USB device for the L432 MCU I so sorely need to get the Rust efforts for &lt;a href="https://solokeys.com"&gt;SoloKeys&lt;/a&gt; off the ground.&lt;/p&gt;

&lt;h1&gt;
  
  
  Turning one of them into a BMP
&lt;/h1&gt;

&lt;p&gt;I followed &lt;a href="https://medium.com/@paramaggarwal/programming-an-stm32f103-board-using-usb-port-blue-pill-953cec0dbc86"&gt;this guide&lt;/a&gt;, which is referenced to from the &lt;a href="https://github.com/blacksphere/blackmagic/wiki/Debugger-Hardware"&gt;official documentation&lt;/a&gt; (search for "use a generic STM32F103 board").&lt;/p&gt;

&lt;h3&gt;
  
  
  Observations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;it's built for &lt;code&gt;PROBE_HOST=stlink&lt;/code&gt; since the same chip is on STM32's Nucleo and Discovery boards as STLink&lt;/li&gt;
&lt;li&gt;I added the initial BMP DFU bootloader &lt;code&gt;blackmagic_dfu.bin&lt;/code&gt; via my trusty &lt;a href="https://www.digitec.ch/de/s1/product/sparkfun-ftdi-basic-breakout-33v-elektronikmodul-5998762"&gt;FTDI breakout&lt;/a&gt;, which I probably overpaid. It turns up as &lt;code&gt;/dev/ttyUSB0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;on Linux, stm32loader needs root (or I didn't &lt;a href="https://solo.solokeys.io/udev/"&gt;fix the udev&lt;/a&gt; properly)&lt;/li&gt;
&lt;li&gt;the pill then enumerated nicely, identifying as &lt;code&gt;OpenMoko, Inc.&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;however: &lt;code&gt;dfu-util&lt;/code&gt; refuses to upload &lt;code&gt;blackmagic.bin&lt;/code&gt; as the F103 says it doesn't have enough flash. but: &lt;a href="https://github.com/blacksphere/blackmagic/blob/master/src/platforms/stlink/Flashsize_F103"&gt;this is not true&lt;/a&gt; - the cheaper versions of the chips just claim they have less flash than they do ;) Anyway, running &lt;code&gt;sudo python stm32_mem.py&lt;/code&gt; then worked&lt;/li&gt;
&lt;li&gt;and finally, &lt;code&gt;/dev/ttyACM0&lt;/code&gt; (the GDB server) and &lt;code&gt;/dev/ttyACM1&lt;/code&gt; (a USART line) turned up \o/&lt;/li&gt;
&lt;li&gt;since &lt;code&gt;cat /dev/ttyACM0&lt;/code&gt; didn't work, this time around I fixed the udev rules:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% cat /etc/udev/rules.d/99-black-magic-probe.rules 
# Black Magic Probe (on RobotDyn STM32 ARM Mini System aka "Black Pill")
# Bus 00x Device 0yy: ID 1d50:6018 OpenMoko, Inc.
ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6018", GROUP="uucp", TAG+="uaccess"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/blacksphere/blackmagic/blob/master/src/platforms/stlink/platform.h"&gt;double-checked&lt;/a&gt; that &lt;code&gt;SWDIO_PORT GPIOB&lt;/code&gt;, &lt;code&gt;SWDIO_PIN GPIO14&lt;/code&gt;, &lt;code&gt;SWCLK_PORT GPIOA&lt;/code&gt;, &lt;code&gt;SWCLK_PIN GPIO5&lt;/code&gt; are still correct&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Outcome
&lt;/h3&gt;

&lt;p&gt;Running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nicolas@berta ~/projects % gdb-multiarch -q                                                                                                                                                                       
&amp;gt;&amp;gt;&amp;gt; target extended-remote /dev/ttyACM0                                                                                                                                                                           
Remote debugging using /dev/ttyACM0
&amp;gt;&amp;gt;&amp;gt; monitor
Black Magic Probe (Firmware v1.6.1-224-g14bedcc) (Hardware Version 0)
Copyright (C) 2015  Black Sphere Technologies Ltd.
License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;

&amp;gt;&amp;gt;&amp;gt; monitor help                                                                                                                                                                                                  
General commands:
        version -- Display firmware version info                                                                                                                                                                  
        help -- Display help for monitor commands
        jtag_scan -- Scan JTAG chain for devices
        swdp_scan -- Scan SW-DP for devices
        targets -- Display list of available targets
        morse -- Display morse error message
        assert_srst -- Assert SRST until:(never(default)| scan | attach)
        halt_timeout -- Timeout (ms) to wait until Cortex-M is halted: (Default 2000)
        hard_srst -- Force a pulse on the hard SRST line - disconnects target
        traceswo -- Start trace capture [(baudrate) for async swo]
&amp;gt;&amp;gt;&amp;gt; monitor targets
Available Targets:
No. Att Driver
No usable targets found.
&amp;gt;&amp;gt;&amp;gt; monitor swdp_scan
Target voltage: unknown
Available Targets:
No. Att Driver
 1      STM32F1 medium density
&amp;gt;&amp;gt;&amp;gt; att 1
Attaching to Remote target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;was a strangely satisfying experience! No more OpenOCD! Hallelujah!&lt;/p&gt;

&lt;h1&gt;
  
  
  Next steps
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The L432 Nucleo (and maybe F3DISCOVERY too?) that I have don't expose the pins to connect to the newly created BMP :/ So, I will try next to just put the BMP firmware directly on the Nucleo's own F103, replacing the STLink firmware.&lt;/li&gt;
&lt;li&gt;test, finally, the Rust &lt;code&gt;usb-device&lt;/code&gt; implementation!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rust</category>
      <category>embedded</category>
      <category>solokeys</category>
    </item>
    <item>
      <title>Rustic OLED on the Nucleo</title>
      <dc:creator>nickray</dc:creator>
      <pubDate>Tue, 18 Dec 2018 01:52:04 +0000</pubDate>
      <link>https://dev.to/nickray/rustic-oled-on-the-nucleo-1o0m</link>
      <guid>https://dev.to/nickray/rustic-oled-on-the-nucleo-1o0m</guid>
      <description>&lt;p&gt;&lt;code&gt;Actual date: 2018-12-17 and 2018-12-18&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Since my &lt;a href="https://github.com/nickray/stm32l432-usb/commit/46bb0e30d2cf07f332b815ffca8f4f72d182cdb3"&gt;USB device efforts&lt;/a&gt; have not led anywhere so far, I diverted my efforts to get an OLED up and running, still on the STM32L4 platform. Eventually, it will be nice to have a &lt;a href="https://solokeys.com/preorder/"&gt;Solo key&lt;/a&gt; with an integrated display!&lt;/p&gt;

&lt;p&gt;Scott Mabin recently added &lt;a href="https://github.com/stm32-rs/stm32l4xx-hal/commit/2d65137a242ddc8c52948d1d6994c7465eaa776b"&gt;I2C support&lt;/a&gt; to his HAL, so I got everything ready quickly. It DID NOT WORK!!!!&lt;/p&gt;

&lt;p&gt;Well. First, I bought a very cheap soldering iron and did a horrible job (first solder experience in over two decades) of attaching the pins to my 0.91" 128x32 OLED (with an &lt;a href="https://github.com/jamwaffles/ssd1306"&gt;SSD1306&lt;/a&gt; chip). Still, did not work!&lt;/p&gt;

&lt;p&gt;Then, I discovered the 0.96" 128x64 OLED with the same chip was already pre-soldered... again, DID NOT WORK!&lt;/p&gt;

&lt;p&gt;(...)&lt;/p&gt;

&lt;p&gt;The next day, I finally followed both &lt;a href="https://conorpp.com/"&gt;Conor's&lt;/a&gt; and &lt;a href="https://github.com/stm32-rs/stm32l4xx-hal/issues/24"&gt;Scott's&lt;/a&gt; advice in trying different I2C addresses. A quick search suggested using &lt;code&gt;0x78&lt;/code&gt; (which is 2*&lt;code&gt;0x3c&lt;/code&gt;, which all the data sheets mention) for cheap Chinese clones such as mine, and ta-daa! Success!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xY6ffZSV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ii3804sqawlqo0cb2xfz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xY6ffZSV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ii3804sqawlqo0cb2xfz.jpeg" alt="SoloKeys logo on OLED, courtesy of Rust"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Further outcome of non-immediate success
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I want &lt;a href="http://www.miniware.com.cn/product/ts80-soldering-iron-more/"&gt;this soldering iron&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;I nearly want &lt;a href="https://www.reichelt.com/de/en/digital-storage-oscilloscope-50-mhz-4-channels-1gs-s-rigol-ds1054z-p239301.html?ARTICLE=239301&amp;amp;&amp;amp;r=1"&gt;this oscilloscope&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;I watched way too much &lt;a href="http://www.eevblog.com/"&gt;eevblog episodes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;I ordered more (cheap) stuff...&lt;/li&gt;
&lt;li&gt;My girlfriend is calling me nutty professor again :D&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rust</category>
      <category>embedded</category>
      <category>solokeys</category>
    </item>
  </channel>
</rss>
