shibosoftwaredev/f1c100s-linux-nema17-stepper-controller
A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.
- Version
- 0.4.56
- License
- unset
- Stars
- 0
scripts/save-round8-checkpoint.mjs
import fs from "node:fs"
import path from "node:path"
import crypto from "node:crypto"
import assert from "node:assert/strict"
import {spawnSync} from "node:child_process"
const destination=path.resolve(process.argv[2]??"")
const checkpointRoot=path.resolve("../../checkpoints")
assert.equal(path.dirname(destination),checkpointRoot)
assert.match(path.basename(destination),/^nema17-round(?:8|9|10)-validated-local-20261020-/)
assert.ok(fs.statSync(destination).isDirectory())
assert.deepEqual(fs.readdirSync(destination),[],"checkpoint destination must be fresh")
const hash=p=>crypto.createHash("sha256").update(fs.readFileSync(p)).digest("hex")
const skipped=new Set(["node_modules",".git","tmp","__pycache__"])
const files={}
function visit(dir){
for(const e of fs.readdirSync(dir,{withFileTypes:true}).sort((a,b)=>a.name.localeCompare(b.name))){
const p=path.join(dir,e.name)
if(skipped.has(e.name)||e.name.startsWith(".env")||[".npmrc",".netrc"].includes(e.name))continue
if(p==="firmware/stm32/build"||/\.(tar\.gz|tgz)$/.test(p))continue
if(e.isDirectory())visit(p)
else {assert.ok(e.isFile(),`review non-file or symbolic link before archiving: ${p}`);files[p]=hash(p)}
}
}
visit(".")
const manifest={createdAt:new Date().toISOString(),files,excluded:[...skipped,".env*",".npmrc",".netrc","firmware/stm32/build","*.tar.gz","*.tgz"],
circuitSha256:hash("dist/index/circuit.json"),fabricationReady:false,localChangesNotPushed:true}
const list=path.join(destination,"checkpoint-files.txt")
fs.writeFileSync(list,Object.keys(files).map(p=>`./${p}`).join("\n")+"\n")
fs.writeFileSync(path.join(destination,"checkpoint-manifest.json"),JSON.stringify(manifest,null,2)+"\n")
const run=args=>{const r=spawnSync("tar",args,{stdio:"inherit"});if(r.error)throw r.error;assert.equal(r.status,0)}
const archive=path.join(destination,"board-checkpoint.tar.gz")
run(["-czf",archive,"-T",list])
const restored=path.join(destination,"restore-verified")
fs.mkdirSync(restored)
run(["-xzf",archive,"-C",restored])
for(const [p,h] of Object.entries(files))assert.equal(hash(path.join(restored,p)),h,`restored ${p}`)
const report={createdAt:new Date().toISOString(),archive,archiveSha256:hash(archive),
filesVerified:Object.keys(files).length,circuitSha256:manifest.circuitSha256,
restoreVerified:true,fabricationReady:false,localChangesNotPushed:true}
fs.writeFileSync(path.join(destination,"checkpoint-report.json"),JSON.stringify(report,null,2)+"\n")
console.log(JSON.stringify(report))