@@ -67,15 +67,20 @@ rustup update stable
6767rustup target add thumbv6m-none-eabi
6868```
6969
70- You may also want to install these helpful tools:
70+ You may also want to install probe-rs, to flash your device over the SWD pins
71+ with a debug probe:
7172
7273``` sh
73- # Useful to creating UF2 images for the RP2040 USB Bootloader
74- cargo install elf2uf2-rs --locked
75- # Useful for flashing over the SWD pins using a supported JTAG probe
7674cargo install --locked probe-rs-tools
7775```
7876
77+ And also [ picotool] , if you are not using a debug probe or wish to create UF2
78+ images for the USB bootloader. You can download a [ pre-built picotool
79+ binary] [ picotool-releases ] for your system.
80+
81+ [ picotool ] : https://github.com/raspberrypi/picotool
82+ [ picotool-releases ] : https://github.com/raspberrypi/pico-sdk-tools/releases
83+
7984## Packages
8085
8186There is a _ Hardware Abstraction Layer_ (or HAL) crate for the RP2040 chip,
@@ -125,11 +130,8 @@ a [separate repository][BSPs].
125130Rust generates standard Arm ELF files, which you can load onto your Raspberry Pi
126131Silicon device with your favourite Arm flashing/debugging tool. In addition, the
127132RP2040 contains a ROM bootloader which appears as a Mass Storage Device over USB
128- that accepts UF2 format images. You can use the ` elf2uf2-rs ` package to convert
129- the Arm ELF file to a UF2 format image.
130-
131- For boards with USB Device support like the Raspberry Pi Pico, we recommend you
132- use the UF2 process.
133+ that accepts UF2 format images. You can use picotool to flash your device over
134+ USB, or convert the Arm ELF file to a UF2 format image.
133135
134136The RP2040 contains two Cortex-M0+ processors, which execute Thumb-2 encoded
135137ARMv6-M instructions. There are no operating-specific features in the binaries
@@ -156,20 +158,16 @@ More detailed information on how the linker flags work can be found in
156158In most cases, it should be sufficient to use the example files from the
157159[ Project Template] .
158160
159- ### Loading a UF2 over USB
160-
161- * Step 1* - Install [ ` elf2uf2-rs ` ] ( https://github.com/JoNil/elf2uf2-rs ) :
161+ ### Loading over USB with picotool
162162
163- ``` console
164- $ cargo install elf2uf2-rs --locked
165- ```
163+ * Step 1* - Install a [ picotool binary] [ picotool-releases ] for your system.
166164
167165* Step 2* - Make sure your .cargo/config contains the following (it should by
168166default if you are working in this repository):
169167
170168``` toml
171169[target .thumbv6m-none-eabi ]
172- runner = " elf2uf2-rs -d "
170+ runner = " picotool load --update --verify --execute -t elf "
173171```
174172
175173The ` thumbv6m-none-eabi ` target may be replaced by the all-Arm wildcard
@@ -180,8 +178,8 @@ whilst holding some kind of "Boot Select" button. On Linux, you will also need
180178to 'mount' the device, like you would a USB Thumb Drive.
181179
182180* Step 4* - Use ` cargo run ` , which will compile the code and started the
183- specified 'runner'. As the 'runner' is the elf2uf2-rs tool , it will build a UF2
184- file and copy it to your RP2040 .
181+ specified 'runner'. As the 'runner' is picotool , it will flash your compiled
182+ binary over USB .
185183
186184``` console
187185$ cargo run --release --features " critical-section-impl,rt,defmt" --example pwm_blink
@@ -190,6 +188,22 @@ $ cargo run --release --features "critical-section-impl,rt,defmt" --example pwm_
190188(The ` pwm_blink ` example doesn't need all these feature flags. They are listed here
191189so you can use the same command for all examples.)
192190
191+ If you want to create a UF2 file, which is loaded by copying it over to the
192+ RPI-RP2 mass storage device, use the ` picotool uf2 convert ` command on your
193+ compiled program with the ` -t elf ` argument.
194+
195+ ``` console
196+ $ picotool uf2 convert -t elf target/thumbv6m-none-eabi/release/pwm_blink
197+ pwm_blink.uf2
198+ ```
199+
200+ Picotool can also read "Binary Info" from a device with ` picotool info ` . To
201+ enable this in your firmware, see the [ rp-binary-info] crate and the
202+ corresponding [ binary info example] .
203+
204+ [ rp-binary-info ] : https://github.com/rp-rs/rp-hal/tree/main/rp-binary-info
205+ [ binary info example ] : https://github.com/rp-rs/rp-hal/blob/main/rp2040-hal-examples/src/bin/binary_info_demo.rs
206+
193207### Loading with probe-rs
194208[ probe-rs] ( https://github.com/probe-rs/probe-rs ) is a library and a
195209command-line tool which can flash a wide variety of microcontrollers
@@ -234,20 +248,6 @@ connected to the RP2040.
234248$ cargo run --release --example pwm_blink
235249```
236250
237- ### Loading with picotool
238-
239- As ELF files produced by compiling Rust code are completely compatible with ELF
240- files produced by compiling C or C++ code, you can also use the Raspberry Pi
241- tool [ picotool] ( https://github.com/raspberrypi/picotool ) . The only thing to be
242- aware of is that picotool expects your ELF files to have a ` .elf ` extension, and
243- by default Rust does not give the ELF files any extension. You can fix this by
244- simply renaming the file.
245-
246- Also of note is that the special
247- [ pico-sdk] ( https://github.com/raspberrypi/pico-sdk ) macros which hide
248- information in the ELF file in a way that ` picotool info ` can read it out, are
249- not supported in Rust. An alternative is TBC.
250-
251251[ Project Template ] : https://github.com/rp-rs/rp2040-project-template
252252
253253<!-- ROADMAP -->
0 commit comments