start tutorial

This commit is contained in:
2026-03-08 19:41:38 +01:00
commit a48ba2963d
81 changed files with 1738 additions and 0 deletions

236
workshop.html Normal file
View File

@@ -0,0 +1,236 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rust on Bluepill Workshop</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@5/dist/reset.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@5/dist/reveal.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@5/dist/theme/white.css" />
<style>
.reveal h1, .reveal h2, .reveal h3 {
text-transform: none;
}
.reveal pre code {
max-height: 420px;
font-size: 0.75em;
}
.small {
font-size: 0.72em;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Rust on Embedded</h1>
<h3>Didacta Workshop</h3>
<p>STM32F103C8 Bluepill + ST-Link + Rust</p>
</section>
<section>
<h2>Workshop Goal</h2>
<ul>
<li>Understand core Rust basics</li>
<li>Build and flash no_std firmware</li>
<li>Blink LED, read button, read analog input</li>
<li>See output with probe-rs RTT logs</li>
</ul>
</section>
<section>
<h2>Flow (60 min)</h2>
<ul>
<li>00 setup, 01-03 Rust basics</li>
<li>04 first embedded app</li>
<li>05 LED blink</li>
<li>06 button input</li>
<li>07 analog readout</li>
<li>08 final combined app</li>
</ul>
</section>
<section>
<h2>How We Work</h2>
<ul>
<li>Edit only <code>task/</code> folders</li>
<li>Use <code>solution/</code> only when stuck</li>
<li>One step at a time, linear slides</li>
</ul>
</section>
<section>
<h2>Step 00 Task: Setup Live</h2>
<p><strong>Next task:</strong> Prepare host + probe tools.</p>
<p><strong>Learn:</strong> Embedded Rust toolchain basics.</p>
<pre><code class="language-bash">bash scripts/setup-live.sh
bash scripts/verify-host.sh
bash scripts/verify-probe.sh</code></pre>
</section>
<section>
<h2>Step 00 Solution</h2>
<ul>
<li><code>rustup</code>, <code>cargo</code>, <code>probe-rs</code> available</li>
<li>Target <code>thumbv7m-none-eabi</code> installed</li>
<li><code>probe-rs list</code> sees ST-Link</li>
<li><code>probe-rs chip list</code> contains <code>STM32F103C8</code></li>
</ul>
</section>
<section>
<h2>Step 01 Task: Rust Hello</h2>
<p><strong>Next task:</strong> Edit the TODO values and run.</p>
<p><strong>Learn:</strong> <code>fn main</code>, variables, <code>println!</code>.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 01 task</code></pre>
</section>
<section>
<h2>Step 01 Solution</h2>
<ul>
<li>Program compiles and runs with <code>cargo run</code></li>
<li>Console output shows your name and workshop title</li>
<li>You can navigate the task/solution structure</li>
</ul>
</section>
<section>
<h2>Step 02 Task: Types + Control Flow</h2>
<p><strong>Next task:</strong> Tune threshold logic in <code>classify_adc</code>.</p>
<p><strong>Learn:</strong> explicit types, <code>if</code>, <code>match</code>.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 02 task</code></pre>
</section>
<section>
<h2>Step 02 Solution</h2>
<ul>
<li>ADC values map to low/medium/high</li>
<li>Button states map to pressed/released</li>
<li>Program output changes correctly with input values</li>
</ul>
</section>
<section>
<h2>Step 03 Task: Ownership + Borrowing</h2>
<p><strong>Next task:</strong> Complete/update state mutation functions.</p>
<p><strong>Learn:</strong> <code>&amp;T</code> vs <code>&amp;mut T</code>, safe mutation design.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 03 task</code></pre>
</section>
<section>
<h2>Step 03 Solution</h2>
<ul>
<li>State is read via immutable reference</li>
<li>State changes happen through mutable references</li>
<li>Compiler enforces safe access patterns</li>
</ul>
</section>
<section>
<h2>Step 04 Task: Embedded no_std Hello</h2>
<p><strong>Next task:</strong> Flash first no_std firmware and watch RTT logs.</p>
<p><strong>Learn:</strong> <code>#![no_std]</code>, <code>#![no_main]</code>, <code>#[entry]</code>.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 04 task</code></pre>
</section>
<section>
<h2>Step 04 Solution</h2>
<ul>
<li>Firmware flashes to Bluepill</li>
<li>RTT shows boot + alive messages</li>
<li>You now have a working embedded Rust baseline</li>
</ul>
</section>
<section>
<h2>Step 05 Task: LED Blink</h2>
<p><strong>Next task:</strong> Toggle PC13 in a timed loop.</p>
<p><strong>Learn:</strong> HAL GPIO output + active-low LED behavior.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 05 task</code></pre>
</section>
<section>
<h2>Step 05 Solution</h2>
<ul>
<li>PC13 low = LED on, PC13 high = LED off</li>
<li>Timer loop controls blink frequency</li>
<li>RTT logs match LED state changes</li>
</ul>
</section>
<section>
<h2>Step 06 Task: Button Input</h2>
<p><strong>Next task:</strong> Read PA0 with pull-up and detect transitions.</p>
<p><strong>Learn:</strong> digital input polling + simple edge detection.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 06 task</code></pre>
</section>
<section>
<h2>Step 06 Solution</h2>
<ul>
<li>Pressed/released events are logged correctly</li>
<li>No repeated spam while button is held</li>
<li>Wiring pattern: PA0 -> button -> GND</li>
</ul>
</section>
<section>
<h2>Step 07 Task: Analog Readout</h2>
<p><strong>Next task:</strong> Read ADC on PA1 and print values.</p>
<p><strong>Learn:</strong> one-shot ADC + value classification.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 07 task</code></pre>
</section>
<section>
<h2>Step 07 Solution</h2>
<ul>
<li>ADC raw value changes with analog input</li>
<li>Classification low/medium/high works</li>
<li>Periodic readout appears in RTT console</li>
</ul>
</section>
<section>
<h2>Step 08 Task: Final Combined</h2>
<p><strong>Next task:</strong> Integrate LED + button + ADC behavior.</p>
<p><strong>Learn:</strong> small embedded state machine.</p>
<pre><code class="language-bash">bash scripts/run-step.sh 08 task</code></pre>
</section>
<section>
<h2>Step 08 Solution</h2>
<ul>
<li>Button toggles mode: Blinking / ForcedOff</li>
<li>ADC value controls blink interval in Blinking mode</li>
<li>Integrated firmware runs stable with logs</li>
</ul>
</section>
<section>
<h2>Workshop Wrap-up</h2>
<ul>
<li>You moved from Rust basics to real MCU firmware</li>
<li>You used no_std, HAL GPIO, button input, and ADC</li>
<li>Next: extend with UART, interrupts, or Embassy async</li>
</ul>
</section>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/reveal.js@5/dist/reveal.js"></script>
<script>
Reveal.initialize({
hash: true,
controls: true,
progress: true,
center: true,
transition: 'slide'
});
</script>
</body>
</html>