|
@@ -28,6 +28,8 @@
|
28
|
28
|
|
29
|
29
|
#include "tcp_comm.h"
|
30
|
30
|
|
|
31
|
+#include "picowota/reboot.h"
|
|
32
|
+
|
31
|
33
|
#ifdef DEBUG
|
32
|
34
|
#include <stdio.h>
|
33
|
35
|
#include "pico/stdio_usb.h"
|
|
@@ -64,7 +66,6 @@ struct event {
|
64
|
66
|
};
|
65
|
67
|
|
66
|
68
|
#define BOOTLOADER_ENTRY_PIN 15
|
67
|
|
-#define BOOTLOADER_ENTRY_MAGIC 0xb105f00d
|
68
|
69
|
|
69
|
70
|
#define TCP_PORT 4242
|
70
|
71
|
|
|
@@ -501,23 +502,6 @@ const struct comm_command info_cmd = {
|
501
|
502
|
.handle = &handle_info,
|
502
|
503
|
};
|
503
|
504
|
|
504
|
|
-static void do_reboot(bool to_bootloader)
|
505
|
|
-{
|
506
|
|
- hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
|
507
|
|
- if (to_bootloader) {
|
508
|
|
- watchdog_hw->scratch[5] = BOOTLOADER_ENTRY_MAGIC;
|
509
|
|
- watchdog_hw->scratch[6] = ~BOOTLOADER_ENTRY_MAGIC;
|
510
|
|
- } else {
|
511
|
|
- watchdog_hw->scratch[5] = 0;
|
512
|
|
- watchdog_hw->scratch[6] = 0;
|
513
|
|
- }
|
514
|
|
- watchdog_reboot(0, 0, 0);
|
515
|
|
- while (1) {
|
516
|
|
- tight_loop_contents();
|
517
|
|
- asm("");
|
518
|
|
- }
|
519
|
|
-}
|
520
|
|
-
|
521
|
505
|
static uint32_t size_reboot(uint32_t *args_in, uint32_t *data_len_out, uint32_t *resp_data_len_out)
|
522
|
506
|
{
|
523
|
507
|
*data_len_out = 0;
|
|
@@ -554,8 +538,8 @@ struct comm_command reboot_cmd = {
|
554
|
538
|
|
555
|
539
|
static bool should_stay_in_bootloader()
|
556
|
540
|
{
|
557
|
|
- bool wd_says_so = (watchdog_hw->scratch[5] == BOOTLOADER_ENTRY_MAGIC) &&
|
558
|
|
- (watchdog_hw->scratch[6] == ~BOOTLOADER_ENTRY_MAGIC);
|
|
541
|
+ bool wd_says_so = (watchdog_hw->scratch[5] == PICOWOTA_BOOTLOADER_ENTRY_MAGIC) &&
|
|
542
|
+ (watchdog_hw->scratch[6] == ~PICOWOTA_BOOTLOADER_ENTRY_MAGIC);
|
559
|
543
|
|
560
|
544
|
return !gpio_get(BOOTLOADER_ENTRY_PIN) || wd_says_so;
|
561
|
545
|
}
|
|
@@ -633,7 +617,7 @@ int main()
|
633
|
617
|
case EVENT_TYPE_REBOOT:
|
634
|
618
|
tcp_comm_server_close(tcp);
|
635
|
619
|
cyw43_arch_deinit();
|
636
|
|
- do_reboot(ev.reboot.to_bootloader);
|
|
620
|
+ picowota_reboot(ev.reboot.to_bootloader);
|
637
|
621
|
/* Should never get here */
|
638
|
622
|
break;
|
639
|
623
|
case EVENT_TYPE_GO:
|