Anthony DiGirolamo | fb41f92 | 2021-03-02 14:32:01 -0800 | [diff] [blame] | 1 | # Pigweed Experimental |
| 2 | |
| 3 | [TOC] |
| 4 | |
Armando Montanez | 3bb6469 | 2023-11-01 16:16:01 +0000 | [diff] [blame] | 5 | This repository contains a variety experiments to help inform various Pigweed |
| 6 | policies, designs, and implementation behaviors. |
| 7 | |
| 8 | Code in this repository is not reviewed to the standard of |
| 9 | [the main Pigweed repository](https://pigweed.googlesource.com/pigweed/pigweed), |
| 10 | and generally speaking is untested and maintained on a best-effort basis. This |
| 11 | is not a repository of "early access" Pigweed modules, but more so a sandbox for |
| 12 | Pigweed contributors to collaborate on investigations. For more information, see |
| 13 | the 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 DiGirolamo | fb41f92 | 2021-03-02 14:32:01 -0800 | [diff] [blame] | 17 | |
| 18 | ## Repository setup |
| 19 | |
| 20 | Clone this repo with `--recursive` to get all required submodules. |
| 21 | |
| 22 | ```sh |
| 23 | git clone --recursive https://pigweed.googlesource.com/pigweed/experimental |
| 24 | ``` |
| 25 | |
| 26 | This will pull the [Pigweed source |
| 27 | repository](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 DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 31 | |
| 32 | ## pw_graphics |
| 33 | |
| 34 | The [//pw_graphics](/pw_graphics) folder contains some libraries for drawing to |
| 35 | an RGB565 framebuffer and displaying it on various platforms. |
| 36 | |
| 37 | The demo applications that make use of these libraries are: |
| 38 | - [//applications/terminal_display](/applications/terminal_display) |
| 39 | |
| 40 | ### Build instructions |
| 41 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 42 | **First time setup:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 43 | |
| 44 | ``` |
| 45 | git clone --recursive https://pigweed.googlesource.com/pigweed/experimental |
| 46 | cd experimental |
| 47 | . ./bootstrap.sh |
| 48 | pw package install imgui |
| 49 | pw package install glfw |
| 50 | pw package install stm32cube_f4 |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 51 | pw package install pico_sdk |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 52 | ``` |
| 53 | |
| 54 | #### **[STM32F429-DISC1](https://www.st.com/en/evaluation-tools/32f429idiscovery.html)** |
| 55 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 56 | **Compile:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 57 | |
| 58 | ```sh |
| 59 | gn gen out --export-compile-commands --args=" |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 60 | dir_pw_third_party_stm32cube_f4=\"$PW_PROJECT_ROOT/environment/packages/stm32cube_f4\" |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 61 | " |
| 62 | ninja -C out |
| 63 | ``` |
| 64 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 65 | **Flash:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 66 | |
| 67 | ``` |
| 68 | openocd -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 Mumford | e2fa184 | 2023-01-17 19:45:43 +0000 | [diff] [blame] | 71 | #### **[STM32F769-DISC0](https://www.st.com/en/evaluation-tools/32f769idiscovery.html)** |
| 72 | |
| 73 | **First time setup:** |
| 74 | ``` |
| 75 | pw package install stm32cube_f7 |
| 76 | ``` |
| 77 | |
| 78 | **Compile:** |
| 79 | |
| 80 | ```sh |
| 81 | gn gen out --export-compile-commands --args=" |
| 82 | dir_pw_third_party_stm32cube_f7=\"//environment/packages/stm32cube_f7\" |
| 83 | " |
| 84 | ninja -C out |
| 85 | ``` |
| 86 | |
| 87 | **Flash:** |
| 88 | |
| 89 | ``` |
| 90 | openocd -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 DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 94 | #### **Linux, Windows or Mac** |
| 95 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 96 | **Compile:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 97 | |
| 98 | ```sh |
| 99 | gn gen out --export-compile-commands --args=" |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 100 | dir_pw_third_party_imgui=\"$PW_PROJECT_ROOT/environment/packages/imgui\" |
Anthony DiGirolamo | c8c7dae | 2022-08-27 01:25:44 +0000 | [diff] [blame] | 101 | dir_pw_third_party_glfw=\"$PW_PROJECT_ROOT/environment/packages/glfw\" |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 102 | " |
| 103 | ninja -C out |
| 104 | ``` |
| 105 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 106 | **Run:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 107 | |
| 108 | ``` |
| 109 | out/host_debug/obj/applications/terminal_display/bin/terminal_demo |
| 110 | ``` |
| 111 | |
Erik Gilling | 55514cd | 2024-02-16 23:22:12 +0000 | [diff] [blame] | 112 | #### ***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 DiGirolamo | 27b990c | 2022-08-23 22:55:29 +0000 | [diff] [blame] | 114 | |
| 115 | Working 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 DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 119 | |
Anthony DiGirolamo | 8d37c56 | 2023-09-01 18:44:09 +0000 | [diff] [blame] | 120 | **First time setup:** |
| 121 | ``` |
| 122 | pw package install pico_sdk |
| 123 | ``` |
| 124 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 125 | **Compile:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 126 | |
| 127 | ```sh |
Anthony DiGirolamo | 8d37c56 | 2023-09-01 18:44:09 +0000 | [diff] [blame] | 128 | gn gen out --export-compile-commands --args=' |
| 129 | PICO_SRC_DIR="//environment/packages/pico_sdk" |
| 130 | ' |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 131 | ninja -C out |
| 132 | ``` |
| 133 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 134 | **Flash:** |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 135 | |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 136 | - Using a uf2 file: |
Anthony DiGirolamo | 9a0ea16 | 2022-05-24 15:08:21 -0700 | [diff] [blame] | 137 | |
Anthony DiGirolamo | 8d37c56 | 2023-09-01 18:44:09 +0000 | [diff] [blame] | 138 | 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 DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 145 | ```sh |
Anthony DiGirolamo | 8d37c56 | 2023-09-01 18:44:09 +0000 | [diff] [blame] | 146 | picotool reboot -f -u |
Anthony DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 147 | ``` |
| 148 | |
Anthony DiGirolamo | 8d37c56 | 2023-09-01 18:44:09 +0000 | [diff] [blame] | 149 | 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 DiGirolamo | 35c0481 | 2022-08-19 18:30:42 +0000 | [diff] [blame] | 155 | |
| 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 Mumford | c62c9f3 | 2022-11-01 17:40:08 +0000 | [diff] [blame] | 194 | |
Anthony DiGirolamo | 8d37c56 | 2023-09-01 18:44:09 +0000 | [diff] [blame] | 195 | **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 Mumford | c62c9f3 | 2022-11-01 17:40:08 +0000 | [diff] [blame] | 207 | #### **[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 | |
| 211 | 1. Build a NXP SDK |
| 212 | 2. Download SDK |
| 213 | 3. Extract SDK's zip file to //environment/SDK_2_12_1_EVK-MIMXRT595 |
| 214 | |
| 215 | **Compile:** |
| 216 | |
| 217 | ```sh |
| 218 | gn 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 | |
| 224 | ninja -C out |
| 225 | ``` |
| 226 | |
| 227 | **Flash the MIMXRT595-EVK:** |
| 228 | |
| 229 | Follow the instructions to flash the MIMXRT595-EVK with the SEGGER J-Link |
| 230 | firmware and using `arm-none-eabi-gdb` at |
| 231 | https://pigweed.dev/targets/mimxrt595_evk/target_docs.html#running-and-debugging. |
Chris Mumford | f9cc798 | 2022-12-14 20:09:16 +0000 | [diff] [blame] | 232 | |
| 233 | #### Teensy 4.1 #### |
| 234 | |
| 235 | https://www.pjrc.com/teensy/loader_cli.html |
| 236 | |
| 237 | ```bash |
| 238 | brew install teensy_loader_cli |
| 239 | ``` |
| 240 | |
| 241 | ```sh |
| 242 | OBJCOPY=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy |
| 243 | INFILE=out/arduino_debug/obj/applications/terminal_display/bin/terminal_demo.elf |
| 244 | OUTFILE=foo.hex |
| 245 | $OBJCOPY -O ihex -R .eeprom -R .fuse -R .lock -R .signature $INFILE $OUTFILE |
| 246 | teensy_loader_cli --mcu=TEENSY41 -w -v $OUTFILE |
| 247 | ``` |