Skip to content
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

Pico 2 W OTA Update Example #559

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function(add_subdirectory_exclude_platforms NAME)
add_subdirectory(${NAME})
endfunction()

# Set signing file for entire project
set_property(GLOBAL PROPERTY PICOTOOL_SIGFILE "${CMAKE_CURRENT_LIST_DIR}/sample_keys/private.pem")

# Add blink example
add_subdirectory_exclude_platforms(blink)
add_subdirectory_exclude_platforms(blink_simple)
Expand Down
4 changes: 2 additions & 2 deletions bootloaders/encrypted/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_linker_script(enc_bootloader "0x20070000" "64k")
pico_set_otp_key_output_file(enc_bootloader ${CMAKE_CURRENT_BINARY_DIR}/otp.json)

# sign, hash, and clear SRAM
pico_sign_binary(enc_bootloader ${CMAKE_CURRENT_LIST_DIR}/private.pem)
pico_sign_binary(enc_bootloader)
pico_hash_binary(enc_bootloader)
pico_load_map_clear_sram(enc_bootloader)

Expand Down Expand Up @@ -87,7 +87,7 @@ pico_set_binary_type(hello_serial_enc no_flash)
add_linker_script(hello_serial_enc "0x20000000" "448k")

# sign, hash, and encrypt
pico_sign_binary(hello_serial_enc ${CMAKE_CURRENT_LIST_DIR}/private.pem)
pico_sign_binary(hello_serial_enc)
pico_hash_binary(hello_serial_enc)
pico_encrypt_binary(hello_serial_enc ${CMAKE_CURRENT_LIST_DIR}/privateaes.bin)

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)
# 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)
# 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_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": "240K",
"families": ["data"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
},
"ignored_during_riscv_boot": true,
"no_reboot_on_uf2_download": true
},
{
"name": "Firmware B",
"id": 12345,
"size": "240K",
"families": ["data"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
},
"link": ["a", 2],
"ignored_during_riscv_boot": true,
"no_reboot_on_uf2_download": true
}
]
}
Loading