update: Added NVS Gen on the Flasher
This commit is contained in:
@@ -274,9 +274,10 @@ async def download_nvs(
|
||||
sn: str,
|
||||
hw_type_override: Optional[str] = Query(None, description="Override hw_type written to NVS (for bespoke firmware)"),
|
||||
hw_revision_override: Optional[str] = Query(None, description="Override hw_revision written to NVS (for bespoke firmware)"),
|
||||
nvs_schema: Optional[str] = Query(None, description="NVS schema to use: 'legacy' or 'new' (default)"),
|
||||
user: TokenPayload = Depends(require_permission("manufacturing", "view")),
|
||||
):
|
||||
binary = service.get_nvs_binary(sn, hw_type_override=hw_type_override, hw_revision_override=hw_revision_override)
|
||||
binary = service.get_nvs_binary(sn, hw_type_override=hw_type_override, hw_revision_override=hw_revision_override, legacy=(nvs_schema == "legacy"))
|
||||
await audit.log_action(
|
||||
admin_user=user.email,
|
||||
action="device_flashed",
|
||||
|
||||
@@ -197,12 +197,13 @@ def update_device_status(sn: str, data: DeviceStatusUpdate, set_by: str | None =
|
||||
return _doc_to_inventory_item(doc_ref.get())
|
||||
|
||||
|
||||
def get_nvs_binary(sn: str, hw_type_override: str | None = None, hw_revision_override: str | None = None) -> bytes:
|
||||
def get_nvs_binary(sn: str, hw_type_override: str | None = None, hw_revision_override: str | None = None, legacy: bool = False) -> bytes:
|
||||
item = get_device_by_sn(sn)
|
||||
return generate_nvs_binary(
|
||||
serial_number=item.serial_number,
|
||||
hw_family=hw_type_override if hw_type_override else item.hw_type,
|
||||
hw_revision=hw_revision_override if hw_revision_override else item.hw_version,
|
||||
legacy=legacy,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -851,6 +851,7 @@ function StepFlash({ device, bespokeOverride, onFlashed }) {
|
||||
const [serial, setSerial] = useState([]);
|
||||
const [serialAutoScroll, setSerialAutoScroll] = useState(true);
|
||||
const [error, setError] = useState("");
|
||||
const [nvsSchema, setNvsSchema] = useState("new");
|
||||
|
||||
const loaderRef = useRef(null);
|
||||
const portRef = useRef(null);
|
||||
@@ -993,9 +994,10 @@ function StepFlash({ device, bespokeOverride, onFlashed }) {
|
||||
const partUrl = bespokeOverride
|
||||
? `/api/manufacturing/devices/${sn}/partitions.bin?hw_type_override=${bespokeOverride.hwFamily}`
|
||||
: `/api/manufacturing/devices/${sn}/partitions.bin`;
|
||||
const nvsSchemaParam = nvsSchema === "legacy" ? "&nvs_schema=legacy" : "";
|
||||
const nvsUrl = bespokeOverride
|
||||
? `/api/manufacturing/devices/${sn}/nvs.bin?hw_type_override=${bespokeOverride.hwFamily}&hw_revision_override=1.0`
|
||||
: `/api/manufacturing/devices/${sn}/nvs.bin`;
|
||||
? `/api/manufacturing/devices/${sn}/nvs.bin?hw_type_override=${bespokeOverride.hwFamily}&hw_revision_override=1.0${nvsSchemaParam}`
|
||||
: `/api/manufacturing/devices/${sn}/nvs.bin${nvsSchema === "legacy" ? "?nvs_schema=legacy" : ""}`;
|
||||
|
||||
appendLog("Fetching bootloader binary…");
|
||||
const blBuffer = await fetchBinary(blUrl);
|
||||
@@ -1232,16 +1234,32 @@ function StepFlash({ device, bespokeOverride, onFlashed }) {
|
||||
</button>
|
||||
)}
|
||||
{portConnected && !done && (
|
||||
<button
|
||||
onClick={handleStartFlash}
|
||||
className="flex items-center gap-2 px-5 py-2 text-sm rounded-md font-medium hover:opacity-90 transition-opacity cursor-pointer"
|
||||
style={{ backgroundColor: "var(--btn-primary)", color: "var(--text-white)" }}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
|
||||
</svg>
|
||||
Start Flashing
|
||||
</button>
|
||||
<>
|
||||
<select
|
||||
value={nvsSchema}
|
||||
onChange={(e) => setNvsSchema(e.target.value)}
|
||||
disabled={flashing}
|
||||
className="px-3 py-2 text-sm rounded-md border cursor-pointer font-medium"
|
||||
style={{
|
||||
backgroundColor: "var(--bg-input)",
|
||||
borderColor: "var(--border-primary)",
|
||||
color: "var(--text-secondary)",
|
||||
}}
|
||||
>
|
||||
<option value="new">NVS: Current Gen</option>
|
||||
<option value="legacy">NVS: Legacy Gen</option>
|
||||
</select>
|
||||
<button
|
||||
onClick={handleStartFlash}
|
||||
className="flex items-center gap-2 px-5 py-2 text-sm rounded-md font-medium hover:opacity-90 transition-opacity cursor-pointer"
|
||||
style={{ backgroundColor: "var(--btn-primary)", color: "var(--text-white)" }}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
|
||||
</svg>
|
||||
Start Flashing
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user