Made everything needed to update firmware. Added the bundle to upload both front and backendin a bundle. Added magic number for more safety

This commit is contained in:
2026-03-03 22:45:41 -05:00
parent fdb13d62d4
commit 85dc698a8d
17 changed files with 467 additions and 44 deletions

View File

@@ -0,0 +1,59 @@
# Universal OTA Bundle
The Universal OTA Bundle allows you to update both the **Firmware** and the **Frontend** of the Calendink Provider in a single operation. This ensures that your UI and backend logic are always in sync.
## 1. How it Works
The bundle is a custom `.bundle` file that contains:
1. A **12-byte header** (Magic `BNDL`, FW size, UI size).
2. The **Firmware binary** (`Provider.bin`).
3. The **Frontend LittleFS binary** (`www_v*.bin`).
The ESP32 backend streams this file, writing the firmware to the next OTA slot and the frontend to the inactive `www` partition. It only commits the update if both parts are written successfully.
## 2. Prerequisites
- You have a working [Frontend Build Environment](build_frontend.md).
- You have the [ESP-IDF SDK](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) installed for firmware compilation.
## 3. Creating a Bundle
To create a new bundle, follow these steps in order:
### Step A: Build the Frontend
Inside the `frontend/` directory:
```bash
npm run build:esp32
```
### Step B: Build the Firmware
From the project **root** directory:
```bash
idf.py build
```
### Step C: Generate the Bundle
Inside the `frontend/` directory:
```bash
npm run ota:bundle
```
> [!NOTE]
> `npm run ota:bundle` now automatically runs `npm run ota:package` first to ensure the latest Svelte build is turned into a LittleFS image before bundling.
The output will be saved in `frontend/bundles/` with a name like `universal_v0.1.11.bundle`.
## 4. Flashing the Bundle
1. Open the Calendink Provider Dashboard in your browser.
2. Navigate to the **System Updates** section.
3. Click the **Universal Bundle** button.
4. Drag and drop your `.bundle` file into the upload area.
5. Click **Update**.
The device will reboot once the upload is complete. You can verify the update by checking the version numbers and the UI changes (like the number of rockets in the header!).
## 5. Troubleshooting
- **"Invalid bundle magic"**: Ensure you are uploading a `.bundle` file, not a `.bin`.
- **"Firmware part is corrupted"**: The bundle was likely created while the firmware build was incomplete or failed.
- **Old UI appearing**: Ensure you ran `npm run build:esp32` *before* `npm run ota:bundle`.

View File

@@ -80,3 +80,9 @@ Once the backend supports it (Phase 2+), you can update the frontend without usi
- Go to the **Frontend Update** section.
- Select the `www.bin` file and click **Flash**.
- The device will automatically write to the inactive partition and reboot.
## 6. Universal OTA Bundle
For a safer and more convenient update experience, you can bundle both the Firmware and Frontend into a single file.
See the [Universal OTA Bundle Guide](build_bundle.md) for details.