Browse Source

add picowota bootloader

Thomas Buck 11 months ago
parent
commit
d2823cde66
7 changed files with 58 additions and 5 deletions
  1. 3
    0
      .gitmodules
  2. 7
    2
      CMakeLists.txt
  3. 1
    0
      README.md
  4. 26
    0
      flash_ota.sh
  5. 4
    0
      src/console.c
  6. 7
    1
      src/state_scan.c
  7. 10
    2
      src/state_settings.c

+ 3
- 0
.gitmodules View File

10
 [submodule "st7789"]
10
 [submodule "st7789"]
11
 	path = st7789
11
 	path = st7789
12
 	url = https://github.com/hepingood/st7789
12
 	url = https://github.com/hepingood/st7789
13
+[submodule "picowota"]
14
+	path = picowota
15
+	url = https://github.com/usedbytes/picowota

+ 7
- 2
CMakeLists.txt View File

159
     pico_cyw43_arch_threadsafe_background
159
     pico_cyw43_arch_threadsafe_background
160
     hardware_flash
160
     hardware_flash
161
     pico_flash
161
     pico_flash
162
+    picowota_reboot
162
 )
163
 )
163
 
164
 
164
 target_compile_definitions(gadget PUBLIC
165
 target_compile_definitions(gadget PUBLIC
171
 # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
172
 # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
172
 target_compile_definitions(gadget PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
173
 target_compile_definitions(gadget PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
173
 
174
 
174
-# create map/bin/hex/uf2 file etc.
175
-pico_add_extra_outputs(gadget)
175
+set(PICOWOTA_WIFI_SSID "WIFI_SSID_HERE")
176
+set(PICOWOTA_WIFI_PASS "WIFI_PASS_HERE")
177
+set(PICOWOTA_WIFI_AP 0)
178
+
179
+add_subdirectory(picowota)
180
+picowota_build_combined(gadget)

+ 1
- 0
README.md View File

123
 And the project uses the [FatFS library](https://github.com/abbrev/fatfs), licensed as BSD 1-clause.
123
 And the project uses the [FatFS library](https://github.com/abbrev/fatfs), licensed as BSD 1-clause.
124
 Also included are the [MCUFont library](https://github.com/mcufont/mcufont) and the [st7789 library](https://github.com/hepingood/st7789), both licensed under the MIT license.
124
 Also included are the [MCUFont library](https://github.com/mcufont/mcufont) and the [st7789 library](https://github.com/hepingood/st7789), both licensed under the MIT license.
125
 It also uses the [BTstack](https://github.com/bluekitchen/btstack/blob/master/LICENSE) included with the Pico SDK, following their [license terms](https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_btstack/LICENSE.RP).
125
 It also uses the [BTstack](https://github.com/bluekitchen/btstack/blob/master/LICENSE) included with the Pico SDK, following their [license terms](https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_btstack/LICENSE.RP).
126
+The included bootloader is [picowota](https://github.com/usedbytes/picowota), licensed as BSD 3-clause.
126
 
127
 
127
 The case design is also licensed as GPLv3.
128
 The case design is also licensed as GPLv3.
128
 It uses a [Pi Pico case model](https://www.printables.com/model/210898-raspberry-pi-pico-case) licensed as CC-BY-NC-SA.
129
 It uses a [Pi Pico case model](https://www.printables.com/model/210898-raspberry-pi-pico-case) licensed as CC-BY-NC-SA.

+ 26
- 0
flash_ota.sh View File

1
+#!/bin/bash
2
+
3
+# ----------------------------------------------------------------------------
4
+# Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
5
+#
6
+# This program is free software: you can redistribute it and/or modify
7
+# it under the terms of the GNU General Public License as published by
8
+# the Free Software Foundation, either version 3 of the License, or
9
+# (at your option) any later version.
10
+#
11
+# This program is distributed in the hope that it will be useful,
12
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+# GNU General Public License for more details.
15
+#
16
+# See <http://www.gnu.org/licenses/>.
17
+# ----------------------------------------------------------------------------
18
+
19
+set -euo pipefail
20
+
21
+# TODO wait for device to be ready
22
+
23
+echo Copying binary
24
+~/go/bin/serial-flash tcp:$1:4242 $2
25
+
26
+echo Done

+ 4
- 0
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"
26
 
27
 
27
 #include "config.h"
28
 #include "config.h"
28
 #include "log.h"
29
 #include "log.h"
96
         println("");
97
         println("");
97
         println("  reset - reset back into this firmware");
98
         println("  reset - reset back into this firmware");
98
         println("   \\x18 - reset to bootloader");
99
         println("   \\x18 - reset to bootloader");
100
+        println("    ota - reset to ota bootloader");
99
         println(" repeat - repeat last command every %d milliseconds", CNSL_REPEAT_MS);
101
         println(" repeat - repeat last command every %d milliseconds", CNSL_REPEAT_MS);
100
         println("   help - print this message");
102
         println("   help - print this message");
101
         println("  mount - make mass storage medium (un)available");
103
         println("  mount - make mass storage medium (un)available");
135
         println("Stop this by calling repeat again.");
137
         println("Stop this by calling repeat again.");
136
     } else if (strcmp(line, "reset") == 0) {
138
     } else if (strcmp(line, "reset") == 0) {
137
         reset_to_main();
139
         reset_to_main();
140
+    } else if (strcmp(line, "ota") == 0) {
141
+        picowota_reboot(true);
138
     } else if (strcmp(line, "mount") == 0) {
142
     } else if (strcmp(line, "mount") == 0) {
139
         bool state = msc_is_medium_available();
143
         bool state = msc_is_medium_available();
140
         println("Currently %s. %s now.",
144
         println("Currently %s. %s now.",

+ 7
- 1
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"
23
 
24
 
24
 #include "config.h"
25
 #include "config.h"
25
 #include "ble.h"
26
 #include "ble.h"
100
     }
101
     }
101
 }
102
 }
102
 
103
 
104
+static void ota_cb(int selection) {
105
+    UNUSED(selection);
106
+    picowota_reboot(true);
107
+}
108
+
103
 void state_scan_enter(void) {
109
 void state_scan_enter(void) {
104
-    menu_init(enter_cb, edit_cb, NULL, NULL);
110
+    menu_init(enter_cb, edit_cb, ota_cb, NULL);
105
     ble_scan(BLE_SCAN_ON);
111
     ble_scan(BLE_SCAN_ON);
106
 }
112
 }
107
 
113
 

+ 10
- 2
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
+
22
 #include "config.h"
24
 #include "config.h"
23
 #include "log.h"
25
 #include "log.h"
24
 #include "menu.h"
26
 #include "menu.h"
51
         break;
53
         break;
52
 
54
 
53
     case 2:
55
     case 2:
54
-        // Workflows
56
+        // Edit Workflows
55
         state_wf_edit(true);
57
         state_wf_edit(true);
56
         state_switch(STATE_WORKFLOW);
58
         state_switch(STATE_WORKFLOW);
57
         break;
59
         break;
58
 
60
 
59
     case 3:
61
     case 3:
60
-        // Reset
62
+        // Factory Reset
61
         mem_load_defaults();
63
         mem_load_defaults();
62
         break;
64
         break;
65
+
66
+    case 4:
67
+        // OTA Update
68
+        picowota_reboot(true);
69
+        break;
63
     }
70
     }
64
 }
71
 }
65
 
72
 
84
     ADD_STATIC_ELEMENT("Brightness (%d)", __builtin_ffs(mem_data()->backlight));
91
     ADD_STATIC_ELEMENT("Brightness (%d)", __builtin_ffs(mem_data()->backlight));
85
     ADD_STATIC_ELEMENT("Edit Workflows");
92
     ADD_STATIC_ELEMENT("Edit Workflows");
86
     ADD_STATIC_ELEMENT("Factory Reset");
93
     ADD_STATIC_ELEMENT("Factory Reset");
94
+    ADD_STATIC_ELEMENT("OTA Update");
87
 
95
 
88
     if (menu->selection < 0) {
96
     if (menu->selection < 0) {
89
         menu->selection = 0;
97
         menu->selection = 0;

Loading…
Cancel
Save