Sfoglia il codice sorgente

add picowota bootloader

Thomas Buck 11 mesi fa
parent
commit
d2823cde66
7 ha cambiato i file con 58 aggiunte e 5 eliminazioni
  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 Vedi File

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

+ 7
- 2
CMakeLists.txt Vedi File

@@ -159,6 +159,7 @@ target_link_libraries(gadget
159 159
     pico_cyw43_arch_threadsafe_background
160 160
     hardware_flash
161 161
     pico_flash
162
+    picowota_reboot
162 163
 )
163 164
 
164 165
 target_compile_definitions(gadget PUBLIC
@@ -171,5 +172,9 @@ pico_set_linker_script(gadget ${CMAKE_CURRENT_SOURCE_DIR}/src/memmap_custom.ld)
171 172
 # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
172 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 Vedi File

@@ -123,6 +123,7 @@ Some code is adapted from the TinyUSB examples.
123 123
 And the project uses the [FatFS library](https://github.com/abbrev/fatfs), licensed as BSD 1-clause.
124 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 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 128
 The case design is also licensed as GPLv3.
128 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 Vedi File

@@ -0,0 +1,26 @@
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 Vedi File

@@ -23,6 +23,7 @@
23 23
 
24 24
 #include "pico/stdlib.h"
25 25
 #include "hardware/watchdog.h"
26
+#include "picowota/reboot.h"
26 27
 
27 28
 #include "config.h"
28 29
 #include "log.h"
@@ -96,6 +97,7 @@ static void cnsl_interpret(const char *line) {
96 97
         println("");
97 98
         println("  reset - reset back into this firmware");
98 99
         println("   \\x18 - reset to bootloader");
100
+        println("    ota - reset to ota bootloader");
99 101
         println(" repeat - repeat last command every %d milliseconds", CNSL_REPEAT_MS);
100 102
         println("   help - print this message");
101 103
         println("  mount - make mass storage medium (un)available");
@@ -135,6 +137,8 @@ static void cnsl_interpret(const char *line) {
135 137
         println("Stop this by calling repeat again.");
136 138
     } else if (strcmp(line, "reset") == 0) {
137 139
         reset_to_main();
140
+    } else if (strcmp(line, "ota") == 0) {
141
+        picowota_reboot(true);
138 142
     } else if (strcmp(line, "mount") == 0) {
139 143
         bool state = msc_is_medium_available();
140 144
         println("Currently %s. %s now.",

+ 7
- 1
src/state_scan.c Vedi File

@@ -20,6 +20,7 @@
20 20
 #include <string.h>
21 21
 
22 22
 #include "pico/stdlib.h"
23
+#include "picowota/reboot.h"
23 24
 
24 25
 #include "config.h"
25 26
 #include "ble.h"
@@ -100,8 +101,13 @@ static void edit_cb(int selection) {
100 101
     }
101 102
 }
102 103
 
104
+static void ota_cb(int selection) {
105
+    UNUSED(selection);
106
+    picowota_reboot(true);
107
+}
108
+
103 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 111
     ble_scan(BLE_SCAN_ON);
106 112
 }
107 113
 

+ 10
- 2
src/state_settings.c Vedi File

@@ -19,6 +19,8 @@
19 19
 #include <stdio.h>
20 20
 #include <string.h>
21 21
 
22
+#include "picowota/reboot.h"
23
+
22 24
 #include "config.h"
23 25
 #include "log.h"
24 26
 #include "menu.h"
@@ -51,15 +53,20 @@ static void enter_cb(int selection) {
51 53
         break;
52 54
 
53 55
     case 2:
54
-        // Workflows
56
+        // Edit Workflows
55 57
         state_wf_edit(true);
56 58
         state_switch(STATE_WORKFLOW);
57 59
         break;
58 60
 
59 61
     case 3:
60
-        // Reset
62
+        // Factory Reset
61 63
         mem_load_defaults();
62 64
         break;
65
+
66
+    case 4:
67
+        // OTA Update
68
+        picowota_reboot(true);
69
+        break;
63 70
     }
64 71
 }
65 72
 
@@ -84,6 +91,7 @@ static void draw(struct menu_state *menu) {
84 91
     ADD_STATIC_ELEMENT("Brightness (%d)", __builtin_ffs(mem_data()->backlight));
85 92
     ADD_STATIC_ELEMENT("Edit Workflows");
86 93
     ADD_STATIC_ELEMENT("Factory Reset");
94
+    ADD_STATIC_ELEMENT("OTA Update");
87 95
 
88 96
     if (menu->selection < 0) {
89 97
         menu->selection = 0;

Loading…
Annulla
Salva