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/prepare-round10-vm.mjs
import fs from "node:fs"
import crypto from "node:crypto"
const write=(p,v)=>fs.writeFileSync(p,JSON.stringify(v,null,2)+"\n")
const circuit=JSON.parse(fs.readFileSync("dist/index/circuit.json"))
let replay=JSON.parse(fs.readFileSync("routing/complete-routes.json"))
const paired=process.env.ROUND10_REWORK_B==="1"
const trimVm=process.env.ROUND10_TRIM_VM==="1"
const stem=trimVm?"round10-vmbwide":paired?"round10-vmb":"round10-vm"
const via=(x,y)=>circuit.some(e=>e.type==="pcb_via"&&Math.hypot(e.x-x,e.y-y)<1e-6)
if(!via(-1.8,-16)||!via(7,-16))throw Error("Original VM crossbar barrels must still exist")
write("routing/round10-placement.circuit.json",circuit)
const extra=[]
if(paired){
replay=replay.filter(t=>t.source_trace_id!=="source_trace_336")
if(trimVm){
const retained=[]
const ownIds=new Set(circuit.filter(e=>e.type==="source_trace"&&e.subcircuit_connectivity_map_key==="MOTOR_CONTROLLER_connectivity_net84").map(e=>e.source_trace_id))
for(const t of replay){
if(!ownIds.has(t.source_trace_id)){retained.push(t);continue}
for(const p of t.route)if(p.route_type==="via")retained.push({...t,route:[p]})
for(let i=1;i<t.route.length;i++){
const a=t.route[i-1],b=t.route[i]
if(a.route_type!=="wire"||b.route_type!=="wire"||a.layer!==b.layer||Math.hypot(a.x-b.x,a.y-b.y)<1e-8)continue
const width=Math.max(a.width,b.width)
if(Math.abs(width-.5)<1e-6&&a.layer==="bottom")continue
const w=Math.abs(width-.5)<1e-6&&a.layer==="top"?.8:width
retained.push({...t,route:[{...a,width:w},{...b,width:w}]})
}
}
replay=retained
}
const sp=circuit.find(e=>e.type==="source_port"&&e.source_port_id==="source_port_537")
const p=circuit.find(e=>e.type==="pcb_port"&&e.source_port_id===sp.source_port_id)
const source=circuit.find(e=>e.type==="source_trace"&&e.source_trace_id==="source_trace_336")
replay.push({type:"pcb_trace",pcb_trace_id:"round10_preserved_B_escape",source_trace_id:source.source_trace_id,
subcircuit_id:source.subcircuit_id,route:[{route_type:"wire",layer:"top",x:p.x,y:p.y,width:.3,start_pcb_port_id:p.pcb_port_id},
{route_type:"wire",layer:"top",x:p.x,y:-15.6,width:.3},
{route_type:"via",x:p.x,y:-15.6,from_layer:"top",to_layer:"bottom",via_diameter:.45,via_hole_diameter:.3}]})
const target=circuit.find(e=>e.type==="pcb_port"&&e.source_port_id==="source_port_582")
extra.push({source:"source_trace_336",constraints:{min_trace_thickness:.3,allowed_layers:["top","bottom"]},
start:{x:p.x,y:-15.6,layers:["top","bottom"],pcb_port_id:"actual_B_escape_barrel"},
target:{x:target.x,y:target.y,layers:["bottom"],pcb_port_id:target.pcb_port_id}})
}
write(`routing/${stem}-retained.json`,replay)
write(`routing/${stem}-moves.json`,{})
const point=(x,y)=>({x,y,layers:["top","bottom"],pcb_port_id:"actual_existing_vm_barrel"})
write(`routing/${stem}-plan.json`,{prefix:stem,candidateOnly:true,
placement:"routing/round10-placement.circuit.json",retained:`routing/${stem}-retained.json`,
extent:[-20.9,-20.9,20.9,20.9],jobs:[{source:"source_trace_305",
constraints:{min_trace_thickness:.8,allowed_layers:["top","bottom"]},
start:point(-1.8,-16),target:point(7,-16)},...extra]})
write("reports/round10-baseline.json",{circuitSha256:crypto.createHash("sha256").update(fs.readFileSync("dist/index/circuit.json")).digest("hex"),
replaySha256:crypto.createHash("sha256").update(fs.readFileSync("routing/complete-routes.json")).digest("hex"),
checkpoint:"../../checkpoints/nema17-round9-validated-local-20261020-HTyidb/restore-verified",noPlacementsChanged:true})
console.log("Candidate only: restore a >=0.80 mm outer-layer path between the exact former crossbar endpoints; all old copper retained")