summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2018-11-30 15:24:06 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2018-11-30 15:37:10 +0100
commit4c318057f63a4e1b5e5facd5fecfade2f17572a3 (patch)
treedfd00580d5382b77bcaa298be3c6eba689d46f89 /utils
parentda752d00844bf8f881b344570f815ff063e4b65e (diff)
downloadrockbox-4c318057f63a4e1b5e5facd5fecfade2f17572a3.tar.gz
rockbox-4c318057f63a4e1b5e5facd5fecfade2f17572a3.tar.bz2
rockbox-4c318057f63a4e1b5e5facd5fecfade2f17572a3.zip
nwzstools/scsitool: try to guess series if possible
If the model is not known (ie model ID in the database) but another device from the same series is known, then the database information probably applies and one can use the "force" option -s to tell the tool to ignore the model ID. Automatically print such advice when the series can be guessed. Change-Id: I6bcc7aa29693df8c3d7d8e709ece7cea650be717
Diffstat (limited to 'utils')
-rw-r--r--utils/nwztools/scsitools/scsitool.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/nwztools/scsitools/scsitool.c b/utils/nwztools/scsitools/scsitool.c
index 69a3403b25..8526f8676b 100644
--- a/utils/nwztools/scsitools/scsitool.c
+++ b/utils/nwztools/scsitools/scsitool.c
@@ -373,6 +373,18 @@ int get_model_and_series(int *model_index, int *series_index, unsigned long *mod
return 0;
}
+/* model IDs follow a pattern: the high 16-bit seem to encode the series and low 16-bit the size
+ * (although this is not entirely reliable). Just try to find any device with the same high 16-bits
+ * and return the series it belongs to. */
+int guess_series_for_model(unsigned long model_id)
+{
+ for(int i = 0; i < NWZ_SERIES_COUNT; i++)
+ for(int j = 0; j < nwz_series[i].mid_count; j++)
+ if(nwz_series[i].mid[j] >> 16 == model_id >> 16)
+ return i;
+ return -1;
+}
+
/* Read nvp node, retrun nonzero on error, update size to actual length. The
* index is the raw node number sent to the device */
int read_nvp_node(int node_index, void *buffer, size_t *size)
@@ -988,6 +1000,13 @@ void help_us(bool unsupported, unsigned long model_id)
cprintf(RED, "Your device is not supported yet.\n");
cprintf(RED, "Please contact developers and send them the information below.\n");
cprintf(RED, "See https://www.rockbox.org/wiki/SonyNWDestTool#ReportDevice\n");
+ /* try to see if we know a device in the same series, so we can recommend a force action */
+ int series_idx = guess_series_for_model(model_id);
+ if(series_idx >= 0)
+ {
+ cprintf(OFF, "It seems your devices belongs to the %s series.\n", nwz_series[series_idx].name);
+ cprintf(OFF, "You can try to re-run this tool with the option -s %s\n", nwz_series[series_idx].codename);
+ }
cprintf(BLUE, "-------------------[ Paste information below ]-------------------\n");
cprintf_field("Model ID: ", "%#lx\n", model_id);
get_dev_info(0, NULL);