blob: 7c0c460bd43595c93c3008719d62983e92a41c3d [file] [log] [blame] [view]
Anthony DiGirolamofb41f922021-03-02 14:32:01 -08001# Pigweed Experimental
2
3[TOC]
4
Armando Montanez3bb64692023-11-01 16:16:01 +00005This repository contains a variety experiments to help inform various Pigweed
6policies, designs, and implementation behaviors.
7
8Code in this repository is not reviewed to the standard of
9[the main Pigweed repository](https://pigweed.googlesource.com/pigweed/pigweed),
10and generally speaking is untested and maintained on a best-effort basis. This
11is not a repository of "early access" Pigweed modules, but more so a sandbox for
12Pigweed contributors to collaborate on investigations. For more information, see
13the contribution guidelines for the
14[experimental repository and where to land code](https://pigweed.dev/docs/contributing.html#experimental-repository-and-where-to-land-code).
15
16**DO NOT DEPEND ON THIS REPOSITORY IN ANY PRODUCTION PROJECT!**
Anthony DiGirolamofb41f922021-03-02 14:32:01 -080017
18## Repository setup
19
20Clone this repo with `--recursive` to get all required submodules.
21
22```sh
23git clone --recursive https://pigweed.googlesource.com/pigweed/experimental
24```
25
26This will pull the [Pigweed source
27repository](https://pigweed.googlesource.com/pigweed/pigweed) into
28`third_party/pigweed`. If you already cloned but forgot to `--recursive` run
29`git submodule update --init` to pull all submodules.
30
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070031
32## pw_graphics
33
34The [//pw_graphics](/pw_graphics) folder contains some libraries for drawing to
35an RGB565 framebuffer and displaying it on various platforms.
36
37The demo applications that make use of these libraries are:
38- [//applications/terminal_display](/applications/terminal_display)
39
40### Build instructions
41
Anthony DiGirolamo35c04812022-08-19 18:30:42 +000042**First time setup:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070043
44```
45git clone --recursive https://pigweed.googlesource.com/pigweed/experimental
46cd experimental
47. ./bootstrap.sh
48pw package install imgui
49pw package install glfw
50pw package install stm32cube_f4
Anthony DiGirolamo35c04812022-08-19 18:30:42 +000051pw package install pico_sdk
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070052```
53
54#### **[STM32F429-DISC1](https://www.st.com/en/evaluation-tools/32f429idiscovery.html)**
55
Anthony DiGirolamo35c04812022-08-19 18:30:42 +000056**Compile:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070057
58```sh
59gn gen out --export-compile-commands --args="
Anthony DiGirolamo35c04812022-08-19 18:30:42 +000060 dir_pw_third_party_stm32cube_f4=\"$PW_PROJECT_ROOT/environment/packages/stm32cube_f4\"
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070061"
62ninja -C out
63```
64
Anthony DiGirolamo35c04812022-08-19 18:30:42 +000065**Flash:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070066
67```
68openocd -f third_party/pigweed/targets/stm32f429i_disc1/py/stm32f429i_disc1_utils/openocd_stm32f4xx.cfg -c "program out/stm32f429i_disc1_stm32cube_debug/obj/applications/terminal_display/bin/terminal_demo.elf verify reset exit"
69```
70
Chris Mumforde2fa1842023-01-17 19:45:43 +000071#### **[STM32F769-DISC0](https://www.st.com/en/evaluation-tools/32f769idiscovery.html)**
72
73**First time setup:**
74```
75pw package install stm32cube_f7
76```
77
78**Compile:**
79
80```sh
81gn gen out --export-compile-commands --args="
82 dir_pw_third_party_stm32cube_f7=\"//environment/packages/stm32cube_f7\"
83"
84ninja -C out
85```
86
87**Flash:**
88
89```
90openocd -f targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/openocd_stm32f7xx.cfg \
91 -c "program out/stm32f769i_disc0_debug/obj/applications/blinky/bin/blinky.elf verify reset exit"
92```
93
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070094#### **Linux, Windows or Mac**
95
Anthony DiGirolamo35c04812022-08-19 18:30:42 +000096**Compile:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -070097
98```sh
99gn gen out --export-compile-commands --args="
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000100 dir_pw_third_party_imgui=\"$PW_PROJECT_ROOT/environment/packages/imgui\"
Anthony DiGirolamoc8c7dae2022-08-27 01:25:44 +0000101 dir_pw_third_party_glfw=\"$PW_PROJECT_ROOT/environment/packages/glfw\"
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700102"
103ninja -C out
104```
105
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000106**Run:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700107
108```
109out/host_debug/obj/applications/terminal_display/bin/terminal_demo
110```
111
Erik Gilling55514cd2024-02-16 23:22:12 +0000112#### ***CURRENTLY NOT WORKING (https://pwbug.dev/325649415)*** - **[Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) Connected to an external SPI display**
113
Anthony DiGirolamo27b990c2022-08-23 22:55:29 +0000114
115Working displays:
116
117- [ILI9341](https://www.adafruit.com/?q=ili9341&sort=BestMatch)
118- [Pico Display Pack 2.0 (ST7789)](https://shop.pimoroni.com/products/pico-display-pack-2-0)
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700119
Anthony DiGirolamo8d37c562023-09-01 18:44:09 +0000120**First time setup:**
121```
122pw package install pico_sdk
123```
124
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000125**Compile:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700126
127```sh
Anthony DiGirolamo8d37c562023-09-01 18:44:09 +0000128gn gen out --export-compile-commands --args='
129 PICO_SRC_DIR="//environment/packages/pico_sdk"
130'
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700131ninja -C out
132```
133
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000134**Flash:**
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700135
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000136- Using a uf2 file:
Anthony DiGirolamo9a0ea162022-05-24 15:08:21 -0700137
Anthony DiGirolamo8d37c562023-09-01 18:44:09 +0000138 1. Reboot pico into BOOTSEL mode by holding the bootsel button on startup.
139 2. Copy `./out/rp2040/obj/applications/terminal_display/terminal_demo.uf2` to your Pi Pico.
140
141- Using `picotool`:
142
143 1. Reboot pico into BOOTSEL mode by holding the bootsel button on startup. Or try forcing a reboot with `picotool`:
144
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000145 ```sh
Anthony DiGirolamo8d37c562023-09-01 18:44:09 +0000146 picotool reboot -f -u
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000147 ```
148
Anthony DiGirolamo8d37c562023-09-01 18:44:09 +0000149 2. Flash the elf or uf2 file and reboot.
150
151 ```sh
152 picotool load ./out/rp2040/obj/applications/terminal_display/bin/terminal_demo.elf
153 picotool reboot
154 ```
Anthony DiGirolamo35c04812022-08-19 18:30:42 +0000155
156- Using a Pico Probe and openocd:
157
158 This requires installing the Raspberry Pi foundation's OpenOCD fork for the
159 Pico probe. More details including how to connect the two Pico boards is available at [Raspberry Pi Pico and RP2040 - C/C++ Part 2: Debugging with VS Code](https://www.digikey.com/en/maker/projects/raspberry-pi-pico-and-rp2040-cc-part-2-debugging-with-vs-code/470abc7efb07432b82c95f6f67f184c0)
160
161 **Install RaspberryPi's OpenOCD Fork:**
162
163 ```sh
164 git clone https://github.com/raspberrypi/openocd.git \
165 --branch picoprobe \
166 --depth=1 \
167 --no-single-branch \
168 openocd-picoprobe
169
170 cd openocd-picoprobe
171
172 ./bootstrap
173 ./configure --enable-picoprobe --prefix=$HOME/apps/openocd --disable-werror
174 make -j2
175 make install
176 ```
177
178 **Setup udev rules (Linux only):**
179
180 ```sh
181 cat <<EOF > 49-picoprobe.rules
182 SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666"
183 KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666"
184 EOF
185 sudo cp 49-picoprobe.rules /usr/lib/udev/rules.d/49-picoprobe.rules
186 sudo udevadm control --reload-rules
187 ```
188
189 **Flash the Pico:**
190
191 ```sh
192 ~/apps/openocd/bin/openocd -f ~/apps/openocd/share/openocd/scripts/interface/picoprobe.cfg -f ~/apps/openocd/share/openocd/scripts/target/rp2040.cfg -c 'program out/rp2040/obj/applications/terminal_display/bin/terminal_demo.elf verify reset exit'
193 ```
Chris Mumfordc62c9f32022-11-01 17:40:08 +0000194
Anthony DiGirolamo8d37c562023-09-01 18:44:09 +0000195 **Launching gdb***
196
197 ```sh
198 ~/apps/openocd/bin/openocd -f ~/apps/openocd/share/openocd/scripts/interface/picoprobe.cfg -f ~/apps/openocd/share/openocd/scripts/target/rp2040.cfg
199 ```
200
201 ```sh
202 gdb-multiarch -ex "target remote :3333" -ex "set print pretty on" out/rp2040/obj/applications/terminal_display/bin/terminal_demo.elf
203 ```
204
205 `arm-none-eabi-gdb` can be used in place of `gdb-multiarch` above.
206
Chris Mumfordc62c9f32022-11-01 17:40:08 +0000207#### **[MIMXRT595-EVK](https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/i-mx-rt595-evaluation-kit:MIMXRT595-EVK) Connected to an external MIPI display**
208
209**Setup NXP SDK:**
210
2111. Build a NXP SDK
2122. Download SDK
2133. Extract SDK's zip file to //environment/SDK_2_12_1_EVK-MIMXRT595
214
215**Compile:**
216
217```sh
218gn gen out --export-compile-commands --args="
219 pw_MIMXRT595_EVK_SDK=\"//environment/SDK_2_12_1_EVK-MIMXRT595\"
220 pw_target_mimxrt595_evk_MANIFEST=\"//environment/SDK_2_12_1_EVK-MIMXRT595/EVK-MIMXRT595_manifest_v3_10.xml\"
221 pw_third_party_mcuxpresso_SDK=\"//targets/mimxrt595_evk:mimxrt595_sdk\"
222"
223
224ninja -C out
225```
226
227**Flash the MIMXRT595-EVK:**
228
229Follow the instructions to flash the MIMXRT595-EVK with the SEGGER J-Link
230firmware and using `arm-none-eabi-gdb` at
231https://pigweed.dev/targets/mimxrt595_evk/target_docs.html#running-and-debugging.
Chris Mumfordf9cc7982022-12-14 20:09:16 +0000232
233#### Teensy 4.1 ####
234
235https://www.pjrc.com/teensy/loader_cli.html
236
237```bash
238brew install teensy_loader_cli
239```
240
241```sh
242OBJCOPY=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy
243INFILE=out/arduino_debug/obj/applications/terminal_display/bin/terminal_demo.elf
244OUTFILE=foo.hex
245$OBJCOPY -O ihex -R .eeprom -R .fuse -R .lock -R .signature $INFILE $OUTFILE
246teensy_loader_cli --mcu=TEENSY41 -w -v $OUTFILE
247```