Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Tomi aa6093b094 Allow defining PICOWOTA_WIFI_AP in the environment vor 2 Jahren
dhcpserver Add WiFi AP mode vor 2 Jahren
picowota_reboot picowota_reboot: Add missing cmsis_core dependency vor 2 Jahren
CMakeLists.txt Allow defining PICOWOTA_WIFI_AP in the environment vor 2 Jahren
LICENSE Add LICENSE and README vor 2 Jahren
README.md Fix typo in README vor 2 Jahren
bootloader.ld Add ability to build combined images vor 2 Jahren
bootloader_shell.ld Add ability to build combined images vor 2 Jahren
combined.ld Add ability to build combined images vor 2 Jahren
gen_imghdr.py Add ability to build combined images vor 2 Jahren
lwipopts.h Initial basic TCP server vor 2 Jahren
main.c Add WiFi AP mode vor 2 Jahren
mkasm.py Add ability to build combined images vor 2 Jahren
pico_sdk_import.cmake Initial basic TCP server vor 2 Jahren
standalone.ld Add ability to build combined images vor 2 Jahren
tcp_comm.c Fix some warnings and optimise for size vor 2 Jahren
tcp_comm.h Port over all the other commands vor 2 Jahren

README.md

picowota - Raspberry Pi Pico W OTA bootloader

picowota, kinda sounds like you’re speaking Belter

This project implements a bootloader for the Raspberry Pi Pico W which allows upload of program code over WiFi (“Over The Air”).

The easiest way to use it is to include this repository as a submodule in the application which you want to be able to update over WiFi.

There’s an example project using picowota at https://github.com/usedbytes/picowota_blink

Using in your project

First add picowota as a submodule to your project:

git submodule add https://github.com/usedbytes/picowota
git submodule update --init picowota
git commit -m "Add picowota submodule"

Then modifiy your project’s CMakeLists.txt to include the picowota directory:

add_subdirectory(picowota)

picowota (currently) connects to an existing WiFi network, so you need to set the SSID and password for the network to connect to.

You can either export the PICOWOTA_WIFI_SSID and PICOWOTA_WIFI_PASS environment variables, or set the CMake variables with the same name:

set(PICOWOTA_WIFI_SSID MyNetworkName)
set(PICOWOTA_WIFI_PASS MyPassw0rd)

Then, you can either build just your standalone app binary (suitable for updating via picowota when it’s already on the Pico), or a combined binary which contains the bootloader and the app (suitable for flashing the first time):

picowota_build_standalone(my_executable_name)
picowota_build_combined(my_executable_name)

Note: The combined target will also build the standalone binary.

To be able to update your app, you must provide a way to return to the bootloader. By default, if GPIO15 is pulled low at boot time, then picowota will stay in bootloader mode, ready to receive new app code.

You can also return to the bootloader from your app code - for example when a button is pressed, or in response to some network request. The picowota_reboot library provides a picowota_reboot(bool to_bootloader) function, which your app can call to get back in to the bootloader.

CMakeLists.txt:

target_link_libraries(my_executable_name picowota_reboot)

your_c_code.c:

#include "picowota/reboot.h"

...

{

	...

	if (should_reboot_to_bootloader) {
		picowota_reboot(true);
	}

	...

}

Uploading code via picowota

Once you’ve got the picowota bootloader installed on your Pico, you can use the https://github.com/usedbytes/serial-flash tool to upload code to it.

As long as the Pico is “in” the picowota bootloader (i.e. because there’s no valid app code uploaded yet, or your app called picowota_reboot(true);), you can upload an app .elf file which was built by picowota_build_standalone():

(Assuming your Pico’s IP address is 192.168.1.123):

serial-flash tcp:192.168.1.123:4242 my_executable_name.elf

After uploading the code, if successful, the Pico will jump to the newly uploaded app.

How it works

This is derived from my Pico non-W bootloader, https://github.com/usedbytes/rp2040-serial-bootloader, which I wrote about in a blog post: https://blog.usedbytes.com/2021/12/pico-serial-bootloader/

The bootloader code attempts to avoid “bricking” by storing a CRC of the app code which gets uploaded. If the CRC doesn’t match, then the app won’t get run and the Pico will stay in picowota bootloader mode. This should make it fairly robust against errors in transfers etc.

Known issues

Bootloader/app size and cyw43 firmware

The WiFi chip on a Pico W needs firmware, which gets built in to any program you build with the Pico SDK. This is relatively large - 300-400 kB, which is why this bootloader is so large.

This gets duplicated in the picowota bootloader binary and also the app binary, which obviously uses up a significant chunk of the Pico’s 2 MB flash.

It would be nice to be able to avoid this duplication, but the Pico SDK libraries don’t give a mechanism to do so.

I’ve raised https://github.com/raspberrypi/pico-sdk/issues/928 for consideration.

Expose an access point, rather than connecting to one

It would perhaps be better if the bootloader set up an access point, rather than trying to connect to an existing network - or even better, provide the option. I expect that wouldn’t be too hard to do.