blob: 945efbde4c9d82abe768f6be2d311f8252bb53cf [file] [log] [blame] [view]
Anthony DiGirolamob302d742023-09-12 16:48:53 +00001# Kudzu
2
3[TOC]
4
Carlos Chinchillab62f14c2023-10-12 20:24:56 +00005## Getting Started
6
7Make sure you've set up [Pigweed's
8prerequisites](https://pigweed.dev/docs/getting_started.html#prerequisites).
9
10**If you're on Windows**, you can automate the initial setup by downloading the
11first-time setup script **from cmd.exe**:
12
13```bat
14curl https://pigweed.googlesource.com/pigweed/sample_project/+/main/tools/setup_windows_prerequisites.bat?format=TEXT > setup_pigweed_prerequisites.b64 && certutil -decode -f setup_pigweed_prerequisites.b64 setup_pigweed_prerequisites.bat && del setup_pigweed_prerequisites.b64
15```
16
17Then you can run the script with the following command **in cmd.exe**:
18
19```bat
20setup_pigweed_prerequisites.bat
21```
22
23Note: You may see a few UAC prompts as the script installs Git, Python, and
24enables developer mode.
25
26Once that is done, you can clone this project with the following command:
27```sh
28git clone https://pigweed.googlesource.com/pigweed/kudzu
29```
30
31### Environment setup
32
33Pigweed uses a local development environment for most of its tools. This
34means tools are not installed to your machine, and are instead stored in a
35directory inside your project (Note: git ignores this directory). The tools
36are temporarily added to the PATH of the current shell session.
37
38To make sure the latest tooling has been fetched and set up, run the bootstrap
39command for your operating system:
40
41**Windows**
42
43```bat
44bootstrap.bat
45```
46
47**Linux & Mac**
48
49```sh
50source ./bootstrap.sh
51```
52
53After tooling updates, you might need to run bootstrap again to ensure the
54latest tools.
55
56After the initial bootstrap, you can use use the `activate` scripts to configure
57the current shell for development without doing a full update.
58
59**Windows**
60
61```sh
62activate.bat
63```
64
65**Linux & Mac**
66
67```sh
68source ./activate.sh
69```
70
71### Device tools setup
72
73Install the pico SDK and tool to flash the device.
74
75```sh
76pw package install pico_sdk
77pw package install picotool
78```
79These packages will be built and added to the path automatically. There is no
80need to add these to the gn arguments.
81
82## Linux Setup
83
84### GLFW Dependency:
85
86Install the GLFW OpenGL library
87```sh
88sudo apt install libglfw3-dev libglfw3
89```
90
91### Udev Rules:
92
93Put the following into `/usr/lib/udev/rules.d/49-picoprobe.rules`
94
95```
96# Pico app mode
97SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE:="0666"
98KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE:="0666", SYMLINK+="rp2040"
99
100# RP2 Boot
101SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE:="0666"
102KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE:="0666", SYMLINK+="rp2040"
103
104# Picoprobe
105SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666"
106KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666", SYMLINK+="picoprobe"
107```
108
109This will also symlink `/dev/picoprobe` and `/dev/rp2040` to the respective
110vendor and product ids.
111
112Apply the above rules with:
113
114```sh
115sudo udevadm control --reload-rules
116sudo udevadm trigger
117```
118
AnthonyDiGirolamo8df95472023-09-28 18:30:14 +0000119## Compile:
Anthony DiGirolamob302d742023-09-12 16:48:53 +0000120
121```sh
122pw build
123```
124
AnthonyDiGirolamo8df95472023-09-28 18:30:14 +0000125## Run:
126
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000127### Host
AnthonyDiGirolamo8df95472023-09-28 18:30:14 +0000128
Anthony DiGirolamo87ec62e2024-03-07 17:54:45 +0000129Run the host app and connect to it via `pw console`:
Anthony DiGirolamob302d742023-09-12 16:48:53 +0000130
131```sh
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000132./out/gn/host_device_simulator.speed_optimized/obj/applications/badge/bin/badge & \
Anthony DiGirolamo87ec62e2024-03-07 17:54:45 +0000133 pw console --socket-addr default ; \
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000134 killall badge
Anthony DiGirolamob302d742023-09-12 16:48:53 +0000135```
136
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000137### Kudzu
138
AnthonyDiGirolamo8df95472023-09-28 18:30:14 +0000139```sh
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000140export ELF=./out/gn/rp2040.size_optimized/obj/applications/badge/bin/badge.elf
141
142picotool reboot -f -u && \
143 sleep 3 && \
144 picotool load -x $ELF
AnthonyDiGirolamo8df95472023-09-28 18:30:14 +0000145```
146
Anthony DiGirolamo87ec62e2024-03-07 17:54:45 +0000147Connect with `pw console`:
Anthony DiGirolamob302d742023-09-12 16:48:53 +0000148
149```sh
Anthony DiGirolamo87ec62e2024-03-07 17:54:45 +0000150pw console --verbose \
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000151 --baudrate 115200 \
Anthony DiGirolamofd8e0a82023-10-12 19:37:23 +0000152 --token-databases ./out/gn/rp2040.size_optimized/obj/applications/badge/bin/badge.elf \
153 --device /dev/rp2040
AnthonyDiGirolamo8df95472023-09-28 18:30:14 +0000154```
Anthony DiGirolamo87ec62e2024-03-07 17:54:45 +0000155
156From Python Repl window you can issue RPCs interactively:
157
158```
159>>> device.rpcs.kudzu.rpc.Kudzu.PackageTemp()
160(Status.OK, kudzu.rpc.PackageTempResponse(temp=27.60657501220703))
161```