<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Josip Seketa</title>
  <id>https://seketa.it/atom.xml</id>
  <updated>2026-09-13T04:02:29Z</updated>
  <link rel="self" href="https://seketa.it/atom.xml"/>
  <link href="https://seketa.it/"/>
  <entry>
    <title>What motivated this long and arduous journey</title>
    <id>https://seketa.it/usb-e-motivation/</id>
    <link href="https://seketa.it/usb-e-motivation/"/>
    <updated>2026-09-12T00:00:00Z</updated>
    <content type="html">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Why the fuck did I need this and what it brought upon me?&lt;/p&gt;
&lt;h2 id=&quot;problem-statement&quot;&gt;Problem statement&lt;/h2&gt;
</content>
  </entry>
  <entry>
    <title>In search of the architecture</title>
    <id>https://seketa.it/searching-for-architecture/</id>
    <link href="https://seketa.it/searching-for-architecture/"/>
    <updated>2026-09-12T00:00:00Z</updated>
    <content type="html">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Stumbling in the dark, searching for meaning and an architecture that could
fulfill the ever changing requirements and optimizations.&lt;/p&gt;
&lt;figure class=&quot;diagram photo&quot;&gt;
&lt;img src=&quot;/assets/images/usb-multiplexer-1x8.webp&quot; width=&quot;542&quot; height=&quot;513&quot; alt=&quot;Cleware USB Multiplexer 1x8: an aluminium box with eight USB-A ports, each with a red button and a status LED, and one USB input&quot;&gt;
&lt;figcaption&gt;Cleware USB Multiplexer 1x8. Photo: Cleware.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class=&quot;diagram photo&quot;&gt;
&lt;img src=&quot;/assets/images/bidirectional-usb-3-multiplexer-01.webp&quot; width=&quot;542&quot; height=&quot;364&quot; alt=&quot;The 8086.net Bi-Directional USB3 MUX from above: a blue board with three USB 3.0 Type-A ports and a three-pin header&quot;&gt;
&lt;figcaption&gt;USB 3.0 digital multiplexer&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class=&quot;diagram photo&quot;&gt;
&lt;img src=&quot;/assets/images/bidirectional-usb-3-multiplexer-02.webp&quot; width=&quot;542&quot; height=&quot;427&quot; alt=&quot;The same board from another angle, showing its silkscreen: 5V tolerant, the A to B and A to C switch table, and the 8086.net logo&quot;&gt;
&lt;figcaption&gt;USB 3.0 digital multiplexer&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class=&quot;diagram photo&quot;&gt;
&lt;img src=&quot;/assets/images/bidirectional-usb-3-multiplexer-03.webp&quot; width=&quot;542&quot; height=&quot;337&quot; alt=&quot;The underside of the board: the switching chip, small transistors and resistors, and the product link 8086.net/p/80860051&quot;&gt;
&lt;figcaption&gt;USB 3.0 digital multiplexer&lt;/figcaption&gt;
&lt;/figure&gt;
</content>
  </entry>
  <entry>
    <title>Two ways to draw a diagram</title>
    <id>https://seketa.it/diagrams/</id>
    <link href="https://seketa.it/diagrams/"/>
    <updated>2026-08-22T00:00:00Z</updated>
    <content type="html">&lt;p&gt;Every diagram here is written as plain text. The left column is &lt;strong&gt;Mermaid&lt;/strong&gt;,
parsed in your browser. The right is &lt;strong&gt;Graphviz&lt;/strong&gt;, compiled to SVG before the
page was built. Same information, two engines, and the differences are the
point.&lt;/p&gt;
&lt;p&gt;Both are self-hosted, so this page still makes no third-party requests. Mermaid
costs 3.4 MB of JavaScript and is opt-in per page — no other post on this site
loads it. Graphviz costs nothing at runtime; it runs on my machine and ships a
static SVG.&lt;/p&gt;
&lt;p&gt;Everything below follows the theme toggle in the header. Mermaid re-renders on
a palette change; the Graphviz SVGs are inlined rather than linked, so the same
CSS variables that colour this page colour them.&lt;/p&gt;
&lt;h2 id=&quot;flowchart&quot;&gt;Flowchart&lt;/h2&gt;
&lt;p&gt;The two-stage login from the OGame scraper.&lt;/p&gt;
&lt;figure class=&quot;diagram diagram--pair&quot;&gt;&lt;div class=&quot;pair&quot;&gt;&lt;div class=&quot;pair__side&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Mermaid&lt;span&gt;in the browser&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;mermaid&quot;&gt;flowchart TD
    A[POST credentials] --&amp;gt;|valid| B[200 OK&amp;lt;br/&amp;gt;bearer token]
    A --&amp;gt;|invalid| C[403 Forbidden]
    B --&amp;gt; D[GET accounts]
&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pair__side diagram--dot&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Graphviz&lt;span&gt;at build time&lt;/span&gt;&lt;/p&gt;&lt;svg
 viewBox=&quot;0.00 0.00 530.00 130.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 126)&quot;&gt;
&lt;title&gt;login&lt;/title&gt;
&lt;!-- post --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;post&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M98,-122C98,-122 12,-122 12,-122 6,-122 0,-116 0,-110 0,-110 0,-82 0,-82 0,-76 6,-70 12,-70 12,-70 98,-70 98,-70 104,-70 110,-76 110,-82 110,-82 110,-110 110,-110 110,-116 104,-122 98,-122&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;55&quot; y=&quot;-99.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;POST&lt;/text&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;55&quot; y=&quot;-85.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;credentials&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ok --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ok&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M321,-122C321,-122 224,-122 224,-122 218,-122 212,-116 212,-110 212,-110 212,-82 212,-82 212,-76 218,-70 224,-70 224,-70 321,-70 321,-70 327,-70 333,-76 333,-82 333,-82 333,-110 333,-110 333,-116 327,-122 321,-122&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;272.5&quot; y=&quot;-99.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;200 OK&lt;/text&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;272.5&quot; y=&quot;-85.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;bearer token&lt;/text&gt;
&lt;/g&gt;
&lt;!-- post&amp;#45;&amp;gt;ok --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;post&amp;#45;&amp;gt;ok&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M110.1,-96C138.36,-96 173.24,-96 203.33,-96&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;203.68,-98.8 211.68,-96 203.68,-93.2 203.68,-98.8&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;158.5&quot; y=&quot;-99&quot; font-family=&quot;monospace&quot; font-size=&quot;10.00&quot;&gt;valid&lt;/text&gt;
&lt;/g&gt;
&lt;!-- bad --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node dead&quot;&gt;
&lt;title&gt;bad&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M326,-38C326,-38 219,-38 219,-38 213,-38 207,-32 207,-26 207,-26 207,-12 207,-12 207,-6 213,0 219,0 219,0 326,0 326,0 332,0 338,-6 338,-12 338,-12 338,-26 338,-26 338,-32 332,-38 326,-38&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;272.5&quot; y=&quot;-15.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;403 Forbidden&lt;/text&gt;
&lt;/g&gt;
&lt;!-- post&amp;#45;&amp;gt;bad --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge dead&quot;&gt;
&lt;title&gt;post&amp;#45;&amp;gt;bad&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M110.1,-76.67C140.56,-65.79 178.7,-52.16 210.25,-40.88&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;211.53,-43.4 218.12,-38.07 209.65,-38.13 211.53,-43.4&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;158.5&quot; y=&quot;-70&quot; font-family=&quot;monospace&quot; font-size=&quot;10.00&quot;&gt;invalid&lt;/text&gt;
&lt;/g&gt;
&lt;!-- acct --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;acct&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M510,-122C510,-122 405,-122 405,-122 399,-122 393,-116 393,-110 393,-110 393,-82 393,-82 393,-76 399,-70 405,-70 405,-70 510,-70 510,-70 516,-70 522,-76 522,-82 522,-82 522,-110 522,-110 522,-116 516,-122 510,-122&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;457.5&quot; y=&quot;-99.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;GET accounts&lt;/text&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;457.5&quot; y=&quot;-85.6&quot; font-family=&quot;sans-serif&quot; font-size=&quot;13.00&quot;&gt;for this player&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ok&amp;#45;&amp;gt;acct --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ok:e&amp;#45;&amp;gt;acct:w&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M333.5,-96C357.05,-96 364.87,-96 384.98,-96&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;385,-98.8 393,-96 385,-93.2 385,-98.8&quot;/&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;&lt;/div&gt;&lt;/div&gt;&lt;figcaption&gt;Graphviz was told to put both outcomes on one rank and to keep the dead branch out of the layout calculation. Mermaid decides for itself.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;The Graphviz source says things Mermaid has no syntax for:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;{ rank=same; ok; bad }                   // the fork reads as a fork
post -&amp;gt; ok  [label=&amp;quot;valid&amp;quot;, weight=10];  // straighten the path that matters
post -&amp;gt; bad [constraint=false];          // dead end stops distorting layout
ok:e -&amp;gt; acct:w;                          // exact compass attach points
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;state-machine&quot;&gt;State machine&lt;/h2&gt;
&lt;p&gt;The SWJ-DP, and the one-way door into a locked part.&lt;/p&gt;
&lt;figure class=&quot;diagram diagram--pair&quot;&gt;&lt;div class=&quot;pair&quot;&gt;&lt;div class=&quot;pair__side&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Mermaid&lt;span&gt;in the browser&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;mermaid&quot;&gt;stateDiagram-v2
    [*] --&amp;gt; JTAG: power-up
    JTAG --&amp;gt; SWD: 0xE79E
    SWD --&amp;gt; JTAG: 0xE73C
    SWD --&amp;gt; Locked: SWJ_CFG=100
    Locked --&amp;gt; SWD: BOOT0 + reset
&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pair__side diagram--dot&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Graphviz&lt;span&gt;at build time&lt;/span&gt;&lt;/p&gt;&lt;svg
 viewBox=&quot;0.00 0.00 139.98 251.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 247)&quot;&gt;
