Browse Source

reset to ota function

Thomas Buck 5 months ago
parent
commit
f0aafe0ba3
7 changed files with 14 additions and 14 deletions
  1. 1
    0
      include/util.h
  2. 1
    2
      src/console.c
  3. 0
    1
      src/mem.c
  4. 2
    0
      src/state_about.c
  5. 2
    2
      src/state_scan.c
  6. 2
    3
      src/state_settings.c
  7. 6
    6
      src/util.c

+ 1
- 0
include/util.h View File

26
 
26
 
27
 bool str_startswith(const char *str, const char *start);
27
 bool str_startswith(const char *str, const char *start);
28
 
28
 
29
+void reset_to_ota(void);
29
 void reset_to_bootloader(void);
30
 void reset_to_bootloader(void);
30
 void reset_to_main(void);
31
 void reset_to_main(void);
31
 
32
 

+ 1
- 2
src/console.c View File

23
 
23
 
24
 #include "pico/stdlib.h"
24
 #include "pico/stdlib.h"
25
 #include "hardware/watchdog.h"
25
 #include "hardware/watchdog.h"
26
-#include "picowota/reboot.h"
27
 
26
 
28
 #include "config.h"
27
 #include "config.h"
29
 #include "log.h"
28
 #include "log.h"
139
     } else if (strcmp(line, "reset") == 0) {
138
     } else if (strcmp(line, "reset") == 0) {
140
         reset_to_main();
139
         reset_to_main();
141
     } else if (strcmp(line, "ota") == 0) {
140
     } else if (strcmp(line, "ota") == 0) {
142
-        picowota_reboot(true);
141
+        reset_to_ota();
143
     } else if (strcmp(line, "mount") == 0) {
142
     } else if (strcmp(line, "mount") == 0) {
144
         bool state = msc_is_medium_available();
143
         bool state = msc_is_medium_available();
145
         println("Currently %s. %s now.",
144
         println("Currently %s. %s now.",

+ 0
- 1
src/mem.c View File

114
         } else {
114
         } else {
115
             debug("loading from flash (0x%08lX)", checksum);
115
             debug("loading from flash (0x%08lX)", checksum);
116
             data_ram = *flash_ptr;
116
             data_ram = *flash_ptr;
117
-            debug("%s", data_ram.data.net[0].pass);
118
         }
117
         }
119
     } else {
118
     } else {
120
         debug("invalid config (0x%02X != 0x%02X)", flash_ptr->version, MEM_VERSION);
119
         debug("invalid config (0x%02X != 0x%02X)", flash_ptr->version, MEM_VERSION);

+ 2
- 0
src/state_about.c View File

53
     "bluekitchen/btstack\n"
53
     "bluekitchen/btstack\n"
54
     "mcufont/mcufont\n"
54
     "mcufont/mcufont\n"
55
     "hepingood/st7789\n"
55
     "hepingood/st7789\n"
56
+    "usedbytes/picowota\n"
57
+    "lwip-tcpip/lwip\n"
56
     "\n"
58
     "\n"
57
 
59
 
58
     "This program is free software: you can redistribute it and/or modify "
60
     "This program is free software: you can redistribute it and/or modify "

+ 2
- 2
src/state_scan.c View File

20
 #include <string.h>
20
 #include <string.h>
21
 
21
 
22
 #include "pico/stdlib.h"
22
 #include "pico/stdlib.h"
23
-#include "picowota/reboot.h"
24
 
23
 
25
 #include "config.h"
24
 #include "config.h"
26
 #include "ble.h"
25
 #include "ble.h"
27
 #include "models.h"
26
 #include "models.h"
28
 #include "mem.h"
27
 #include "mem.h"
29
 #include "menu.h"
28
 #include "menu.h"
29
+#include "util.h"
30
 #include "state.h"
30
 #include "state.h"
31
 #include "state_workflow.h"
31
 #include "state_workflow.h"
32
 #include "state_volcano_run.h"
32
 #include "state_volcano_run.h"
103
 
103
 
104
 static void ota_cb(int selection) {
104
 static void ota_cb(int selection) {
105
     UNUSED(selection);
105
     UNUSED(selection);
106
-    picowota_reboot(true);
106
+    reset_to_ota();
107
 }
107
 }
108
 
108
 
109
 void state_scan_enter(void) {
109
 void state_scan_enter(void) {

+ 2
- 3
src/state_settings.c View File

19
 #include <stdio.h>
19
 #include <stdio.h>
20
 #include <string.h>
20
 #include <string.h>
21
 
21
 
22
-#include "picowota/reboot.h"
23
-
24
 #include "config.h"
22
 #include "config.h"
25
 #include "log.h"
23
 #include "log.h"
26
 #include "main.h"
24
 #include "main.h"
27
 #include "menu.h"
25
 #include "menu.h"
28
 #include "mem.h"
26
 #include "mem.h"
27
+#include "util.h"
29
 #include "state.h"
28
 #include "state.h"
30
 #include "state_value.h"
29
 #include "state_value.h"
31
 #include "state_workflow.h"
30
 #include "state_workflow.h"
85
 
84
 
86
     case 6:
85
     case 6:
87
         // OTA Update
86
         // OTA Update
88
-        picowota_reboot(true);
87
+        reset_to_ota();
89
         break;
88
         break;
90
 
89
 
91
     default:
90
     default:

+ 6
- 6
src/util.c View File

19
 #include <string.h>
19
 #include <string.h>
20
 #include "pico/stdlib.h"
20
 #include "pico/stdlib.h"
21
 #include "pico/bootrom.h"
21
 #include "pico/bootrom.h"
22
-#include "hardware/watchdog.h"
22
+#include "picowota/reboot.h"
23
 
23
 
24
 #ifdef CYW43_WL_GPIO_LED_PIN
24
 #ifdef CYW43_WL_GPIO_LED_PIN
25
 #include "pico/cyw43_arch.h"
25
 #include "pico/cyw43_arch.h"
81
 #endif // PICO_DEFAULT_LED_PIN
81
 #endif // PICO_DEFAULT_LED_PIN
82
 }
82
 }
83
 
83
 
84
+void reset_to_ota(void) {
85
+    picowota_reboot(true);
86
+}
87
+
84
 void reset_to_main(void) {
88
 void reset_to_main(void) {
85
-    watchdog_enable(1, 1);
86
-    while (1) {
87
-        // wait 1ms until watchdog kills us
88
-        asm volatile("nop");
89
-    }
89
+    picowota_reboot(false);
90
 }
90
 }
91
 
91
 
92
 void hexdump(const uint8_t *buff, size_t len) {
92
 void hexdump(const uint8_t *buff, size_t len) {

Loading…
Cancel
Save