Skip to content

Pico 2 W OTA Update Example #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ App|Description
[picow_http_client](pico_w/wifi/http_client) | Demonstrates how to make http and https requests
[picow_http_client_verify](pico_w/wifi/http_client) | Demonstrates how to make a https request with server authentication
[picow_mqtt_client](pico_w/wifi/mqtt) | Demonstrates how to implement a MQTT client application
[picow_ota_update](pico_w/wifi/ota_update) | A simple OTA update server (RP235x Only). You can run [python_ota_update.py](pico_w/wifi/python_test_tcp/python_ota_update.py) to upload UF2s to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid the word "Simple" - maybe "minimal"


#### FreeRTOS examples

Expand Down
3 changes: 2 additions & 1 deletion pico_w/wifi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ else()
add_subdirectory_exclude_platforms(mqtt)

if (NOT PICO_MBEDTLS_PATH)
message("Skipping tls examples as PICO_MBEDTLS_PATH is not defined")
message("Skipping some examples as PICO_MBEDTLS_PATH is not defined")
else()
add_subdirectory_exclude_platforms(tls_client)
add_subdirectory_exclude_platforms(ota_update rp2040)
endif()
endif()
55 changes: 55 additions & 0 deletions pico_w/wifi/ota_update/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
add_executable(picow_ota_update_background
picow_ota_update.c
)
target_compile_definitions(picow_ota_update_background PRIVATE
WIFI_SSID=\"${WIFI_SSID}\"
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
PICO_CRT0_IMAGE_TYPE_TBYB=1
)
target_include_directories(picow_ota_update_background PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
)
target_link_libraries(picow_ota_update_background
pico_cyw43_arch_lwip_threadsafe_background
pico_stdlib
pico_sha256
boot_uf2_headers
)

pico_use_wifi_firmware_partition(picow_ota_update_background)

pico_hash_binary(picow_ota_update_background)
pico_sign_binary(picow_ota_update_background ${CMAKE_CURRENT_LIST_DIR}/private.pem)
# pico_set_binary_type(picow_ota_update_background no_flash)
# pico_package_uf2_output(picow_ota_update_background 0x10000000)

pico_add_extra_outputs(picow_ota_update_background)

add_executable(picow_ota_update_poll
picow_ota_update.c
)
target_compile_definitions(picow_ota_update_poll PRIVATE
WIFI_SSID=\"${WIFI_SSID}\"
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
PICO_CRT0_IMAGE_TYPE_TBYB=1
)
target_include_directories(picow_ota_update_poll PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
)
target_link_libraries(picow_ota_update_poll
pico_cyw43_arch_lwip_poll
pico_stdlib
pico_sha256
boot_uf2_headers
)

pico_use_wifi_firmware_partition(picow_ota_update_poll)

pico_hash_binary(picow_ota_update_poll)
pico_sign_binary(picow_ota_update_poll ${CMAKE_CURRENT_LIST_DIR}/private.pem)
# pico_set_binary_type(picow_ota_update_poll no_flash)
# pico_package_uf2_output(picow_ota_update_poll 0x10000000)

pico_add_extra_outputs(picow_ota_update_poll)
10 changes: 10 additions & 0 deletions pico_w/wifi/ota_update/lwipopts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef _LWIPOPTS_H
#define _LWIPOPTS_H

// Generally you would define your own explicit list of lwIP options
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
//
// This example uses a common include to avoid repetition
#include "lwipopts_examples_common.h"

#endif
64 changes: 64 additions & 0 deletions pico_w/wifi/ota_update/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"version": [1, 0],
"unpartitioned": {
"families": ["absolute"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
}
},
"partitions": [
{
"name": "Main A",
"id": 0,
"size": "1744K",
"families": ["rp2350-arm-s", "rp2350-riscv"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
}
},
{
"name": "Main B",
"id": 0,
"size": "1744K",
"families": ["rp2350-arm-s", "rp2350-riscv"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
},
"link": ["a", 0]
},
{
"name": "Firmware A",
"id": "0x776966696669726d",
"start": "3500k",
"size": "256K",
"families": ["cyw43-firmware"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
},
"ignored_during_riscv_boot": true,
"no_reboot_on_uf2_download": true
},
{
"name": "Firmware B",
"id": 12345,
"size": "256K",
"families": ["cyw43-firmware"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
},
"link": ["a", 2],
"ignored_during_riscv_boot": true,
"no_reboot_on_uf2_download": true
}
]
}
Loading