spiflash 0.0.post11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spiflash-0.0.post11/.gitignore +52 -0
- spiflash-0.0.post11/LICENSE +202 -0
- spiflash-0.0.post11/PKG-INFO +174 -0
- spiflash-0.0.post11/README.md +157 -0
- spiflash-0.0.post11/docs/DEVELOPING.md +87 -0
- spiflash-0.0.post11/docs/SOURCES.md +51 -0
- spiflash-0.0.post11/pyproject.toml +86 -0
- spiflash-0.0.post11/src/spiflash/__init__.py +72 -0
- spiflash-0.0.post11/src/spiflash/_version.py +24 -0
- spiflash-0.0.post11/src/spiflash/cli.py +135 -0
- spiflash-0.0.post11/src/spiflash/data/manufacturers.json +2308 -0
- spiflash-0.0.post11/src/spiflash/data/records.json +1948 -0
- spiflash-0.0.post11/src/spiflash/data/sources.json +90 -0
- spiflash-0.0.post11/src/spiflash/db.py +163 -0
- spiflash-0.0.post11/src/spiflash/model.py +322 -0
- spiflash-0.0.post11/src/spiflash/py.typed +0 -0
- spiflash-0.0.post11/src/spiflash/vendors.py +82 -0
- spiflash-0.0.post11/tests/test_cli.py +87 -0
- spiflash-0.0.post11/tests/test_cparse.py +136 -0
- spiflash-0.0.post11/tests/test_db.py +296 -0
- spiflash-0.0.post11/tests/test_extract.py +588 -0
- spiflash-0.0.post11/tests/test_update_db.py +78 -0
- spiflash-0.0.post11/tools/sources.toml +52 -0
- spiflash-0.0.post11/tools/spiflash_extract/__init__.py +16 -0
- spiflash-0.0.post11/tools/spiflash_extract/cparse.py +349 -0
- spiflash-0.0.post11/tools/spiflash_extract/fetch.py +80 -0
- spiflash-0.0.post11/tools/spiflash_extract/flashrom.py +228 -0
- spiflash-0.0.post11/tools/spiflash_extract/linux.py +232 -0
- spiflash-0.0.post11/tools/spiflash_extract/openfpgaloader.py +83 -0
- spiflash-0.0.post11/tools/spiflash_extract/openocd.py +122 -0
- spiflash-0.0.post11/tools/spiflash_extract/record.py +108 -0
- spiflash-0.0.post11/tools/spiflash_extract/uboot.py +139 -0
- spiflash-0.0.post11/tools/update_db.py +119 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
venv/
|
|
10
|
+
|
|
11
|
+
# Tooling caches
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.ruff_cache/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
.cache/
|
|
16
|
+
.uvcache/
|
|
17
|
+
|
|
18
|
+
# Coverage artifacts (pytest-cov / coverage.py)
|
|
19
|
+
.coverage
|
|
20
|
+
.coverage.*
|
|
21
|
+
htmlcov/
|
|
22
|
+
|
|
23
|
+
# hatch-vcs writes this at build/editable-install time; it is derived from git.
|
|
24
|
+
/src/spiflash/_version.py
|
|
25
|
+
|
|
26
|
+
# tools/update_db.py fetches the upstream sources here.
|
|
27
|
+
/upstream/
|
|
28
|
+
|
|
29
|
+
# Debian build byproducts. debian/changelog is written by the build
|
|
30
|
+
# (apt-repo-action's scripts/deb-version.py) and never committed.
|
|
31
|
+
debian/changelog
|
|
32
|
+
/built-debs/
|
|
33
|
+
*.deb
|
|
34
|
+
*.buildinfo
|
|
35
|
+
*.changes
|
|
36
|
+
/debian/.debhelper/
|
|
37
|
+
/debian/files
|
|
38
|
+
/debian/*.debhelper
|
|
39
|
+
/debian/*.substvars
|
|
40
|
+
/debian/python3-spiflash/
|
|
41
|
+
/.pybuild/
|
|
42
|
+
/debian/debhelper-build-stamp
|
|
43
|
+
|
|
44
|
+
# Project-local scratch
|
|
45
|
+
tmp/
|
|
46
|
+
|
|
47
|
+
# Claude Code local config and subagent-driven-development scratch
|
|
48
|
+
/.claude/
|
|
49
|
+
/.superpowers/
|
|
50
|
+
|
|
51
|
+
# Git worktrees for branches in flight
|
|
52
|
+
/.worktrees/
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: spiflash
|
|
3
|
+
Version: 0.0.post11
|
|
4
|
+
Summary: A database of SPI flash chips (JEDEC ids, sizes, erase geometry, features), merged from Linux, U-Boot, flashrom, flashprog, OpenOCD and openFPGALoader.
|
|
5
|
+
Project-URL: Homepage, https://github.com/mithro/spiflash
|
|
6
|
+
Project-URL: Issues, https://github.com/mithro/spiflash/issues
|
|
7
|
+
Author-email: Tim Ansell <me@mith.ro>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: flash,flashrom,fpga,jedec,jep106,sfdp,spi,spi-nand,spi-nor
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
14
|
+
Classifier: Topic :: System :: Hardware
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# spiflash
|
|
19
|
+
|
|
20
|
+
A database of SPI flash chips — JEDEC ids, part names, sizes, page and sector
|
|
21
|
+
sizes, erase opcodes and block layouts, supply voltages and capabilities —
|
|
22
|
+
merged from the flash tables of every project that keeps one:
|
|
23
|
+
|
|
24
|
+
| source | what is read | records |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| [Linux](https://github.com/torvalds/linux) | `drivers/mtd/spi-nor/*.c`, `drivers/mtd/nand/spi/*.c` | 377 (127 SPI NAND) |
|
|
27
|
+
| [U-Boot](https://github.com/u-boot/u-boot) | `drivers/mtd/spi/spi-nor-ids.c` | 334 |
|
|
28
|
+
| [flashrom](https://github.com/flashrom/flashrom) | `flashchips/*.c` (SPI chips only) | 512 |
|
|
29
|
+
| [flashprog](https://review.sourcearcade.org/flashprog.git) | `flashchips.c` (SPI chips only) | 480 |
|
|
30
|
+
| [OpenOCD](https://github.com/openocd-org/openocd) | `src/flash/nor/spi.c`, and `src/helper/jep106.inc` for manufacturer names | 190 |
|
|
31
|
+
| [openFPGALoader](https://github.com/trabucayre/openFPGALoader) | `src/spiFlashdb.hpp` | 53 |
|
|
32
|
+
|
|
33
|
+
Together that is 778 distinct chip ids (651 SPI NOR, 127 SPI NAND) from 37
|
|
34
|
+
manufacturers, 459 of them described by more than one source, plus the full
|
|
35
|
+
JEP106 manufacturer list. Every entry keeps the upstream file and line it came
|
|
36
|
+
from, and where the sources disagree (60 ids do) both answers are kept.
|
|
37
|
+
|
|
38
|
+
`spiflash sources` (or `spiflash.sources()`) names the exact upstream commits
|
|
39
|
+
the shipped data was extracted from.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
pip install spiflash # or: uv tool install spiflash
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
It has no dependencies. Or, as a Debian package, from the signed apt
|
|
48
|
+
repository at https://mith.ro/spiflash/. There is one per suite (bookworm,
|
|
49
|
+
trixie, forky and sid), and the package is `Architecture: all`, so it installs
|
|
50
|
+
on any architecture. Put your suite's name in place of `trixie` below
|
|
51
|
+
(Raspberry Pi OS uses Debian's codenames):
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
sudo install -d -m0755 /etc/apt/keyrings
|
|
55
|
+
curl -fsSL https://mith.ro/spiflash/spiflash.gpg | sudo tee /etc/apt/keyrings/spiflash.gpg > /dev/null
|
|
56
|
+
echo "deb [signed-by=/etc/apt/keyrings/spiflash.gpg] https://mith.ro/spiflash/trixie/ ./" \
|
|
57
|
+
| sudo tee /etc/apt/sources.list.d/spiflash.list
|
|
58
|
+
sudo apt update
|
|
59
|
+
sudo apt install python3-spiflash # provides the spiflash command
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The repository's signing key is
|
|
63
|
+
`B528 6C61 A99A 9E6A 5B8A 8E5B 6B2D 7683 DE01 081D`
|
|
64
|
+
(`gpg --show-keys /etc/apt/keyrings/spiflash.gpg` shows it).
|
|
65
|
+
|
|
66
|
+
## The command
|
|
67
|
+
|
|
68
|
+
What answered `9f` with `ef 40 18`?
|
|
69
|
+
|
|
70
|
+
```console
|
|
71
|
+
$ spiflash id ef4018
|
|
72
|
+
ef4018 Winbond W25Q128, W25Q128.V, W25Q128FV, W25Q128JV (nor)
|
|
73
|
+
size 16 MiB, page 256 B, sector 64 KiB, 2.7-3.6 V
|
|
74
|
+
features: dual_read erase_32k erase_4k erase_64k fast_read lock otp quad_read sfdp
|
|
75
|
+
from: flashrom, flashprog, linux, u-boot, openocd, openfpgaloader
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`-v` lists every upstream entry with its file and line, `--json` prints it all
|
|
79
|
+
as JSON. Bytes after the three-byte id narrow the answer: a Spansion
|
|
80
|
+
S25FL128S answers `01 20 18 4d 01 80`, and `spiflash id '01 20 18 4d 01 80'`
|
|
81
|
+
drops the variants with other extended ids. A leading `7f` continuation code is
|
|
82
|
+
optional (`1c7018` and `7f1c7018` are both an Eon EN25QH128).
|
|
83
|
+
|
|
84
|
+
What does a part answer?
|
|
85
|
+
|
|
86
|
+
```console
|
|
87
|
+
$ spiflash find gd25q64
|
|
88
|
+
c84017 GigaDevice GD25Q64, GD25Q64C (nor)
|
|
89
|
+
size 8 MiB, page 256 B, sector 64 KiB, 2.7-3.6 V
|
|
90
|
+
...
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
A family (`w25q128`), a part (`W25Q128JV`) or a full order code
|
|
94
|
+
(`S25FL128SAGMFI001`) all work; flashrom's `.` wildcards (`W25Q128.V`) are
|
|
95
|
+
understood.
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
spiflash list --manufacturer winbond # every Winbond id
|
|
99
|
+
spiflash list --type nand
|
|
100
|
+
spiflash id --method res1 10 # a legacy RES signature byte (M25P10)
|
|
101
|
+
spiflash jep106 7f1c # "Eon Silicon Devices"
|
|
102
|
+
spiflash sources # the upstream commits
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## The library
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import spiflash
|
|
109
|
+
|
|
110
|
+
(chip,) = spiflash.lookup("ef4018") # or b"\xef\x40\x18", 0xef4018, [0xef, 0x40, 0x18]
|
|
111
|
+
chip.manufacturer # 'Winbond'
|
|
112
|
+
chip.names # ('W25Q128', 'W25Q128.V', 'W25Q128FV', 'W25Q128JV')
|
|
113
|
+
chip.size, chip.page_size, chip.sector_size # (16777216, 256, 65536)
|
|
114
|
+
chip.voltage # (2700, 3600), in mV
|
|
115
|
+
"quad_read" in chip.features # True
|
|
116
|
+
chip.feature_sources("quad_read") # ('flashprog', 'linux', 'openocd', 'u-boot')
|
|
117
|
+
chip.conflicts # {} -- or {"page_size": {256: (...), 512: (...)}}
|
|
118
|
+
|
|
119
|
+
for r in chip.records: # every upstream entry, as extracted
|
|
120
|
+
print(r.source, r.name, r.url, r.erasers, r.opcodes, r.flags)
|
|
121
|
+
|
|
122
|
+
spiflash.find("MX25L12835F") # by part name, best match first
|
|
123
|
+
spiflash.jep106(0xC2) # 'Macronix'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
A `Flash` is one chip id, and several parts can share one (a W25Q128BV, FV and
|
|
127
|
+
JV all answer `ef4018`), so it lists every name the sources give. Its single
|
|
128
|
+
values (`size`, `page_size`, `sector_size`, `voltage`, `manufacturer`) are what
|
|
129
|
+
most sources agree on, ties going to flashrom, then flashprog, Linux, U-Boot,
|
|
130
|
+
OpenOCD and openFPGALoader; `values("size")` shows who says what. `features`
|
|
131
|
+
is everything any source claims, from this list:
|
|
132
|
+
|
|
133
|
+
| feature | meaning |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `erase_4k`, `erase_32k`, `erase_64k` | that erase size is supported (0x20, 0x52, 0xd8) |
|
|
136
|
+
| `sfdp` | answers SFDP (JESD216) queries |
|
|
137
|
+
| `fast_read`, `dual_read`, `quad_read`, `octal_read`, `octal_dtr_read` | read modes |
|
|
138
|
+
| `quad_pp`, `octal_dtr_pp` | page program modes |
|
|
139
|
+
| `qpi` | QPI (4-4-4) mode |
|
|
140
|
+
| `4byte_addr`, `4byte_opcodes` | 4-byte addressing; dedicated 4-byte opcodes |
|
|
141
|
+
| `otp`, `lock`, `rww`, `no_erase` | OTP area; status-register block protection; read-while-write; FRAM/MRAM |
|
|
142
|
+
|
|
143
|
+
The upstream's own flags (`SPI_NOR_HAS_TB`, `FEATURE_WRSR2`, ...) are kept on
|
|
144
|
+
each record's `flags` for anything this list does not capture.
|
|
145
|
+
|
|
146
|
+
## Updating the data
|
|
147
|
+
|
|
148
|
+
The data is generated, never edited: `tools/sources.toml` pins each upstream to
|
|
149
|
+
a commit, and
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
uv run tools/update_db.py # rebuild src/spiflash/data/ from the pins
|
|
153
|
+
uv run tools/update_db.py --latest # move the pins to each upstream's HEAD first
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
fetches only the files it reads (a sparse, blobless, depth-1 fetch: about
|
|
157
|
+
15 MB for Linux) and parses the tables as text. A weekly workflow reports when an
|
|
158
|
+
upstream table has changed. See [docs/DEVELOPING.md](docs/DEVELOPING.md) for
|
|
159
|
+
how the extraction works and [docs/SOURCES.md](docs/SOURCES.md) for what is
|
|
160
|
+
taken from where, and under what terms.
|
|
161
|
+
|
|
162
|
+
## Credits
|
|
163
|
+
|
|
164
|
+
The extraction follows the approach of LiteSPI's
|
|
165
|
+
[`spi_nor_config_generator`](https://github.com/litex-hub/litespi/tree/feature/module-generator-overrides/tools/spi_nor_config_generator)
|
|
166
|
+
(Antmicro, 2020): the same upstreams, a JSON record per upstream entry, and the
|
|
167
|
+
handling of OpenOCD's `w25q128fv/jv`-style names. The parsers are new, as Linux
|
|
168
|
+
and flashrom have both since changed their table formats. The data itself is
|
|
169
|
+
the work of the people who maintain those tables.
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
Apache-2.0; see [LICENSE](LICENSE) and, for the data,
|
|
174
|
+
[docs/SOURCES.md](docs/SOURCES.md).
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# spiflash
|
|
2
|
+
|
|
3
|
+
A database of SPI flash chips — JEDEC ids, part names, sizes, page and sector
|
|
4
|
+
sizes, erase opcodes and block layouts, supply voltages and capabilities —
|
|
5
|
+
merged from the flash tables of every project that keeps one:
|
|
6
|
+
|
|
7
|
+
| source | what is read | records |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| [Linux](https://github.com/torvalds/linux) | `drivers/mtd/spi-nor/*.c`, `drivers/mtd/nand/spi/*.c` | 377 (127 SPI NAND) |
|
|
10
|
+
| [U-Boot](https://github.com/u-boot/u-boot) | `drivers/mtd/spi/spi-nor-ids.c` | 334 |
|
|
11
|
+
| [flashrom](https://github.com/flashrom/flashrom) | `flashchips/*.c` (SPI chips only) | 512 |
|
|
12
|
+
| [flashprog](https://review.sourcearcade.org/flashprog.git) | `flashchips.c` (SPI chips only) | 480 |
|
|
13
|
+
| [OpenOCD](https://github.com/openocd-org/openocd) | `src/flash/nor/spi.c`, and `src/helper/jep106.inc` for manufacturer names | 190 |
|
|
14
|
+
| [openFPGALoader](https://github.com/trabucayre/openFPGALoader) | `src/spiFlashdb.hpp` | 53 |
|
|
15
|
+
|
|
16
|
+
Together that is 778 distinct chip ids (651 SPI NOR, 127 SPI NAND) from 37
|
|
17
|
+
manufacturers, 459 of them described by more than one source, plus the full
|
|
18
|
+
JEP106 manufacturer list. Every entry keeps the upstream file and line it came
|
|
19
|
+
from, and where the sources disagree (60 ids do) both answers are kept.
|
|
20
|
+
|
|
21
|
+
`spiflash sources` (or `spiflash.sources()`) names the exact upstream commits
|
|
22
|
+
the shipped data was extracted from.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
pip install spiflash # or: uv tool install spiflash
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
It has no dependencies. Or, as a Debian package, from the signed apt
|
|
31
|
+
repository at https://mith.ro/spiflash/. There is one per suite (bookworm,
|
|
32
|
+
trixie, forky and sid), and the package is `Architecture: all`, so it installs
|
|
33
|
+
on any architecture. Put your suite's name in place of `trixie` below
|
|
34
|
+
(Raspberry Pi OS uses Debian's codenames):
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
sudo install -d -m0755 /etc/apt/keyrings
|
|
38
|
+
curl -fsSL https://mith.ro/spiflash/spiflash.gpg | sudo tee /etc/apt/keyrings/spiflash.gpg > /dev/null
|
|
39
|
+
echo "deb [signed-by=/etc/apt/keyrings/spiflash.gpg] https://mith.ro/spiflash/trixie/ ./" \
|
|
40
|
+
| sudo tee /etc/apt/sources.list.d/spiflash.list
|
|
41
|
+
sudo apt update
|
|
42
|
+
sudo apt install python3-spiflash # provides the spiflash command
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The repository's signing key is
|
|
46
|
+
`B528 6C61 A99A 9E6A 5B8A 8E5B 6B2D 7683 DE01 081D`
|
|
47
|
+
(`gpg --show-keys /etc/apt/keyrings/spiflash.gpg` shows it).
|
|
48
|
+
|
|
49
|
+
## The command
|
|
50
|
+
|
|
51
|
+
What answered `9f` with `ef 40 18`?
|
|
52
|
+
|
|
53
|
+
```console
|
|
54
|
+
$ spiflash id ef4018
|
|
55
|
+
ef4018 Winbond W25Q128, W25Q128.V, W25Q128FV, W25Q128JV (nor)
|
|
56
|
+
size 16 MiB, page 256 B, sector 64 KiB, 2.7-3.6 V
|
|
57
|
+
features: dual_read erase_32k erase_4k erase_64k fast_read lock otp quad_read sfdp
|
|
58
|
+
from: flashrom, flashprog, linux, u-boot, openocd, openfpgaloader
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`-v` lists every upstream entry with its file and line, `--json` prints it all
|
|
62
|
+
as JSON. Bytes after the three-byte id narrow the answer: a Spansion
|
|
63
|
+
S25FL128S answers `01 20 18 4d 01 80`, and `spiflash id '01 20 18 4d 01 80'`
|
|
64
|
+
drops the variants with other extended ids. A leading `7f` continuation code is
|
|
65
|
+
optional (`1c7018` and `7f1c7018` are both an Eon EN25QH128).
|
|
66
|
+
|
|
67
|
+
What does a part answer?
|
|
68
|
+
|
|
69
|
+
```console
|
|
70
|
+
$ spiflash find gd25q64
|
|
71
|
+
c84017 GigaDevice GD25Q64, GD25Q64C (nor)
|
|
72
|
+
size 8 MiB, page 256 B, sector 64 KiB, 2.7-3.6 V
|
|
73
|
+
...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A family (`w25q128`), a part (`W25Q128JV`) or a full order code
|
|
77
|
+
(`S25FL128SAGMFI001`) all work; flashrom's `.` wildcards (`W25Q128.V`) are
|
|
78
|
+
understood.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
spiflash list --manufacturer winbond # every Winbond id
|
|
82
|
+
spiflash list --type nand
|
|
83
|
+
spiflash id --method res1 10 # a legacy RES signature byte (M25P10)
|
|
84
|
+
spiflash jep106 7f1c # "Eon Silicon Devices"
|
|
85
|
+
spiflash sources # the upstream commits
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## The library
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import spiflash
|
|
92
|
+
|
|
93
|
+
(chip,) = spiflash.lookup("ef4018") # or b"\xef\x40\x18", 0xef4018, [0xef, 0x40, 0x18]
|
|
94
|
+
chip.manufacturer # 'Winbond'
|
|
95
|
+
chip.names # ('W25Q128', 'W25Q128.V', 'W25Q128FV', 'W25Q128JV')
|
|
96
|
+
chip.size, chip.page_size, chip.sector_size # (16777216, 256, 65536)
|
|
97
|
+
chip.voltage # (2700, 3600), in mV
|
|
98
|
+
"quad_read" in chip.features # True
|
|
99
|
+
chip.feature_sources("quad_read") # ('flashprog', 'linux', 'openocd', 'u-boot')
|
|
100
|
+
chip.conflicts # {} -- or {"page_size": {256: (...), 512: (...)}}
|
|
101
|
+
|
|
102
|
+
for r in chip.records: # every upstream entry, as extracted
|
|
103
|
+
print(r.source, r.name, r.url, r.erasers, r.opcodes, r.flags)
|
|
104
|
+
|
|
105
|
+
spiflash.find("MX25L12835F") # by part name, best match first
|
|
106
|
+
spiflash.jep106(0xC2) # 'Macronix'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
A `Flash` is one chip id, and several parts can share one (a W25Q128BV, FV and
|
|
110
|
+
JV all answer `ef4018`), so it lists every name the sources give. Its single
|
|
111
|
+
values (`size`, `page_size`, `sector_size`, `voltage`, `manufacturer`) are what
|
|
112
|
+
most sources agree on, ties going to flashrom, then flashprog, Linux, U-Boot,
|
|
113
|
+
OpenOCD and openFPGALoader; `values("size")` shows who says what. `features`
|
|
114
|
+
is everything any source claims, from this list:
|
|
115
|
+
|
|
116
|
+
| feature | meaning |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `erase_4k`, `erase_32k`, `erase_64k` | that erase size is supported (0x20, 0x52, 0xd8) |
|
|
119
|
+
| `sfdp` | answers SFDP (JESD216) queries |
|
|
120
|
+
| `fast_read`, `dual_read`, `quad_read`, `octal_read`, `octal_dtr_read` | read modes |
|
|
121
|
+
| `quad_pp`, `octal_dtr_pp` | page program modes |
|
|
122
|
+
| `qpi` | QPI (4-4-4) mode |
|
|
123
|
+
| `4byte_addr`, `4byte_opcodes` | 4-byte addressing; dedicated 4-byte opcodes |
|
|
124
|
+
| `otp`, `lock`, `rww`, `no_erase` | OTP area; status-register block protection; read-while-write; FRAM/MRAM |
|
|
125
|
+
|
|
126
|
+
The upstream's own flags (`SPI_NOR_HAS_TB`, `FEATURE_WRSR2`, ...) are kept on
|
|
127
|
+
each record's `flags` for anything this list does not capture.
|
|
128
|
+
|
|
129
|
+
## Updating the data
|
|
130
|
+
|
|
131
|
+
The data is generated, never edited: `tools/sources.toml` pins each upstream to
|
|
132
|
+
a commit, and
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
uv run tools/update_db.py # rebuild src/spiflash/data/ from the pins
|
|
136
|
+
uv run tools/update_db.py --latest # move the pins to each upstream's HEAD first
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
fetches only the files it reads (a sparse, blobless, depth-1 fetch: about
|
|
140
|
+
15 MB for Linux) and parses the tables as text. A weekly workflow reports when an
|
|
141
|
+
upstream table has changed. See [docs/DEVELOPING.md](docs/DEVELOPING.md) for
|
|
142
|
+
how the extraction works and [docs/SOURCES.md](docs/SOURCES.md) for what is
|
|
143
|
+
taken from where, and under what terms.
|
|
144
|
+
|
|
145
|
+
## Credits
|
|
146
|
+
|
|
147
|
+
The extraction follows the approach of LiteSPI's
|
|
148
|
+
[`spi_nor_config_generator`](https://github.com/litex-hub/litespi/tree/feature/module-generator-overrides/tools/spi_nor_config_generator)
|
|
149
|
+
(Antmicro, 2020): the same upstreams, a JSON record per upstream entry, and the
|
|
150
|
+
handling of OpenOCD's `w25q128fv/jv`-style names. The parsers are new, as Linux
|
|
151
|
+
and flashrom have both since changed their table formats. The data itself is
|
|
152
|
+
the work of the people who maintain those tables.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
Apache-2.0; see [LICENSE](LICENSE) and, for the data,
|
|
157
|
+
[docs/SOURCES.md](docs/SOURCES.md).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Developing spiflash
|
|
2
|
+
|
|
3
|
+
Contributor notes. For what the package does, see the [README](../README.md);
|
|
4
|
+
for how versions reach PyPI and apt, see [RELEASING.md](../RELEASING.md).
|
|
5
|
+
|
|
6
|
+
## Setup and gates
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
uv sync --group dev
|
|
10
|
+
uv run ruff check && uv run mypy && uv run pytest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Those three are what the `test` job of `.github/workflows/deb.yml` runs, on
|
|
14
|
+
Python 3.11 to 3.14. A green run is what "mergeable" means, and on `main` what
|
|
15
|
+
publishes.
|
|
16
|
+
|
|
17
|
+
## Layout
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
src/spiflash/ the package: model.py (Record, Flash), db.py (loading,
|
|
21
|
+
lookup, find), vendors.py (one name per vendor), cli.py
|
|
22
|
+
src/spiflash/data/ generated: records.json, manufacturers.json, sources.json
|
|
23
|
+
tools/sources.toml the upstream commits the data is built from
|
|
24
|
+
tools/update_db.py fetch, extract, write the data
|
|
25
|
+
tools/spiflash_extract/
|
|
26
|
+
cparse.py just enough C: find tables, split initialisers,
|
|
27
|
+
evaluate integer expressions (SZ_16M, BIT(3), 64 * 1024)
|
|
28
|
+
record.py the common record every extractor writes
|
|
29
|
+
linux.py uboot.py flashrom.py openocd.py openfpgaloader.py
|
|
30
|
+
fetch.py sparse, blobless, depth-1 fetch of one commit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The extractors are not in the wheel; the sdist carries them so the data can be
|
|
34
|
+
rebuilt from it.
|
|
35
|
+
|
|
36
|
+
## Updating the data
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
uv run tools/update_db.py # rebuild from the pins in tools/sources.toml
|
|
40
|
+
uv run tools/update_db.py --latest # move the pins to each upstream's HEAD, then rebuild
|
|
41
|
+
uv run tools/update_db.py --check # fail if the committed data differs
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Commit `tools/sources.toml` and `src/spiflash/data/` together. The data files
|
|
45
|
+
hold one record per line, so `git diff` reads chip by chip.
|
|
46
|
+
|
|
47
|
+
`.github/workflows/upstream.yml` runs `--check` on every change to the data or
|
|
48
|
+
the tools, and `--latest --check` weekly. It is deliberately not part of
|
|
49
|
+
`deb.yml`: a release should not wait on six servers.
|
|
50
|
+
|
|
51
|
+
## When an upstream changes its format
|
|
52
|
+
|
|
53
|
+
An extractor that meets something it does not understand raises, naming the
|
|
54
|
+
file and line, rather than guessing: an unknown probe in flashrom, an `.id`
|
|
55
|
+
that is not `SNOR_ID(...)` in Linux, an identifier the expression evaluator has
|
|
56
|
+
no value for. Fix the extractor, and add the new shape to the miniature tree in
|
|
57
|
+
`tests/test_extract.py`, which holds a cut-down copy of each format.
|
|
58
|
+
|
|
59
|
+
A new vendor spelling fails `test_vendor_spellings_all_canonical`: add it to
|
|
60
|
+
`src/spiflash/vendors.py`.
|
|
61
|
+
|
|
62
|
+
## Adding a source
|
|
63
|
+
|
|
64
|
+
1. A `[name]` table in `tools/sources.toml`: `url`, `branch`, `commit`, the
|
|
65
|
+
`paths` to fetch, and the `license` of those files.
|
|
66
|
+
2. `tools/spiflash_extract/<name>.py` with `extract(root) -> list[Record]`,
|
|
67
|
+
built with `record.make(...)`, and an entry in `update_db.EXTRACTORS`.
|
|
68
|
+
3. Tests on a miniature tree in `tests/test_extract.py`.
|
|
69
|
+
4. Its place in `SOURCE_PRIORITY` (`src/spiflash/model.py`), and a row in the
|
|
70
|
+
README and `docs/SOURCES.md`.
|
|
71
|
+
|
|
72
|
+
## Building the Debian package locally
|
|
73
|
+
|
|
74
|
+
The CI build is `mithro/apt-repo-action`'s `build-deb`: `dpkg-buildpackage -A`
|
|
75
|
+
in a `debian:<suite>` container, after its `scripts/deb-version.py` writes
|
|
76
|
+
`debian/changelog`. By hand, from a clean clone:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
docker run --rm -v "$PWD:/work/src" -v /path/to/apt-repo-action:/a:ro -w /work/src debian:trixie bash -ec '
|
|
80
|
+
apt-get update && apt-get install -y --no-install-recommends build-essential debhelper dpkg-dev fakeroot git python3
|
|
81
|
+
apt-get build-dep -y ./ && git config --global --add safe.directory "*"
|
|
82
|
+
python3 /a/scripts/deb-version.py --suite trixie --write-changelog
|
|
83
|
+
dpkg-buildpackage -us -uc -A'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The package's own tests run during the build (`debian/rules`), and
|
|
87
|
+
`packaging/install-test.sh` is the smoke test CI runs in a clean container.
|