Updated WEEK10
@@ -0,0 +1,79 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
|
||||
<!-- Background grid decoration -->
|
||||
<g opacity="0.06">
|
||||
<line x1="0" y1="100" x2="1200" y2="100" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="200" x2="1200" y2="200" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="300" x2="1200" y2="300" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="400" x2="1200" y2="400" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="500" x2="1200" y2="500" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="600" x2="1200" y2="600" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="700" x2="1200" y2="700" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="200" y1="0" x2="200" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="400" y1="0" x2="400" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="600" y1="0" x2="600" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="800" y1="0" x2="800" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="1000" y1="0" x2="1000" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
</g>
|
||||
|
||||
<!-- Hex rain decoration -->
|
||||
<g opacity="0.04" font-family="'Courier New',monospace" font-size="14" fill="#00ff41">
|
||||
<text x="50" y="80">4F 70 65 6E 4F 43 44</text>
|
||||
<text x="900" y="120">10 00 02 34 08 B5 01</text>
|
||||
<text x="150" y="180">47 44 42 20 52 45 56</text>
|
||||
<text x="800" y="240">20 08 20 00 FF AA 00</text>
|
||||
<text x="80" y="350">52 50 32 33 35 30 00</text>
|
||||
<text x="950" y="380">0A 0A 0F 12 12 1A 1A</text>
|
||||
<text x="100" y="520">41 52 4D 76 38 2D 4D</text>
|
||||
<text x="870" y="560">00 FF 41 00 D4 FF 88</text>
|
||||
<text x="60" y="680">47 48 49 44 52 41 00</text>
|
||||
<text x="920" y="720">FF 00 40 C0 C0 C0 00</text>
|
||||
</g>
|
||||
|
||||
<!-- Corner accents -->
|
||||
<polyline points="30,30 30,80 80,80" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="1170,30 1170,80 1120,80" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="30,770 30,720 80,720" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="1170,770 1170,720 1120,720" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
|
||||
<!-- Top accent line -->
|
||||
<rect x="100" y="140" width="1000" height="2" fill="#00ff41" opacity="0.4"/>
|
||||
|
||||
<!-- Course Title -->
|
||||
<text x="600" y="210" text-anchor="middle" font-family="'Courier New',monospace" font-size="56" font-weight="bold" fill="#00ff41">Embedded Systems</text>
|
||||
<text x="600" y="278" text-anchor="middle" font-family="'Courier New',monospace" font-size="56" font-weight="bold" fill="#00ff41">Reverse Engineering</text>
|
||||
|
||||
<!-- Divider -->
|
||||
<rect x="300" y="310" width="600" height="2" fill="#00d4ff" opacity="0.6"/>
|
||||
|
||||
<!-- Week Number -->
|
||||
<text x="600" y="380" text-anchor="middle" font-family="'Courier New',monospace" font-size="42" font-weight="bold" fill="#00d4ff">// WEEK 10</text>
|
||||
|
||||
<!-- Week Topic -->
|
||||
<text x="600" y="440" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Conditionals in Embedded Systems:</text>
|
||||
<text x="600" y="478" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Debugging and Hacking Static & Dynamic</text>
|
||||
<text x="600" y="516" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Conditionals w/ SG90 Servo Motor PWM</text>
|
||||
|
||||
<!-- Bottom accent line -->
|
||||
<rect x="100" y="570" width="1000" height="2" fill="#00ff41" opacity="0.4"/>
|
||||
|
||||
<!-- University -->
|
||||
<text x="600" y="635" text-anchor="middle" font-family="'Courier New',monospace" font-size="36" font-weight="bold" fill="#ffaa00">George Mason University</text>
|
||||
|
||||
<!-- Bottom badge -->
|
||||
<rect x="400" y="670" width="400" height="40" rx="20" fill="none" stroke="#00ff41" stroke-width="1.5" opacity="0.5"/>
|
||||
<text x="600" y="697" text-anchor="middle" font-family="'Courier New',monospace" font-size="20" fill="#00ff41" opacity="0.7">RP2350 // ARM Cortex-M33</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,82 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Conditionals Overview</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Static vs Dynamic Decision Making</text>
|
||||
|
||||
<!-- What Are Conditionals -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="150">What Are Conditionals?</text>
|
||||
<text class="txt" x="50" y="185">Structures that let programs choose</text>
|
||||
<text class="txt" x="50" y="215">different paths based on conditions</text>
|
||||
|
||||
<!-- Static -->
|
||||
<rect class="pnl" x="30" y="250" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="290">Static Conditional</text>
|
||||
<text class="dim" x="50" y="320">Value fixed at compile time</text>
|
||||
|
||||
<rect x="50" y="340" width="515" height="150" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="370">int choice = 1;</text>
|
||||
<text class="dim" x="370" y="370">// never changes</text>
|
||||
<text class="txt" x="70" y="400">if (choice == 1)</text>
|
||||
<text class="grn" x="100" y="430">printf("1");</text>
|
||||
<text class="dim" x="370" y="430">// always runs</text>
|
||||
<text class="red" x="70" y="460">else printf("2");</text>
|
||||
<text class="dim" x="370" y="460">// never runs</text>
|
||||
|
||||
<!-- Dynamic -->
|
||||
<rect class="pnl" x="615" y="250" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="635" y="290">Dynamic Conditional</text>
|
||||
<text class="dim" x="635" y="320">Value changes at runtime</text>
|
||||
|
||||
<rect x="635" y="340" width="515" height="150" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="655" y="370">choice = getchar();</text>
|
||||
<text class="dim" x="655" y="398">// user types a key</text>
|
||||
<text class="txt" x="655" y="428">if (choice == '1')</text>
|
||||
<text class="grn" x="685" y="458">printf("1");</text>
|
||||
<text class="dim" x="895" y="458">// maybe runs</text>
|
||||
|
||||
<!-- Two Control Structures -->
|
||||
<rect class="pnl" x="30" y="530" width="555" height="230" rx="8"/>
|
||||
<text class="sub" x="50" y="570">if/else</text>
|
||||
|
||||
<text class="amb" x="50" y="605">Feature</text>
|
||||
<text class="amb" x="280" y="605">Description</text>
|
||||
<line x1="50" y1="615" x2="565" y2="615" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="50" y="645">Condition</text>
|
||||
<text class="dim" x="280" y="645">Any boolean expr</text>
|
||||
<text class="txt" x="50" y="675">Values</text>
|
||||
<text class="dim" x="280" y="675">Ranges, complex logic</text>
|
||||
<text class="txt" x="50" y="705">Fall-through</text>
|
||||
<text class="dim" x="280" y="705">No</text>
|
||||
<text class="txt" x="50" y="735">Best for</text>
|
||||
<text class="dim" x="280" y="735">2-3 conditions</text>
|
||||
|
||||
<!-- switch/case -->
|
||||
<rect class="pnl" x="615" y="530" width="555" height="230" rx="8"/>
|
||||
<text class="sub" x="635" y="570">switch/case</text>
|
||||
|
||||
<text class="amb" x="635" y="605">Feature</text>
|
||||
<text class="amb" x="865" y="605">Description</text>
|
||||
<line x1="635" y1="615" x2="1150" y2="615" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="635" y="645">Condition</text>
|
||||
<text class="dim" x="865" y="645">Single variable</text>
|
||||
<text class="txt" x="635" y="675">Values</text>
|
||||
<text class="dim" x="865" y="675">Discrete only</text>
|
||||
<text class="txt" x="635" y="705">Fall-through</text>
|
||||
<text class="dim" x="865" y="705">Yes (no break)</text>
|
||||
<text class="txt" x="635" y="735">Best for</text>
|
||||
<text class="dim" x="865" y="735">Many conditions</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,89 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Static Conditionals</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Fixed Outcome -- Same Path Every Time</text>
|
||||
|
||||
<!-- Code -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="320" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Static Code Pattern</text>
|
||||
<rect x="50" y="170" width="515" height="240" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="200">int choice = 1;</text>
|
||||
<text class="dim" x="370" y="200">// NEVER changes</text>
|
||||
<text class="txt" x="70" y="235">while (true) {</text>
|
||||
<text class="txt" x="100" y="270">if (choice == 1)</text>
|
||||
<text class="grn" x="130" y="300">printf("1");</text>
|
||||
<text class="txt" x="100" y="330">else if (choice == 2)</text>
|
||||
<text class="red" x="130" y="360">printf("2");</text>
|
||||
<text class="dim" x="370" y="360">// dead code</text>
|
||||
<text class="txt" x="100" y="390">else</text>
|
||||
|
||||
<!-- Flow Diagram -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="320" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Execution Flow</text>
|
||||
|
||||
<rect x="680" y="175" width="190" height="40" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="690" y="202">choice == 1?</text>
|
||||
|
||||
<line x1="870" y1="195" x2="910" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<text class="grn" x="915" y="202">YES</text>
|
||||
|
||||
<rect x="980" y="175" width="150" height="40" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="1055" y="202" text-anchor="middle">print "1"</text>
|
||||
|
||||
<text class="red" x="790" y="245">NO (never taken)</text>
|
||||
<line x1="775" y1="215" x2="775" y2="255" stroke="#ff0040" stroke-width="1" stroke-dasharray="4"/>
|
||||
|
||||
<rect x="680" y="260" width="190" height="40" rx="6" fill="#0a0a0f" stroke="#1a1a2e" stroke-dasharray="4"/>
|
||||
<text class="dim" x="710" y="287">choice == 2?</text>
|
||||
|
||||
<text class="dim" x="700" y="330">NO (never reached)</text>
|
||||
|
||||
<rect x="680" y="345" width="190" height="40" rx="6" fill="#0a0a0f" stroke="#1a1a2e" stroke-dasharray="4"/>
|
||||
<text class="dim" x="710" y="372">print "?"</text>
|
||||
|
||||
<text class="dim" x="635" y="415">Only ONE path ever executes!</text>
|
||||
|
||||
<!-- Execution Trace -->
|
||||
<rect class="pnl" x="30" y="450" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="490">Every Loop Iteration (Always the Same)</text>
|
||||
<text class="grn" x="50" y="525">1. if(1==1) --> TRUE</text>
|
||||
<text class="grn" x="450" y="525">2. print "1"</text>
|
||||
<text class="grn" x="720" y="525">3. switch(1) case 1</text>
|
||||
<text class="grn" x="50" y="555">4. print "one"</text>
|
||||
<text class="grn" x="350" y="555">5. servo 0deg</text>
|
||||
<text class="grn" x="620" y="555">6. sleep 500ms</text>
|
||||
<text class="grn" x="900" y="555">7. servo 180deg</text>
|
||||
|
||||
<!-- Serial Output -->
|
||||
<rect class="pnl" x="30" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="50" y="630">Serial Output (Forever)</text>
|
||||
<rect x="50" y="645" width="515" height="95" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="grn" x="70" y="675">1</text>
|
||||
<text class="grn" x="70" y="700">one</text>
|
||||
<text class="grn" x="70" y="725">1</text>
|
||||
<text class="dim" x="150" y="700">// repeats forever</text>
|
||||
|
||||
<!-- Servo -->
|
||||
<rect class="pnl" x="615" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="635" y="630">Servo Motion (Forever)</text>
|
||||
<text class="txt" x="635" y="670">0deg</text>
|
||||
<text class="amb" x="730" y="670">--></text>
|
||||
<text class="txt" x="800" y="670">180deg</text>
|
||||
<text class="amb" x="920" y="670">--></text>
|
||||
<text class="txt" x="990" y="670">0deg</text>
|
||||
<text class="dim" x="635" y="705">Sweeps back and forth, 500ms each</text>
|
||||
<text class="dim" x="635" y="735">Continuous, predictable motion</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1,95 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Dynamic Conditionals</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Runtime Input Changes the Path</text>
|
||||
|
||||
<!-- Code -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="340" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Dynamic Code Pattern</text>
|
||||
<rect x="50" y="170" width="515" height="260" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="200">uint8_t choice = 0;</text>
|
||||
<text class="txt" x="70" y="235">while (true) {</text>
|
||||
<text class="amb" x="100" y="270">choice = getchar();</text>
|
||||
<text class="dim" x="100" y="300">// waits for keyboard input</text>
|
||||
<text class="txt" x="100" y="330">if (choice == 0x31)</text>
|
||||
<text class="grn" x="130" y="360">printf("1");</text>
|
||||
<text class="txt" x="100" y="390">else if (choice == 0x32)</text>
|
||||
<text class="grn" x="130" y="420">printf("2");</text>
|
||||
|
||||
<!-- Flow Diagram -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="340" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Execution Flow</text>
|
||||
|
||||
<rect x="720" y="170" width="280" height="40" rx="6" fill="#0a0a0f" stroke="#ffaa00"/>
|
||||
<text class="amb" x="740" y="197">choice = getchar()</text>
|
||||
|
||||
<line x1="860" y1="210" x2="860" y2="240" stroke="#888" stroke-width="2"/>
|
||||
|
||||
<rect x="720" y="245" width="200" height="40" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="820" y="272" text-anchor="middle">choice=='1'?</text>
|
||||
|
||||
<text class="grn" x="960" y="272">YES</text>
|
||||
<line x1="920" y1="265" x2="955" y2="265" stroke="#00ff41" stroke-width="2"/>
|
||||
<text class="dim" x="1030" y="272">servo 0-180</text>
|
||||
|
||||
<line x1="820" y1="285" x2="820" y2="310" stroke="#888" stroke-width="2"/>
|
||||
<text class="red" x="840" y="307">NO</text>
|
||||
|
||||
<rect x="720" y="315" width="200" height="40" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="820" y="342" text-anchor="middle">choice=='2'?</text>
|
||||
|
||||
<text class="grn" x="960" y="342">YES</text>
|
||||
<line x1="920" y1="335" x2="955" y2="335" stroke="#00ff41" stroke-width="2"/>
|
||||
<text class="dim" x="1030" y="342">servo 180-0</text>
|
||||
|
||||
<line x1="820" y1="355" x2="820" y2="380" stroke="#888" stroke-width="2"/>
|
||||
|
||||
<text class="red" x="740" y="400">print "??"</text>
|
||||
<text class="dim" x="635" y="435">Each iteration can take a DIFFERENT path</text>
|
||||
|
||||
<!-- getchar ASCII -->
|
||||
<rect class="pnl" x="30" y="470" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="510">getchar() Returns ASCII</text>
|
||||
<text class="txt" x="50" y="545">'1' = 0x31</text>
|
||||
<text class="txt" x="240" y="545">'2' = 0x32</text>
|
||||
<text class="txt" x="50" y="580">'x' = 0x78</text>
|
||||
<text class="txt" x="240" y="580">'y' = 0x79</text>
|
||||
<text class="dim" x="410" y="545">Blocks until</text>
|
||||
<text class="dim" x="410" y="580">keypress</text>
|
||||
|
||||
<!-- Behavior Table -->
|
||||
<rect class="pnl" x="615" y="470" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="510">Input --> Behavior</text>
|
||||
|
||||
<text class="amb" x="635" y="545">Key</text>
|
||||
<text class="amb" x="740" y="545">Output</text>
|
||||
<text class="amb" x="920" y="545">Servo</text>
|
||||
<line x1="635" y1="555" x2="1150" y2="555" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="635" y="580">'1'</text>
|
||||
<text class="grn" x="740" y="580">"1" + "one"</text>
|
||||
<text class="dim" x="920" y="580">0deg --> 180deg</text>
|
||||
<text class="txt" x="635" y="605">'2'</text>
|
||||
<text class="grn" x="740" y="605">"2" + "two"</text>
|
||||
<text class="dim" x="920" y="605">180deg --> 0deg</text>
|
||||
|
||||
<!-- Project Info -->
|
||||
<rect class="pnl" x="30" y="640" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="680">Two Projects</text>
|
||||
<text class="cyn" x="50" y="715">0x001d_static-conditionals</text>
|
||||
<text class="dim" x="530" y="715">choice = 1 (fixed)</text>
|
||||
<text class="cyn" x="50" y="745">0x0020_dynamic-conditionals</text>
|
||||
<text class="dim" x="530" y="745">choice = getchar() (user input)</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,96 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">PWM Basics</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Pulse Width Modulation for Servo Control</text>
|
||||
|
||||
<!-- What is PWM -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="150">What is PWM?</text>
|
||||
<text class="txt" x="50" y="185">Rapidly switching a signal ON and OFF</text>
|
||||
<text class="dim" x="50" y="213">Ratio of on-time to off-time controls power</text>
|
||||
|
||||
<!-- PWM waveform diagram -->
|
||||
<text class="grn" x="650" y="155">HIGH</text>
|
||||
<line x1="700" y1="165" x2="700" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="700" y1="165" x2="830" y2="165" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="830" y1="165" x2="830" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="830" y1="195" x2="920" y2="195" stroke="#888" stroke-width="2"/>
|
||||
<line x1="920" y1="195" x2="920" y2="165" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="920" y1="165" x2="1050" y2="165" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="1050" y1="165" x2="1050" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="1050" y1="195" x2="1140" y2="195" stroke="#888" stroke-width="2"/>
|
||||
<text class="dim" x="650" y="230">ON</text>
|
||||
<text class="dim" x="750" y="230">OFF</text>
|
||||
<text class="dim" x="850" y="230">ON</text>
|
||||
<text class="dim" x="990" y="230">OFF</text>
|
||||
|
||||
<!-- Servo Pulse Widths -->
|
||||
<rect class="pnl" x="30" y="290" width="1140" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="330">Servo PWM (50Hz = 20ms period)</text>
|
||||
|
||||
<!-- 0 degrees -->
|
||||
<text class="amb" x="50" y="370">0deg (1ms pulse):</text>
|
||||
<line x1="330" y1="355" x2="380" y2="355" stroke="#00ff41" stroke-width="3"/>
|
||||
<line x1="380" y1="355" x2="380" y2="375" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="380" y1="375" x2="900" y2="375" stroke="#888" stroke-width="1" stroke-dasharray="3"/>
|
||||
<text class="dim" x="400" y="370">1ms HIGH</text>
|
||||
<text class="dim" x="700" y="370">19ms LOW</text>
|
||||
|
||||
<!-- 90 degrees -->
|
||||
<text class="amb" x="50" y="420">90deg (1.5ms pulse):</text>
|
||||
<line x1="330" y1="405" x2="410" y2="405" stroke="#00ff41" stroke-width="3"/>
|
||||
<line x1="410" y1="405" x2="410" y2="425" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="410" y1="425" x2="900" y2="425" stroke="#888" stroke-width="1" stroke-dasharray="3"/>
|
||||
<text class="dim" x="430" y="420">1.5ms HIGH</text>
|
||||
<text class="dim" x="700" y="420">18.5ms LOW</text>
|
||||
|
||||
<!-- 180 degrees -->
|
||||
<text class="amb" x="50" y="470">180deg (2ms pulse):</text>
|
||||
<line x1="330" y1="455" x2="440" y2="455" stroke="#00ff41" stroke-width="3"/>
|
||||
<line x1="440" y1="455" x2="440" y2="475" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="440" y1="475" x2="900" y2="475" stroke="#888" stroke-width="1" stroke-dasharray="3"/>
|
||||
<text class="dim" x="460" y="470">2ms HIGH</text>
|
||||
<text class="dim" x="700" y="470">18ms LOW</text>
|
||||
|
||||
<text class="dim" x="50" y="510">Pulse WIDTH determines angle, not duty cycle</text>
|
||||
<text class="dim" x="50" y="535">Total period always 20ms (50Hz)</text>
|
||||
|
||||
<!-- Angle Table -->
|
||||
<rect class="pnl" x="30" y="570" width="555" height="190" rx="8"/>
|
||||
<text class="sub" x="50" y="610">Angle to Pulse Width</text>
|
||||
|
||||
<text class="amb" x="50" y="645">Angle</text>
|
||||
<text class="amb" x="180" y="645">Pulse</text>
|
||||
<text class="amb" x="340" y="645">Ticks (1MHz)</text>
|
||||
<line x1="50" y1="655" x2="565" y2="655" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="50" y="685">0deg</text>
|
||||
<text class="grn" x="180" y="685">1000us</text>
|
||||
<text class="dim" x="340" y="685">1000</text>
|
||||
<text class="txt" x="50" y="715">90deg</text>
|
||||
<text class="grn" x="180" y="715">1500us</text>
|
||||
<text class="dim" x="340" y="715">1500</text>
|
||||
<text class="txt" x="50" y="745">180deg</text>
|
||||
<text class="grn" x="180" y="745">2000us</text>
|
||||
<text class="dim" x="340" y="745">2000</text>
|
||||
|
||||
<!-- Formula -->
|
||||
<rect class="pnl" x="615" y="570" width="555" height="190" rx="8"/>
|
||||
<text class="sub" x="635" y="610">Formula</text>
|
||||
<text class="cyn" x="635" y="650">pulse = 1000 + (angle/180) x 1000</text>
|
||||
<text class="dim" x="635" y="685">Example for 90deg:</text>
|
||||
<text class="txt" x="635" y="715">1000 + (90/180) x 1000</text>
|
||||
<text class="grn" x="635" y="745">= 1500us = 1500 ticks</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,83 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">PWM Timing Chain</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">150MHz System Clock to 50Hz Servo Signal</text>
|
||||
|
||||
<!-- Clock Division Chain -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="230" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Clock Division</text>
|
||||
|
||||
<rect x="50" y="175" width="250" height="50" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="95" y="207">150 MHz Clock</text>
|
||||
|
||||
<text class="amb" x="320" y="207">/ 150</text>
|
||||
<line x1="300" y1="200" x2="315" y2="200" stroke="#ffaa00" stroke-width="2"/>
|
||||
<line x1="395" y1="200" x2="415" y2="200" stroke="#ffaa00" stroke-width="2"/>
|
||||
|
||||
<rect x="420" y="175" width="250" height="50" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="475" y="207">1 MHz PWM</text>
|
||||
|
||||
<text class="dim" x="690" y="207">1 tick = 1us</text>
|
||||
|
||||
<line x1="670" y1="200" x2="685" y2="200" stroke="#ffaa00" stroke-width="2"/>
|
||||
|
||||
<text class="txt" x="50" y="260">Step 1: 150,000,000 / 150 = 1,000,000 Hz</text>
|
||||
<text class="dim" x="50" y="290">Each PWM tick = exactly 1 microsecond</text>
|
||||
|
||||
<text class="txt" x="50" y="320">Step 2: Wrap at 20,000 ticks = 20ms = 50Hz</text>
|
||||
<text class="dim" x="680" y="320">Wrap value = 19,999</text>
|
||||
|
||||
<!-- SG90 Specs -->
|
||||
<rect class="pnl" x="30" y="360" width="555" height="220" rx="8"/>
|
||||
<text class="sub" x="50" y="400">SG90 Servo Motor</text>
|
||||
|
||||
<text class="amb" x="50" y="435">Parameter</text>
|
||||
<text class="amb" x="300" y="435">Value</text>
|
||||
<line x1="50" y1="445" x2="565" y2="445" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="50" y="475">Voltage</text>
|
||||
<text class="dim" x="300" y="475">4.8V - 6V (use 5V)</text>
|
||||
<text class="txt" x="50" y="505">Rotation</text>
|
||||
<text class="dim" x="300" y="505">0deg to 180deg</text>
|
||||
<text class="txt" x="50" y="535">Pulse Width</text>
|
||||
<text class="dim" x="300" y="535">1000us - 2000us</text>
|
||||
<text class="txt" x="50" y="565">Frequency</text>
|
||||
<text class="dim" x="300" y="565">50Hz (20ms period)</text>
|
||||
|
||||
<!-- Wiring -->
|
||||
<rect class="pnl" x="615" y="360" width="555" height="220" rx="8"/>
|
||||
<text class="sub" x="635" y="400">Wiring to Pico 2</text>
|
||||
|
||||
<rect x="635" y="425" width="100" height="45" rx="4" fill="#0a0a0f" stroke="#00d4ff" stroke-width="1"/>
|
||||
<text class="cyn" x="655" y="454">Pico</text>
|
||||
|
||||
<rect x="1040" y="425" width="100" height="45" rx="4" fill="#0a0a0f" stroke="#ffaa00" stroke-width="1"/>
|
||||
<text class="amb" x="1060" y="454">SG90</text>
|
||||
|
||||
<line x1="735" y1="438" x2="1040" y2="438" stroke="#ffaa00" stroke-width="2"/>
|
||||
<line x1="735" y1="458" x2="1040" y2="458" stroke="#ff0040" stroke-width="2"/>
|
||||
|
||||
<text class="dim" x="635" y="495">GPIO 6 = Signal (Orange)</text>
|
||||
<text class="dim" x="635" y="520">VBUS 5V = VCC (Red)</text>
|
||||
<text class="dim" x="635" y="545">GND = GND (Brown)</text>
|
||||
<text class="red" x="635" y="570">Add 1000uF capacitor on power!</text>
|
||||
|
||||
<!-- Power Warning -->
|
||||
<rect class="pnl" x="30" y="600" width="1140" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="640">Power Safety</text>
|
||||
<text class="red" x="50" y="675">NEVER use 3.3V pin for servo!</text>
|
||||
<text class="txt" x="50" y="710">Servos draw 650mA+ (spikes to 1A)</text>
|
||||
<text class="dim" x="50" y="740">Use VBUS (5V from USB) with 1000uF 25V capacitor</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,55 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Static Source Code</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">0x001d_static-conditionals.c</text>
|
||||
|
||||
<!-- Source Code -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="490" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Full Source</text>
|
||||
<rect x="50" y="170" width="1100" height="410" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
|
||||
<text class="dim" x="70" y="200">#include <stdio.h></text>
|
||||
<text class="dim" x="70" y="225">#include "pico/stdlib.h"</text>
|
||||
<text class="dim" x="70" y="250">#include "servo.h"</text>
|
||||
<text class="cyn" x="70" y="280">#define SERVO_GPIO 6</text>
|
||||
|
||||
<text class="cyn" x="70" y="315">int main(void) {</text>
|
||||
<text class="txt" x="100" y="345">stdio_init_all();</text>
|
||||
<text class="amb" x="100" y="375">int choice = 1;</text>
|
||||
<text class="dim" x="430" y="375">// STATIC!</text>
|
||||
<text class="txt" x="100" y="405">servo_init(SERVO_GPIO);</text>
|
||||
|
||||
<text class="txt" x="100" y="440">while (true) {</text>
|
||||
<text class="txt" x="130" y="470">if (choice == 1)</text>
|
||||
<text class="grn" x="160" y="500">printf("1\r\n");</text>
|
||||
<text class="txt" x="130" y="530">else if (choice == 2)</text>
|
||||
<text class="dim" x="160" y="560">printf("2\r\n");</text>
|
||||
<text class="dim" x="430" y="560">// dead code</text>
|
||||
|
||||
<!-- Bottom section: switch + servo -->
|
||||
<rect class="pnl" x="30" y="610" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="650">switch Block</text>
|
||||
<rect x="50" y="665" width="515" height="75" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="70" y="693">switch(choice) {</text>
|
||||
<text class="txt" x="100" y="718">case 1: puts("one"); break;</text>
|
||||
|
||||
<rect class="pnl" x="615" y="610" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="650">Servo Loop</text>
|
||||
<rect x="635" y="665" width="515" height="75" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="655" y="693">servo_set_angle(0.0f);</text>
|
||||
<text class="txt" x="655" y="718">sleep_ms(500);</text>
|
||||
<text class="dim" x="900" y="718">// then 180</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,50 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Dynamic Source Code</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">0x0020_dynamic-conditionals.c</text>
|
||||
|
||||
<!-- Source Code -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="530" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Full Source</text>
|
||||
<rect x="50" y="170" width="1100" height="450" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
|
||||
<text class="dim" x="70" y="200">#include <stdio.h></text>
|
||||
<text class="dim" x="70" y="225">#include "pico/stdlib.h"</text>
|
||||
<text class="dim" x="70" y="250">#include "servo.h"</text>
|
||||
<text class="cyn" x="70" y="280">#define SERVO_GPIO 6</text>
|
||||
|
||||
<text class="cyn" x="70" y="315">int main(void) {</text>
|
||||
<text class="txt" x="100" y="345">stdio_init_all();</text>
|
||||
<text class="amb" x="100" y="375">uint8_t choice = 0;</text>
|
||||
<text class="dim" x="430" y="375">// DYNAMIC!</text>
|
||||
<text class="txt" x="100" y="405">servo_init(SERVO_GPIO);</text>
|
||||
|
||||
<text class="txt" x="100" y="440">while (true) {</text>
|
||||
<text class="amb" x="130" y="470">choice = getchar();</text>
|
||||
<text class="dim" x="430" y="470">// wait for input</text>
|
||||
<text class="txt" x="130" y="500">if (choice == 0x31)</text>
|
||||
<text class="dim" x="430" y="500">// '1'</text>
|
||||
<text class="grn" x="160" y="530">printf("1\r\n");</text>
|
||||
<text class="txt" x="130" y="560">else if (choice == 0x32)</text>
|
||||
<text class="dim" x="430" y="560">// '2'</text>
|
||||
<text class="grn" x="160" y="590">printf("2\r\n");</text>
|
||||
|
||||
<!-- switch block with servo -->
|
||||
<rect class="pnl" x="30" y="660" width="1140" height="100" rx="8"/>
|
||||
<text class="sub" x="50" y="695">switch Block (with servo control)</text>
|
||||
<text class="txt" x="50" y="730">case '1': print "one", servo 0-->180, sleep 500ms</text>
|
||||
<text class="txt" x="50" y="750">case '2': print "two", servo 180-->0, sleep 500ms</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,101 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Branch Instructions</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">How Conditionals Become Assembly</text>
|
||||
|
||||
<!-- Branch Instruction Table -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="150">ARM Branch Instructions</text>
|
||||
|
||||
<text class="amb" x="50" y="190">Instr</text>
|
||||
<text class="amb" x="170" y="190">Meaning</text>
|
||||
<text class="amb" x="440" y="190">Condition</text>
|
||||
<line x1="50" y1="200" x2="565" y2="200" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="grn" x="50" y="230">b</text>
|
||||
<text class="txt" x="170" y="230">Branch always</text>
|
||||
<text class="dim" x="440" y="230">Always</text>
|
||||
|
||||
<text class="grn" x="50" y="260">beq</text>
|
||||
<text class="txt" x="170" y="260">Branch if Equal</text>
|
||||
<text class="dim" x="440" y="260">Z flag set</text>
|
||||
|
||||
<text class="grn" x="50" y="290">bne</text>
|
||||
<text class="txt" x="170" y="290">Branch if !=</text>
|
||||
<text class="dim" x="440" y="290">Z flag clear</text>
|
||||
|
||||
<text class="grn" x="50" y="320">bgt</text>
|
||||
<text class="txt" x="170" y="320">Branch if ></text>
|
||||
<text class="dim" x="440" y="320">Signed ></text>
|
||||
|
||||
<text class="grn" x="50" y="350">blt</text>
|
||||
<text class="txt" x="170" y="350">Branch if <</text>
|
||||
<text class="dim" x="440" y="350">Signed <</text>
|
||||
|
||||
<!-- C to Assembly -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="635" y="150">C --> Assembly</text>
|
||||
|
||||
<text class="dim" x="635" y="182">C code:</text>
|
||||
<rect x="635" y="192" width="515" height="60" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="655" y="218">if (choice == 0x31)</text>
|
||||
<text class="grn" x="675" y="243">printf("1");</text>
|
||||
|
||||
<text class="dim" x="635" y="280">Assembly:</text>
|
||||
<rect x="635" y="290" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="655" y="318">cmp r4, #0x31</text>
|
||||
<text class="dim" x="900" y="318">// compare</text>
|
||||
<text class="cyn" x="655" y="346">bne skip_printf</text>
|
||||
<text class="dim" x="900" y="346">// skip if !=</text>
|
||||
|
||||
<!-- Flow Diagram -->
|
||||
<rect class="pnl" x="30" y="390" width="1140" height="180" rx="8"/>
|
||||
<text class="sub" x="50" y="430">Conditional Branch Flow</text>
|
||||
|
||||
<rect x="50" y="450" width="230" height="42" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="165" y="478" text-anchor="middle">cmp r4, #0x31</text>
|
||||
|
||||
<line x1="280" y1="471" x2="320" y2="471" stroke="#888" stroke-width="2"/>
|
||||
|
||||
<rect x="325" y="450" width="270" height="42" rx="6" fill="#0a0a0f" stroke="#ffaa00"/>
|
||||
<text class="amb" x="460" y="478" text-anchor="middle">beq target_addr</text>
|
||||
|
||||
<line x1="595" y1="460" x2="650" y2="460" stroke="#00ff41" stroke-width="2"/>
|
||||
<text class="grn" x="660" y="464">r4==0x31: JUMP</text>
|
||||
|
||||
<line x1="440" y1="492" x2="440" y2="515" stroke="#ff0040" stroke-width="2"/>
|
||||
<text class="red" x="465" y="515">r4!=0x31: continue next</text>
|
||||
|
||||
<text class="dim" x="50" y="548">cmp sets CPU flags, branch reads them</text>
|
||||
|
||||
<!-- NOP Encoding -->
|
||||
<rect class="pnl" x="30" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="50" y="630">NOP (No Operation)</text>
|
||||
<text class="txt" x="50" y="665">ARM Thumb NOP:</text>
|
||||
<text class="grn" x="320" y="665">00 bf</text>
|
||||
<text class="dim" x="420" y="665">2 bytes</text>
|
||||
<text class="txt" x="50" y="700">Wide NOP:</text>
|
||||
<text class="grn" x="320" y="700">00 f0 00 80</text>
|
||||
<text class="dim" x="50" y="730">Replaces 4-byte bl instruction</text>
|
||||
|
||||
<!-- Hacking Branches -->
|
||||
<rect class="pnl" x="615" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="635" y="630">Hacking Branches</text>
|
||||
<text class="txt" x="635" y="665">Change branch target addr</text>
|
||||
<text class="dim" x="635" y="690">Redirect program flow</text>
|
||||
<text class="txt" x="635" y="715">NOP out instructions</text>
|
||||
<text class="dim" x="635" y="740">Erase code silently</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,83 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Hacking Conditionals</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Strings, Timing, Stealth Commands</text>
|
||||
|
||||
<!-- Hack 1: String -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Hack 1: Change Strings</text>
|
||||
<text class="txt" x="50" y="185">Change "1" to "2":</text>
|
||||
<text class="red" x="340" y="185">0x31</text>
|
||||
<text class="amb" x="420" y="185">--></text>
|
||||
<text class="grn" x="480" y="185">0x32</text>
|
||||
<text class="txt" x="50" y="220">"one" to "fun":</text>
|
||||
<text class="red" x="280" y="220">6f 6e 65</text>
|
||||
<text class="amb" x="410" y="220">--></text>
|
||||
<text class="grn" x="460" y="220">66 75 6e</text>
|
||||
|
||||
<!-- Hack 2: Timing -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Hack 2: Speed Up Servo</text>
|
||||
<text class="txt" x="635" y="185">Change sleep_ms delay:</text>
|
||||
<text class="red" x="635" y="220">0x1F4 (500ms)</text>
|
||||
<text class="amb" x="860" y="220">--></text>
|
||||
<text class="grn" x="920" y="220">0x064 (100ms)</text>
|
||||
|
||||
<!-- Hack 3: Stealth -->
|
||||
<rect class="pnl" x="30" y="280" width="1140" height="240" rx="8"/>
|
||||
<text class="sub" x="50" y="320">Hack 3: Stealth Commands</text>
|
||||
<text class="dim" x="50" y="348">Hidden keys move servo with NO output</text>
|
||||
|
||||
<text class="amb" x="50" y="383">Patch</text>
|
||||
<text class="amb" x="280" y="383">Original</text>
|
||||
<text class="amb" x="530" y="383">Hacked</text>
|
||||
<text class="amb" x="800" y="383">Purpose</text>
|
||||
<line x1="50" y1="393" x2="1140" y2="393" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="txt" x="50" y="423">Compare 1</text>
|
||||
<text class="red" x="280" y="423">#0x31 ('1')</text>
|
||||
<text class="grn" x="530" y="423">#0x78 ('x')</text>
|
||||
<text class="dim" x="800" y="423">New trigger key</text>
|
||||
|
||||
<text class="txt" x="50" y="453">Compare 2</text>
|
||||
<text class="red" x="280" y="453">#0x32 ('2')</text>
|
||||
<text class="grn" x="530" y="453">#0x79 ('y')</text>
|
||||
<text class="dim" x="800" y="453">New trigger key</text>
|
||||
|
||||
<text class="txt" x="50" y="483">puts calls</text>
|
||||
<text class="red" x="280" y="483">bl puts</text>
|
||||
<text class="grn" x="530" y="483">00 bf 00 bf</text>
|
||||
<text class="dim" x="800" y="483">NOP out prints</text>
|
||||
|
||||
<!-- Hack 4: Angle -->
|
||||
<rect class="pnl" x="30" y="540" width="555" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="575">Hack 4: Change Angle</text>
|
||||
<text class="txt" x="50" y="610">180.0f --> 30.0f:</text>
|
||||
<text class="red" x="50" y="640">00 00 34 43</text>
|
||||
<text class="amb" x="260" y="640">--></text>
|
||||
<text class="grn" x="320" y="640">00 00 f0 41</text>
|
||||
|
||||
<!-- Result -->
|
||||
<rect class="pnl" x="615" y="540" width="555" height="120" rx="8"/>
|
||||
<text class="sub" x="635" y="575">Stealth Result</text>
|
||||
<text class="txt" x="635" y="610">'1','2': normal output + servo</text>
|
||||
<text class="cyn" x="635" y="640">'x','y': NO output, servo moves</text>
|
||||
|
||||
<!-- Bottom summary -->
|
||||
<rect class="pnl" x="30" y="680" width="1140" height="80" rx="8"/>
|
||||
<text class="sub" x="50" y="715">Workflow</text>
|
||||
<text class="dim" x="50" y="740">Patch bytes in Ghidra --> export .bin --> convert to UF2 --> flash to Pico</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,85 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">PWM & Servo Hacking</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Conditionals, PWM, Servo, and Hacking</text>
|
||||
|
||||
<!-- Static vs Dynamic -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Static vs Dynamic</text>
|
||||
|
||||
<text class="grn" x="50" y="185">Static</text>
|
||||
<text class="dim" x="200" y="185">choice = 1 (fixed)</text>
|
||||
<text class="dim" x="200" y="210">Same path every iteration</text>
|
||||
<text class="dim" x="200" y="235">Compiler may optimize</text>
|
||||
|
||||
<text class="cyn" x="50" y="270">Dynamic</text>
|
||||
<text class="dim" x="200" y="270">choice = getchar()</text>
|
||||
<text class="dim" x="200" y="295">Different paths at runtime</text>
|
||||
|
||||
<!-- PWM -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="635" y="150">PWM for Servos</text>
|
||||
<text class="txt" x="635" y="185">150MHz / 150 = 1MHz tick</text>
|
||||
<text class="txt" x="635" y="220">Wrap 20000 = 50Hz (20ms)</text>
|
||||
<text class="dim" x="635" y="255">0deg=1000us 90deg=1500us 180deg=2000us</text>
|
||||
<text class="cyn" x="635" y="290">pulse = 1000 + (angle/180) x 1000</text>
|
||||
|
||||
<!-- Branch Instructions -->
|
||||
<rect class="pnl" x="30" y="330" width="555" height="180" rx="8"/>
|
||||
<text class="sub" x="50" y="370">Branch Instructions</text>
|
||||
<text class="grn" x="50" y="405">cmp r4, #0x31</text>
|
||||
<text class="dim" x="350" y="405">Compare</text>
|
||||
<text class="grn" x="50" y="435">beq target</text>
|
||||
<text class="dim" x="350" y="435">Jump if equal</text>
|
||||
<text class="grn" x="50" y="465">bne target</text>
|
||||
<text class="dim" x="350" y="465">Jump if not equal</text>
|
||||
<text class="dim" x="50" y="495">NOP = 00 bf (erase code)</text>
|
||||
|
||||
<!-- Key Addresses -->
|
||||
<rect class="pnl" x="615" y="330" width="555" height="180" rx="8"/>
|
||||
<text class="sub" x="635" y="370">Key Values</text>
|
||||
<text class="cyn" x="635" y="405">0x10000234</text>
|
||||
<text class="dim" x="870" y="405">main()</text>
|
||||
<text class="cyn" x="635" y="435">0x40070000</text>
|
||||
<text class="dim" x="870" y="435">UART0</text>
|
||||
<text class="cyn" x="635" y="465">0x1F4</text>
|
||||
<text class="dim" x="870" y="465">500 (sleep_ms)</text>
|
||||
<text class="cyn" x="635" y="495">0x43340000</text>
|
||||
<text class="dim" x="870" y="495">180.0f IEEE-754</text>
|
||||
|
||||
<!-- Hacking Techniques -->
|
||||
<rect class="pnl" x="30" y="530" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="570">4 Hack Types Applied</text>
|
||||
<text class="amb" x="50" y="600">String</text>
|
||||
<text class="dim" x="180" y="600">"one"-->"fun"</text>
|
||||
<text class="amb" x="420" y="600">Timing</text>
|
||||
<text class="dim" x="550" y="600">500ms-->100ms</text>
|
||||
<text class="amb" x="50" y="625">Stealth</text>
|
||||
<text class="dim" x="180" y="625">NOP out prints</text>
|
||||
<text class="amb" x="420" y="625">Angle</text>
|
||||
<text class="dim" x="550" y="625">180.0f-->30.0f</text>
|
||||
|
||||
<!-- Projects and IEEE -->
|
||||
<rect class="pnl" x="30" y="660" width="555" height="100" rx="8"/>
|
||||
<text class="sub" x="50" y="692">Projects</text>
|
||||
<text class="dim" x="50" y="718">0x001d_static-conditionals</text>
|
||||
<text class="dim" x="50" y="740">0x0020_dynamic-conditionals</text>
|
||||
|
||||
<rect class="pnl" x="615" y="660" width="555" height="100" rx="8"/>
|
||||
<text class="sub" x="635" y="692">IEEE-754 Angles</text>
|
||||
<text class="dim" x="635" y="718">0.0f=00000000 90.0f=42b40000</text>
|
||||
<text class="dim" x="635" y="740">180.0f=43340000 30.0f=41f00000</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -24,12 +24,12 @@ A **structure** (or **struct**) is a user-defined data type that groups related
|
||||
```c
|
||||
// Define a struct type
|
||||
typedef struct {
|
||||
uint8_t led1_pin; // GPIO pin for LED 1
|
||||
uint8_t led2_pin; // GPIO pin for LED 2
|
||||
uint8_t led3_pin; // GPIO pin for LED 3
|
||||
bool led1_state; // Is LED 1 on?
|
||||
bool led2_state; // Is LED 2 on?
|
||||
bool led3_state; // Is LED 3 on?
|
||||
uint8_t led1_pin; // GPIO pin for LED 1
|
||||
uint8_t led2_pin; // GPIO pin for LED 2
|
||||
uint8_t led3_pin; // GPIO pin for LED 3
|
||||
bool led1_state; // Is LED 1 on?
|
||||
bool led2_state; // Is LED 2 on?
|
||||
bool led3_state; // Is LED 3 on?
|
||||
} simple_led_ctrl_t;
|
||||
```
|
||||
|
||||
@@ -39,15 +39,15 @@ typedef struct {
|
||||
| |
|
||||
| simple_led_ctrl_t leds |
|
||||
| +-------------------------------------------------------------+|
|
||||
| | led1_pin: 16 led2_pin: 17 led3_pin: 18 ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | | 16 | | 17 | | 18 | ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | led1_pin: 16 led2_pin: 17 led3_pin: 18 ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | | 16 | | 17 | | 18 | ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | ||
|
||||
| | led1_state: false led2_state: false led3_state: false ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | | false | | false | | false | ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | led1_state: false led2_state: false led3_state: false ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| | | false | | false | | false | ||
|
||||
| | +--------+ +--------+ +--------+ ||
|
||||
| +-------------------------------------------------------------+|
|
||||
| |
|
||||
| All 6 members live together as ONE variable called "leds" |
|
||||
@@ -120,12 +120,12 @@ When you have a **pointer** to a struct, use the **arrow operator** (`->`):
|
||||
|
||||
```c
|
||||
simple_led_ctrl_t leds;
|
||||
simple_led_ctrl_t *ptr = &leds; // Pointer to the struct
|
||||
simple_led_ctrl_t *ptr = &leds; // Pointer to the struct
|
||||
|
||||
// These are equivalent:
|
||||
leds.led1_pin = 16; // Using dot with struct variable
|
||||
ptr->led1_pin = 16; // Using arrow with pointer
|
||||
(*ptr).led1_pin = 16; // Dereferencing then dot (same thing)
|
||||
leds.led1_pin = 16; // Using dot with struct variable
|
||||
ptr->led1_pin = 16; // Using arrow with pointer
|
||||
(*ptr).led1_pin = 16; // Dereferencing then dot (same thing)
|
||||
```
|
||||
|
||||
```
|
||||
@@ -181,9 +181,9 @@ simple_led_ctrl_t leds = {
|
||||
| Remote Control IR Receiver |
|
||||
| +----------+ +----------+ |
|
||||
| | Button | | | |
|
||||
| | 1 | --- IR Light Pulses --- | ++ | |
|
||||
| | 1 | --- IR Light Pulses --- | ++ | |
|
||||
| | +---+ | ~~~~~~~~~~~~? | Sensor | |
|
||||
| | | ?? | | | | |
|
||||
| | | ?? | | | | |
|
||||
| | +---+ | +----+-----+ |
|
||||
| | IR LED | | |
|
||||
| +----------+ ? |
|
||||
@@ -437,11 +437,11 @@ Before we start, make sure you have:
|
||||
| | | | (VS1838B) | |
|
||||
| | | +------+------+ |
|
||||
| | | | |
|
||||
| | GPIO 16 |---[220 ohm]---(RED LED)----+ |
|
||||
| | GPIO 16 |---[220 ohm]---(RED LED)----+ |
|
||||
| | | | |
|
||||
| | GPIO 17 |---[220 ohm]---(GRN LED)----+ |
|
||||
| | GPIO 17 |---[220 ohm]---(GRN LED)----+ |
|
||||
| | | | |
|
||||
| | GPIO 18 |---[220 ohm]---(YEL LED)----+ |
|
||||
| | GPIO 18 |---[220 ohm]---(YEL LED)----+ |
|
||||
| | | | |
|
||||
| | 3.3V |-------------------------+-- IR VCC |
|
||||
| | | | |
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
|
||||
<!-- Background grid decoration -->
|
||||
<g opacity="0.06">
|
||||
<line x1="0" y1="100" x2="1200" y2="100" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="200" x2="1200" y2="200" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="300" x2="1200" y2="300" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="400" x2="1200" y2="400" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="500" x2="1200" y2="500" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="600" x2="1200" y2="600" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="700" x2="1200" y2="700" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="200" y1="0" x2="200" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="400" y1="0" x2="400" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="600" y1="0" x2="600" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="800" y1="0" x2="800" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="1000" y1="0" x2="1000" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
</g>
|
||||
|
||||
<!-- Hex rain decoration -->
|
||||
<g opacity="0.04" font-family="'Courier New',monospace" font-size="14" fill="#00ff41">
|
||||
<text x="50" y="80">4F 70 65 6E 4F 43 44</text>
|
||||
<text x="900" y="120">10 00 02 34 08 B5 01</text>
|
||||
<text x="150" y="180">47 44 42 20 52 45 56</text>
|
||||
<text x="800" y="240">20 08 20 00 FF AA 00</text>
|
||||
<text x="80" y="350">52 50 32 33 35 30 00</text>
|
||||
<text x="950" y="380">0A 0A 0F 12 12 1A 1A</text>
|
||||
<text x="100" y="520">41 52 4D 76 38 2D 4D</text>
|
||||
<text x="870" y="560">00 FF 41 00 D4 FF 88</text>
|
||||
<text x="60" y="680">47 48 49 44 52 41 00</text>
|
||||
<text x="920" y="720">FF 00 40 C0 C0 C0 00</text>
|
||||
</g>
|
||||
|
||||
<!-- Corner accents -->
|
||||
<polyline points="30,30 30,80 80,80" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="1170,30 1170,80 1120,80" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="30,770 30,720 80,720" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="1170,770 1170,720 1120,720" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
|
||||
<!-- Top accent line -->
|
||||
<rect x="100" y="140" width="1000" height="2" fill="#00ff41" opacity="0.4"/>
|
||||
|
||||
<!-- Course Title -->
|
||||
<text x="600" y="210" text-anchor="middle" font-family="'Courier New',monospace" font-size="56" font-weight="bold" fill="#00ff41">Embedded Systems</text>
|
||||
<text x="600" y="278" text-anchor="middle" font-family="'Courier New',monospace" font-size="56" font-weight="bold" fill="#00ff41">Reverse Engineering</text>
|
||||
|
||||
<!-- Divider -->
|
||||
<rect x="300" y="310" width="600" height="2" fill="#00d4ff" opacity="0.6"/>
|
||||
|
||||
<!-- Week Number -->
|
||||
<text x="600" y="380" text-anchor="middle" font-family="'Courier New',monospace" font-size="42" font-weight="bold" fill="#00d4ff">// WEEK 11</text>
|
||||
|
||||
<!-- Week Topic -->
|
||||
<text x="600" y="440" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Structures and Functions in</text>
|
||||
<text x="600" y="478" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Embedded Systems: Debugging and Hacking</text>
|
||||
<text x="600" y="516" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">w/ IR Remote Control & NEC Protocol</text>
|
||||
|
||||
<!-- Bottom accent line -->
|
||||
<rect x="100" y="570" width="1000" height="2" fill="#00ff41" opacity="0.4"/>
|
||||
|
||||
<!-- University -->
|
||||
<text x="600" y="635" text-anchor="middle" font-family="'Courier New',monospace" font-size="36" font-weight="bold" fill="#ffaa00">George Mason University</text>
|
||||
|
||||
<!-- Bottom badge -->
|
||||
<rect x="400" y="670" width="400" height="40" rx="20" fill="none" stroke="#00ff41" stroke-width="1.5" opacity="0.5"/>
|
||||
<text x="600" y="697" text-anchor="middle" font-family="'Courier New',monospace" font-size="20" fill="#00ff41" opacity="0.7">RP2350 // ARM Cortex-M33</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,70 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">C Structures (Structs)</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Grouping Related Data Together</text>
|
||||
|
||||
<!-- What is a Struct -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="150">What is a Struct?</text>
|
||||
<text class="txt" x="50" y="185">A user-defined type that groups</text>
|
||||
<text class="txt" x="50" y="215">related variables under one name</text>
|
||||
<text class="dim" x="50" y="250">Like a form with multiple fields</text>
|
||||
<text class="dim" x="50" y="275">-- each field holds different data</text>
|
||||
|
||||
<!-- Struct Definition -->
|
||||
<rect class="pnl" x="30" y="330" width="555" height="300" rx="8"/>
|
||||
<text class="sub" x="50" y="370">Struct Definition</text>
|
||||
<rect x="50" y="385" width="515" height="230" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="413">typedef struct {</text>
|
||||
<text class="txt" x="100" y="441">uint8_t led1_pin;</text>
|
||||
<text class="txt" x="100" y="469">uint8_t led2_pin;</text>
|
||||
<text class="txt" x="100" y="497">uint8_t led3_pin;</text>
|
||||
<text class="txt" x="100" y="525">bool led1_state;</text>
|
||||
<text class="txt" x="100" y="553">bool led2_state;</text>
|
||||
<text class="txt" x="100" y="581">bool led3_state;</text>
|
||||
<text class="cyn" x="70" y="607">} simple_led_ctrl_t;</text>
|
||||
|
||||
<!-- Why Use Structs -->
|
||||
<rect class="pnl" x="615" y="330" width="555" height="300" rx="8"/>
|
||||
<text class="sub" x="635" y="370">Why Use Structs?</text>
|
||||
<text class="grn" x="635" y="410">1.</text>
|
||||
<text class="txt" x="680" y="410">Organization</text>
|
||||
<text class="dim" x="680" y="435">Related data stays together</text>
|
||||
<text class="grn" x="635" y="470">2.</text>
|
||||
<text class="txt" x="680" y="470">Readability</text>
|
||||
<text class="dim" x="680" y="495">Code easier to understand</text>
|
||||
<text class="grn" x="635" y="530">3.</text>
|
||||
<text class="txt" x="680" y="530">Scalability</text>
|
||||
<text class="dim" x="680" y="555">Easy to add more features</text>
|
||||
<text class="grn" x="635" y="590">4.</text>
|
||||
<text class="txt" x="680" y="590">Pass to Functions</text>
|
||||
|
||||
<!-- Struct Container Visualization -->
|
||||
<rect class="pnl" x="30" y="650" width="1140" height="110" rx="8"/>
|
||||
<text class="sub" x="50" y="682">simple_led_ctrl_t leds</text>
|
||||
<rect x="50" y="695" width="170" height="45" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="65" y="724">pin1: 16</text>
|
||||
<rect x="240" y="695" width="170" height="45" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="255" y="724">pin2: 17</text>
|
||||
<rect x="430" y="695" width="170" height="45" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="445" y="724">pin3: 18</text>
|
||||
<rect x="630" y="695" width="160" height="45" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="dim" x="645" y="722">state1: 0</text>
|
||||
<rect x="810" y="695" width="160" height="45" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="dim" x="825" y="722">state2: 0</text>
|
||||
<rect x="990" y="695" width="160" height="45" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="dim" x="1005" y="722">state3: 0</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
@@ -0,0 +1,85 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Struct Memory Layout</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">How Structs Are Stored and Accessed</text>
|
||||
|
||||
<!-- Memory Layout Table -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="280" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Memory Layout (6 bytes total)</text>
|
||||
|
||||
<text class="amb" x="50" y="190">Address</text>
|
||||
<text class="amb" x="230" y="190">Member</text>
|
||||
<text class="amb" x="500" y="190">Size</text>
|
||||
<text class="amb" x="650" y="190">Value</text>
|
||||
<line x1="50" y1="200" x2="1140" y2="200" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="cyn" x="50" y="230">0x20000000</text>
|
||||
<text class="txt" x="250" y="230">led1_pin</text>
|
||||
<text class="dim" x="500" y="230">1 byte</text>
|
||||
<text class="grn" x="680" y="230">16 (0x10)</text>
|
||||
|
||||
<text class="cyn" x="50" y="260">0x20000001</text>
|
||||
<text class="txt" x="250" y="260">led2_pin</text>
|
||||
<text class="dim" x="500" y="260">1 byte</text>
|
||||
<text class="grn" x="680" y="260">17 (0x11)</text>
|
||||
|
||||
<text class="cyn" x="50" y="290">0x20000002</text>
|
||||
<text class="txt" x="250" y="290">led3_pin</text>
|
||||
<text class="dim" x="500" y="290">1 byte</text>
|
||||
<text class="grn" x="680" y="290">18 (0x12)</text>
|
||||
|
||||
<text class="cyn" x="50" y="320">0x20000003</text>
|
||||
<text class="txt" x="250" y="320">led1_state</text>
|
||||
<text class="dim" x="500" y="320">1 byte</text>
|
||||
<text class="txt" x="680" y="320">0 (false)</text>
|
||||
|
||||
<text class="cyn" x="50" y="350">0x20000004</text>
|
||||
<text class="txt" x="250" y="350">led2_state</text>
|
||||
<text class="dim" x="500" y="350">1 byte</text>
|
||||
<text class="txt" x="680" y="350">0 (false)</text>
|
||||
|
||||
<text class="cyn" x="50" y="380">0x20000005</text>
|
||||
<text class="txt" x="250" y="380">led3_state</text>
|
||||
<text class="dim" x="500" y="380">1 byte</text>
|
||||
<text class="txt" x="680" y="380">0 (false)</text>
|
||||
|
||||
<!-- Dot Operator -->
|
||||
<rect class="pnl" x="30" y="410" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="50" y="450">Dot Operator ( . )</text>
|
||||
<text class="dim" x="50" y="478">Use with struct variable</text>
|
||||
<rect x="50" y="492" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="70" y="520">leds.led1_pin = 16;</text>
|
||||
<text class="txt" x="70" y="548">leds.led1_state = true;</text>
|
||||
|
||||
<!-- Arrow Operator -->
|
||||
<rect class="pnl" x="615" y="410" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="635" y="450">Arrow Operator ( -> )</text>
|
||||
<text class="dim" x="635" y="478">Use with pointer to struct</text>
|
||||
<rect x="635" y="492" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="655" y="520">ptr->led1_pin = 16;</text>
|
||||
<text class="dim" x="655" y="548">// same as (*ptr).led1_pin</text>
|
||||
|
||||
<!-- Designated Initializer -->
|
||||
<rect class="pnl" x="30" y="600" width="1140" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="640">Designated Initializers</text>
|
||||
<rect x="50" y="655" width="740" height="85" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="683">simple_led_ctrl_t leds = {</text>
|
||||
<text class="grn" x="100" y="713">.led1_pin = 16, .led2_pin = 17, .led3_pin = 18</text>
|
||||
<text class="cyn" x="70" y="730">};</text>
|
||||
<text class="dim" x="820" y="690">Clear which value goes</text>
|
||||
<text class="dim" x="820" y="715">to which member</text>
|
||||
<text class="dim" x="820" y="740">Order doesn't matter</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,88 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">NEC IR Protocol</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Infrared Remote Control Communication</text>
|
||||
|
||||
<!-- How IR Works -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="140" rx="8"/>
|
||||
<text class="sub" x="50" y="150">How IR Works</text>
|
||||
<text class="txt" x="50" y="185">Remote sends invisible light pulses</text>
|
||||
<text class="txt" x="50" y="215">IR receiver on GPIO 5 reads signal</text>
|
||||
<text class="dim" x="600" y="185">IR LED flashes in specific patterns</text>
|
||||
<text class="dim" x="600" y="215">Each pattern = different button</text>
|
||||
|
||||
<!-- NEC Frame -->
|
||||
<rect class="pnl" x="30" y="270" width="1140" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="310">NEC Protocol Frame (32 bits)</text>
|
||||
|
||||
<rect x="50" y="330" width="180" height="50" rx="6" fill="#0a0a0f" stroke="#ffaa00"/>
|
||||
<text class="amb" x="80" y="362">Leader</text>
|
||||
<rect x="240" y="330" width="180" height="50" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="268" y="362">Address</text>
|
||||
<rect x="430" y="330" width="180" height="50" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="455" y="362">Addr Inv</text>
|
||||
<rect x="620" y="330" width="180" height="50" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="648" y="362">Command</text>
|
||||
<rect x="810" y="330" width="180" height="50" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="840" y="362">Cmd Inv</text>
|
||||
<rect x="1000" y="330" width="130" height="50" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="dim" x="1030" y="362">Stop</text>
|
||||
|
||||
<text class="dim" x="80" y="410">9ms+4.5ms</text>
|
||||
<text class="dim" x="280" y="410">8-bit</text>
|
||||
<text class="dim" x="460" y="410">8-bit check</text>
|
||||
<text class="dim" x="660" y="410">8-bit</text>
|
||||
<text class="dim" x="850" y="410">8-bit check</text>
|
||||
|
||||
<text class="dim" x="50" y="450">Leader says "attention!", address identifies device, command is the button pressed</text>
|
||||
|
||||
<!-- Command Code Table -->
|
||||
<rect class="pnl" x="30" y="490" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="530">NEC Command Codes</text>
|
||||
|
||||
<text class="amb" x="50" y="570">Button</text>
|
||||
<text class="amb" x="200" y="570">NEC Code</text>
|
||||
<text class="amb" x="380" y="570">LED</text>
|
||||
<line x1="50" y1="580" x2="565" y2="580" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="txt" x="50" y="610">1</text>
|
||||
<text class="grn" x="200" y="610">0x0C</text>
|
||||
<text class="red" x="380" y="610">Red (GP16)</text>
|
||||
|
||||
<text class="txt" x="50" y="640">2</text>
|
||||
<text class="grn" x="200" y="640">0x18</text>
|
||||
<text class="grn" x="380" y="640">Green (GP17)</text>
|
||||
|
||||
<text class="txt" x="50" y="670">3</text>
|
||||
<text class="grn" x="200" y="670">0x5E</text>
|
||||
<text class="amb" x="380" y="670">Yellow (GP18)</text>
|
||||
|
||||
<!-- Wiring -->
|
||||
<rect class="pnl" x="615" y="490" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="635" y="530">Hardware Wiring</text>
|
||||
<text class="cyn" x="635" y="565">GPIO 5</text>
|
||||
<text class="txt" x="800" y="565">IR Receiver (VS1838B)</text>
|
||||
<text class="cyn" x="635" y="595">GPIO 16</text>
|
||||
<text class="txt" x="800" y="595">Red LED + 220 ohm</text>
|
||||
<text class="cyn" x="635" y="625">GPIO 17</text>
|
||||
<text class="txt" x="800" y="625">Green LED + 220 ohm</text>
|
||||
<text class="cyn" x="635" y="655">GPIO 18</text>
|
||||
<text class="txt" x="800" y="655">Yellow LED + 220 ohm</text>
|
||||
|
||||
<!-- Bottom -->
|
||||
<rect class="pnl" x="30" y="710" width="1140" height="50" rx="8"/>
|
||||
<text class="dim" x="50" y="742">Projects: 0x0023_structures and 0x0026_functions</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,91 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Functions in C</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Reusable Blocks of Code</text>
|
||||
|
||||
<!-- Function Anatomy -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="195" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Anatomy of a Function</text>
|
||||
<rect x="50" y="168" width="1100" height="50" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="200">int ir_to_led_number(int ir_command) {</text>
|
||||
|
||||
<text class="amb" x="70" y="235">^^^</text>
|
||||
<text class="amb" x="128" y="235">^^^^^^^^^^^^^^^^</text>
|
||||
<text class="amb" x="372" y="235">^^^^^^^^^^^^^^</text>
|
||||
<text class="dim" x="70" y="258">ret</text>
|
||||
<text class="dim" x="128" y="258">function name</text>
|
||||
<text class="dim" x="372" y="258">parameter</text>
|
||||
|
||||
<rect x="50" y="270" width="1100" height="35" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="grn" x="70" y="295">if (ir_command == 0x0C) return 1;</text>
|
||||
<text class="dim" x="600" y="295">// body + return value</text>
|
||||
|
||||
<!-- Function Types Table -->
|
||||
<rect class="pnl" x="30" y="325" width="555" height="245" rx="8"/>
|
||||
<text class="sub" x="50" y="365">Function Types</text>
|
||||
|
||||
<text class="amb" x="50" y="400">Type</text>
|
||||
<text class="amb" x="330" y="400">Example</text>
|
||||
<line x1="50" y1="410" x2="565" y2="410" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="txt" x="50" y="440">No params, no ret</text>
|
||||
<text class="dim" x="330" y="440">leds_all_off()</text>
|
||||
|
||||
<text class="txt" x="50" y="470">Params, no return</text>
|
||||
<text class="dim" x="330" y="470">blink_led(..)</text>
|
||||
|
||||
<text class="txt" x="50" y="500">No params, return</text>
|
||||
<text class="dim" x="330" y="500">ir_getkey()</text>
|
||||
|
||||
<text class="txt" x="50" y="530">Params + return</text>
|
||||
<text class="dim" x="330" y="530">ir_to_led_num()</text>
|
||||
|
||||
<text class="txt" x="50" y="560">Struct pointer</text>
|
||||
<text class="dim" x="330" y="560">get_led_pin()</text>
|
||||
|
||||
<!-- Key Functions -->
|
||||
<rect class="pnl" x="615" y="325" width="555" height="245" rx="8"/>
|
||||
<text class="sub" x="635" y="365">Key Functions</text>
|
||||
|
||||
<text class="grn" x="635" y="400">ir_to_led_number(cmd)</text>
|
||||
<text class="dim" x="635" y="425">Maps NEC code to LED 1/2/3</text>
|
||||
|
||||
<text class="grn" x="635" y="460">get_led_pin(leds, num)</text>
|
||||
<text class="dim" x="635" y="485">Returns GPIO pin for LED</text>
|
||||
|
||||
<text class="grn" x="635" y="520">blink_led(pin, cnt, ms)</text>
|
||||
<text class="dim" x="635" y="545">Blinks LED cnt times</text>
|
||||
|
||||
<!-- Call Chain - Vertical Flow -->
|
||||
<rect class="pnl" x="30" y="590" width="1140" height="170" rx="8"/>
|
||||
<text class="sub" x="50" y="630">Function Call Chain</text>
|
||||
|
||||
<text class="cyn" x="50" y="665">main()</text>
|
||||
<text class="dim" x="200" y="665">--></text>
|
||||
<text class="amb" x="250" y="665">process_ir_led_command()</text>
|
||||
|
||||
<text class="txt" x="100" y="695">1. leds_all_off()</text>
|
||||
<text class="dim" x="400" y="695">Turn all LEDs off</text>
|
||||
|
||||
<text class="txt" x="100" y="725">2. ir_to_led_number()</text>
|
||||
<text class="dim" x="400" y="725">Map NEC to LED</text>
|
||||
|
||||
<text class="txt" x="700" y="695">3. get_led_pin()</text>
|
||||
<text class="dim" x="950" y="695">Get GPIO pin</text>
|
||||
|
||||
<text class="txt" x="700" y="725">4. blink_led()</text>
|
||||
<text class="dim" x="950" y="725">Blink + stay on</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,66 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Struct Pointers in Functions</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Passing Data Efficiently</text>
|
||||
|
||||
<!-- Why Pointers -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Why Pass by Pointer?</text>
|
||||
<text class="grn" x="50" y="185">Efficient</text>
|
||||
<text class="dim" x="250" y="185">4 bytes (address) not 6</text>
|
||||
<text class="grn" x="50" y="215">Modifiable</text>
|
||||
<text class="dim" x="250" y="215">Function can change original</text>
|
||||
<text class="grn" x="50" y="245">Standard</text>
|
||||
<text class="dim" x="250" y="245">Embedded systems practice</text>
|
||||
|
||||
<!-- Arrow Operator -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="160" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Arrow Operator</text>
|
||||
<text class="txt" x="635" y="185">leds->led1_pin</text>
|
||||
<text class="dim" x="635" y="215">Same as (*leds).led1_pin</text>
|
||||
<text class="dim" x="635" y="245">Use -> when leds is a pointer</text>
|
||||
|
||||
<!-- leds_all_off -->
|
||||
<rect class="pnl" x="30" y="290" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="330">leds_all_off()</text>
|
||||
<rect x="50" y="348" width="515" height="125" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="378">void leds_all_off(</text>
|
||||
<text class="cyn" x="100" y="408">simple_led_ctrl_t *leds) {</text>
|
||||
<text class="txt" x="100" y="438">gpio_put(leds->led1_pin, 0);</text>
|
||||
<text class="txt" x="100" y="463">gpio_put(leds->led2_pin, 0);</text>
|
||||
|
||||
<!-- blink_led -->
|
||||
<rect class="pnl" x="615" y="290" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="635" y="330">blink_led()</text>
|
||||
<rect x="635" y="348" width="515" height="125" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="655" y="378">void blink_led(uint8_t pin,</text>
|
||||
<text class="cyn" x="685" y="408">uint8_t count, uint32_t ms){</text>
|
||||
<text class="txt" x="685" y="438">gpio_put(pin, true);</text>
|
||||
<text class="txt" x="685" y="463">sleep_ms(ms);</text>
|
||||
|
||||
<!-- process_ir_led_command -->
|
||||
<rect class="pnl" x="30" y="510" width="1140" height="250" rx="8"/>
|
||||
<text class="sub" x="50" y="550">process_ir_led_command() -- Main Command Processor</text>
|
||||
<rect x="50" y="568" width="1100" height="170" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="598">int process_ir_led_command(int cmd,</text>
|
||||
<text class="cyn" x="100" y="628">simple_led_ctrl_t *leds, uint8_t blink_count) {</text>
|
||||
<text class="txt" x="100" y="660">leds_all_off(leds);</text>
|
||||
<text class="dim" x="600" y="660">// turn all off first</text>
|
||||
<text class="txt" x="100" y="690">int num = ir_to_led_number(cmd);</text>
|
||||
<text class="dim" x="600" y="690">// map NEC to LED</text>
|
||||
<text class="txt" x="100" y="720">blink_led(get_led_pin(leds, num),</text>
|
||||
<text class="dim" x="600" y="720">// blink then stay on</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,57 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Structures Source Code</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">0x0023_structures.c</text>
|
||||
|
||||
<!-- Source Code -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="520" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Full Source</text>
|
||||
<rect x="50" y="168" width="1100" height="445" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
|
||||
<text class="dim" x="70" y="198">#include <stdio.h></text>
|
||||
<text class="dim" x="70" y="225">#include "pico/stdlib.h"</text>
|
||||
<text class="dim" x="70" y="252">#include "ir.h"</text>
|
||||
|
||||
<text class="cyn" x="70" y="285">typedef struct {</text>
|
||||
<text class="txt" x="100" y="312">uint8_t led1_pin, led2_pin, led3_pin;</text>
|
||||
<text class="txt" x="100" y="339">bool led1_state, led2_state, led3_state;</text>
|
||||
<text class="cyn" x="70" y="366">} simple_led_ctrl_t;</text>
|
||||
|
||||
<text class="cyn" x="70" y="400">int main(void) {</text>
|
||||
<text class="txt" x="100" y="427">stdio_init_all();</text>
|
||||
<text class="amb" x="100" y="454">simple_led_ctrl_t leds = {</text>
|
||||
<text class="grn" x="130" y="481">.led1_pin=16, .led2_pin=17, .led3_pin=18</text>
|
||||
<text class="amb" x="100" y="508">};</text>
|
||||
|
||||
<text class="txt" x="100" y="540">gpio_init(leds.led1_pin);</text>
|
||||
<text class="dim" x="500" y="540">// init 16, 17, 18</text>
|
||||
<text class="txt" x="100" y="567">ir_init(5);</text>
|
||||
<text class="dim" x="500" y="567">// IR on GPIO 5</text>
|
||||
<text class="txt" x="100" y="594">while (true) {</text>
|
||||
<text class="dim" x="500" y="594">// main loop</text>
|
||||
|
||||
<!-- Program Flow -->
|
||||
<rect class="pnl" x="30" y="650" width="1140" height="110" rx="8"/>
|
||||
<text class="sub" x="50" y="685">Main Loop Flow</text>
|
||||
<text class="txt" x="50" y="715">ir_getkey()</text>
|
||||
<text class="dim" x="230" y="715">--></text>
|
||||
<text class="txt" x="270" y="715">check NEC code</text>
|
||||
<text class="dim" x="490" y="715">--></text>
|
||||
<text class="txt" x="530" y="715">set state</text>
|
||||
<text class="dim" x="680" y="715">--></text>
|
||||
<text class="txt" x="720" y="715">gpio_put()</text>
|
||||
<text class="dim" x="50" y="740">0x0C=LED1(red) 0x18=LED2(green) 0x5E=LED3(yellow)</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,73 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Struct Flattening</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">How Compilers Transform Structs</text>
|
||||
|
||||
<!-- C Level -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="220" rx="8"/>
|
||||
<text class="sub" x="50" y="150">C Code (High Level)</text>
|
||||
<rect x="50" y="168" width="515" height="140" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="198">gpio_init(leds.led1_pin);</text>
|
||||
<text class="dim" x="70" y="225">// leds.led1_pin = 16</text>
|
||||
<text class="cyn" x="70" y="258">gpio_init(leds.led2_pin);</text>
|
||||
<text class="dim" x="70" y="285">// leds.led2_pin = 17</text>
|
||||
|
||||
<!-- Assembly Level -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="220" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Assembly (Flattened)</text>
|
||||
<rect x="635" y="168" width="515" height="140" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="grn" x="655" y="198">movs r0, #0x10</text>
|
||||
<text class="dim" x="900" y="198">// 16</text>
|
||||
<text class="txt" x="655" y="225">bl gpio_init</text>
|
||||
<text class="grn" x="655" y="258">movs r0, #0x11</text>
|
||||
<text class="dim" x="900" y="258">// 17</text>
|
||||
<text class="txt" x="655" y="285">bl gpio_init</text>
|
||||
|
||||
<!-- The Key Insight -->
|
||||
<rect class="pnl" x="30" y="350" width="1140" height="130" rx="8"/>
|
||||
<text class="sub" x="50" y="390">The Key Insight</text>
|
||||
<text class="red" x="50" y="425">Struct abstraction DISAPPEARS</text>
|
||||
<text class="txt" x="520" y="425">at assembly level</text>
|
||||
<text class="dim" x="50" y="455">You see individual values (16, 17, 18) not struct names</text>
|
||||
|
||||
<!-- Struct Member Mapping -->
|
||||
<rect class="pnl" x="30" y="500" width="1140" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="540">Struct Member Mapping</text>
|
||||
|
||||
<text class="amb" x="50" y="575">Assembly</text>
|
||||
<text class="amb" x="280" y="575">Struct Member</text>
|
||||
<text class="amb" x="560" y="575">Physical</text>
|
||||
<text class="amb" x="800" y="575">NEC Code</text>
|
||||
<line x1="50" y1="585" x2="1140" y2="585" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="grn" x="50" y="615">0x10 (16)</text>
|
||||
<text class="txt" x="280" y="615">led1_pin</text>
|
||||
<text class="red" x="560" y="615">Red LED</text>
|
||||
<text class="cyn" x="800" y="615">0x0C</text>
|
||||
|
||||
<text class="grn" x="50" y="645">0x11 (17)</text>
|
||||
<text class="txt" x="280" y="645">led2_pin</text>
|
||||
<text class="grn" x="560" y="645">Green LED</text>
|
||||
<text class="cyn" x="800" y="645">0x18</text>
|
||||
|
||||
<text class="grn" x="50" y="675">0x12 (18)</text>
|
||||
<text class="txt" x="280" y="675">led3_pin</text>
|
||||
<text class="amb" x="560" y="675">Yellow LED</text>
|
||||
<text class="cyn" x="800" y="675">0x5E</text>
|
||||
|
||||
<text class="dim" x="50" y="710">Sequential values (16,17,18) reveal the struct pattern</text>
|
||||
<text class="dim" x="50" y="735">Recognize patterns to reconstruct original structs in Ghidra</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,77 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Hacking Structures</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Swapping GPIO Pin Assignments</text>
|
||||
|
||||
<!-- The Hack -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Swap LED 1 and LED 2</text>
|
||||
<text class="txt" x="50" y="185">Find gpio_init values:</text>
|
||||
<text class="red" x="50" y="220">0x10 (16)</text>
|
||||
<text class="amb" x="230" y="220">--></text>
|
||||
<text class="grn" x="290" y="220">0x11 (17)</text>
|
||||
<text class="red" x="50" y="255">0x11 (17)</text>
|
||||
<text class="amb" x="230" y="255">--></text>
|
||||
<text class="grn" x="290" y="255">0x10 (16)</text>
|
||||
<text class="dim" x="50" y="290">Swap the two byte values</text>
|
||||
|
||||
<!-- Result -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Result After Hack</text>
|
||||
|
||||
<text class="amb" x="635" y="185">Before:</text>
|
||||
<text class="txt" x="635" y="215">Btn 1 --> GPIO 16 --> Red</text>
|
||||
<text class="txt" x="635" y="245">Btn 2 --> GPIO 17 --> Green</text>
|
||||
|
||||
<text class="amb" x="635" y="275">After:</text>
|
||||
<text class="grn" x="790" y="275">SWAPPED!</text>
|
||||
|
||||
<!-- Before/After Detail -->
|
||||
<rect class="pnl" x="30" y="330" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="370">Before (Normal)</text>
|
||||
<text class="txt" x="50" y="405">Btn 1 (0x0C) --> GPIO 16</text>
|
||||
<text class="red" x="450" y="405">Red</text>
|
||||
<text class="txt" x="50" y="435">Btn 2 (0x18) --> GPIO 17</text>
|
||||
<text class="grn" x="450" y="435">Green</text>
|
||||
<text class="dim" x="50" y="465">Log and LED match correctly</text>
|
||||
|
||||
<rect class="pnl" x="615" y="330" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="370">After (Hacked)</text>
|
||||
<text class="txt" x="635" y="405">Btn 1 (0x0C) --> GPIO 17</text>
|
||||
<text class="grn" x="1035" y="405">Green!</text>
|
||||
<text class="txt" x="635" y="435">Btn 2 (0x18) --> GPIO 16</text>
|
||||
<text class="red" x="1035" y="435">Red!</text>
|
||||
<text class="dim" x="635" y="465">Log says RED but GREEN lights</text>
|
||||
|
||||
<!-- Log Desynchronization -->
|
||||
<rect class="pnl" x="30" y="500" width="1140" height="180" rx="8"/>
|
||||
<text class="sub" x="50" y="540">Log Desynchronization</text>
|
||||
|
||||
<text class="amb" x="50" y="575">Terminal Log:</text>
|
||||
<text class="txt" x="300" y="575">NEC command: 0x0C</text>
|
||||
<text class="dim" x="600" y="575">(expects Red)</text>
|
||||
|
||||
<text class="amb" x="50" y="610">Physical LED:</text>
|
||||
<text class="grn" x="300" y="610">GREEN LED on</text>
|
||||
<text class="red" x="600" y="610">MISMATCH!</text>
|
||||
|
||||
<text class="dim" x="50" y="645">Operator sees correct logs but WRONG behavior</text>
|
||||
|
||||
<!-- Stuxnet Reference -->
|
||||
<rect class="pnl" x="30" y="700" width="1140" height="60" rx="8"/>
|
||||
<text class="sub" x="50" y="735">Stuxnet:</text>
|
||||
<text class="dim" x="250" y="735">False "normal" data to operators, equipment destroyed</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,73 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">.ELF vs .BIN Analysis</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Ghidra Analysis of 0x0026_functions</text>
|
||||
|
||||
<!-- Comparison Table -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="220" rx="8"/>
|
||||
<text class="sub" x="50" y="150">.ELF vs .BIN Comparison</text>
|
||||
|
||||
<text class="amb" x="50" y="190">Feature</text>
|
||||
<text class="amb" x="350" y="190">.BIN File</text>
|
||||
<text class="amb" x="700" y="190">.ELF File</text>
|
||||
<line x1="50" y1="200" x2="1140" y2="200" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="txt" x="50" y="230">Symbols</text>
|
||||
<text class="red" x="350" y="230">None</text>
|
||||
<text class="grn" x="700" y="230">Function names</text>
|
||||
|
||||
<text class="txt" x="50" y="260">Sections</text>
|
||||
<text class="red" x="350" y="260">Raw bytes only</text>
|
||||
<text class="grn" x="700" y="260">.text .data .rodata</text>
|
||||
|
||||
<text class="txt" x="50" y="290">Debug info</text>
|
||||
<text class="red" x="350" y="290">None</text>
|
||||
<text class="grn" x="700" y="290">May include debug</text>
|
||||
|
||||
<text class="txt" x="50" y="320">Use case</text>
|
||||
<text class="txt" x="350" y="320">Flash to device</text>
|
||||
<text class="txt" x="700" y="320">Analysis + debug</text>
|
||||
|
||||
<!-- Ghidra Import -->
|
||||
<rect class="pnl" x="30" y="350" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="390">Importing .BIN</text>
|
||||
<text class="txt" x="50" y="425">Manual setup required:</text>
|
||||
<text class="dim" x="50" y="450">ARM Cortex 32 little endian</text>
|
||||
<text class="dim" x="50" y="480">Block: .text</text>
|
||||
<text class="dim" x="50" y="505">Base: 10000000</text>
|
||||
<text class="dim" x="50" y="530">No function names</text>
|
||||
|
||||
<rect class="pnl" x="615" y="350" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="635" y="390">Importing .ELF</text>
|
||||
<text class="txt" x="635" y="425">Auto-detected by Ghidra:</text>
|
||||
<text class="grn" x="635" y="450">ARM format recognized</text>
|
||||
<text class="grn" x="635" y="480">Sections auto-loaded</text>
|
||||
<text class="grn" x="635" y="505">Symbol tree populated</text>
|
||||
<text class="grn" x="635" y="530">Named functions visible</text>
|
||||
|
||||
<!-- Important Note -->
|
||||
<rect class="pnl" x="30" y="570" width="1140" height="100" rx="8"/>
|
||||
<text class="sub" x="50" y="610">Important Rule</text>
|
||||
<text class="red" x="50" y="645">Analyze the .ELF</text>
|
||||
<text class="dim" x="350" y="645">for symbol information</text>
|
||||
<text class="grn" x="650" y="645">Patch the .BIN</text>
|
||||
<text class="dim" x="900" y="645">for flashing</text>
|
||||
|
||||
<!-- Workflow -->
|
||||
<rect class="pnl" x="30" y="690" width="1140" height="70" rx="8"/>
|
||||
<text class="sub" x="50" y="722">Export Workflow</text>
|
||||
<text class="dim" x="50" y="742">Patch .bin in Ghidra --> uf2conv.py --> flash to Pico 2</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,85 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
||||
<style>
|
||||
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
||||
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
||||
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
||||
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
||||
.dim{font:20px 'Courier New',monospace;fill:#888}
|
||||
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
||||
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
||||
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
||||
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
||||
.badge{stroke:#00ff41;rx:14}
|
||||
</style>
|
||||
<rect class="bg" width="1200" height="800"/>
|
||||
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
|
||||
<text class="title" x="600" y="52" text-anchor="middle">Structs & IR Protocol</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Structs, Functions, IR, and Hacking</text>
|
||||
|
||||
<!-- Structs -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="180" rx="8"/>
|
||||
<text class="sub" x="50" y="150">C Structures</text>
|
||||
<text class="txt" x="50" y="185">Group related data together</text>
|
||||
<text class="dim" x="50" y="210">Dot (.) for variables</text>
|
||||
<text class="dim" x="50" y="235">Arrow (->) for pointers</text>
|
||||
<text class="dim" x="50" y="260">Designated init: .pin = 16</text>
|
||||
|
||||
<!-- NEC Protocol -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="180" rx="8"/>
|
||||
<text class="sub" x="635" y="150">NEC IR Protocol</text>
|
||||
<text class="txt" x="635" y="185">32-bit frame: addr + cmd</text>
|
||||
<text class="cyn" x="635" y="215">0x0C</text>
|
||||
<text class="dim" x="750" y="215">Button 1</text>
|
||||
<text class="cyn" x="635" y="245">0x18</text>
|
||||
<text class="dim" x="750" y="245">Button 2</text>
|
||||
<text class="cyn" x="635" y="275">0x5E</text>
|
||||
<text class="dim" x="750" y="275">Button 3</text>
|
||||
|
||||
<!-- Functions -->
|
||||
<rect class="pnl" x="30" y="310" width="555" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="350">Functions</text>
|
||||
<text class="txt" x="50" y="385">Reusable blocks, one job each</text>
|
||||
<text class="dim" x="50" y="410">ir_to_led_number()</text>
|
||||
<text class="dim" x="50" y="435">get_led_pin() / blink_led()</text>
|
||||
<text class="dim" x="50" y="460">process_ir_led_command()</text>
|
||||
|
||||
<!-- Struct Flattening -->
|
||||
<rect class="pnl" x="615" y="310" width="555" height="160" rx="8"/>
|
||||
<text class="sub" x="635" y="350">Assembly Flattening</text>
|
||||
<text class="txt" x="635" y="385">Structs vanish in assembly</text>
|
||||
<text class="dim" x="635" y="410">Only see values: 0x10 0x11 0x12</text>
|
||||
<text class="dim" x="635" y="435">Pattern recognition is key</text>
|
||||
<text class="dim" x="635" y="460">.ELF has symbols, .BIN doesn't</text>
|
||||
|
||||
<!-- Key Addresses -->
|
||||
<rect class="pnl" x="30" y="490" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="530">Key Values</text>
|
||||
<text class="cyn" x="50" y="565">0x10000234</text>
|
||||
<text class="dim" x="250" y="565">main()</text>
|
||||
<text class="cyn" x="50" y="595">GPIO 5</text>
|
||||
<text class="dim" x="250" y="595">IR receiver</text>
|
||||
<text class="cyn" x="50" y="625">GPIO 16/17/18</text>
|
||||
<text class="dim" x="250" y="625">Red/Green/Yellow</text>
|
||||
|
||||
<!-- Hacking -->
|
||||
<rect class="pnl" x="615" y="490" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="530">Hacking Techniques</text>
|
||||
<text class="amb" x="635" y="565">GPIO swap</text>
|
||||
<text class="dim" x="850" y="565">0x10 <--> 0x11</text>
|
||||
<text class="amb" x="635" y="595">Log desync</text>
|
||||
<text class="dim" x="850" y="595">Logs lie!</text>
|
||||
<text class="amb" x="635" y="625">Stuxnet</text>
|
||||
<text class="dim" x="850" y="625">Same concept</text>
|
||||
|
||||
<!-- Projects -->
|
||||
<rect class="pnl" x="30" y="660" width="555" height="100" rx="8"/>
|
||||
<text class="sub" x="50" y="695">Projects</text>
|
||||
<text class="dim" x="50" y="722">0x0023_structures</text>
|
||||
<text class="dim" x="50" y="744">0x0026_functions</text>
|
||||
|
||||
<!-- Takeaway -->
|
||||
<rect class="pnl" x="615" y="660" width="555" height="100" rx="8"/>
|
||||
<text class="sub" x="635" y="695">Key Takeaway</text>
|
||||
<text class="dim" x="635" y="722">Patch bytes, mislead logs</text>
|
||||
<text class="dim" x="635" y="744">hardware does what YOU say</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |