xref: /aosp_15_r20/external/pigweed/docs/blog/01-kudzu.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1.. _docs-blog-01-kudzu:
2
3==========================
4Pigweed Eng Blog #1: Kudzu
5==========================
6.. raw:: html
7
8   <script type="application/ld+json">
9     {
10       "@context": "https://schema.org",
11       "@type": "NewsArticle",
12       "headline": "Kudzu: Pigweed's whimsical take on a development board",
13       "image": [
14         "https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-diagonal.jpg"
15       ],
16       "datePublished": "2023-10-12T19:27:00+08:00",
17       "dateModified": "2023-10-12T19:27:00+08:00",
18       "author": [{
19         "@type": "Person",
20         "name": "Erik Gilling",
21         "url": "https://github.com/konkers"
22       }]
23     }
24   </script>
25
26.. admonition:: A note from the Pigweed Eng Blog editors
27
28   Welcome to the Pigweed Eng Blog! This is an informal blog where Pigweed
29   teammates, contributors, and users can share ideas and projects related to
30   Pigweed.
31
32   Our first post comes from Erik Gilling, a software engineer on the
33   Pigweed team. Today, Erik is going to tell you about Kudzu,
34   "Pigweed's whimsical take on a development board"…
35
36   Please note that **while Kudzu is open source, its hardware isn't publicly
37   available**. Pigweed users may find the `Kudzu source
38   code <https://pigweed.googlesource.com/pigweed/kudzu/+/refs/heads/main>`_
39   to be a helpful example of a complex Pigweed integration.
40
41.. card::
42    :img-background: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-diagonal.jpg
43    :link: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-diagonal.jpg
44    :img-alt: A single Kudzu badge face-up on a table viewed at a diagonal.
45
46----------------------------
47It all started so innocently
48----------------------------
49The Pigweed team is taking a field trip to the
50`Bay Area Maker Faire <https://makerfaire.com/bay-area/>`_ because
51unsurprisingly, that's the kind of good time we're up for! While discussing
52the plans at a team meeting I suggested: "We should make PCB badges that run
53Pigweed and wear that to the Faire!" I've always wanted to make a PCB badge
54and this seemed like the perfect opportunity to make a simple PCB that we could
55do a little bit of hacking on.
56
57--------
58"Simple"
59--------
60The idea resonated with the team… perhaps too well. What started as
61something simple in my head quickly started creeping features. Hence
62the name `Kudzu <https://en.wikipedia.org/wiki/Kudzu>`_: a vine
63considered invasive in many parts of the world. Pigweed's a weed.
64Our RFCs are called "seeds". We're all about the plant puns…
65
66Anyways, the conversation went something like this:
67
68  "We should have some sort of sensor so it does something…"
69
70  "How should we power it? Let's do LiPo charging…"
71
72  "Let's add a display to highlight our recent
73  :ref:`Display Support SEED <seed-0104>`!"
74
75  "Touch screen?"
76
77  "D-Pad and buttons?"
78
79  "Speaker?"
80
81  "Wireless?"
82
83  "No!… but also yes…"
84
85We quickly realized that what we wanted was more than a badge. We wanted a
86showcase for Pigweed. We wanted a project we can point people at to show them
87Pigweed running at it's best. And thus Kudzu was born. Part badge, part
88development board, part handheld gaming system, and all Pigweed.
89
90----------------
91The laundry list
92----------------
93We settled on the following laundry list of features and components:
94
95`RP2040 Microcontroller <https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html>`_
96  There's a lot to love about the RP2040: a reasonable amount of SRAM,
97  support for large/cheap/execute-in-place external flash, a wicked cool
98  programmable I/O block, and most importantly: easy and cheap to source!
99
100`16 MB of Flash <https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf>`_
101  We're adding the maximum amount of flash that the RP2040 can support. This
102  way we can pack as much awesome into the firmware as possible. Realistically
103  16 MB is an embarrassingly large amount of space for an embedded project and I
104  can't wait to see what cool stuff we fill it with!
105
106USB-C Connector
107  While we're not adding USB Power Delivery to the board, the USB C connector
108  is robust and common. Many of us on the team are tired of digging micro
109  (or even mini) USB cables out of our desk drawers to hook up brand new dev
110  boards or JTAG programmers!
111
112LiPo Battery with `charger <https://www.microchip.com/en-us/product/mcp73831>`_ and `fuel gauge <https://www.analog.com/en/products/max17048.html>`_
113  Once we decided on a portable gaming form factor, we wanted to have a
114  built-in, rechargeable battery. The battery is 900mA and is set to charge at 500mA
115  from USB when the system is off and 250mA when the system is running. As an
116  added bonus we threw in a fuel gauge chip. Partly because it's really nice to
117  have an accurate view of the battery charge state and partly because it's
118  a neat chip to write software for.
119
120`3.2" IPS display with capacitive touch <https://www.buydisplay.com/3-2-inch-240x320-ips-tft-lcd-display-optl-capacitive-touchscreen-st7789>`_
121  This display is 240x320 which presents two challenges. First, it's naturally
122  portrait instead of landscape. We solve this by rotating the buffers once
123  they're rendered. The second is that a single 16-bit x 320 x 240 frame buffer
124  is ~150K which is over half of the 264K of SRAM in the RP2040. Instead, we're
125  rendering at 160x120 and using the PIO module to `pixel double
126  <https://github.com/32blit/32blit-sdk>`_ the buffer as we're sending it to the
127  display. As an added bonus, the chunkier pixels gives Kudzu a nice retro feel.
128
129Directional Pad and Buttons
130  Here we're leaning on off-the-shelf buttons and silicone pads. Game
131  controller design is a whole rabbit hole and we're going to rely on the
132  collective wisdom of the retro modding community to give us nice-feeling
133  controls.
134
135`Six Axis IMU <https://invensense.tdk.com/products/motion-tracking/6-axis/icm-42670-p/>`_
136  An IMU is a great general purpose peripheral to demonstrate Pigweed's HAL
137  layer. Plus, there's all sorts of cool demos you can write with an IMU and
138  a display.
139
140`I2S Audio DAC/Amplifier <https://www.analog.com/media/en/technical-documentation/data-sheets/max98357a-max98357b.pdf>`_ and Speaker
141  Chip tunes are best tunes. A couple of us on the team would love to
142  port/write a tracker or FM synthesis engine.
143
144Gameboy Advance Link Port
145  As a simple way of hooking two devices together, we added link port. Again
146  we're using an existing link port and cable to avoid reinventing to wheel.
147  Plus, there's something awful nostalgic about that port!
148
149... and `One More Thing <https://www.espressif.com/en/products/socs/esp32-c3>`_
150  I kinda snuck an ESP32-C3 module onto the board at the last minute. Having
151  wireless is something we wanted but didn't want to burden the initial design
152  and bring up with it. My thinking is that we'll leave the module un-populated
153  for now. My hope is that adding it to the board now may keep these boards from
154  becoming landfill when we decide to tackle wireless.
155
156--------------------------
157Design, build, and rollout
158--------------------------
159I used `KiCad <https://www.kicad.org/>`_ to design the board. It's an open
160source PCB design package that has been making incredible strides in
161functionality and usability in the past few years. It comes with a high-quality
162library of symbols and footprint which is supplemented by community-maintained
163open source libraries.
164
165.. card::
166   :img-top: https://storage.googleapis.com/pigweed-media/kudzu-schematic.png
167   :link: https://storage.googleapis.com/pigweed-media/kudzu-schematic.png
168   :img-alt: A screenshot of Kudzu's schematic.
169   :text-align: center
170
171   Kudzu schematic
172
173After some careful design review from the team and a few friends of Pigweed we
174sent off the board to get fabbed and "patiently" waited for it to be delivered.
175
176An EE at a previous company I worked at had a saying: "If you haven't found
177three problems with your board, you're not done looking". The three problems
178we found in order from least to most crushing are:
179
180.. card::
181   :img-top: https://storage.googleapis.com/pigweed-media/kudzu-display-connector.jpeg
182   :link: https://storage.googleapis.com/pigweed-media/kudzu-display-connector.jpeg
183   :img-alt: The reworked display connector with many bodge wires.
184   :text-align: center
185
186   The reworked display connector and the unpopulated footprint for the "one more thing"
187   that "we'll get to eventually"
188
189#. **The BOOT and RESET labels were reversed.** This led to some initial
190   confusion on why the boards would not come up in bootloader mode.
191
192#. **One of the FETs (Q3) had the wrong pinout.** This caused the power
193   switch to be stuck on and the charge rate switching to not work.
194
195#. **The pins on the display FPC connector were swapped.** This one was really
196   crushing. The connector was fairly fine-pitched and 40 pins!
197
198We were able to bring up the whole board including the display by rotating the
199connector. Sadly the display would not fit in the 3D printed parts
200we'd designed when plugged into the rotated connection. To validate our 3D
201printed parts, I painstakingly reworked on-board to get the connector oriented
202correctly. However, that was too much work and too fragile for all the boards.
203We had to do a re-spin and Maker Faire was approaching quickly! Time to lather,
204rinse, and repeat.
205
206Fast forward to Monday night before Maker Faire. The boards come in and I spent
207the evening preparing for a build party. On Tuesday, with some
208`robotic help <https://www.opulo.io/>`_, we managed to build and test 8 boards
209and get them in team members' hands on Wednesday.
210
211.. card::
212   :img-top: https://storage.googleapis.com/pigweed-media/kudzu-pnp.jpg
213   :link: https://storage.googleapis.com/pigweed-media/kudzu-pnp.jpg
214   :img-alt: A photo of the Opulo LumenPnP
215   :text-align: center
216
217   Our robotic help (Opulo LumenPnP)
218
219Thankfully, because Pigweed is modular and portable, we were able to get our
220software working on it quickly, freeing us to spend the next couple days hacking
221together some simple fun demos for Maker Faire!
222
223------
224Photos
225------
226.. grid:: 1 1 2 2
227
228   .. grid-item-card::
229      :img-background: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-diagonal.jpg
230      :link: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-diagonal.jpg
231      :img-alt: A single Kudzu badge face-up on a table viewed at a diagonal.
232
233   .. grid-item-card::
234      :img-background: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-back.jpg
235      :link: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-back.jpg
236      :img-alt: A single Kudzu badge face-down on a table viewed at a diagonal.
237
238.. grid:: 1 1 2 2
239
240   .. grid-item-card::
241      :img-background: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-top-down.jpg
242      :link: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-top-down.jpg
243      :img-alt: A single Kudzu badge face-up on a table viewed from above.
244
245   .. grid-item-card::
246      :img-background: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-front-standing.jpg
247      :link: https://storage.googleapis.com/pigweed-media/kudzu-finished-photo-front-standing.jpg
248      :img-alt: A single Kudzu badge standing up on a table viewed from the front.
249
250.. card::
251   :img-top: https://storage.googleapis.com/pigweed-media/kudzu-badges.jpg
252   :link: https://storage.googleapis.com/pigweed-media/kudzu-badges.jpg
253   :img-alt: A photo of 6 of the Kudzu badges
254   :text-align: center
255
256   Six Kudzu badges for Maker Faire 2023
257
258----------
259Learn more
260----------
261We don't have any plans to distribute hardware outside of our team but are
262excited to publish the living project to serve as an example of how to build
263firmware integrated with Pigweed. Over the coming months we'll be publishing
264more functionality to the repository.
265
266Head over to the `Kudzu repo <https://pigweed.googlesource.com/pigweed/kudzu>`_
267where you'll find:
268
269* KiCad PCB Design
270* Example firmware demonstrating:
271   * :ref:`module-pw_system` integration
272   * :ref:`module-pw_rpc` and :ref:`module-pw_log` support
273   * Use of Pigweed's :ref:`module-pw_digital_io`, :ref:`module-pw_i2c`,
274     and :ref:`module-pw_spi` hardware abstraction layers
275
276.. pigweed-live::
277