2. Inspect the binary and figure out what sections are missing. Explain why each of the sections
is missing. take a look at [Inspect binaries](#inspect-binaries). (**1p**)
3. Add the `cortex-m-rt` crate to your project and define a
function as an *entry point* for your firmware. Inspect the binary and see if the required sections
are present. (**1p**)
:::tip
The `cargo add` command adds crates to a project.
:::
4. Write a linker script to add the correct sections to your binary.
Take a look at [Linker script](#linker-script). Inspect the binary and see if the
required sections are present. (**1p**)
5. Write the build script to instruct the linker to use the linker script. Take a look at [Build script](#build-script).
Inspect the binary and see if the required sections are present. Is one of the sections missing? (**1p**)
:::tip
Make sure that the build script only uses linker scripts that exist in the project.
Some crates, like `cortex-m-rt` and `defmt` provide linker scripts.
:::
6. Print a message from the main function using semihosting. Try running
the firmware using `probe-rs run target/...$app_name`. Why doesn't it work? Take a look at [Semihosting](#semihosting) (**1p**).
7. Add the `rp235x_hal` crate to the project and configure the `.start_block` and the `.end_block`. Take
a look at [The `.start_block` and `.end_block`](#the-start_block-and-end_blocks). (**1p**)
8. Use semihosting to print the panic message in the *panic handler*. Use the `panic!` macro to
generate a panic. Take a look at [Printing the panic](#printing-the-panic) (**1p**).
9. Use the `defmt` and `defmt_rtt` crates to print `info!` and `error!` messages. Generate a panic to verify the error message.
Take a look at [Using `defmt`](#using-defmt) (**1p**)
:::tip
- Make sure you add all the necessary linker scripts to the `build.rs` build script.
- Make sure you enable the `defmt` and `critical-section-impl` features of the `rp235x_hal` crate.
- Make sure you set the `DEFMT_LOG` variable to `info` when building to see the `info` messages or
use the `.cargo/config.toml` file (take a look at [Filtering Messages](#filtering-messages)).
- Messages are printed together with the location where the message was issued. To supress this
use the ` --no-location` parameter for `probe-rs run`.
:::
10. Use the `panic-probe` crate to display better panics. (**1p**)
:::tip
- This crate provides a panic handler.
- Enable the `print-defmt` features of `panic-probe` to use `defmt` to print panics.
:::
11. Make the necessary configuration so that you can use `cargo run` to flash the firmware. Take a look
at [Using `cargo run`](#using-cargo-run) (**1p**)
:::tip
You can add the `--no-location` parameter to the runner.
:::
## VS Code probe-rs Extension
The [`probe-rs` extension for *Visual Studio Code*](https://marketplace.visualstudio.com/items?itemName=probe-rs.probe-rs-debugger) is a powerful tool designed to streamline
the development and debugging of embedded Rust applications. It provides a seamless experience
for flashing firmware, setting breakpoints, and inspecting memory on embedded devices,
including the Raspberry Pi Pico 1 and Pico 2. By integrating with `probe-rs`, this extension
removes the complexity of configuring traditional debugging setups that rely on *GDB* and *OpenOCD*.
Using `probe-rs` within *VS Code* greatly simplifies the debugging workflow. Instead of manually
invoking command-line tools to flash firmware and debug, users can configure the extension via a
simple `launch.json` file. This configuration specifies the target chip, the firmware binary
to flash, and debugging options. Once set up, developers can start debugging with a
single click or by pressing `F5`, making the process efficient and user-friendly.
It integrates natively with `defmt`, allowing developers to view structured log messages
directly within VS Code’s terminal. This is especially useful for debugging
applications running on resource-constrained devices like the Raspberry Pi Pico 1 and Pico 2,
where traditional logging methods may be impractical.
### Set up `launch.json`
VS Code's `probe-rs` extension uses a configuration file called `launch.json` located in the
`.vscode` folder of the project.
<Tabs>
<TabItem value="rp2350" label="Raspberry Pi Pico 2" default>