&lt;title&gt;swj&lt;/title&gt;
&lt;!-- start --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node pip&quot;&gt;
&lt;title&gt;start&lt;/title&gt;
&lt;ellipse fill=&quot;lightgrey&quot; stroke=&quot;black&quot; cx=&quot;49.98&quot; cy=&quot;-237&quot; rx=&quot;6&quot; ry=&quot;6&quot;/&gt;
&lt;/g&gt;
&lt;!-- JTAG --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;JTAG&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M69.65,-185C69.65,-185 30.32,-185 30.32,-185 25.15,-185 19.98,-179.83 19.98,-174.67 19.98,-174.67 19.98,-164.33 19.98,-164.33 19.98,-159.17 25.15,-154 30.32,-154 30.32,-154 69.65,-154 69.65,-154 74.82,-154 79.98,-159.17 79.98,-164.33 79.98,-164.33 79.98,-174.67 79.98,-174.67 79.98,-179.83 74.82,-185 69.65,-185&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;49.98&quot; y=&quot;-166.4&quot; font-family=&quot;sans-serif&quot; font-size=&quot;12.00&quot;&gt;JTAG&lt;/text&gt;
&lt;/g&gt;
&lt;!-- start&amp;#45;&amp;gt;JTAG --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;start&amp;#45;&amp;gt;JTAG&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M49.98,-230.86C49.98,-222.67 49.98,-206.17 49.98,-192.49&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;52.43,-192.26 49.98,-185.26 47.53,-192.26 52.43,-192.26&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;71.48&quot; y=&quot;-205.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;power&amp;#45;up&lt;/text&gt;
&lt;/g&gt;
&lt;!-- SWD --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;SWD&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M70.15,-108C70.15,-108 29.82,-108 29.82,-108 24.65,-108 19.48,-102.83 19.48,-97.67 19.48,-97.67 19.48,-87.33 19.48,-87.33 19.48,-82.17 24.65,-77 29.82,-77 29.82,-77 70.15,-77 70.15,-77 75.32,-77 80.48,-82.17 80.48,-87.33 80.48,-87.33 80.48,-97.67 80.48,-97.67 80.48,-102.83 75.32,-108 70.15,-108&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;49.98&quot; y=&quot;-89.4&quot; font-family=&quot;sans-serif&quot; font-size=&quot;12.00&quot;&gt;SWD&lt;/text&gt;
&lt;/g&gt;
&lt;!-- JTAG&amp;#45;&amp;gt;SWD --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;JTAG&amp;#45;&amp;gt;SWD&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M28.68,-153.86C23.18,-148.89 17.97,-142.84 14.98,-136 11.39,-127.76 15.16,-119.84 21.37,-113.12&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;23.13,-114.82 26.51,-108.22 19.75,-111.27 23.13,-114.82&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;30.98&quot; y=&quot;-128.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;0xE79E&lt;/text&gt;
&lt;/g&gt;
&lt;!-- SWD&amp;#45;&amp;gt;JTAG --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;SWD&amp;#45;&amp;gt;JTAG&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M49.98,-108.03C49.98,-118.92 49.98,-134.01 49.98,-146.39&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;47.53,-146.68 49.98,-153.68 52.43,-146.68 47.53,-146.68&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;65.98&quot; y=&quot;-128.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;0xE73C&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Locked --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node dead&quot;&gt;
&lt;title&gt;Locked&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M77.15,-31C77.15,-31 22.82,-31 22.82,-31 17.65,-31 12.48,-25.83 12.48,-20.67 12.48,-20.67 12.48,-10.33 12.48,-10.33 12.48,-5.17 17.65,0 22.82,0 22.82,0 77.15,0 77.15,0 82.32,0 87.48,-5.17 87.48,-10.33 87.48,-10.33 87.48,-20.67 87.48,-20.67 87.48,-25.83 82.32,-31 77.15,-31&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;49.98&quot; y=&quot;-12.4&quot; font-family=&quot;sans-serif&quot; font-size=&quot;12.00&quot;&gt;Locked&lt;/text&gt;
&lt;/g&gt;
&lt;!-- SWD&amp;#45;&amp;gt;Locked --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge dead&quot;&gt;
&lt;title&gt;SWD&amp;#45;&amp;gt;Locked&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M19.46,-77.31C12.47,-72.53 5.94,-66.47 1.98,-59 -2.81,-49.97 2.01,-41.95 10.17,-35.38&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;11.96,-37.11 16.27,-31.07 9.14,-33.11 11.96,-37.11&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;30.98&quot; y=&quot;-51.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;SWJ_CFG=100&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Locked&amp;#45;&amp;gt;SWD --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Locked&amp;#45;&amp;gt;SWD&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5,2&quot; d=&quot;M57.16,-31.03C59.51,-36.52 61.81,-42.91 62.98,-49 64.31,-55.9 63.05,-63.27 60.87,-69.9&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;58.46,-69.34 58.23,-76.75 63.04,-71.1 58.46,-69.34&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;97.48&quot; y=&quot;-51.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;BOOT0 + reset&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;&lt;/div&gt;&lt;/div&gt;&lt;figcaption&gt;Mermaid&amp;#39;s stateDiagram-v2 knows what a start state is; in Graphviz it is a small filled circle you draw yourself.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;class-diagram&quot;&gt;Class diagram&lt;/h2&gt;
&lt;figure class=&quot;diagram diagram--pair&quot;&gt;&lt;div class=&quot;pair&quot;&gt;&lt;div class=&quot;pair__side&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Mermaid&lt;span&gt;in the browser&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;mermaid&quot;&gt;classDiagram
    class Service {
        +String name
        +Number port
        +start()
    }
    class UniverseService {
        +exists(name, lang)
    }
    class AccountService {
        +listForPlayer(token)
    }
    Service &amp;lt;|-- UniverseService
    Service &amp;lt;|-- AccountService
&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pair__side diagram--dot&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Graphviz&lt;span&gt;at build time&lt;/span&gt;&lt;/p&gt;&lt;svg
 viewBox=&quot;0.00 0.00 314.00 162.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 158)&quot;&gt;
&lt;title&gt;services&lt;/title&gt;
&lt;!-- Service --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Service&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;98,-0.5 98,-72.5 205,-72.5 205,-0.5 98,-0.5&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;151.5&quot; y=&quot;-59.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;Service&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;98,-52.5 205,-52.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;106&quot; y=&quot;-39.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;+ name : String&lt;/text&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;106&quot; y=&quot;-27.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;+ port : Number&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;98,-20.5 205,-20.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;106&quot; y=&quot;-7.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;+ start()&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Universe --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Universe&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;0,-113.5 0,-153.5 133,-153.5 133,-113.5 0,-113.5&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;66.5&quot; y=&quot;-140.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;UniverseService&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;0,-133.5 133,-133.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;8&quot; y=&quot;-120.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;+ exists(name, lang)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Universe&amp;#45;&amp;gt;Service --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Universe&amp;#45;&amp;gt;Service&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M83.7,-113.28C92.38,-103.58 103.27,-91.4 113.77,-79.67&quot;/&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;116.23,-81.64 119.88,-72.84 111.53,-77.44 116.23,-81.64&quot;/&gt;
&lt;/g&gt;
&lt;!-- Account --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Account&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;169,-113.5 169,-153.5 306,-153.5 306,-113.5 169,-113.5&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;237.5&quot; y=&quot;-140.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;AccountService&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;169,-133.5 306,-133.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;177&quot; y=&quot;-120.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;+ listForPlayer(token)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Account&amp;#45;&amp;gt;Service --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Account&amp;#45;&amp;gt;Service&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M220.1,-113.28C211.32,-103.58 200.3,-91.4 189.68,-79.67&quot;/&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;191.86,-77.39 183.49,-72.84 187.19,-81.62 191.86,-77.39&quot;/&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;&lt;/div&gt;&lt;/div&gt;&lt;figcaption&gt;Mermaid has real class semantics. Graphviz is drawing a record shape that happens to look like a class.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;That &lt;code&gt;&amp;lt;|--&lt;/code&gt; is worth a note. A shortcode that passes its body through
unescaped hands the browser a &lt;code&gt;&amp;lt;&lt;/code&gt; followed by a pipe, and the parser has
opinions. Escaping it is what makes the class diagram survive.&lt;/p&gt;
&lt;h2 id=&quot;entity-relationship&quot;&gt;Entity relationship&lt;/h2&gt;
&lt;figure class=&quot;diagram diagram--pair&quot;&gt;&lt;div class=&quot;pair&quot;&gt;&lt;div class=&quot;pair__side&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Mermaid&lt;span&gt;in the browser&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;mermaid&quot;&gt;erDiagram
    PLAYER ||--o{ ACCOUNT : owns
    ACCOUNT }o--|| UNIVERSE : &amp;quot;lives in&amp;quot;
    UNIVERSE {
        string name
        string language
        int playerCount
    }
    ACCOUNT {
        string id
        string server
    }
&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pair__side diagram--dot&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Graphviz&lt;span&gt;at build time&lt;/span&gt;&lt;/p&gt;&lt;svg
 viewBox=&quot;0.00 0.00 576.00 53.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 49)&quot;&gt;
&lt;title&gt;er&lt;/title&gt;
&lt;!-- Player --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Player&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;0,-4.5 0,-40.5 84,-40.5 84,-4.5 0,-4.5&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;29&quot; y=&quot;-19.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;PLAYER&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;58,-4.5 58,-40.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;66&quot; y=&quot;-19.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;id&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Account --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Account&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;190,-4.5 190,-40.5 313,-40.5 313,-4.5 190,-4.5&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;225.5&quot; y=&quot;-19.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;ACCOUNT&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;261,-4.5 261,-40.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;269&quot; y=&quot;-25.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;id&lt;/text&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;269&quot; y=&quot;-13.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Player&amp;#45;&amp;gt;Account --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Player&amp;#45;&amp;gt;Account&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.49,-22.5C112.53,-22.5 150.19,-22.5 182.56,-22.5&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;182.81,-24.95 189.81,-22.5 182.81,-20.05 182.81,-24.95&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;137&quot; y=&quot;-25.3&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;owns 1..n&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Universe --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Universe&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;414,-0.5 414,-44.5 568,-44.5 568,-0.5 414,-0.5&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;449.5&quot; y=&quot;-19.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;UNIVERSE&lt;/text&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;485,-0.5 485,-44.5 &quot;/&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;493&quot; y=&quot;-31.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;name&lt;/text&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;493&quot; y=&quot;-19.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;language&lt;/text&gt;
&lt;text text-anchor=&quot;start&quot; x=&quot;493&quot; y=&quot;-7.7&quot; font-family=&quot;sans-serif&quot; font-size=&quot;11.00&quot;&gt;playerCount&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Account&amp;#45;&amp;gt;Universe --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Account&amp;#45;&amp;gt;Universe&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M313.05,-22.5C341.42,-22.5 375.68,-22.5 406.47,-22.5&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;406.8,-24.95 413.8,-22.5 406.8,-20.05 406.8,-24.95&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;363.5&quot; y=&quot;-25.3&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;lives in&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;&lt;/div&gt;&lt;/div&gt;&lt;figcaption&gt;Crow&amp;#39;s feet are built into Mermaid. Graphviz needs the cardinality written on the edge as a label.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;commit-history&quot;&gt;Commit history&lt;/h2&gt;
&lt;figure class=&quot;diagram diagram--pair&quot;&gt;&lt;div class=&quot;pair&quot;&gt;&lt;div class=&quot;pair__side&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Mermaid&lt;span&gt;in the browser&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;mermaid&quot;&gt;gitGraph
    commit id: &amp;quot;jekyll&amp;quot;
    branch zola
    checkout zola
    commit id: &amp;quot;port content&amp;quot;
    commit id: &amp;quot;workshop design&amp;quot;
    commit id: &amp;quot;diagrams&amp;quot;
