General Note GCC 

The latest version of Pi OS only supplies GCC 8.3 in a bare metal compiler configuration arm-none-eabi and this is the Kit you should select.

The alternative 10.2 targets Linux and cannot be used to compile Pico programs.

Windows 10 currently supplies 10.3 arm-none-eabi for bare metal targets.

General Note RDP

The latest version of Pi OS needs some tweeking to make Windows remote desktop work.

See the article on I Programmer - Remote Desktop To A Headless Pi Running Bullseye

General Note PIO

To avoid having to use GPIO lines in SPI mode the driver makes use of one of the PIOs. This means that you should avoid using the same PIO as the WiFi driver for general purpose I/O. Which PIO is used is set by

#define CYW43_SPI_PIO_PREFERRED_PIO 1

You can override this if you want to but it is simpler to use PIO 0 for your own PIO programs. The driver uses a single state machine and ten bytes of instruction memory. If you want to use PIO 1 you can use pio_claim_unused_sm to find a free state machine.

All of the examples in the PIO chapter use PIO 0.

General Note Windows Installer

As of SDK 1.5 there is an official installation script for Windows and it makes the job of getting started much simpler. You can find it at:

https://github.com/raspberrypi/pico-setup-windows

and it is easy to use and it works.

To find the exe file you first need to navigate to the latest releases:

Then download the appropriate installer from the Assets section.

And run the .exe file from the command prompt.

At the time of writing it automatically installs and configures the following:

  1. Arm GNU Toolchain

  2. CMake

  3. Ninja

  4. Python 3.9

  5. Git for Windows

  6. Visual Studio Code

  7. OpenOCD

The installation provides a specially configured version of VS Code – Pico-Visual Studio Code and a Pico configured PowerShell and Command Prompt. In fact the PowerShell is used to start VS Code with the correct environment parameters. It also installs Ninja as the make utility not the default Nmake.

You need to always ensure that you start VS Code using the Pico shortcut otherwise you will get an unconfigured VS Code that will not know how to compile your program.

Errata

Page 71

Swap the Emitter Collector labels on the diagram at the top of the page. The Emitter is always the one with the arrow!

Page 84 Top line

Change:

We have already met the functions that sets a GPIO line to input or output:

To read:

We have already met the functions that set a GPIO line to input or output:

Page 85

Change:

One of the most common input circuits is the switch or button. If you want another external button you can use any GPIO line and the circuit explained in the previous chapter. That is, the switch has to have either a pull-up or pull-down resistor either provided by you or a built-in one enabled using software.

To read:

One of the most common input circuits is the switch or button. If you want add a button you can use any GPIO line and the circuit explained in the previous chapter. That is, the switch has to have either a pull-up or pull-down resistor either provided by you or a built-in one enabled using software.

Change:

The program simply tests for the line to be pulled low by the switch being closed and then sets GP21 high. If you connect GP21 to an LED or a logic analyzer you will see the effect of the button being closed – the LED will light up while it is pressed. Notice GP22 goes low to indicate that the switch is pressed.

To read

The program simply tests for the line, GP21, to be pulled low by the switch being closed and then sets GP22 high. If you connect GP22 to an LED or a logic analyzer you will see the effect of the button being closed – the LED will light up while it is pressed.

 Page 88

If you are only interested in transmitting data from the Pico you only need to connect Pin 1 and Pin10.

change to 

If you are only interested in transmitting data from the Pico you only need to connect Pin 1 and Pin 2.

 

Page 287

The fist line of int presence(uint8_t pin) 

gpio_set_dir(2, GPIO_OUT);

should be

gpio_set_dir(pin, GPIO_OUT);

The function is correct in the final listing.

Spotted by Larry Simoneau - many thanks.

Page 344

Change the body function from:

err_t body(void *arg, struct altcp_pcb *conn,
                                      struct pbuf *p, err_t err)
{
    printf("body\n");
    pbuf_copy_partial(p, myBuff, p->tot_len, 0);  
    printf("%s", myBuff);
    return ERR_OK;
}

to

err_t body(void *arg, struct altcp_pcb *conn,
                                      struct pbuf *p, err_t err)
{
    printf("body\n");
    pbuf_copy_partial(p, myBuff, p->tot_len, 0);
    pbuf_free(p);
    printf("%s", myBuff);
    return ERR_OK;
}
 
That is add pbuf_free(p). Without it there is a memory leak that slows the calls to the client down until at around 25
calls it no longer has enough memory to work.