Skip to content

Commit b250973

Browse files
committed
fw: Add 'bootloader' command to enter UF2 bootloader mode
- Add reset_usb_boot() extern C declaration - Implement enterUf2Bootloader() function - Add 'bootloader' serial command for remote firmware updates - Device enters UF2 bootloader mode without physical button press
1 parent bc8aa8b commit b250973

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fw/src/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#include "amsky01_utils.h"
99
#include "config.h"
1010

11+
// RP2040 bootloader reset function
12+
extern "C" {
13+
void reset_usb_boot(uint32_t usb_activity_gpio_mask, uint32_t disable_interface_mask);
14+
}
15+
1116
// Firmware and hardware version info
1217
#define DEVICE_NAME "AMSKY01A"
1318
#define FW_VERSION BUILD_VERSION
@@ -48,6 +53,14 @@ const unsigned long MEASUREMENT_INTERVAL = 2000; // 2 seconds
4853
// Režim posílání celé IR mapy po UARTu
4954
bool thrmap_streaming = false;
5055

56+
// Enter UF2 bootloader mode
57+
static void enterUf2Bootloader() {
58+
Serial.println("# Entering UF2 bootloader mode...");
59+
Serial.flush();
60+
delay(100);
61+
reset_usb_boot(0, 0); // Reset to UF2 bootloader in ROM
62+
}
63+
5164
static void processSerialCommand(const char *cmd)
5265
{
5366
if (strcmp(cmd, "thrmap_on") == 0)
@@ -72,6 +85,10 @@ static void processSerialCommand(const char *cmd)
7285
{
7386
configManager.reset();
7487
}
88+
else if (strcmp(cmd, "bootloader") == 0)
89+
{
90+
enterUf2Bootloader();
91+
}
7592
else if (strncmp(cmd, "set ", 4) == 0)
7693
{
7794
// Parse "set <param> <value>" commands

0 commit comments

Comments
 (0)