&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pair__side diagram--dot&quot;&gt;&lt;p class=&quot;pair__label&quot;&gt;Graphviz&lt;span&gt;at build time&lt;/span&gt;&lt;/p&gt;&lt;svg
 viewBox=&quot;0.00 0.00 243.00 34.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 30)&quot;&gt;
&lt;title&gt;rebuild&lt;/title&gt;
&lt;!-- c1 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c1&lt;/title&gt;
&lt;ellipse fill=&quot;lightgrey&quot; stroke=&quot;black&quot; cx=&quot;40&quot; cy=&quot;-18&quot; rx=&quot;8&quot; ry=&quot;8&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;16&quot; y=&quot;-2.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;jekyll&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c2 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c2&lt;/title&gt;
&lt;ellipse fill=&quot;lightgrey&quot; stroke=&quot;black&quot; cx=&quot;88&quot; cy=&quot;-18&quot; rx=&quot;8&quot; ry=&quot;8&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;64&quot; y=&quot;-2.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;port content&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c1&amp;#45;&amp;gt;c2 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;c1&amp;#45;&amp;gt;c2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M48.19,-18C54.9,-18 65.09,-18 73.35,-18&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;73.71,-20.1 79.71,-18 73.71,-15.9 73.71,-20.1&quot;/&gt;
&lt;/g&gt;
&lt;!-- c3 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c3&lt;/title&gt;
&lt;ellipse fill=&quot;lightgrey&quot; stroke=&quot;black&quot; cx=&quot;136&quot; cy=&quot;-18&quot; rx=&quot;8&quot; ry=&quot;8&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;183.5&quot; y=&quot;-2.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;workshop design&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c2&amp;#45;&amp;gt;c3 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;c2&amp;#45;&amp;gt;c3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M96.19,-18C102.9,-18 113.09,-18 121.35,-18&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;121.71,-20.1 127.71,-18 121.71,-15.9 121.71,-20.1&quot;/&gt;
&lt;/g&gt;
&lt;!-- c4 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c4&lt;/title&gt;
&lt;ellipse fill=&quot;lightgrey&quot; stroke=&quot;black&quot; cx=&quot;184&quot; cy=&quot;-18&quot; rx=&quot;8&quot; ry=&quot;8&quot;/&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;213.5&quot; y=&quot;-12.8&quot; font-family=&quot;monospace&quot; font-size=&quot;9.00&quot;&gt;diagrams&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c3&amp;#45;&amp;gt;c4 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;c3&amp;#45;&amp;gt;c4&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M144.19,-18C150.9,-18 161.09,-18 169.35,-18&quot;/&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;169.71,-20.1 175.71,-18 169.71,-15.9 169.71,-20.1&quot;/&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;&lt;/div&gt;&lt;/div&gt;&lt;figcaption&gt;A git graph is a directed acyclic graph, which is the thing Graphviz was built for. This is the one where it is arguably the better fit.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;where-graphviz-simply-has-nothing&quot;&gt;Where Graphviz simply has nothing&lt;/h2&gt;
&lt;p&gt;Three of the diagram types below have no Graphviz equivalent. Not a harder
equivalent — none. Graphviz draws graphs: nodes joined by edges. A sequence
diagram is a timeline, a gantt is a calendar, a pie is a proportion, and none
of those are graphs.&lt;/p&gt;
&lt;h3 id=&quot;sequence&quot;&gt;Sequence&lt;/h3&gt;
&lt;figure class=&quot;diagram&quot;&gt;&lt;pre class=&quot;mermaid&quot;&gt;sequenceDiagram
    participant H as Host
    participant T as Target
    H-&amp;gt;&amp;gt;T: 8-bit request
    Note over H,T: turnaround
    T--&amp;gt;&amp;gt;H: 3-bit ACK
    Note over H,T: turnaround
    H-&amp;gt;&amp;gt;T: 32 data bits + parity
&lt;/pre&gt;&lt;figcaption&gt;Mermaid only. The turnaround periods are the part that is easy to miss when reading the SWD spec.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;gantt&quot;&gt;Gantt&lt;/h3&gt;
&lt;figure class=&quot;diagram&quot;&gt;&lt;pre class=&quot;mermaid&quot;&gt;gantt
    title Posts, by project
    dateFormat YYYY-MM-DD
    axisFormat %Y
    section STM32
    Setting it all up      :done, 2018-06-02, 90d
    How SWD actually works :active, 2026-08-21, 60d
    section OGame
    Initial design         :done, 2020-08-23, 40d
    Microservices          :done, 2020-09-27, 40d
    section Go
    Golang notes           :done, 2022-10-16, 60d
&lt;/pre&gt;&lt;figcaption&gt;Mermaid only. The publishing history of this site, including the silences.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;pie&quot;&gt;Pie&lt;/h3&gt;
&lt;figure class=&quot;diagram&quot;&gt;&lt;pre class=&quot;mermaid&quot;&gt;pie showData
    title Code in these posts, by language
    &amp;quot;C&amp;quot; : 96
    &amp;quot;ARM asm&amp;quot; : 34
    &amp;quot;JavaScript&amp;quot; : 88
    &amp;quot;JSON&amp;quot; : 62
    &amp;quot;Makefile&amp;quot; : 44
&lt;/pre&gt;&lt;figcaption&gt;Mermaid only.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;bars&quot;&gt;Bars&lt;/h3&gt;
&lt;figure class=&quot;diagram&quot;&gt;&lt;pre class=&quot;mermaid&quot;&gt;xychart-beta horizontal
    title &amp;quot;Code in these posts, by language&amp;quot;
    x-axis [C, &amp;quot;ARM asm&amp;quot;, JavaScript, JSON, Makefile]
    y-axis &amp;quot;lines&amp;quot; 0 --&amp;gt; 100
    bar [96, 34, 88, 62, 44]
&lt;/pre&gt;&lt;figcaption&gt;Mermaid only. The same numbers as the pie, with the names on the axis instead of in a legend.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;what-the-comparison-actually-shows&quot;&gt;What the comparison actually shows&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Mermaid wins on breadth and on effort.&lt;/strong&gt; It has diagram types Graphviz will
never have, the source lives in the post, and there is no build step. It also
renders on GitHub, so the markdown is not inert in the repository.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Graphviz wins on control and on weight.&lt;/strong&gt; &lt;code&gt;rank&lt;/code&gt;, &lt;code&gt;weight&lt;/code&gt;, &lt;code&gt;constraint&lt;/code&gt;,
&lt;code&gt;group&lt;/code&gt; and compass ports let you insist on an arrangement rather than accept
one, and the reader downloads no JavaScript at all. The cost is a separate
file per diagram and a script that has to run before the site builds.&lt;/p&gt;
&lt;p&gt;The honest split: Mermaid for diagrams where the shape does not carry meaning,
Graphviz when it does or when the page should stay free of JavaScript. Neither
is the default; the diagram decides.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>How SWD actually works</title>
    <id>https://seketa.it/swd-protocol/</id>
    <link href="https://seketa.it/swd-protocol/"/>
    <updated>2026-08-21T00:00:00Z</updated>
    <content type="html">&lt;p&gt;In the first post I wired six pins between the J-Link and the blue pill, typed
