Skip to content

Commit 042947e

Browse files
committed
Fix Risc-V alignment & stack issues
1 parent 3dc381f commit 042947e

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pico_w/wifi/ota_update/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pico_use_wifi_firmware_partition(picow_ota_update_poll)
4949

5050
pico_hash_binary(picow_ota_update_poll)
5151
pico_sign_binary(picow_ota_update_poll ${CMAKE_CURRENT_LIST_DIR}/private.pem)
52-
# pico_set_binary_type(picow_ota_update_background no_flash)
53-
# pico_package_uf2_output(picow_ota_update_background 0x10000000)
52+
# pico_set_binary_type(picow_ota_update_poll no_flash)
53+
# pico_package_uf2_output(picow_ota_update_poll 0x10000000)
5454

5555
pico_add_extra_outputs(picow_ota_update_poll)

pico_w/wifi/ota_update/picow_ota_update.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ typedef struct TCP_UPDATE_SERVER_T_ {
3030
struct tcp_pcb *server_pcb;
3131
struct tcp_pcb *client_pcb;
3232
bool complete;
33-
uint8_t buffer_sent[SHA256_RESULT_BYTES];
34-
uint8_t buffer_recv[BUF_SIZE];
33+
__attribute__((aligned(4))) uint8_t buffer_sent[SHA256_RESULT_BYTES];
34+
__attribute__((aligned(4))) uint8_t buffer_recv[BUF_SIZE];
3535
int sent_len;
3636
int recv_len;
3737
int num_blocks;
@@ -300,6 +300,15 @@ static bool tcp_update_server_open(void *arg) {
300300
int main() {
301301
stdio_init_all();
302302

303+
#ifdef __riscv
304+
// Increased bootrom stack is required for some of the functions in this example
305+
bootrom_stack_t stack = {
306+
.base = malloc(0x400),
307+
.size = 0x400
308+
};
309+
rom_set_bootrom_stack(&stack);
310+
#endif
311+
303312
if (cyw43_arch_init()) {
304313
printf("failed to initialise\n");
305314
return 1;

0 commit comments

Comments
 (0)