diff --git a/build-scripts/I2S-4MFlash-sdkconfig.defaults b/build-scripts/I2S-4MFlash-sdkconfig.defaults index 1ffb822d..869db482 100644 --- a/build-scripts/I2S-4MFlash-sdkconfig.defaults +++ b/build-scripts/I2S-4MFlash-sdkconfig.defaults @@ -857,8 +857,6 @@ CONFIG_DAC_CONFIG="" CONFIG_SPDIF_CONFIG="" CONFIG_ETH_CONFIG="" CONFIG_DAC_CONTROLSET="" -CONFIG_DAC_KNOWN_CONFIGURATIONS="ESP-A1S-AC101(audio kit 2.2)-Fixed GPIOs|ESP-A1S-ES8388(audio kit 2.2+)-Fixed GPIOs" -CONFIG_DAC_KNOWN_CONFIGURATIONS_GPIOS="model CONFIG_I2C_SDA=-1 CONFIG_I2C_SCL=-1 CONFIG_SDIF_NUM=0 diff --git a/build-scripts/SqueezeAmp-sdkconfig.defaults b/build-scripts/SqueezeAmp-sdkconfig.defaults index 9f5a4912..3de68529 100644 --- a/build-scripts/SqueezeAmp-sdkconfig.defaults +++ b/build-scripts/SqueezeAmp-sdkconfig.defaults @@ -856,8 +856,6 @@ CONFIG_ETH_SPI_SPEED=20000000 CONFIG_BASIC_I2C_BT=y CONFIG_ETH_CONFIG="" CONFIG_DAC_CONTROLSET="" -CONFIG_DAC_KNOWN_CONFIGURATIONS="ESP-A1S-AC101(audio kit 2.2)-Fixed GPIOs|ESP-A1S-ES8388(audio kit 2.2+)-Fixed GPIOs" -CONFIG_DAC_KNOWN_CONFIGURATIONS_GPIOS="model CONFIG_I2S_BCK_IO=-1 CONFIG_I2S_WS_IO=-1 CONFIG_I2S_DO_IO=-1 diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 3e22539a..370db63d 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -107,17 +107,6 @@ menu "Squeezelite-ESP32" endmenu menu "Audio settings" - menu "Known Configurations" - visible if BASIC_I2C_BT - config DAC_KNOWN_CONFIGURATIONS - string "Known DAC configurations" - default "ESP32A1S Old (AC101)|ESP32A1S V2.2+ (ES8388)|Xiaomi Gateway" if BASIC_I2C_BT - default "" - config DAC_KNOWN_CONFIGURATIONS_GPIOS - string "GPIOs for known DAC configurations" - default "model=AC101,sda=33,scl=32,bck=27,ws=26,di=35,do=25|model=ES8388,bck=5,ws=25,do=26,sda=18,scl=23,i2c=16|model=I2S,bck=12,ws=26,do=25,i2c=106,sda=18,scl=23" if BASIC_I2C_BT - default "" - endmenu menu "DAC settings" visible if BASIC_I2C_BT menu "I2S settings" diff --git a/sdkconfig_compare.js b/sdkconfig_compare.js index 5c7e018b..4e73d493 100644 --- a/sdkconfig_compare.js +++ b/sdkconfig_compare.js @@ -3,6 +3,13 @@ const fs = require("fs"); // Require the file system processing library const readline = require("readline"); // Require the readline processing library +var map_types = { + "UNSET": 0, + "VALUE": 1, + "COMMENT": 2 +}; + + // buildMap // Read the sdkconfig file specified by fileName and produce a map of the name/value pairs contained // within. A Promise is returned that is fulfilled when the file has been read. @@ -13,12 +20,14 @@ function buildMap(fileName) { reject(err); }); const map = {}; + const lines_index = []; + var lineNo = 1; const lineReader = readline.createInterface({ input: readStream, crlfDelay: Infinity }); - + // Called when a new line has been read from the file. lineReader.on("line", (line) => { line = line.trim(); // Trim whitespace from the line. @@ -26,20 +35,51 @@ function buildMap(fileName) { if (line.length == 0) { // Ignore empty lines return; } - if (line.startsWith("#")) { // Ignore comment lines - return; - } + + // split lines using named capture group regex, and loop through the resulting array + var regexp = /^\s*[#]\s*(?CONFIG[^\s]*) is not set\s*$|^\s*(?[#].*)$|^\s*(?[^#]{1}[^\s=]*)=(?.*)$/gm; + var match = regexp.exec(line); + var key=""; + var map_entry={}; + while (match != null) { + if (match.groups.unset_key) { + key = match.groups.unset_key; + map_entry = { + key:key, + type: map_types.UNSET, + value: undefined, + index: lineNo++, + }; - const parts = line.split("="); // Split the line into parts separated by the '=' character. - if (map.hasOwnProperty(parts[0])) { - console.log(`Odd ... we found ${parts[0]} twice.`); + } else if (match.groups.comment) { + // accumulate comments in an array + map_entry={ + type: map_types.COMMENT, + value: match.groups.comment, + index: lineNo++, + }; + + } + else { + key = match.groups.key; + map_entry = { + key:key, + type: map_types.VALUE, + value: match.groups.value, + index: lineNo++, + }; + } + if(map_entry.type!=map_types.COMMENT){ + map[key] = map_entry; + } + lines_index.push(map_entry); + match = regexp.exec(line); } - map[parts[0]] = parts[1]; // Populate the map element. }); // on(line) // Called when all the lines from the file have been consumed. lineReader.on("close", () => { - resolve(map); + resolve({map, lines_index}); }); // on(close) }); @@ -48,46 +88,81 @@ function buildMap(fileName) { const args = process.argv; -if (args.length != 4) { - console.log("Usage: node sdkconfig_compare file1 file2"); +if (args.length != 3) { + console.log("Usage: node sdkconfig_compare file1 "); process.exit(); } -const file1 = args[2]; -const file2 = args[3]; -buildMap(file1).then((result) => { - buildMap(file2).then((result2) => { - buildMap("./sdkconfig.defaults").then((result3) => { +const sdkconfig = ".\\sdkconfig"; +const comparedFile = args[2]; + +buildMap(sdkconfig).then((sdkConfigResult ) => { + var sdkconfigMap = sdkConfigResult.map; + var sdkconfigLines = sdkConfigResult.lines_index; + buildMap(comparedFile).then((comparedResult) => { + var comparedFileMap = comparedResult.map; + var comparedLines = comparedResult.lines_index; + buildMap(".\\sdkconfig.defaults").then((sdkconfigResults) => { + var sdkconfig_defaults = sdkconfigResults.map; + var sdkconfig_defaults_lines = sdkconfigResults.lines_index; // Three passes // In A and not B // in B and not A // value different in A and B - console.log(`\n\n${file1} properties that are missing in ${file2}\n**************************`); - for (const prop in result) { - if (result.hasOwnProperty(prop)) { - if (!result2.hasOwnProperty(prop) && !result3.hasOwnProperty(prop)) { - console.log(`${prop}=${result[prop]}`); - } + var newmap = {}; + var entry={}; + console.log(`\n\n${sdkconfig} properties that are missing in ${comparedFile}\n**************************`); + for (const prop in sdkconfigMap) { + entry = sdkconfigMap[prop]; + if(entry.type==map_types.COMMENT || entry.type== map_types.UNSET) continue; + if (!comparedFileMap.hasOwnProperty(prop) && !sdkconfig_defaults.hasOwnProperty(prop)) { + newmap[prop] = entry; + console.log(`${prop}=${entry.value}`); } + else if(comparedFileMap.hasOwnProperty(prop)){ + newmap[prop] =entry; + } + } - console.log(`\n\n${file2} properties that are missing in ${file1}\n**************************`); - for (const prop in result2) { - if (result2.hasOwnProperty(prop)) { - if (!result.hasOwnProperty(prop) && !result3.hasOwnProperty(prop)) { - console.log(`${prop}=${result2[prop]}`); + console.log(`\n\n${comparedFile} properties that are missing in ${sdkconfig}\n**************************`); + for (const prop in comparedFileMap) { + entry = comparedFileMap[prop]; + if(entry.type==map_types.COMMENT || entry.type== map_types.UNSET) continue; + if (comparedFileMap.hasOwnProperty(prop)) { + if (!sdkconfigMap.hasOwnProperty(prop) && !sdkconfig_defaults.hasOwnProperty(prop)) { + console.log(`${prop}=${entry.value}`); } } } console.log(`\n\nproperties that are different between the 2 files \n**************************`); - for (const prop in result) { - if (result.hasOwnProperty(prop)) { - if (result2.hasOwnProperty(prop)) { - if (result[prop] != result2[prop]) { - console.log(`${prop} : [${result[prop]}] != [${result2[prop]}]`); + for (const prop in sdkconfigMap) { + entry = sdkconfigMap[prop]; + if(entry.type==map_types.COMMENT) continue; + if (sdkconfigMap.hasOwnProperty(prop)) { + if (comparedFileMap.hasOwnProperty(prop)) { + if (entry.value != comparedFileMap[prop].value) { + console.log(`${prop} : [${entry.value}] != [${comparedFileMap[prop].value}]`); } } } } + var newlines = []; + for(const prop in newmap){ + newlines.splice(newmap[prop].index,0, `${prop}=${newmap[prop].value}`); + } + comparedLines.forEach(line=>{ + if(line.type==map_types.COMMENT ) { + newlines.splice(line.index,0, line.value); + } + else if(line.type==map_types.UNSET){ + newlines.splice(line.index,0, `# ${line.key} is not set`); + } + }); + + console.log(`\n\${comparedFile} with missing properties\n**************************`); + newlines.forEach(line => { + console.log(line); + }); }).catch((err) => { console.log(err);