Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ and their exported `source_port` flags. It does not read or require sibling
Use tscircuit 0.0.2745 or newer, which exports these attributes as `is_output`, `is_input`,
`is_using_internal_pullup`, and `is_configured_for_i2c_sda` / `is_configured_for_i2c_scl`.
Capability flags such as `isGpio` alone do not select a pin function. Connected
pins with missing or unsupported functions produce an error identifying the
MCU name/part number, physical pin numbers/labels and required TSX attributes,
without generated record IDs or a converter stack trace. Missing MCU port
pins with missing or unsupported functions produce an error. Missing-direction
errors contain one short line per pin with the component name, physical pin
number, label and problem, for example
`- U1 pin 4 (DIO11): GPIO direction is missing`. The CLI adds its standard failure
prefix; these diagnostics omit manufacturer part numbers, TSX setup instructions,
generated record IDs and converter stack traces. Missing MCU port
records or traces referencing absent source ports also fail before a new
SysConfig file is written; no behavior is inferred from signal names.
If more than one supported MCU is present, select one with `--component U1`
Expand Down
9 changes: 6 additions & 3 deletions npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ ti check-sysconfig ./board.circuit.tsx

Use tscircuit 0.0.2745 or newer for TSX export. For supported CC2340 circuits, GPIO/I2C choices come from existing MCU
`pinAttributes` exported to Circuit JSON. No separate request JSON is required
or read implicitly. Missing connected-pin functions fail with physical pin and
signal labels and the required TSX attributes, without generated record IDs
or a converter stack trace. Missing MCU port records
or read implicitly. Missing connected-pin functions fail. Missing-direction
errors contain one short line per pin with the component name, physical pin
number, label and problem, for example
`- U1 pin 4 (DIO11): GPIO direction is missing`. The CLI adds its standard failure
prefix; these diagnostics omit manufacturer part numbers, TSX setup instructions,
generated record IDs and converter stack traces. Missing MCU port records
or connected source-port records also fail before a new `.syscfg` is written.
Use `--component U1` when selecting between multiple MCUs.
Connected 32768 Hz two-terminal crystals on MCU pins 14/15 select the external
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/bun": "^1.4.0",
"@types/react": "^19.2.17",
"bun-match-svg": "^0.0.17",
"circuit-json-to-sysconfig": "github:tscircuit/circuit-json-to-sysconfig#3da9ac4b464a84eac13615dc684da7105065c685",
"circuit-json-to-sysconfig": "github:tscircuit/circuit-json-to-sysconfig#05add591d6d678cc7457c985b08096690d1e3949",
"circuit-to-svg": "0.0.410",
"tscircuit": "0.0.2745",
"typescript": "^5.0.0"
Expand Down
2 changes: 2 additions & 0 deletions scripts/test-npm-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async function testCli({ command, cwd }) {
name: "ENABLE",
pin_number: 4,
is_output: true,
is_bidirectional: true,
},
]),
);
Expand Down Expand Up @@ -202,6 +203,7 @@ async function testCli({ command, cwd }) {
name: "ENABLE",
pin_number: 4,
is_output: true,
is_bidirectional: true,
},
{
type: "source_trace",
Expand Down
20 changes: 8 additions & 12 deletions tests/cli/sysconfig-errors-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ test("Circuit JSON error output names unresolved pins without IDs or a stack", (
name: "DIO11",
pin_number: 4,
is_gpio: true,
is_bidirectional: true,
},
{
type: "source_port",
Expand All @@ -76,6 +77,7 @@ test("Circuit JSON error output names unresolved pins without IDs or a stack", (
name: "DIO13",
pin_number: 6,
is_gpio: true,
is_bidirectional: true,
},
{
type: "source_trace",
Expand All @@ -91,11 +93,8 @@ test("Circuit JSON error output names unresolved pins without IDs or a stack", (
expect(result).toEqual({ status: 1, stdout: "", sysconfigWritten: false });
expect(stderr).toMatchInlineSnapshot(`
"Failed to generate SysConfig: SysConfig conversion failed:
Unresolved CC2340 pin configuration for U1 (CC2340R52E0RGER):
- U1 pin 4 (DIO11): no GPIO direction or supported peripheral selected
- U1 pin 6 (DIO13): no GPIO direction or supported peripheral selected
Update U1's TSX pinAttributes with the intended function for each listed pin: set exactly one of isInput: true or isOutput: true for GPIO, or activeCapability: "i2c_sda" / "i2c_scl" for I2C.
Datasheet capabilities such as isGpio describe what a pin supports; they do not select how this board uses it.
- U1 pin 4 (DIO11): GPIO direction is missing
- U1 pin 6 (DIO13): GPIO direction is missing
"
`);
});
Expand All @@ -108,8 +107,8 @@ test("TSX error output explains board choices without a request file or stack",
<chip name="U1" manufacturerPartNumber="CC2340R52E0RGER"
pinLabels={{ pin4: "DIO11", pin6: "DIO13" }}
pinAttributes={{
pin4: { isGpio: true },
pin6: { isGpio: true },
pin4: { isGpio: true, isBidirectional: true },
pin6: { isGpio: true, isBidirectional: true },
}} />
<net name="PMIC_LP" /><net name="CHARGER_INT" />
<trace from=".U1 > .DIO11" to="net.PMIC_LP" />
Expand All @@ -120,11 +119,8 @@ test("TSX error output explains board choices without a request file or stack",
expect(result).toEqual({ status: 1, stdout: "", sysconfigWritten: false });
expect(stderr).toMatchInlineSnapshot(`
"Failed to generate SysConfig: SysConfig conversion failed:
Unresolved CC2340 pin configuration for U1 (CC2340R52E0RGER):
- U1 pin 4 (DIO11): no GPIO direction or supported peripheral selected
- U1 pin 6 (DIO13): no GPIO direction or supported peripheral selected
Update U1's TSX pinAttributes with the intended function for each listed pin: set exactly one of isInput: true or isOutput: true for GPIO, or activeCapability: "i2c_sda" / "i2c_scl" for I2C.
Datasheet capabilities such as isGpio describe what a pin supports; they do not select how this board uses it.
- U1 pin 4 (DIO11): GPIO direction is missing
- U1 pin 6 (DIO13): GPIO direction is missing
"
`);
});
22 changes: 13 additions & 9 deletions tests/cli/sysconfig-from-circuit.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ test("connected pins with missing roles fail without a request-file suggestion",
});
writeFileSync(join(f.cwd, "board.circuit.json"), JSON.stringify(incomplete));
assert.equal(await f.run(["generate-sysconfig", "board.circuit.json"]), 1);
assert.match(f.stderr.join("\n"), /U1.*CC2340R52E0RGER/);
assert.match(f.stderr.join("\n"), /pin 4[\s\S]*pinAttributes/);
assert.match(
f.stderr.join("\n"),
/- U1 pin 4 \(ENABLE\): GPIO direction is missing/,
);
assert.doesNotMatch(
f.stderr.join("\n"),
/request file is missing|source_component_id|source_port_id|\bat \S+|throw new Error|convert\.mjs:\d/,
);
assert.doesNotMatch(f.stderr.join("\n"), /\(mcu,|\(output,/);
assert.match(f.stderr.join("\n"), /isInput: true or isOutput: true/);
assert.equal(existsSync(join(f.cwd, "board.syscfg")), false);
});

Expand Down Expand Up @@ -183,8 +184,8 @@ test("TSX pinAttributes export selected GPIO roles without a request file", asyn
<chip name="U1" manufacturerPartNumber="CC2340R52E0RGER"
pinLabels={{ pin4: "DIO11", pin5: "DIO12" }}
pinAttributes={{
pin4: { isOutput: true },
pin5: { isInput: true, isUsingInternalPullup: true },
pin4: { isOutput: true, isBidirectional: true },
pin5: { isInput: true, isUsingInternalPullup: true, isBidirectional: true },
}} />
</board>
);`,
Expand All @@ -200,6 +201,11 @@ test("TSX pinAttributes export selected GPIO roles without a request file", asyn
const exported = JSON.parse(
readFileSync(join(f.cwd, "dist/board/circuit.json"), "utf8"),
);
assert.ok(
exported
.filter((port) => port.type === "source_port")
.every((port) => port.is_bidirectional === true),
);
assert.equal(
exported.find(
(port) => port.type === "source_port" && port.pin_number === 4,
Expand Down Expand Up @@ -231,10 +237,8 @@ test("a TSX pin failure prints actionable labels without the converter stack", a
);
assert.equal(await f.run(["generate-sysconfig", "board.circuit.tsx"]), 1);
const message = f.stderr.join("\n");
assert.match(message, /U1 \(CC2340R52E0RGER\)/);
assert.match(message, /U1 pin 4 \(DIO11\)/);
assert.match(message, /U1 pin 6 \(DIO13\)/);
assert.match(message, /Update U1's TSX pinAttributes/);
assert.match(message, /- U1 pin 4 \(DIO11\): GPIO direction is missing/);
assert.match(message, /- U1 pin 6 \(DIO13\): GPIO direction is missing/);
assert.doesNotMatch(
message,
/source_component_\d|source_port_\d|\bat \S+|throw new Error/,
Expand Down
6 changes: 4 additions & 2 deletions tests/cli/sysconfig.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ test("missing pin functions are reported without requiring a firmware request fi
assert.equal(await f.run(["generate-sysconfig", "index.circuit.tsx"]), 1);
assert.ok(existsSync(join(f.cwd, "dist/index/circuit.json")));
const message = f.stderr.join("\n");
assert.match(message, /Unresolved CC2340 pin configuration/);
assert.match(message, /pinAttributes/);
assert.match(
message,
/- U1_MCU pin 9 \(DISP_PWR_N\): GPIO direction is missing/,
);
assert.doesNotMatch(
message,
/source_component_\d|source_port_\d|throw new Error|\bat \S+/,
Expand Down
Loading