WIP: Rasperry Pi Connect library preview #3202

Draft
kilograham wants to merge 13 commits from rpi-connect-preview into develop
kilograham commented 2026-09-19 15:15:35 -05:00 (Migrated from github.com)

APIs and integrations are subject to change

APIs and integrations are subject to change
will-v-pi (Migrated from github.com) reviewed 2026-09-22 08:22:40 -05:00
@ -0,0 +984,4 @@
char sig_header[512];
snprintf(sig_header, sizeof(sig_header),
"X-Connect-Identity-Signature: %s", signature);
additional_headers = curl_slist_append(additional_headers, sig_header);
will-v-pi (Migrated from github.com) commented 2026-09-22 08:22:40 -05:00

I think this needs the Accept: */* header added, for on-device use?

    additional_headers = curl_slist_append(additional_headers, sig_header);
    additional_headers = curl_slist_append(additional_headers, "Accept: */*");
I think this needs the `Accept: */*` header added, for on-device use? ```suggestion additional_headers = curl_slist_append(additional_headers, sig_header); additional_headers = curl_slist_append(additional_headers, "Accept: */*"); ```
will-v-pi (Migrated from github.com) reviewed 2026-09-22 10:04:13 -05:00
@ -0,0 +875,4 @@
}
}
return 0;
}
will-v-pi (Migrated from github.com) commented 2026-09-22 10:04:13 -05:00

Keys should be ECC, not RAW - I've added picotool support in https://github.com/raspberrypi/picotool/pull/362 for picotool otp load -s 0xc0 device-priv-key.pem to go with this change

int rpi_connect_ota_read_identity_key_otp(unsigned int start_row, unsigned char out_key[32]) {
    volatile uint16_t *otp_data = (volatile uint16_t *)OTP_DATA_GUARDED_BASE;
    size_t key_offset = 0;
    unsigned int rows = 32 / 2; // 16 rows of 2 bytes

    for (unsigned int i = 0; i < rows && key_offset < 32; i++) {
        uint16_t row = otp_data[start_row + i];
        for (int b = 0; b < 2 && key_offset < 32; b++) {
            out_key[key_offset++] = (unsigned char)(row & 0xff);
            row >>= 8;
        }
    }
    return 0;
}
Keys should be ECC, not RAW - I've added `picotool` support in https://github.com/raspberrypi/picotool/pull/362 for `picotool otp load -s 0xc0 device-priv-key.pem` to go with this change ```suggestion int rpi_connect_ota_read_identity_key_otp(unsigned int start_row, unsigned char out_key[32]) { volatile uint16_t *otp_data = (volatile uint16_t *)OTP_DATA_GUARDED_BASE; size_t key_offset = 0; unsigned int rows = 32 / 2; // 16 rows of 2 bytes for (unsigned int i = 0; i < rows && key_offset < 32; i++) { uint16_t row = otp_data[start_row + i]; for (int b = 0; b < 2 && key_offset < 32; b++) { out_key[key_offset++] = (unsigned char)(row & 0xff); row >>= 8; } } return 0; } ```
will-v-pi (Migrated from github.com) reviewed 2026-09-22 10:49:38 -05:00
@ -0,0 +156,4 @@
return 0;
}
static char *ffs_get_string(uint8_t file_id) {
will-v-pi (Migrated from github.com) commented 2026-09-22 10:49:38 -05:00

This and ffs_update_string seem like useful functions (and is duplicated in the pico-example too) - could they be made public in the pico_ffs library instead?

Preferably with the change I suggested in pico-examples to use strndup(data, rc) instead, so it supports non-NUL-terminated strings, as those will be easier to provision

This and `ffs_update_string` seem like useful functions (and is duplicated in the pico-example too) - could they be made public in the `pico_ffs` library instead? Preferably with the change I suggested in pico-examples to use `strndup(data, rc)` instead, so it supports non-NUL-terminated strings, as those will be easier to provision
will-v-pi (Migrated from github.com) reviewed 2026-09-22 11:45:46 -05:00
will-v-pi (Migrated from github.com) commented 2026-09-22 11:45:46 -05:00

@lurch suggested there might be a better name for this function - given it just creates a UF2 that overwrites the first 4k of wherever it ends up (start of flash, a partition, or an offset) maybe pico_create_4k_overwrite_uf2?

function(pico_create_4k_overwrite_uf2 TARGET)
@lurch suggested there might be a better name for this function - given it just creates a UF2 that overwrites the first 4k of wherever it ends up (start of flash, a partition, or an offset) maybe `pico_create_4k_overwrite_uf2`? ```suggestion function(pico_create_4k_overwrite_uf2 TARGET) ```
will-v-pi (Migrated from github.com) reviewed 2026-09-23 08:35:28 -05:00
@ -0,0 +224,4 @@
uint32_t last_sector_number = LAST_SECTOR_NUMBER(uf2_target_partition.permissions_and_location);
uint32_t total_sector_count = 1 + last_sector_number - first_sector_number;
uint32_t maximum_code_size = FLASH_SECTOR_SIZE * total_sector_count;
uint32_t update_size = UF2_BLOCK_SIZE * fimg_state->total_num_blocks;
will-v-pi (Migrated from github.com) commented 2026-09-23 08:35:28 -05:00

This should be UF2_DATA_PAGE_SIZE, as that's the size of the actual data being written

    uint32_t update_size = UF2_DATA_PAGE_SIZE * fimg_state->total_num_blocks;
This should be `UF2_DATA_PAGE_SIZE`, as that's the size of the actual data being written ```suggestion uint32_t update_size = UF2_DATA_PAGE_SIZE * fimg_state->total_num_blocks; ```
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'rpi-connect-preview:rpi-connect-preview'
git switch 'rpi-connect-preview'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'develop'
git merge --no-ff 'rpi-connect-preview'
git switch 'rpi-connect-preview'
git rebase 'develop'
git switch 'develop'
git merge --ff-only 'rpi-connect-preview'
git switch 'rpi-connect-preview'
git rebase 'develop'
git switch 'develop'
git merge --no-ff 'rpi-connect-preview'
git switch 'develop'
git merge --squash 'rpi-connect-preview'
git switch 'develop'
git merge --ff-only 'rpi-connect-preview'
git switch 'develop'
git merge 'rpi-connect-preview'
git push origin 'develop'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!3202
No description provided.