&lt;code&gt;connect&lt;/code&gt;, and the chip answered. That was enough to get a LED blinking, but
“it answered” is not an explanation. Two of those six wires do all the work,
and I wanted to know what they were actually saying.&lt;/p&gt;
&lt;h2 id=&quot;why-two-wires-and-not-five&quot;&gt;Why two wires and not five&lt;/h2&gt;
&lt;p&gt;JTAG wants TCK, TMS, TDI and TDO, and usually NJTRST as well. On a 48-pin part
that is a lot of pins to spend on something you only need while developing.&lt;/p&gt;
&lt;p&gt;Serial Wire Debug does the same job with two: &lt;strong&gt;SWDIO&lt;/strong&gt; for data and &lt;strong&gt;SWCLK&lt;/strong&gt;
for the clock. On the STM32F103 the two protocols share pins, and the debug
block that arbitrates between them is called the SWJ-DP:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Pin&lt;/th&gt;&lt;th&gt;JTAG&lt;/th&gt;&lt;th&gt;SWD&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;PA13&lt;/td&gt;&lt;td&gt;JTMS&lt;/td&gt;&lt;td&gt;SWDIO&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PA14&lt;/td&gt;&lt;td&gt;JTCK&lt;/td&gt;&lt;td&gt;SWCLK&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PA15&lt;/td&gt;&lt;td&gt;JTDI&lt;/td&gt;&lt;td&gt;free&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PB3&lt;/td&gt;&lt;td&gt;JTDO&lt;/td&gt;&lt;td&gt;TRACESWO&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PB4&lt;/td&gt;&lt;td&gt;NJTRST&lt;/td&gt;&lt;td&gt;free&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Choosing SWD hands PA15 and PB4 back to you as ordinary GPIO, and leaves PB3
available for trace output if you want it. There is a way to lose all of this
permanently, which I get to at the end.&lt;/p&gt;
&lt;h2 id=&quot;the-wire-protocol&quot;&gt;The wire protocol&lt;/h2&gt;
&lt;p&gt;SWCLK is always driven by the host. SWDIO is bidirectional, and both ends
follow the same rule: drive SWDIO on the falling edge of SWCLK, sample it on
the rising edge.&lt;/p&gt;
&lt;h3 id=&quot;turnaround&quot;&gt;Turnaround&lt;/h3&gt;
&lt;p&gt;Because one line carries both directions, there has to be a moment where
nobody drives it while ownership changes. That is the &lt;strong&gt;turnaround&lt;/strong&gt; period,
one clock cycle by default, and it happens twice in every transaction: after
the host finishes its request, and again after the target finishes its reply.&lt;/p&gt;
&lt;p&gt;Drawn out, one whole read looks like this:&lt;/p&gt;
&lt;figure class=&quot;diagram diagram--wave&quot;&gt;&lt;script type=&quot;WaveDrom&quot;&gt;{ &quot;signal&quot;: [
  { &quot;name&quot;: &quot;SWCLK&quot;,     &quot;wave&quot;: &quot;P.............|............&quot; },
  { &quot;name&quot;: &quot;SWDIO&quot;,     &quot;wave&quot;: &quot;03.......z4..5|.......6z0..&quot;, &quot;data&quot;: [&quot;8-bit request&quot;, &quot;ACK&quot;, &quot;32-bit data&quot;, &quot;P&quot;] },
  {},
  { &quot;name&quot;: &quot;driven by&quot;, &quot;wave&quot;: &quot;5........z6...|........z5..&quot;, &quot;data&quot;: [&quot;host&quot;, &quot;target&quot;, &quot;host&quot;] }
],
&quot;config&quot;: { &quot;skin&quot;: &quot;narrow&quot; }
}
&lt;/script&gt;&lt;figcaption&gt;A read transaction; P is the parity bit. The two z regions are the turnarounds: neither end is driving, which is what makes a single-wire bidirectional bus possible.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;line-states&quot;&gt;Line states&lt;/h3&gt;
&lt;p&gt;Two more line states matter:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Line reset&lt;/strong&gt; — at least 50 clock cycles with SWDIO held high. This puts
the debug port into a known state, and is how every session starts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Idle&lt;/strong&gt; — clocks with SWDIO low. The target needs these to finish posted
work, which turns out to matter more than it sounds like it should.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;bit-banging-it&quot;&gt;Bit-banging it&lt;/h3&gt;
&lt;p&gt;Bit-banging the physical layer is two functions:&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__file&quot;&gt;swd.c&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-c&quot;&gt;&lt;span class=&quot;s-storage s-modifier s-c&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;swd_clock_out&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;bit&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-begin s-c&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;swclk_low&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;          &lt;span class=&quot;s-comment s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;/*&lt;/span&gt; target samples on the rising edge, so set up now &lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;swdio_write&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;bit&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;swclk_high&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-end s-c&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;s-storage s-modifier s-c&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;swd_clock_in&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-storage s-type s-c&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-begin s-c&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;
	&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; bit&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;swclk_low&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;          &lt;span class=&quot;s-comment s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;/*&lt;/span&gt; target drives SWDIO here &lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;swclk_high&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	bit &lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;swdio_read&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;s-comment s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;/*&lt;/span&gt; sample on the rising edge &lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;s-keyword s-control s-c&quot;&gt;return&lt;/span&gt; bit&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-end s-c&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;convincing-the-chip-to-speak-swd&quot;&gt;Convincing the chip to speak SWD&lt;/h2&gt;
&lt;p&gt;After power-up the SWJ-DP may still be listening for JTAG. Switching it over
is a fixed incantation:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Line reset: 50 or more clocks, SWDIO high.&lt;/li&gt;
&lt;li&gt;Send the 16-bit JTAG-to-SWD select sequence &lt;code&gt;0xE79E&lt;/code&gt;, least significant bit
first, so &lt;code&gt;0111 1001 1110 0111&lt;/code&gt; goes out on the wire.&lt;/li&gt;
&lt;li&gt;Line reset again.&lt;/li&gt;
&lt;li&gt;Read the DP IDCODE register. A sane value back means you are in SWD.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;reset    1111111111 ... 1111111111    (&amp;gt;= 50 cycles, SWDIO high)
select   0111100111100111             (0xE79E, LSB first)
reset    1111111111 ... 1111111111    (&amp;gt;= 50 cycles)
read     DP register 0x00 (IDCODE)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The mirror-image sequence &lt;code&gt;0xE73C&lt;/code&gt; switches back to JTAG, which I have never
had a reason to use.&lt;/p&gt;
&lt;h2 id=&quot;one-transaction&quot;&gt;One transaction&lt;/h2&gt;
&lt;p&gt;Everything after the handshake has the same shape: an 8-bit request from the
host, a 3-bit acknowledgement from the target, and a 33-bit data phase, with a
turnaround cycle either side of the acknowledgement.&lt;/p&gt;
&lt;h3 id=&quot;the-request&quot;&gt;The request&lt;/h3&gt;
&lt;p&gt;The request, again LSB first:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;Start&lt;/td&gt;&lt;td&gt;always 1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;APnDP&lt;/td&gt;&lt;td&gt;0 = debug port, 1 = access port&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;RnW&lt;/td&gt;&lt;td&gt;0 = write, 1 = read&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;A[2]&lt;/td&gt;&lt;td&gt;register address bit 2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;A[3]&lt;/td&gt;&lt;td&gt;register address bit 3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Parity&lt;/td&gt;&lt;td&gt;even parity over bits 1 to 4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Stop&lt;/td&gt;&lt;td&gt;always 0&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Park&lt;/td&gt;&lt;td&gt;always 1&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Or as it sits on the wire:&lt;/p&gt;
&lt;figure class=&quot;diagram diagram--bytefield&quot;&gt;&lt;svg xmlns:svg=&quot;http://www.w3.org/2000/svg&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; version=&quot;1.0&quot; viewBox=&quot;0 0 553 50&quot; &gt;&lt;text x=&quot;72&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;0&lt;/text&gt;&lt;text x=&quot;136&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;1&lt;/text&gt;&lt;text x=&quot;200&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;2&lt;/text&gt;&lt;text x=&quot;264&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;3&lt;/text&gt;&lt;text x=&quot;328&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;4&lt;/text&gt;&lt;text x=&quot;392&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;5&lt;/text&gt;&lt;text x=&quot;456&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;6&lt;/text&gt;&lt;text x=&quot;520&quot; y=&quot;8&quot; font-family=&quot;Courier New, monospace&quot; font-size=&quot;11&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot; &gt;7&lt;/text&gt;&lt;line x1=&quot;40&quot; y1=&quot;15&quot; x2=&quot;104&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;40&quot; y1=&quot;49&quot; x2=&quot;104&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;104&quot; y1=&quot;15&quot; x2=&quot;104&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;40&quot; y1=&quot;15&quot; x2=&quot;40&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;72&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;Start&lt;/text&gt;&lt;line x1=&quot;104&quot; y1=&quot;15&quot; x2=&quot;168&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;104&quot; y1=&quot;49&quot; x2=&quot;168&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;168&quot; y1=&quot;15&quot; x2=&quot;168&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;104&quot; y1=&quot;15&quot; x2=&quot;104&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;136&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;APnDP&lt;/text&gt;&lt;line x1=&quot;168&quot; y1=&quot;15&quot; x2=&quot;232&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;168&quot; y1=&quot;49&quot; x2=&quot;232&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;232&quot; y1=&quot;15&quot; x2=&quot;232&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;168&quot; y1=&quot;15&quot; x2=&quot;168&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;200&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;RnW&lt;/text&gt;&lt;line x1=&quot;232&quot; y1=&quot;15&quot; x2=&quot;296&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;232&quot; y1=&quot;49&quot; x2=&quot;296&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;296&quot; y1=&quot;15&quot; x2=&quot;296&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;232&quot; y1=&quot;15&quot; x2=&quot;232&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;264&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;A[2]&lt;/text&gt;&lt;line x1=&quot;296&quot; y1=&quot;15&quot; x2=&quot;360&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;296&quot; y1=&quot;49&quot; x2=&quot;360&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;360&quot; y1=&quot;15&quot; x2=&quot;360&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;296&quot; y1=&quot;15&quot; x2=&quot;296&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;328&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;A[3]&lt;/text&gt;&lt;line x1=&quot;360&quot; y1=&quot;15&quot; x2=&quot;424&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;360&quot; y1=&quot;49&quot; x2=&quot;424&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;424&quot; y1=&quot;15&quot; x2=&quot;424&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;360&quot; y1=&quot;15&quot; x2=&quot;360&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;392&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;Parity&lt;/text&gt;&lt;line x1=&quot;424&quot; y1=&quot;15&quot; x2=&quot;488&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;424&quot; y1=&quot;49&quot; x2=&quot;488&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;488&quot; y1=&quot;15&quot; x2=&quot;488&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;424&quot; y1=&quot;15&quot; x2=&quot;424&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;456&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;Stop&lt;/text&gt;&lt;line x1=&quot;488&quot; y1=&quot;15&quot; x2=&quot;552&quot; y2=&quot;15&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;488&quot; y1=&quot;49&quot; x2=&quot;552&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;552&quot; y1=&quot;15&quot; x2=&quot;552&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;line x1=&quot;488&quot; y1=&quot;15&quot; x2=&quot;488&quot; y2=&quot;49&quot; stroke=&quot;#000000&quot; stroke-width=&quot;1&quot; /&gt;&lt;text font-size=&quot;18&quot; font-family=&quot;Palatino, Georgia, Times New Roman, serif&quot; x=&quot;520&quot; y=&quot;33&quot; text-anchor=&quot;middle&quot; dominant-baseline=&quot;middle&quot; &gt;Park&lt;/text&gt;&lt;/svg&gt;&lt;figcaption&gt;The 8-bit request, least significant bit first.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;building-it&quot;&gt;Building it&lt;/h3&gt;
&lt;p&gt;Only two address bits, because the register space is deliberately tiny. The
&lt;code&gt;SELECT&lt;/code&gt; register does the rest of the addressing. Building a request is four
lines:&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__file&quot;&gt;swd.c&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-c&quot;&gt;&lt;span class=&quot;s-storage s-modifier s-c&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s-support s-type s-stdint s-c&quot;&gt;uint8_t&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;swd_request&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s-support s-type s-stdint s-c&quot;&gt;uint8_t&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-begin s-c&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;
	&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; a2 &lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;addr &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-c&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; a3 &lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;addr &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-c&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; parity &lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt; ap &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;^&lt;/span&gt; read &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;^&lt;/span&gt; a2 &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;^&lt;/span&gt; a3&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;s-keyword s-control s-c&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;      &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;   &lt;span class=&quot;s-comment s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;/*&lt;/span&gt; start &lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;ap     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;read   &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;a2     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;a3     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;parity &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;      &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;   &lt;span class=&quot;s-comment s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;/*&lt;/span&gt; stop &lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
	     &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;      &lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;s-comment s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;/*&lt;/span&gt; park &lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-end s-c&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;the-acknowledgement-and-the-data&quot;&gt;The acknowledgement and the data&lt;/h3&gt;
&lt;p&gt;The acknowledgement is three bits, LSB first:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Value&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;What it means&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;0b001&lt;/code&gt;&lt;/td&gt;&lt;td&gt;OK&lt;/td&gt;&lt;td&gt;proceed to the data phase&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;0b010&lt;/code&gt;&lt;/td&gt;&lt;td&gt;WAIT&lt;/td&gt;&lt;td&gt;busy, retry the same transaction&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;0b100&lt;/code&gt;&lt;/td&gt;&lt;td&gt;FAULT&lt;/td&gt;&lt;td&gt;something is wrong; read CTRL/STAT and clear it&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Then 32 data bits, LSB first, followed by one even parity bit covering those
32. On a write the host sends them, on a read the target does. Get the parity
wrong and the target quietly ignores the write, which is a miserable bug to
find.&lt;/p&gt;
&lt;h2 id=&quot;reading-memory&quot;&gt;Reading memory&lt;/h2&gt;
&lt;p&gt;Two register banks sit behind that interface. The &lt;strong&gt;DP&lt;/strong&gt;, or Debug Port, is
the SWD end itself: IDCODE, ABORT, CTRL/STAT, SELECT, RDBUFF. The &lt;strong&gt;AP&lt;/strong&gt;, or
Access Port, is the bridge onto the chip’s bus. The one you want is the
MEM-AP, and three of its registers matter: CSW for configuration, TAR for the
target address, DRW for the data.&lt;/p&gt;
&lt;p&gt;Reading a single word goes like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;1. write DP SELECT   choose AP 0, register bank 0
2. write AP CSW      32-bit access, auto-increment off
3. write AP TAR      0x08000000
4. read  AP DRW      returns the PREVIOUS result, not this one
5. read  DP RDBUFF   the word you actually asked for
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Step 4 is the part that catches everyone. AP reads are posted: the transaction
kicks off the read and hands back whatever the last one produced. The value
you want arrives on the next read, or out of RDBUFF. Write a driver that reads
DRW once and trusts it, and you get a plausible-looking word belonging to the
previous operation. That is an evening gone.&lt;/p&gt;
&lt;h2 id=&quot;the-number-in-the-log&quot;&gt;The number in the log&lt;/h2&gt;
&lt;p&gt;The first post has this line in it, straight out of J-Link Commander:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;Found SWD-DP with ID 0x1BA01477
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At the time I copied past it. It decodes cleanly:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Bits&lt;/th&gt;&lt;th&gt;Value&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;31 - 28&lt;/td&gt;&lt;td&gt;&lt;code&gt;0x1&lt;/code&gt;&lt;/td&gt;&lt;td&gt;version 1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;27 - 12&lt;/td&gt;&lt;td&gt;&lt;code&gt;0xBA01&lt;/code&gt;&lt;/td&gt;&lt;td&gt;part number: Cortex-M3 SW-DP&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;11 - 1&lt;/td&gt;&lt;td&gt;&lt;code&gt;0x23B&lt;/code&gt;&lt;/td&gt;&lt;td&gt;designer: ARM (JEP106)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td&gt;always 1&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;&lt;code&gt;0xBA01&lt;/code&gt; is the serial wire debug port; the JTAG one is &lt;code&gt;0xBA00&lt;/code&gt;. So that line
is the chip confirming the protocol switch worked — which is exactly the
thing I had assumed rather than checked.&lt;/p&gt;
&lt;h2 id=&quot;swo-the-optional-third-wire&quot;&gt;SWO, the optional third wire&lt;/h2&gt;
&lt;p&gt;The wiring list in the first post has SWCLK and SWDIO, and then SWO going to
PB3. That one is not part of SWD at all.&lt;/p&gt;
&lt;p&gt;SWO is Serial Wire Output: a one-way trace channel from the ITM, through the
TPIU, out on PB3. It gives you a printf-shaped debug channel without spending
a USART on it, and without the timing damage a breakpoint does. It is
independent of the two-wire protocol above — SWD runs perfectly well with
PB3 unconnected, which is how I had it for a long time before wiring it.&lt;/p&gt;
&lt;!-- TODO(josip): if you ever captured SWO output, a screenshot would sit well here. --&gt;
&lt;h2 id=&quot;how-to-lock-yourself-out&quot;&gt;How to lock yourself out&lt;/h2&gt;
&lt;p&gt;The SWJ-DP configuration lives in &lt;code&gt;AFIO_MAPR&lt;/code&gt;, in the &lt;code&gt;SWJ_CFG[2:0]&lt;/code&gt; field:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Value&lt;/th&gt;&lt;th&gt;Effect&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;000&lt;/code&gt;&lt;/td&gt;&lt;td&gt;full SWJ: JTAG and SWD both available (reset state)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;001&lt;/code&gt;&lt;/td&gt;&lt;td&gt;full SWJ, but NJTRST released as GPIO&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;010&lt;/code&gt;&lt;/td&gt;&lt;td&gt;JTAG disabled, SWD enabled: frees PA15, PB3, PB4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;100&lt;/code&gt;&lt;/td&gt;&lt;td&gt;JTAG &lt;strong&gt;and&lt;/strong&gt; SWD both disabled&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;&lt;code&gt;010&lt;/code&gt; is the useful one. &lt;code&gt;100&lt;/code&gt; is how you brick a development board: the
moment that write lands the debugger has no way in, and it lands again a few
milliseconds after every reset.&lt;/p&gt;
&lt;p&gt;The way out is BOOT0. Pulling it high and resetting starts the factory
bootloader, which never touches &lt;code&gt;AFIO_MAPR&lt;/code&gt;, so the debug port stays alive
long enough to erase the flash. Connect-under-reset does the same job by
grabbing the port in the gap before your code runs. Neither is enjoyable at
midnight, so it is worth knowing before you write to that field rather than
after.&lt;/p&gt;
&lt;h2 id=&quot;where-the-real-answers-are&quot;&gt;Where the real answers are&lt;/h2&gt;
&lt;p&gt;Two documents, and they disagree with nobody:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ARM Debug Interface Architecture Specification, ADIv5&lt;/strong&gt; (IHI0031) — the
protocol itself: framing, parity, and the DP and AP register maps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RM0008&lt;/strong&gt;, the STM32F103 reference manual — the chip-specific half: pin
mapping, &lt;code&gt;AFIO_MAPR&lt;/code&gt;, and what the trace hardware will do.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;None of this is anything the datasheets do not already say. It just took me
longer than I expected to find where they said it.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Golang notes</title>
    <id>https://seketa.it/golang-notes/</id>
    <link href="https://seketa.it/golang-notes/"/>
    <updated>2022-10-16T00:00:00Z</updated>
    <content type="html">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Installing the Go environment has never been easier: download the executable,
run it, and you have a working installation.&lt;/p&gt;
&lt;p&gt;Go is an open source programming language from Google, originally developed for
Google’s own needs — large codebases, many engineers, slow builds.&lt;/p&gt;
&lt;h2 id=&quot;first-program&quot;&gt;First program&lt;/h2&gt;
&lt;p&gt;Every Go program starts in &lt;code&gt;package main&lt;/code&gt;, with a &lt;code&gt;main&lt;/code&gt; function as the entry
point. The &lt;code&gt;fmt&lt;/code&gt; package (short for &lt;em&gt;formatting&lt;/em&gt;) handles input and output.&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__file&quot;&gt;hello.go&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-go&quot;&gt;&lt;span class=&quot;s-keyword s-control s-go&quot;&gt;package&lt;/span&gt; main

&lt;span class=&quot;s-meta s-import s-go&quot;&gt;&lt;span class=&quot;s-meta s-import s-go&quot;&gt;&lt;span class=&quot;s-keyword s-control s-import s-go&quot;&gt;import&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-go&quot;&gt;&amp;quot;&lt;/span&gt;fmt&lt;span class=&quot;s-punctuation s-definition s-string s-end s-go&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;s-meta s-function s-declaration s-go&quot;&gt;&lt;span class=&quot;s-storage s-type s-go&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;s-entity s-name s-function s-go&quot;&gt;main&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-go&quot;&gt;&lt;span class=&quot;s-meta s-group s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-group s-begin s-go&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-go&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-go&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-go&quot;&gt;&lt;span class=&quot;s-meta s-group s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-group s-end s-go&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-go&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s-meta s-function s-go&quot;&gt;&lt;span class=&quot;s-meta s-block s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-block s-begin s-go&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-go&quot;&gt;&lt;span class=&quot;s-meta s-block s-go&quot;&gt;
	fmt&lt;span class=&quot;s-meta s-function-call s-method s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-accessor s-go&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-variable s-function s-go&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-group s-begin s-go&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-go&quot;&gt;&lt;span class=&quot;s-meta s-group s-go&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-go&quot;&gt;&amp;quot;&lt;/span&gt;Hello world!&lt;span class=&quot;s-punctuation s-definition s-string s-end s-go&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-group s-end s-go&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-go&quot;&gt;&lt;span class=&quot;s-meta s-block s-go&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-block s-end s-go&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;Run it directly with &lt;code&gt;go run hello.go&lt;/code&gt;, or compile a binary with &lt;code&gt;go build&lt;/code&gt;.&lt;/p&gt;
&lt;!-- TODO(josip): pick this back up - next up was probably types and slices. --&gt;
</content>
  </entry>
  <entry>
    <title>Microservices</title>
    <id>https://seketa.it/microservices/</id>
    <link href="https://seketa.it/microservices/"/>
    <updated>2020-09-27T00:00:00Z</updated>
    <content type="html">&lt;p&gt;Checking if the universe exists with test cases and code coverage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ROUTE:&lt;/strong&gt; /universe/exists&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;METHOD:&lt;/strong&gt; POST&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NAME:&lt;/strong&gt; Universe exists&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PORT:&lt;/strong&gt; 4000&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;accepted arguments
&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;language&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;returns
&lt;ul&gt;
&lt;li&gt;if server exists return server data as json&lt;/li&gt;
&lt;li&gt;if server does not exist return error message&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;ERRORS:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;server not reachable&lt;/li&gt;
&lt;li&gt;server not found&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example server data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-json&quot;&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-begin s-json&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;language&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;ar&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;number&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;name&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;Quantum&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;playerCount&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;1005&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;playersOnline&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;opened&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;2016-05-06T11:15:08+0000&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;startDate&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;2016-05-06T11:15:08+0000&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;endDate&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-language s-json&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;serverClosed&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;prefered&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;signupClosed&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;settings&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-begin s-json&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;aks&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;fleetSpeed&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;wreckField&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;serverLabel&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;empty&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;economySpeed&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;planetFields&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;universeSize&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;serverCategory&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;miner&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;espionageProbeRaids&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;premiumValidationGift&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;8000&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;debrisFieldFactorShips&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;researchDurationDivisor&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;debrisFieldFactorDefence&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-json&quot;&gt;0&lt;/span&gt;
	&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-end s-json&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-end s-json&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Allowing only the POST method in expressjs:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-js&quot;&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;route&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;/universe/exists&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt;&lt;span class=&quot;s-storage s-type s-function s-js&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-parameter s-function s-js&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-js&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-meta s-conditional s-js&quot;&gt;&lt;span class=&quot;s-keyword s-control s-conditional s-js&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;s-meta s-brackets s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-brackets s-js&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;content-type&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-brackets s-js&quot;&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-comparison s-js&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;application/json&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;queryObj&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

		&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;universe&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;queryObj&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt;&lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-function s-arrow s-js&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;status&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;body&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;	
	&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-conditional s-js&quot;&gt;&lt;span class=&quot;s-keyword s-control s-conditional s-js&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;s-meta s-brackets s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-brackets s-js&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;content-type&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-brackets s-js&quot;&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-comparison s-js&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;application/json&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-js&quot;&gt;400&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;Only accepting Content-Type: application/json&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt;&lt;span class=&quot;s-storage s-type s-function s-js&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-parameter s-function s-js&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-js&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;Access-Control-Allow-Methods&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;POST&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-js&quot;&gt;405&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Initial design</title>
    <id>https://seketa.it/initial-design/</id>
    <link href="https://seketa.it/initial-design/"/>
    <updated>2020-08-23T00:00:00Z</updated>
    <content type="html">&lt;p&gt;&lt;img src=&quot;/assets/images/boring_writer.gif&quot; alt=&quot;Boring writer&quot; title=&quot;Boring writer&quot; /&gt;
&lt;img src=&quot;/assets/images/concept_level.gif&quot; alt=&quot;Concept level&quot; title=&quot;Concept level&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I would like the take the very first paragraph to get the logical basics down. Programming implementation down the road is “just” a question of a language syntax.&lt;/p&gt;
&lt;p&gt;Before I wrote anything there was reconnaisance to be made.
With the help of the Chrome Developer tools I recorded the steps needed to login to the overview page (automatic redirect).&lt;/p&gt;
&lt;p&gt;Login consists of the two levels:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Login with the e-mail which takes us to the overview of servers and already active accounts&lt;/li&gt;
&lt;li&gt;Login to the specific account&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Firstly I needed to set the minimum goal. The goal was to successfully login to the game and just output the pure html; if successful I would get the wall of text in the console, otherwise just a short piece of redirect code (HTTP 301&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;).&lt;/p&gt;
&lt;p&gt;Using apitester.com for quick and dirty test.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/first_post.png&quot; alt=&quot;alt text&quot; title=&quot;Title&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If successful, the post request should return the token, among other things.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request url&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://gameforge.com/api/v1/auth/thin/sessions&quot;&gt;https://gameforge.com/api/v1/auth/thin/sessions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request method&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;POST&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request body&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;identity=YOUR_EMAIL&amp;amp;password=YOUR_PASSWORD&amp;amp;locale=de_DE&amp;amp;gfLang=de&amp;amp;platformGameId=1dfd8e7e-6e1a-4eb1-8c64-03c3b62efd2f&amp;amp;gameEnvironmentId=0a31d605-ffaf-43e7-aa02-d06df7116fc8&amp;amp;autoGameAccountCreation=false&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request valid response body&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-json&quot;&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-begin s-json&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;token&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;e9f942cc-b714-462b-91bb-ef91b40f08d1&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;isPlatformLogin&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-language s-json&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;isGameAccountMigrated&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-language s-json&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;platformUserId&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;95ddac3a-d1b6-4160-9a5b-2a623f8d94de&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;isGameAccountCreated&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-language s-json&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-pair s-json&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;hasUnmigratedGameAccounts&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-constant s-language s-json&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-end s-json&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Request invalid response body&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-json&quot;&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-begin s-json&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;error&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-begin s-json&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-key s-json&quot;&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;message&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-structure s-dictionary s-value s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-separator s-dictionary s-key-value s-json&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-double s-json&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-json&quot;&gt;&amp;quot;&lt;/span&gt;Forbidden&lt;span class=&quot;s-punctuation s-definition s-string s-end s-json&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-end s-json&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-dictionary s-end s-json&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/first_post_token.png&quot; alt=&quot;alt text&quot; title=&quot;Title&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The whole flow, then, is one POST that forks:&lt;/p&gt;
&lt;figure class=&quot;diagram&quot;&gt;&lt;pre class=&quot;mermaid&quot;&gt;flowchart LR
    A[POST credentials] --&amp;gt;|valid| B[200 OK&amp;lt;br/&amp;gt;bearer token]
    A --&amp;gt;|invalid| C[403 Forbidden]
    B --&amp;gt; D[GET accounts&amp;lt;br/&amp;gt;for this player]
&lt;/pre&gt;&lt;figcaption&gt;The POST either yields a bearer token or it does not; only the token branch continues.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Let’s see how the first step looks like.
Used library: request-promise &lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;
Success criteria: fetch all the accounts bound to the user/player&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-js&quot;&gt;&lt;span class=&quot;s-storage s-type s-js&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;rp&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;request-promise&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-storage s-type s-js&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;user_agent&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-storage s-type s-js&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;tough&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;tough-cookie&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-storage s-type s-js&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;jar&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;rp&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;jar&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-storage s-type s-js&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;links&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;https://gameforge.com/api/v1/auth/thin/sessions&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;https://lobby.ogame.gameforge.com/api/users/me/accounts&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;login_post_options&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;POST&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;links&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;User-Agent&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;user_agent&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;				
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;identity&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-support s-type s-object s-process s-js&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-support s-type s-object s-process s-js&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;OGAME_EMAIL&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;password&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-support s-type s-object s-process s-js&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-support s-type s-object s-process s-js&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;OGAME_PASSWORD&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;locale&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;de_DE&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;gfLang&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;de&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;platformGameId&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;1dfd8e7e-6e1a-4eb1-8c64-03c3b62efd2f&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;gameEnvironmentId&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;0a31d605-ffaf-43e7-aa02-d06df7116fc8&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
				&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;autoGameAccountCreation&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;false&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
			&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;jar&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;jar&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;resolveWithFullResponse&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-boolean s-true s-js&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-boolean s-true s-js&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;get_options&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;GET&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;links&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;User-Agent&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;user_agent&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;&lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;Authorization&lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-null s-js&quot;&gt;null&lt;/span&gt;
			&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;followAllRedirects&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-boolean s-false s-js&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;jar&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;jar&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;resolveWithFullResponse&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-boolean s-true s-js&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-boolean s-true s-js&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt;&lt;span class=&quot;s-storage s-type s-js&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-function s-js&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;s-entity s-name s-function s-js&quot;&gt;set_authorization_token&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;token&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-js&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;get_options&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;Authorization&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-single s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-js&quot;&gt;&amp;#39;&lt;/span&gt;Bearer &lt;span class=&quot;s-punctuation s-definition s-string s-end s-js&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-arithmetic s-js&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;token&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt;&lt;span class=&quot;s-storage s-type s-js&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-function s-js&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;s-entity s-name s-function s-js&quot;&gt;get_accounts&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-js&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;s-meta s-try s-js&quot;&gt;&lt;span class=&quot;s-keyword s-control s-trycatch s-js&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s-comment s-line s-double-slash s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-js&quot;&gt;//&lt;/span&gt;first post request - 1st step login
&lt;/span&gt;	&lt;span class=&quot;s-storage s-type s-js&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;post&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;rp&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;login_post_options&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-function-call s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;set_authorization_token&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;token&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-comment s-line s-double-slash s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-js&quot;&gt;//&lt;/span&gt;get all the accounts
&lt;/span&gt;	&lt;span class=&quot;s-storage s-type s-js&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;s-keyword s-operator s-assignment s-js&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;rp&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;get_options&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;accounts&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-keyword s-control s-flow s-js&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s-variable s-other s-object s-js&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-property s-object s-js&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-catch s-js&quot;&gt;&lt;span class=&quot;s-keyword s-control s-trycatch s-js&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-support s-type s-object s-console s-js&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-support s-function s-console s-js&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;error&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
	&lt;/span&gt;&lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-meta s-function-call s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;get_accounts&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-variable s-function s-js&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-declaration s-js&quot;&gt;&lt;span class=&quot;s-variable s-parameter s-function s-js&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-function s-arrow s-js&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-block s-js&quot;&gt;&lt;span class=&quot;s-meta s-function-call s-method s-js&quot;&gt;&lt;span class=&quot;s-support s-type s-object s-console s-js&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;s-punctuation s-accessor s-js&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s-support s-function s-console s-js&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-variable s-other s-readwrite s-js&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-comma s-js&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s-meta s-object-literal s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s-meta s-object-literal s-key s-js&quot;&gt;depth&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-key-value s-js&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s-constant s-language s-null s-js&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-block s-js&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-js&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-js&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-statement s-js&quot;&gt;;&lt;/span&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;1&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;/sup&gt;
&lt;p&gt;More on HTTP codes: &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_HTTP_status_codes&quot;&gt;https://en.wikipedia.org/wiki/List_of_HTTP_status_codes&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;2&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;/sup&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/request/request-promise&quot;&gt;https://github.com/request/request-promise&lt;/a&gt;, deprecated as of 1st of April 2020&lt;/p&gt;
&lt;/div&gt;
</content>
  </entry>
  <entry>
    <title>Setting it all up</title>
    <id>https://seketa.it/blinking-a-led/</id>
    <link href="https://seketa.it/blinking-a-led/"/>
    <updated>2018-06-02T00:00:00Z</updated>
    <content type="html">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;After some time sifting through code and making/breaking things, I decided to put stuff in writing.&lt;/p&gt;
&lt;p&gt;Beginning was with an IDE. I migrated since to command line compiling and linking tools to better understand the background and how the things work.&lt;/p&gt;
&lt;p&gt;Chip of choice is STM32F103C8 commonly known as the blue pill, named so after a size factor and PCB color.&lt;/p&gt;
&lt;p&gt;Tools of choice: open source and widely used. GNU gcc for ARM microcontroller and GNU ld linker. For flashing the chip I use JLink for uploading the hex file.&lt;/p&gt;
&lt;p&gt;Why does binary file format suck? When you need to put variables at exact memory address in address space, binary file format fills everything with blank space up until the declared variable,
and that can grow to a quite big size. When I discovered this, I was perplexed why my binary file was cca 1 GB in size, instead of a few KBs. That’s why I switched to Intel hex format, or
more popularly called just hex. JLink flash utility supports binary AND hex formats, amongst others.&lt;/p&gt;
&lt;p&gt;A little background about the tools needed. Compiler transforms source code to object files, and linker pieces the bits together to produce one ouput file, which is then ready to be uploaded
to the chip with a flash tool.&lt;/p&gt;
&lt;p&gt;We’re going to start with the simplest possible example. Blinking the led inaccurately and with an uninitialized clock source, which defaults to 8 MHz internal RC clock.&lt;/p&gt;
&lt;p&gt;What does it tell us? That the linker, compiler and uploader work correctly. With a proper stepping stone, we are always free to break and make things, for example “code refactoring”,
fancy name for rewriting code because you don’t like it, think it’s ugly or it’s a depressing Saturday afternoon.&lt;/p&gt;
&lt;h2 id=&quot;entry-to-the-main-program&quot;&gt;Entry to the main program&lt;/h2&gt;
&lt;p&gt;After compiler and linker together make a salad, where does it start? Does it start in a random chunk of memory, and if not, how can I tell them where to exactly start?&lt;/p&gt;
&lt;p&gt;For that we have a global start function as an entry to the program.
If a global directive is missing for a symbol, that symbol will not be placed in the object code’s export table, so linker has no way of knowing about the symbol.
We also need to put the address of the stacktop right at the beginning of memory space. After that comes the reset address, where the microcontroller ALWAYS ends up first after resetting.&lt;/p&gt;
&lt;p&gt;After we have defined global entry in the program (for the linker) and reset entry, we can add a path that leads to our main function (entry to our c part of the program).&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__file&quot;&gt;startup.s&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;.global _start
_start:
stacktop: .word 0x20001000
.word reset
.word hang

reset:
	bl notmain
	b hang
.thumb_func
hang:   b .
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;recommendation&quot;&gt;Recommendation&lt;/h2&gt;
&lt;p&gt;I can also recommend a really good github repository from dwelch67 that got me on the right track.
&lt;a href=&quot;https://github.com/dwelch67/stm32_samples/tree/master/STM32F103C8T6&quot;&gt;dwelch67’s repository&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Majority of code during this post will be explaining the code that can be found in the link above, with simplifications and modifications.&lt;/p&gt;
&lt;p&gt;I am not going to say to copy all from somebody else. But for the beginning I recommend it because they made it work, and it should also work when compiled and flashed.
After we have that working base example, then comes the creativity and design choices in question.&lt;/p&gt;
&lt;h2 id=&quot;functions-for-direct-register-access&quot;&gt;Functions for direct register access&lt;/h2&gt;
&lt;p&gt;We are going to need a function to directly access registers and also fill them with data. Functions used are assembler functions PUT32 and GET32.
Assembler functions can be used directly in C program code and first four registers are filled with function paramaters. That means that the r0 registers will be filled with the first function
parameter up until r3. Square brackets signify that the value in the register is meant as an address. .globl keyword signifies that the function is global and accessible anywhere.&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__file&quot;&gt;startup.s&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;.globl PUT32
PUT32:
	str r1,[r0]
	bx lr

.globl GET32
GET32:
	ldr r0,[r0]
	bx lr
	
.globl dummy
	dummy:
	bx lr
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;getting-the-led-up-and-running&quot;&gt;Getting the led up and running&lt;/h2&gt;
&lt;p&gt;Bluepill board has a led light connected to the PC13 pin. We need to enable clock for port C, initialize the pin as a push pull output, then toggle the pin.&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__file&quot;&gt;programentry.c&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-c&quot;&gt;&lt;span class=&quot;s-storage s-type s-c&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;PUT32&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;GET32&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s-storage s-type s-c&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;dummy&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-variable s-parameter s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;define address base for port C
&lt;/span&gt;&lt;span class=&quot;s-meta s-preprocessor s-macro s-c&quot;&gt;&lt;span class=&quot;s-keyword s-control s-import s-define s-c&quot;&gt;#define&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-preprocessor s-macro s-c&quot;&gt; &lt;span class=&quot;s-entity s-name s-constant s-preprocessor s-c&quot;&gt;GPIOCBASE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-preprocessor s-macro s-c&quot;&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x40011000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;define address base for clock control
&lt;/span&gt;&lt;span class=&quot;s-meta s-preprocessor s-macro s-c&quot;&gt;&lt;span class=&quot;s-keyword s-control s-import s-define s-c&quot;&gt;#define&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-preprocessor s-macro s-c&quot;&gt; &lt;span class=&quot;s-entity s-name s-constant s-preprocessor s-c&quot;&gt;RCCBASE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-preprocessor s-macro s-c&quot;&gt; &lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x40021000&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;our entry point into the program, defined in our assembler file
&lt;/span&gt;&lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-entity s-name s-function s-c&quot;&gt;notmain&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-parameters s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-begin s-c&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;
	&lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; ra&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-storage s-type s-c&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;s-storage s-type s-c&quot;&gt;int&lt;/span&gt; rx&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;

	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;GET32&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;RCCBASE&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x18&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-augmented s-c&quot;&gt;|=&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;enable port c
&lt;/span&gt;	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;PUT32&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;RCCBASE&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x18&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt;ra&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;config
&lt;/span&gt;	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;GET32&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;GPIOCBASE&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x04&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-augmented s-c&quot;&gt;&amp;amp;=&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;PC13
&lt;/span&gt;	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-augmented s-c&quot;&gt;|=&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;PC13
&lt;/span&gt;	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-augmented s-c&quot;&gt;&amp;amp;=&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;PC13
&lt;/span&gt;	ra&lt;span class=&quot;s-keyword s-operator s-assignment s-augmented s-c&quot;&gt;|=&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;s-comment s-line s-double-slash s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-comment s-c&quot;&gt;//&lt;/span&gt;PC13
&lt;/span&gt;	&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;PUT32&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;GPIOCBASE&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x04&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt;ra&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;s-keyword s-control s-c&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;rx&lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;rx&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-begin s-c&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;PUT32&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;GPIOCBASE&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x10&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;s-keyword s-control s-c&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;ra&lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;ra&lt;span class=&quot;s-keyword s-operator s-comparison s-c&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;200000&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;ra&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;dummy&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;ra&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;PUT32&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;GPIOCBASE&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0x10&lt;/span&gt;&lt;span class=&quot;s-punctuation s-separator s-c&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;s-keyword s-control s-c&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;ra&lt;span class=&quot;s-keyword s-operator s-assignment s-c&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;ra&lt;span class=&quot;s-keyword s-operator s-comparison s-c&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;200000&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;ra&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-keyword s-operator s-arithmetic s-c&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-variable s-function s-c&quot;&gt;dummy&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;ra&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function-call s-c&quot;&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;s-punctuation s-section s-block s-end s-c&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
	&lt;span class=&quot;s-keyword s-control s-c&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;s-meta s-group s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-c&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s-constant s-numeric s-c&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-c&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-punctuation s-terminator s-c&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s-meta s-function s-c&quot;&gt;&lt;span class=&quot;s-meta s-block s-c&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-block s-end s-c&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;Bits that interest us:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;RCC_APB2ENR&lt;/th&gt;&lt;th&gt;…&lt;/th&gt;&lt;th&gt;bit 4&lt;/th&gt;&lt;th&gt;…&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;0x018 offset&lt;/td&gt;&lt;td&gt;…&lt;/td&gt;&lt;td&gt;IOPCEN&lt;/td&gt;&lt;td&gt;…&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Taken from page 153 of the manual. We are putting 1 into the bit 4 of the APB2 clock enable register to turn on the clock for the port C peripherals.&lt;/p&gt;
&lt;p&gt;Link for creating the tables: &lt;a href=&quot;https://ozh.github.io/ascii-tables/&quot;&gt;https://ozh.github.io/ascii-tables/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;GPIO configuration registers are split into two registers: Low and High. Low register contain the pins from 0 to 7 and High contain pins from 8 to 15.&lt;/p&gt;
&lt;p&gt;Bits that interest us:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;GPIOx_CRH&lt;/th&gt;&lt;th&gt;…&lt;/th&gt;&lt;th&gt;Bits 23-22&lt;/th&gt;&lt;th&gt;Bits 21-20&lt;/th&gt;&lt;th&gt;…&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;0x04 offset&lt;/td&gt;&lt;td&gt;…&lt;/td&gt;&lt;td&gt;CNF13[1:0]&lt;/td&gt;&lt;td&gt;MODE13[1:0]&lt;/td&gt;&lt;td&gt;…&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Taken from page 188 of the manual. We are setting the values in the bits 20-21 for the pin mode and 22-23 for the configuration mode of the pin.&lt;/p&gt;
&lt;p&gt;On the page 167 we may read about valid bit combos for those four bits.&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;CNFy[1:0]&lt;/th&gt;&lt;th&gt;In input mode (MODE[1:0]=00)&lt;/th&gt;&lt;th&gt;In output mode(MODE[1:0]&amp;gt;00)&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;for CRH&lt;/td&gt;&lt;td&gt;00: Analog mode&lt;/td&gt;&lt;td&gt;00: General purpose output Push-pull&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;y = 8…15&lt;/td&gt;&lt;td&gt;01: Floating input&lt;/td&gt;&lt;td&gt;01: General purpose output Open-drain&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;for CRL&lt;/td&gt;&lt;td&gt;10: Input with pull-up / pull-down&lt;/td&gt;&lt;td&gt;10: Alternate function output Push-pull&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;y = 0…7&lt;/td&gt;&lt;td&gt;11: Reserved state&lt;/td&gt;&lt;td&gt;11: Alternate function output Open-drain&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;MODEy[1:0]&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;for CRH&lt;/td&gt;&lt;td&gt;00: Input mode (reset state)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;y = 8…15&lt;/td&gt;&lt;td&gt;01: Output mode, max speed 10 MHz&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;for CRL&lt;/td&gt;&lt;td&gt;10: Output mode, max speed 2 MHz&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;y = 0…7&lt;/td&gt;&lt;td&gt;11: Output mode, max speed 50 MHz&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;For writing your own library, you will need to familiarize yourself with the datashet of the microcontroller, in this case STM32F103C8 RM0008 Reference Manual. The datasheet will be
extensively used throughout the posts.&lt;/p&gt;
&lt;p&gt;Up until now we have two files: startup.s and programentry.c. Now we need to setup an environment for compiling, linking and flashing.&lt;/p&gt;
&lt;h2 id=&quot;linker-file&quot;&gt;Linker file&lt;/h2&gt;
&lt;p&gt;Linker file looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;	MEMORY
	{
		rom : ORIGIN = 0x08000000, LENGTH = 0x1000
		ram : ORIGIN = 0x20000000, LENGTH = 0x1000
	}

	SECTIONS
	{
		.text : { *(.text*) } &amp;gt; rom
		.rodata : { *(.rodata*) } &amp;gt; rom
		.bss : { *(.bss*) } &amp;gt; ram
	}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;MEMORY keyword tells us how the memory is organized and how big it is. SECTIONS keyword defines where the types of program data should go. In this example we tell the linker that
.text and .rodata should go in ROM part of the memory, and .bss data in the RAM part of the memory.
(.bss) =&amp;gt; segment for uninitialized data.
(.data) =&amp;gt; segment for initialized data here by default.
(.rodata) =&amp;gt; segment for constant data.&lt;/p&gt;
&lt;p&gt;I am using GNU ld linker, as a good open source choice widely used. I am not trying to use black magic or obscure tools.&lt;/p&gt;
&lt;h2 id=&quot;makefile&quot;&gt;Makefile&lt;/h2&gt;
&lt;p&gt;Minimum unix tools required are make and rm, both used in the makefile.&lt;/p&gt;
&lt;p&gt;Let’s go through the makefile.
Here, we are just declaring some variables to make the makefile more readable.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;ARMGNU = arm-none-eabi

AOPS = --warn --fatal-warnings -mcpu=cortex-m3
COPS = -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding -mcpu=cortex-m0
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is the first “recipe” in linker terminology, that can be invoked with “make all” or just “make”. Invoking only “make” will execute the first found recipe.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;	all : output.hex
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is the second recipe which is used for a cleanup of produced files, leaving only the source files intact.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;clean:
	rm -f *.bin
	rm -f *.o
	rm -f *.elf
	rm -f *.list
	rm -f *.bc
	rm -f *.opt.s
	rm -f *.norm.s
	rm -f *.hex
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are defining rules for compilation of our two source files. startup.o needs startup.s and that’s why we are declaring .s file on the right side as a dependency, and building the
file with an assembler (-as, or full blown command arm-linux-gnueabi-as)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;startup.o : startup.s
	$(ARMGNU)-as $(AOPS) startup.s -o startup.o
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;File programentry.c is being compiled here with a gcc compiler. It is also being specified that we are using thumb instruction set (-mthumb), cpu Cortex-M3 (-mcpu=cortex-m3), architecture
ARMv7 (armv7-m), that the input file is programentry.c and output file should be programentry.o.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;programentry.o : programentry.c	
	$(ARMGNU)-gcc $(COPS) -mthumb -mcpu=cortex-m3 -march=armv7-m -c programentry.c -o programentry.o
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is the build of the final output file that is going to be flashed on the chip. Our final output file depends on three files. Linker file linker.ld and two object files startup.o and
programentry.o compiled from the source files.
the source files&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;	output.hex : linker.ld startup.o programentry.o
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here are the objects linked according to linker file linker.ld and output is an elf file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;		$(ARMGNU)-ld -o output.elf -T linker.ld startup.o programentry.o
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Object dump (objdump) is used to dump the contents from an .elf file to the .list file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;		$(ARMGNU)-objdump -D output.elf &amp;gt; output.list
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, from the .elf file we get the final output file with objcopy.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;		$(ARMGNU)-objcopy output.elf output.hex -O ihex
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;hardware-used-for-flashing-the-chip&quot;&gt;Hardware used for flashing the chip&lt;/h2&gt;
&lt;p&gt;I am using Segger’s J-link to flash the chip via the SWD (Single Wire Debugging) interface and am also using JLink v5.10u, an older version of the flashing software. If it works, there’s no
reason to continuously update.&lt;/p&gt;
&lt;p&gt;Hardware connections are as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-text s-plain&quot;&gt;J-link Pin 1 = VCCref =&amp;gt; Pin 1 SWD Connector
J-link Pin 7 = SWDIO =&amp;gt; SWDIO Pin
J-link Pin 9 = SWCLK =&amp;gt; SWCLK Pin
J-link Pin 13 = SWO =&amp;gt; PB3 Pin
J-link Pin 19 = Target power supply =&amp;gt; 3v3 pin of the microcontroller
J-link Pin 4 = Ground Pin =&amp;gt; connect to any GND pin of the microcontroller
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To enable the J-link to power the target, the following command must be input through the J-link command line: “power on perm”.&lt;/p&gt;
&lt;p&gt;To connect to the microcontroller, I run the J-link flash program through the command line. Here is the output.&lt;/p&gt;
&lt;figure class=&quot;code&quot;&gt;&lt;figcaption class=&quot;code__bar&quot;&gt;&lt;span class=&quot;code__dots&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;span class=&quot;code__label&quot;&gt;J-Link Commander&lt;/span&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;s-source s-dosbatch&quot;&gt;	Microsoft Windows [Version &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;6&lt;/span&gt;.&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;7601&lt;/span&gt;]
	Copyright &lt;span class=&quot;s-meta s-group s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-dosbatch&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;s-punctuation s-section s-group s-end s-dosbatch&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;2009&lt;/span&gt; Microsoft Corporation.  All rights reserved.

	C:\Users\Bunny&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;jlink
	SEGGER J-Link Commander V5.10u &lt;span class=&quot;s-meta s-group s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-dosbatch&quot;&gt;(&lt;/span&gt;Compiled Mar &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;17&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;2016&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;18&lt;/span&gt;:&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;57&lt;/span&gt;:&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;s-punctuation s-section s-group s-end s-dosbatch&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	DLL version V5.10u, compiled Mar &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;17&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;2016&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;18&lt;/span&gt;:&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;56&lt;/span&gt;:&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;47&lt;/span&gt;

	Connecting to J-Link via USB...O.K.
	Firmware: J-Link ARM V8 compiled Nov &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;28&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;2014&lt;/span&gt; &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;13&lt;/span&gt;:&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;44&lt;/span&gt;:&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;46&lt;/span&gt;
	Hardware version: V8.&lt;span class=&quot;s-constant s-numeric s-integer s-octal s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-numeric s-octal s-dosbatch&quot;&gt;0&lt;/span&gt;0&lt;/span&gt;
	S/N: &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;58001139&lt;/span&gt;
	License&lt;span class=&quot;s-meta s-group s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-dosbatch&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;s-punctuation s-section s-group s-end s-dosbatch&quot;&gt;)&lt;/span&gt;&lt;/span&gt;: RDI,FlashDL,FlashBP,JFlash
	VTref = &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;4&lt;/span&gt;.801V


	&lt;span class=&quot;s-keyword s-command s-dosbatch&quot;&gt;Type&lt;/span&gt; &lt;span class=&quot;s-string s-quoted s-double s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-dosbatch&quot;&gt;&amp;quot;&lt;/span&gt;connect&lt;span class=&quot;s-punctuation s-definition s-string s-end s-dosbatch&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; to establish a target connection, &amp;#39;?&amp;#39; &lt;span class=&quot;s-keyword s-control s-repeat s-dosbatch&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;s-keyword s-command s-dosbatch&quot;&gt;help&lt;/span&gt;
	J-Link&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;connect
	Please specify device / core. &lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;lt;&lt;/span&gt;Default&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;: STM32F103C8
	&lt;span class=&quot;s-keyword s-command s-dosbatch&quot;&gt;Type&lt;/span&gt; &amp;#39;?&amp;#39; &lt;span class=&quot;s-keyword s-control s-repeat s-dosbatch&quot;&gt;for&lt;/span&gt; selection dialog
	Device&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;
	Please specify target interface:
	  J) JTAG &lt;span class=&quot;s-meta s-group s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-dosbatch&quot;&gt;(&lt;/span&gt;Default&lt;span class=&quot;s-punctuation s-section s-group s-end s-dosbatch&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
	  S) SWD
	TIF&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;s
	Specify target interface speed [kHz]. &lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;lt;&lt;/span&gt;Default&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;: &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;4000&lt;/span&gt; kHz
	Speed&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;
	Device &lt;span class=&quot;s-string s-quoted s-double s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-string s-begin s-dosbatch&quot;&gt;&amp;quot;&lt;/span&gt;STM32F103C8&lt;span class=&quot;s-punctuation s-definition s-string s-end s-dosbatch&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; selected.


	Found SWD-DP with ID &lt;span class=&quot;s-constant s-numeric s-integer s-hexadecimal s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-numeric s-hexadecimal s-dosbatch&quot;&gt;0x&lt;/span&gt;1BA01477&lt;/span&gt;
	Found SWD-DP with ID &lt;span class=&quot;s-constant s-numeric s-integer s-hexadecimal s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-definition s-numeric s-hexadecimal s-dosbatch&quot;&gt;0x&lt;/span&gt;1BA01477&lt;/span&gt;
	Found Cortex-M3 r1p1, Little endian.
	FPUnit: &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;6&lt;/span&gt; code &lt;span class=&quot;s-meta s-group s-dosbatch&quot;&gt;&lt;span class=&quot;s-punctuation s-section s-group s-begin s-dosbatch&quot;&gt;(&lt;/span&gt;BP&lt;span class=&quot;s-punctuation s-section s-group s-end s-dosbatch&quot;&gt;)&lt;/span&gt;&lt;/span&gt; slots and &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;2&lt;/span&gt; literal slots
	CoreSight components:
	ROMTbl &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt; @ E00FF000
	ROMTbl &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt; [&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt;]: FFF0F000, CID: B105E00D, PID: 001BB000 SCS
	ROMTbl &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt; [&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;1&lt;/span&gt;]: FFF02000, CID: B105E00D, PID: 001BB002 DWT
	ROMTbl &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt; [&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;2&lt;/span&gt;]: FFF03000, CID: B105E00D, PID: 000BB003 FPB
	ROMTbl &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt; [&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;3&lt;/span&gt;]: FFF01000, CID: B105E00D, PID: 001BB001 ITM
	ROMTbl &lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;0&lt;/span&gt; [&lt;span class=&quot;s-constant s-numeric s-integer s-decimal s-dosbatch&quot;&gt;4&lt;/span&gt;]: FFF41000, CID: B105900D, PID: 001BB923 TPIU-Lite
	Cortex-M3 identified.
	J-Link&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;power on perm
	J-Link&lt;span class=&quot;s-keyword s-operator s-redirection s-dosbatch&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;We are using the “loadfile” command to load the hex file onto the chip. After flashing the chip, we issue “r” for reset and “g” for go command. The led should inaccurately, but happily blink.&lt;/p&gt;
</content>
  </entry>
</feed>
