Newer
Older
[Raspberry Pi Pico C/C++ SDK][1]
[Raspberry Pi Pico Quick Start][2]
[Raspberry Pi Pico W (WiFi) Quick start][3]
## Tools
**This guide as been tested for Ubuntu 22.04**
### Toolchain
A docker image containing all the tools is available. You can build it with the following command.
```bash
docker build -t pico-dev .
```
Alternatively you can pull the image from GitLab.
TODO: push image to gitlab
To run the image you can use the run script:
```bash
./run
```
or
```bash
docker run --rm -it --name pico-env -v $PWD:/mnt/ pico-dev
```
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
### Flash and debug
You can use the Raspberry Pi Debug probe to flash and debug applications. To use it you must first install OpenOCD.
Download and install the OpenOCD dependencies:
```bash
sudo apt install automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev
```
Clone, build and install OpenOCD:
```bash
cd ~
git clone https://github.com/raspberrypi/openocd.git --branch rp2040-v0.12.0 --depth=1 --no-single-branch
cd openocd
./bootstrap
./configure
make -j4
sudo make install
```
Check OpenOCD version:
```bash
openocd --version
```
Output:
```bash
Open On-Chip Debugger 0.12.0-g4d87f6d (2024-01-08-14:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
```
Create a file with any name (ex. pico_openocd.rules) under /etc/udev/rules.d and put this line inside.
```bash
ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000c", MODE="660", GROUP="plugdev", TAG+="uaccess"
```
## Compile Pico W code
Run the docker container and navigate to the *sht30/pico_w* folder. Create a *build* folder and navigate to it:
```bash
mkdir build && cd build
```
Inside the *build* folder you will setup the **CMake** environnement.
```bash
cmake -DPICO_BOARD=grove_pico_w ..
```
This will initialize **CMake** and generate a Makefile. To build the project simply run:
```bash
make
```
Alternatively you can run the *build.sh* script from the top folder.
1. Setup project folder and board type (run only once)
```bash
./build.sh -p sht30/pico_w/ -t grove_pico_w
```
2. Compile
```bash
./build.sh -b
```
## Deploy application on the Raspberry Pi Pico
### Flash using UF2 (USB Flashing Format)
You can flash the Pico via USB using the *.uf2* file.
1. Power up the Pico while pressing the **BOOTSEL** button
2. You Pico should show up as a drive.
3. Copy the *pico_w/build/sht30.uf2* onto the Pico.
1. Linux:
```bash
cp pico_w/build/sht30.uf2 /media/$USER/RPI-RP2
```
2. Windows: Drag and drop the file
### Flash using debug probe and OpenOCD
Run the build script with the *-f* option:
```bash
./build.sh -f
```
> :warning: This command must be performed on your host machine not in a running docker container
[1]:https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf?_gl=1*155jvvo*_ga*MTk5NjQ0ODQwNy4xNzAyNjI5NzEx*_ga_22FD70LWDS*MTcwNDI5MDg1OS4zLjEuMTcwNDI5MTA0Ny4wLjAuMA..
[2]:https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf?_gl=1*i8b34r*_ga*MTk5NjQ0ODQwNy4xNzAyNjI5NzEx*_ga_22FD70LWDS*MTcwNDI5MDg1OS4zLjEuMTcwNDI5MTEzNy4wLjAuMA..
[3]:https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf?_gl=1*19f24rw*_ga*MTk5NjQ0ODQwNy4xNzAyNjI5NzEx*_ga_22FD70LWDS*MTcwNDI5MDg1OS4zLjEuMTcwNDI5MTA0OS4wLjAuMA..