{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "sftool CLI Configuration Schema",
"description": "JSON schema for configuring one sftool command invocation",
"type": "object",
"properties": {
"chip": {
"type": "string",
"enum": [ "SF32LB52", "SF32LB56", "SF32LB58" ],
"description": "Target chip type"
},
"memory": {
"type": "string",
"enum": [ "nor", "nand", "sd" ],
"default": "nor",
"description": "Memory type"
},
"port": {
"type": "string",
"description": "Serial port device"
},
"baud": {
"type": "integer",
"default": 1000000,
"description": "Serial port baud rate"
},
"before": {
"type": "string",
"enum": [ "default_reset", "no_reset", "no_reset_no_sync" ],
"default": "default_reset",
"description": "Action before connecting to the chip"
},
"after": {
"type": "string",
"enum": [ "no_reset", "soft_reset" ],
"default": "soft_reset",
"description": "Action after sftool finishes"
},
"connect_attempts": {
"type": "integer",
"default": 3,
"description": "Number of attempts to connect (≤0 = infinite)"
},
"compat": {
"type": "boolean",
"default": false,
"description": "Enable compatibility mode"
},
"quiet": {
"type": "boolean",
"default": false,
"description": "Suppress progress bar output"
},
"write_flash": {
"$ref": "#/definitions/writeFlashCommand"
},
"read_flash": {
"$ref": "#/definitions/readFlashCommand"
},
"erase_flash": {
"$ref": "#/definitions/eraseFlashCommand"
},
"erase_region": {
"$ref": "#/definitions/eraseRegionCommand"
}
},
"required": [ "chip", "port" ],
"oneOf": [
{ "required": [ "write_flash" ] },
{ "required": [ "read_flash" ] },
{ "required": [ "erase_flash" ] },
{ "required": [ "erase_region" ] }
],
"additionalProperties": false,
"definitions": {
"hexString": {
"type": "string",
"pattern": "^0x[0-9A-Fa-f]+$",
"description": "Hexadecimal string, e.g. 0x12000000"
},
"writeFlashFile": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Filesystem path to the binary file"
},
"address": {
"$ref": "#/definitions/hexString",
"description": "Optional target address for this file"
}
},
"required": [ "path" ],
"additionalProperties": false
},
"readFlashFile": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Filesystem path for the output file"
},
"address": {
"$ref": "#/definitions/hexString"
},
"size": {
"$ref": "#/definitions/hexString",
"description": "Number of bytes to read"
}
},
"required": [ "path", "address", "size" ],
"additionalProperties": false
},
"regionItem": {
"type": "object",
"properties": {
"address": {
"$ref": "#/definitions/hexString"
},
"size": {
"$ref": "#/definitions/hexString"
}
},
"required": [ "address", "size" ],
"additionalProperties": false
},
"writeFlashCommand": {
"type": "object",
"description": "Parameters for the write_flash command",
"properties": {
"verify": {
"type": "boolean",
"default": false,
"description": "Verify after writing"
},
"erase_all": {
"type": "boolean",
"default": false,
"description": "Erase entire flash first"
},
"no_compress": {
"type": "boolean",
"default": false,
"description": "Disable compression"
},
"files": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/definitions/writeFlashFile" },
"description": "List of files to write with optional addresses"
}
},
"required": [ "files" ],
"additionalProperties": false
},
"readFlashCommand": {
"type": "object",
"description": "Parameters for the read_flash command",
"properties": {
"files": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/definitions/readFlashFile" },
"description": "List of files to read with address and size"
}
},
"required": [ "files" ],
"additionalProperties": false
},
"eraseFlashCommand": {
"type": "object",
"description": "Parameters for the erase_flash command",
"properties": {
"address": {
"$ref": "#/definitions/hexString"
}
},
"required": [ "address" ],
"additionalProperties": false
},
"eraseRegionCommand": {
"type": "object",
"description": "Parameters for the erase_region command",
"properties": {
"regions": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/definitions/regionItem" },
"description": "List of regions (address & size) to erase"
}
},
"required": [ "regions" ],
"additionalProperties": false
}
}
}