Transform workspace into OpenKE Stock USB Installer generator (v1.0.0)

This commit is contained in:
Dark98
2026-09-24 00:16:18 +00:00
parent c0dd058ae7
commit 6a43841867
17 changed files with 1218 additions and 1132 deletions
+61 -69
View File
@@ -1,69 +1,61 @@
# Ender-3 V3 KE Firmware Notes
## Stock firmware source
- Downloaded official image: `Ender-3_V3_KE_F005_ota_img_V1.1.0.17.img`
- Official version: `V1.1.0.17`
- Manifest layers inside the archive:
- `xImage` (`kernel`)
- `rootfs.squashfs` (`rootfs`)
- `zero.bin` (`rtos`)
## 7z archive password
The official Creality firmware archive is password-protected.
Password:
`$1$cxswfile$ZFd0RWFYkJQugbtKVGL9y0`
## Workspace layout
- Stock archive cache: `./Ender-3_V3_KE_F005_ota_img_V1.1.0.17.img`
- Overlay tree for our changes: `./overlay_rootfs/`
- Build cache: `./build/_toolcache/squashfs-tools-ng-1.3.2-mingw64/`
- Temporary build workspace: whichever directory you pass with `--build-dir`
## Useful edit points in the stock rootfs
- Klipper startup/service hook: `rootfs_extract/etc/init.d/S55klipper_service`
- WebRTC startup/service hook: `rootfs_extract/etc/init.d/S97webrtc`
- Stock printer profile:
- `rootfs_extract/usr/share/klipper/config/F005/printer.cfg`
- `rootfs_extract/usr/share/klipper/config/F005/gcode_macro.cfg`
- `rootfs_extract/usr/share/klipper/config/F005/printer_params.cfg`
- Runtime printer config is copied into `/usr/data/printer_data/config/` on the device
## Notes
- The shipped `.img` file is a 7z archive, not a raw flash image.
- The build flow starts from the stock archive, overlays `overlay_rootfs/`, and repacks the result.
- The helper uses native `rdsquashfs` and `gensquashfs` on Linux. Install
`squashfs-tools-ng` so those binaries are on `PATH`. On Windows it uses the
bundled `rdsquashfs.exe` / `gensquashfs.exe` tools from `squashfs-tools-ng`.
- The repack path is metadata-preserving: it reuses the stock SquashFS layout so symlinks and execute bits survive the round trip.
- `xImage.full` is a stock U-Boot `uImage` kernel blob. Its raw payload can be derived if kernel-side edits are needed.
- Stock-updater-facing version scheme in this workspace: `11034`
- UI/display version stays on the dotted printer-side label `v1.1.0.33`
- The display/version string is sourced from `overlay_rootfs/etc/ota_info`.
- The firmware image is intended to flash through the stock USB updater without any manual printer-side file edits.
- The helper build process keeps the stock updater happy by using the numeric package version and stock archive layout.
## Rebuild
Use the helper script:
```powershell
python .\tools\ke_firmware.py build --build-dir D:\DarKE_build --stock-archive .\Ender-3_V3_KE_F005_ota_img_V1.1.0.17.img --overlay-dir .\overlay_rootfs --output .\build\DarKE_KE_F005_ota_img_V11034.img
```
Compare the rebuilt rootfs against stock, allowing only the overlay tree to differ:
```powershell
python .\tools\ke_firmware.py compare --stock-archive .\Ender-3_V3_KE_F005_ota_img_V1.1.0.17.img --rebuilt-archive .\build\DarKE_KE_F005_ota_img_V11034.img --overlay-dir .\overlay_rootfs
```
## Stock-safe flash summary
- Put the generated `DarKE_KE_F005_ota_img_V11034.img` on a USB drive.
- Flash it with the printer's built-in updater.
# Firmware Architecture & Packaging Notes
This document contains technical reference information on stock firmware layouts, encryption passwords, partition budgets, and packaging mechanics for the **Ender-3 V3 KE** and **Creality Nebula Pad**.
---
## 1. Stock Firmware Baselines
| Target | Official Baseline Image | Version | Board Name | Derived 7z Encryption Password |
| :--- | :--- | :--- | :--- | :--- |
| **Ender-3 V3 KE** | `Ender-3_V3_KE_F005_ota_img_V1.1.0.17.img` | `V1.1.0.17` | `F005` | `$1$cxswfile$ZFd0RWFYkJQugbtKVGL9y0` |
| **Nebula Pad** | `NEBULA_ota_img_V1.1.0.30.img` | `V1.1.0.30` | `NEBULA` | `$1$cxswfile$XG7ANbYX3bq2H2xmmwrka.` |
### Password Derivation Algorithm
```bash
openssl passwd -1 -salt cxswfile "${BOARD_NAME}C3_7e_bz"
```
Or in Python:
```python
derive_creality_password(board_name) # implemented in tools/pack_openke.py
```
---
## 2. Partition Capacities & Budget Qualification
Creality's X2000 partition table enforces hard upper bounds on flashable images:
| Sub-Payload | Target Partition | Hardware Limit | OpenKE Payload Size | Headroom |
| :--- | :--- | :--- | :--- | :--- |
| **`xImage`** (Linux kernel) | `kernel` (`p5`) / `kernel2` (`p6`) | **8 MiB** (8,388,608 B) | **5.54 MiB** (5,541,952 B) | +2.71 MiB (66.1% used) |
| **`rootfs.squashfs`** | `rootfs` (`p7`) / `rootfs2` (`p8`) | **500 MiB** (524,288,000 B) | **330.85 MiB** (346,923,008 B) | +169.15 MiB (66.2% used) |
| **`zero.bin`** (RTOS) | `rtos` (`p3`) / `rtos2` (`p4`) | **4 MiB** (4,194,304 B) | **0.41–0.42 MiB** (~430 KiB) | +3.58 MiB (10.3% used) |
Both kernel and rootfs fit comfortably with substantial safety margins.
---
## 3. Tooling Overview
* **[`build_openke_image.sh`](file:///root/Development/OpenKE/DarKE/build_openke_image.sh)**:
Top-level script for building ready-to-flash OpenKE `.img` files directly from build artifacts.
* **[`tools/pack_openke.py`](file:///root/Development/OpenKE/DarKE/tools/pack_openke.py)**:
Core Python packager. Validates partition budgets, verifies SHA256 against `build-manifest.txt`, slices payloads into 1 MiB chunks with MD5 sidecars, derives board passwords, and compresses encrypted 7z envelopes.
* **[`assets/zero.bin`](file:///root/Development/OpenKE/DarKE/assets/zero.bin)**:
Cached RTOS binary for the Ender-3 V3 KE (`F005`).
* **[`assets/zero_nebula.bin`](file:///root/Development/OpenKE/DarKE/assets/zero_nebula.bin)**:
Cached RTOS binary for the Nebula Smart Kit / Nebula Pad (`NEBULA`).
* **[`tools/ke_firmware.py`](file:///root/Development/OpenKE/DarKE/tools/ke_firmware.py)**:
Legacy utility for extracting stock images, overlaying files onto stock rootfs, and repacking pre-rooted stock images.
---
## 4. Key Rules for Creality OTA Packages
From reverse-engineering `/etc/ota_bin/local_ota_update.sh`:
1. **Folder Name Parity**: The root directory inside the 7z archive **must match the `.img` filename** without the `.img` extension.
- Example: `NEBULA_ota_img_V1.1.0.34.img` $\rightarrow$ folder inside 7z must be `NEBULA_ota_img_V1.1.0.34/`.
2. **Dotted Versioning**: The version must be formatted with dots (e.g. `1.1.0.34`), not a raw integer, so `master-server`'s `[0-9]{1,3}` parser can compare versions.
3. **Chunking**: Chunks are 1,048,576 bytes each. Chunk `0000` points to the whole-file MD5, and subsequent chunks chain the previous chunk's MD5.