Anthony DiGirolamo | b302d74 | 2023-09-12 16:48:53 +0000 | [diff] [blame] | 1 | # Kudzu |
| 2 | |
| 3 | [TOC] |
| 4 | |
Carlos Chinchilla | b62f14c | 2023-10-12 20:24:56 +0000 | [diff] [blame] | 5 | ## Getting Started |
| 6 | |
| 7 | Make sure you've set up [Pigweed's |
| 8 | prerequisites](https://pigweed.dev/docs/getting_started.html#prerequisites). |
| 9 | |
| 10 | **If you're on Windows**, you can automate the initial setup by downloading the |
| 11 | first-time setup script **from cmd.exe**: |
| 12 | |
| 13 | ```bat |
| 14 | curl 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 | |
| 17 | Then you can run the script with the following command **in cmd.exe**: |
| 18 | |
| 19 | ```bat |
| 20 | setup_pigweed_prerequisites.bat |
| 21 | ``` |
| 22 | |
| 23 | Note: You may see a few UAC prompts as the script installs Git, Python, and |
| 24 | enables developer mode. |
| 25 | |
| 26 | Once that is done, you can clone this project with the following command: |
| 27 | ```sh |
| 28 | git clone https://pigweed.googlesource.com/pigweed/kudzu |
| 29 | ``` |
| 30 | |
| 31 | ### Environment setup |
| 32 | |
| 33 | Pigweed uses a local development environment for most of its tools. This |
| 34 | means tools are not installed to your machine, and are instead stored in a |
| 35 | directory inside your project (Note: git ignores this directory). The tools |
| 36 | are temporarily added to the PATH of the current shell session. |
| 37 | |
| 38 | To make sure the latest tooling has been fetched and set up, run the bootstrap |
| 39 | command for your operating system: |
| 40 | |
| 41 | **Windows** |
| 42 | |
| 43 | ```bat |
| 44 | bootstrap.bat |
| 45 | ``` |
| 46 | |
| 47 | **Linux & Mac** |
| 48 | |
| 49 | ```sh |
| 50 | source ./bootstrap.sh |
| 51 | ``` |
| 52 | |
| 53 | After tooling updates, you might need to run bootstrap again to ensure the |
| 54 | latest tools. |
| 55 | |
| 56 | After the initial bootstrap, you can use use the `activate` scripts to configure |
| 57 | the current shell for development without doing a full update. |
| 58 | |
| 59 | **Windows** |
| 60 | |
| 61 | ```sh |
| 62 | activate.bat |
| 63 | ``` |
| 64 | |
| 65 | **Linux & Mac** |
| 66 | |
| 67 | ```sh |
| 68 | source ./activate.sh |
| 69 | ``` |
| 70 | |
| 71 | ### Device tools setup |
| 72 | |
| 73 | Install the pico SDK and tool to flash the device. |
| 74 | |
| 75 | ```sh |
| 76 | pw package install pico_sdk |
| 77 | pw package install picotool |
| 78 | ``` |
| 79 | These packages will be built and added to the path automatically. There is no |
| 80 | need to add these to the gn arguments. |
| 81 | |
| 82 | ## Linux Setup |
| 83 | |
| 84 | ### GLFW Dependency: |
| 85 | |
| 86 | Install the GLFW OpenGL library |
| 87 | ```sh |
| 88 | sudo apt install libglfw3-dev libglfw3 |
| 89 | ``` |
| 90 | |
| 91 | ### Udev Rules: |
| 92 | |
| 93 | Put the following into `/usr/lib/udev/rules.d/49-picoprobe.rules` |
| 94 | |
| 95 | ``` |
| 96 | # Pico app mode |
| 97 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE:="0666" |
| 98 | KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE:="0666", SYMLINK+="rp2040" |
| 99 | |
| 100 | # RP2 Boot |
| 101 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE:="0666" |
| 102 | KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE:="0666", SYMLINK+="rp2040" |
| 103 | |
| 104 | # Picoprobe |
| 105 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666" |
| 106 | KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666", SYMLINK+="picoprobe" |
| 107 | ``` |
| 108 | |
| 109 | This will also symlink `/dev/picoprobe` and `/dev/rp2040` to the respective |
| 110 | vendor and product ids. |
| 111 | |
| 112 | Apply the above rules with: |
| 113 | |
| 114 | ```sh |
| 115 | sudo udevadm control --reload-rules |
| 116 | sudo udevadm trigger |
| 117 | ``` |
| 118 | |
AnthonyDiGirolamo | 8df9547 | 2023-09-28 18:30:14 +0000 | [diff] [blame] | 119 | ## Compile: |
Anthony DiGirolamo | b302d74 | 2023-09-12 16:48:53 +0000 | [diff] [blame] | 120 | |
| 121 | ```sh |
| 122 | pw build |
| 123 | ``` |
| 124 | |
AnthonyDiGirolamo | 8df9547 | 2023-09-28 18:30:14 +0000 | [diff] [blame] | 125 | ## Run: |
| 126 | |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 127 | ### Host |
AnthonyDiGirolamo | 8df9547 | 2023-09-28 18:30:14 +0000 | [diff] [blame] | 128 | |
Anthony DiGirolamo | 87ec62e | 2024-03-07 17:54:45 +0000 | [diff] [blame] | 129 | Run the host app and connect to it via `pw console`: |
Anthony DiGirolamo | b302d74 | 2023-09-12 16:48:53 +0000 | [diff] [blame] | 130 | |
| 131 | ```sh |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 132 | ./out/gn/host_device_simulator.speed_optimized/obj/applications/badge/bin/badge & \ |
Anthony DiGirolamo | 87ec62e | 2024-03-07 17:54:45 +0000 | [diff] [blame] | 133 | pw console --socket-addr default ; \ |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 134 | killall badge |
Anthony DiGirolamo | b302d74 | 2023-09-12 16:48:53 +0000 | [diff] [blame] | 135 | ``` |
| 136 | |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 137 | ### Kudzu |
| 138 | |
AnthonyDiGirolamo | 8df9547 | 2023-09-28 18:30:14 +0000 | [diff] [blame] | 139 | ```sh |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 140 | export ELF=./out/gn/rp2040.size_optimized/obj/applications/badge/bin/badge.elf |
| 141 | |
| 142 | picotool reboot -f -u && \ |
| 143 | sleep 3 && \ |
| 144 | picotool load -x $ELF |
AnthonyDiGirolamo | 8df9547 | 2023-09-28 18:30:14 +0000 | [diff] [blame] | 145 | ``` |
| 146 | |
Anthony DiGirolamo | 87ec62e | 2024-03-07 17:54:45 +0000 | [diff] [blame] | 147 | Connect with `pw console`: |
Anthony DiGirolamo | b302d74 | 2023-09-12 16:48:53 +0000 | [diff] [blame] | 148 | |
| 149 | ```sh |
Anthony DiGirolamo | 87ec62e | 2024-03-07 17:54:45 +0000 | [diff] [blame] | 150 | pw console --verbose \ |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 151 | --baudrate 115200 \ |
Anthony DiGirolamo | fd8e0a8 | 2023-10-12 19:37:23 +0000 | [diff] [blame] | 152 | --token-databases ./out/gn/rp2040.size_optimized/obj/applications/badge/bin/badge.elf \ |
| 153 | --device /dev/rp2040 |
AnthonyDiGirolamo | 8df9547 | 2023-09-28 18:30:14 +0000 | [diff] [blame] | 154 | ``` |
Anthony DiGirolamo | 87ec62e | 2024-03-07 17:54:45 +0000 | [diff] [blame] | 155 | |
| 156 | From 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 | ``` |