summaryrefslogtreecommitdiff
path: root/utils/nwztools/database/nwz_db.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-11-11 15:40:56 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-11-11 16:07:14 +0100
commit44bb2856a59be53ef5ede154a39c54a59b1cc6d0 (patch)
treece343ecff309d6d0172ea56946a9ce679329b250 /utils/nwztools/database/nwz_db.h
parent19de536ce2f3c8066ca5be9b570f72e5c1e88342 (diff)
downloadrockbox-44bb2856a59be53ef5ede154a39c54a59b1cc6d0.tar.gz
rockbox-44bb2856a59be53ef5ede154a39c54a59b1cc6d0.zip
nwztools/database: add database of information on Sony NWZ linux players
There must be an evil genius in Sony's Walkman division. Someone who made sure that each model is close enough to the previous one so that little code is needed but different enough so that an educated guess is not enough. Each linux-based Sony player has a model ID (mid) which is a 32-bit integer. I was able to extract a list of all model IDs and the correspoding name of the player (see README). This gives us 1) a nice list of all players (because NWZ-A729 vs NWZ-A729B, really Sony?) 2) an easy way to find the name of player programatically. It seems that the lower 8-bit of the model ID gives the storage size but don't bet your life on it. The remaining bytes seem to follow some kind of pattern but there are exceptions. From this list, I was able to build a list of all Sony's series (up to quite recent one). The only safe way to build that is by hand, with a list of series, each series having a list of model IDs. The notion of series is very important because all models in a series share the same firmware. A very important concept on Sony's players is the NVP, an area of the flash that stores data associated with keys. The README contains more information but basically this is where is record the model ID, the destination, the boot flags, the firmware upgrade flags, the boot image, the DRM keys, and a lot of other stuff. Of course Sony decided to slightly tweak the index of the keys regularly over time which means that each series has a potentially different map, and we need this map to talk to the NVP driver. Fortunately, Sony distributes the kernel for all its players and they contain a kernel header with this information. I wrote a script to unpack kernel sources and parse this header, producing a bunch of nw-*.txt files, included in this commit. This map is very specific though: it maps Sony's 3-letter names (bti) to indexes (1). This is not very useful without the decription (bti = boot image) and its size (262144). This information is harder to come by, and is only stored in one place: if icx_nvp_emmc.ko drivers, found on the device. Fortunately, Sony distributes a number of firmware upgrade, that contain the rootfs, than once extracted contain this driver. The driver is a standard ELF files with symbols. I wrote a parsing tool (nvptool) that is able to extract this information from the drivers. Using that, I produced a bunch of nodes-nw*.txt files. A reasonable assumption is that nodes meaning and size do not change over time (bti is always the boot image and is always 262144 bytes), so by merging a few of those file, we can get a complete picture (note that some nodes that existed in older player do not exists anymore so we really need to merge several ones from different generations). The advantage of storing all this information in plain text files, is that it now makes it easy to parse it and produce whatever format we want to use it. I wrote a python script that parses all this mess and produces a C file and header with all this information (nwz_db.{c,h}). Change-Id: Id790581ddd527d64418fe9e4e4df8e0546117b80
Diffstat (limited to 'utils/nwztools/database/nwz_db.h')
-rw-r--r--utils/nwztools/database/nwz_db.h185
1 files changed, 185 insertions, 0 deletions
diff --git a/utils/nwztools/database/nwz_db.h b/utils/nwztools/database/nwz_db.h
new file mode 100644
index 0000000000..95aff48afa
--- /dev/null
+++ b/utils/nwztools/database/nwz_db.h
@@ -0,0 +1,185 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2016 Amaury Pouly
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#ifndef __NWZ_DB_H__
21#define __NWZ_DB_H__
22
23/** /!\ This file was automatically generated, DO NOT MODIFY IT DIRECTLY /!\ */
24
25/* List of all known NVP nodes */
26enum nwz_nvp_node_t
27{
28 NWZ_NVP_APD, /* application debug mode flag */
29 NWZ_NVP_APP, /* application parameter */
30 NWZ_NVP_BFD, /* btmw factory scdb */
31 NWZ_NVP_BFP, /* btmw factory pair info */
32 NWZ_NVP_BLF, /* browser log mode flag */
33 NWZ_NVP_BML, /* btmw log mode flag */
34 NWZ_NVP_BOK, /* beep ok flag */
35 NWZ_NVP_BPR, /* bluetooth address | bluetooth parameter */
36 NWZ_NVP_BTC, /* battery calibration */
37 NWZ_NVP_BTI, /* boot image */
38 NWZ_NVP_CGP, /* */
39 NWZ_NVP_CLV, /* color variation */
40 NWZ_NVP_CNG, /* aad/empr key | aad key */
41 NWZ_NVP_CTR, /* */
42 NWZ_NVP_DBA, /* aad icv */
43 NWZ_NVP_DBG, /* */
44 NWZ_NVP_DBI, /* dead battery image */
45 NWZ_NVP_DBV, /* empr icv | empr key */
46 NWZ_NVP_DCC, /* secure clock */
47 NWZ_NVP_DOR, /* key mode (debug/release) */
48 NWZ_NVP_E00, /* EMPR 0 */
49 NWZ_NVP_E01, /* EMPR 1 */
50 NWZ_NVP_E02, /* EMPR 2 */
51 NWZ_NVP_E03, /* EMPR 3 */
52 NWZ_NVP_E04, /* EMPR 4 */
53 NWZ_NVP_E05, /* EMPR 5 */
54 NWZ_NVP_E06, /* EMPR 6 */
55 NWZ_NVP_E07, /* EMPR 7 */
56 NWZ_NVP_E08, /* EMPR 8 */
57 NWZ_NVP_E09, /* EMPR 9 */
58 NWZ_NVP_E10, /* EMPR 10 */
59 NWZ_NVP_E11, /* EMPR 11 */
60 NWZ_NVP_E12, /* EMPR 12 */
61 NWZ_NVP_E13, /* EMPR 13 */
62 NWZ_NVP_E14, /* EMPR 14 */
63 NWZ_NVP_E15, /* EMPR 15 */
64 NWZ_NVP_E16, /* EMPR 16 */
65 NWZ_NVP_E17, /* EMPR 17 */
66 NWZ_NVP_E18, /* EMPR 18 */
67 NWZ_NVP_E19, /* EMPR 19 */
68 NWZ_NVP_E20, /* EMPR 20 */
69 NWZ_NVP_E21, /* EMPR 21 */
70 NWZ_NVP_E22, /* EMPR 22 */
71 NWZ_NVP_E23, /* EMPR 23 */
72 NWZ_NVP_E24, /* EMPR 24 */
73 NWZ_NVP_E25, /* EMPR 25 */
74 NWZ_NVP_E26, /* EMPR 26 */
75 NWZ_NVP_E27, /* EMPR 27 */
76 NWZ_NVP_E28, /* EMPR 28 */
77 NWZ_NVP_E29, /* EMPR 29 */
78 NWZ_NVP_E30, /* EMPR 30 */
79 NWZ_NVP_E31, /* EMPR 31 */
80 NWZ_NVP_EDW, /* quick shutdown flag */
81 NWZ_NVP_ERI, /* update error image */
82 NWZ_NVP_EXM, /* exception monitor mode */
83 NWZ_NVP_FMP, /* fm parameter */
84 NWZ_NVP_FNI, /* function information */
85 NWZ_NVP_FPI, /* */
86 NWZ_NVP_FUI, /* update image */
87 NWZ_NVP_FUP, /* firmware update flag */
88 NWZ_NVP_FUR, /* */
89 NWZ_NVP_FVI, /* */
90 NWZ_NVP_GTY, /* getty mode flag */
91 NWZ_NVP_HDI, /* hold image */
92 NWZ_NVP_HLD, /* hold mode */
93 NWZ_NVP_INS, /* */
94 NWZ_NVP_IPT, /* disable iptable flag */
95 NWZ_NVP_KAS, /* key and signature */
96 NWZ_NVP_LBI, /* low battery image */
97 NWZ_NVP_LYR, /* */
98 NWZ_NVP_MAC, /* wifi mac address */
99 NWZ_NVP_MCR, /* marlin crl */
100 NWZ_NVP_MDK, /* marlin device key */
101 NWZ_NVP_MDL, /* middleware parameter */
102 NWZ_NVP_MID, /* model id */
103 NWZ_NVP_MLK, /* marlin key */
104 NWZ_NVP_MSC, /* mass storage class mode */
105 NWZ_NVP_MSO, /* MSC only mode flag */
106 NWZ_NVP_MTM, /* marlin time */
107 NWZ_NVP_MUK, /* marlin user key */
108 NWZ_NVP_NCP, /* noise cancel driver parameter */
109 NWZ_NVP_NVR, /* */
110 NWZ_NVP_PCD, /* product code */
111 NWZ_NVP_PCI, /* precharge image */
112 NWZ_NVP_PRK, /* */
113 NWZ_NVP_PSK, /* bluetooth pskey */
114 NWZ_NVP_PTS, /* wifi protected setup */
115 NWZ_NVP_RBT, /* */
116 NWZ_NVP_RND, /* wmt key | random data */
117 NWZ_NVP_RTC, /* rtc alarm */
118 NWZ_NVP_SDC, /* SD Card export flag */
119 NWZ_NVP_SDP, /* sound driver parameter */
120 NWZ_NVP_SER, /* serial number */
121 NWZ_NVP_SFI, /* starfish id */
122 NWZ_NVP_SHE, /* */
123 NWZ_NVP_SHP, /* ship information */
124 NWZ_NVP_SID, /* service id */
125 NWZ_NVP_SKD, /* slacker id file */
126 NWZ_NVP_SKT, /* slacker time */
127 NWZ_NVP_SKU, /* */
128 NWZ_NVP_SLP, /* time out to sleep */
129 NWZ_NVP_SPS, /* speaker ship info */
130 NWZ_NVP_SYI, /* system information */
131 NWZ_NVP_TR0, /* EKB 0 */
132 NWZ_NVP_TR1, /* EKB 1 */
133 NWZ_NVP_TST, /* test mode flag */
134 NWZ_NVP_UBP, /* u-boot password */
135 NWZ_NVP_UFN, /* update file name */
136 NWZ_NVP_UMS, /* */
137 NWZ_NVP_UPS, /* */
138 NWZ_NVP_VRT, /* europe vol regulation flag */
139 NWZ_NVP_COUNT /* Number of nvp nodes */
140};
141
142/* Invalid NVP index */
143#define NWZ_NVP_INVALID -1 /* Non-existent entry */
144/* Number of models */
145#define NWZ_MODEL_COUNT 181
146/* Number of series */
147#define NWZ_SERIES_COUNT 36
148
149/* NVP node info */
150struct nwz_nvp_info_t
151{
152 const char *name; /* Sony's name: "bti" */
153 unsigned long size; /* Size in bytes */
154 const char *desc; /* Description: "bootloader image" */
155};
156
157/* NVP index map (nwz_nvp_node_t -> index) */
158typedef int nwz_nvp_index_t[NWZ_NVP_COUNT];
159
160/* Model info */
161struct nwz_model_info_t
162{
163 unsigned long mid; /* Model ID: first 4 bytes of the NVP mid entry */
164 const char *name; /* Human name: "NWZ-E463" */
165};
166
167/* Series info */
168struct nwz_series_info_t
169{
170 const char *codename; /* Rockbox codename: nwz-e460 */
171 const char *name; /* Human name: "NWZ-E460 Series" */
172 int mid_count; /* number of entries in mid_list */
173 unsigned long *mid; /* List of model IDs */
174 /* Pointer to a name -> index map, nonexistent entries map to NWZ_NVP_INVALID */
175 nwz_nvp_index_t *nvp_index;
176};
177
178/* List of all NVP entries, indexed by nwz_nvp_node_t */
179extern struct nwz_nvp_info_t nwz_nvp[NWZ_NVP_COUNT];
180/* List of all models, sorted by increasing values of model ID */
181extern struct nwz_model_info_t nwz_model[NWZ_MODEL_COUNT];
182/* List of all series */
183extern struct nwz_series_info_t nwz_series[NWZ_SERIES_COUNT];
184
185#endif /* __NWZ_DB_H__ */