blob: 29d90e4d358885b97be8886cd5882f228a9e760b [file] [log] [blame] [view]
J. Neuschäfer14da5f72024-04-24 13:40:02 +02001flashprog
2=========
Ronald G. Minnich1e5003f2002-04-10 18:02:07 +00003
Nico Huberc3b02dc2023-08-12 01:13:45 +02004flashprog is a utility for detecting, reading, writing, verifying and erasing
Carl-Daniel Hailfinger1ebf8452009-08-18 23:50:14 +00005flash chips. It is often used to flash BIOS/EFI/coreboot/firmware images
6in-system using a supported mainboard, but it also supports flashing of network
Uwe Hermannc7e8a0c2009-05-19 14:14:21 +00007cards (NICs), SATA controller cards, and other external devices which can
8program flash chips.
Uwe Hermanne74b9f82009-04-10 14:41:29 +00009
Stefan Tauner23e10b82016-01-23 16:16:49 +000010It supports a wide range of flash chips (most commonly found in SOIC8, DIP8,
11SOIC16, WSON8, PLCC32, DIP32, TSOP32, and TSOP40 packages), which use various
12protocols such as LPC, FWH, parallel flash, or SPI.
Uwe Hermann42eb17f2008-01-18 17:48:51 +000013
Nico Huber5b4695c2024-08-02 22:56:25 +020014Be careful when using flashprog on laptops! The embedded controller (EC) present in
15older laptops (~pre 2011) might interact badly with any attempts to communicate with the
Stefan Tauner23e10b82016-01-23 16:16:49 +000016flash chip and may brick your laptop.
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +000017
18Please make a backup of your flash chip before writing to it.
19
Nico Huberc3b02dc2023-08-12 01:13:45 +020020Please see the flashprog(8) manpage.
Stefan Reinauer009c51b2010-01-03 23:50:28 +000021
Uwe Hermann2dc5f422006-11-20 20:32:35 +000022
Nico Huber79451f12024-08-02 22:51:55 +020023Source Packaging
24----------------
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000025
Nico Huberc3b02dc2023-08-12 01:13:45 +020026To package flashprog and remove dependencies on Git, either use
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000027make export
28or
29make tarball
30
Nico Huberc3b02dc2023-08-12 01:13:45 +020031'make export' will export all flashprog files from the Git repository at
32revision HEAD into a directory named "$EXPORTDIR/flashprog-$RELEASENAME"
Nico Huber68917092017-11-13 20:12:58 +010033and will additionally add a "versioninfo.inc" file in that directory to
34contain the Git revision of the exported tree and a date for the manual
35page.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000036
Nico Huber68917092017-11-13 20:12:58 +010037'make tarball' will simply tar up the result of make export and compress
38it with bzip2.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000039
Nico Huber68917092017-11-13 20:12:58 +010040The snapshot tarballs are the result of 'make tarball' and require no
41further processing.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000042
43
Uwe Hermannd1129ac2009-05-28 15:07:42 +000044Build Instructions
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +000045------------------
46
Nico Huberc3b02dc2023-08-12 01:13:45 +020047To build flashprog you need to install the following software:
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +000048
Nico Hubercbbd6012024-08-02 23:17:03 +020049 * git (if you check out the source from the repository)
50 * build utilities: meson or make and a C compiler (build-essential or similar depending on OS/distribution)
51 * pkg-config to find library dependencies
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +000052 * pciutils+libpci (if you want support for mainboard or PCI device flashing)
Nico Hubercbbd6012024-08-02 23:17:03 +020053 * libusb 1.0 development package (if you want support for USB programmers, except BusPirate and serprog based)
54 * libftdi 1.0 development package (if you want support for FT2232H or programmers based on it)
55 * libjaylink development package (if you want support for J-LINK programmers)
56 * libgpiod development package (if you want support for GPIO bitbanging under Linux)
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +000057
Nico Hubercbbd6012024-08-02 23:17:03 +020058Compilation with a limited set of programmer drivers is possible. `make` will
59output hints how to disable programmers with missing dependencies.
Uwe Hermann87c07932009-05-05 16:15:46 +000060
Nico Hubercbbd6012024-08-02 23:17:03 +020061### Package names for the above vary across OS distributions:
62
63On Linux et al, look for the following packages:
64
65 * git
66 * gcc
67 * meson / make
68 * pkg-config / pkgconf (not needed if none of the below are used)
69 * pciutils / libpci (optional)
70 * pciutils-devel / pciutils-dev / libpci-dev (optional)
71 * libusb / libusb-1.0-0-dev (optional)
72 * libftdi / libftdi1-dev (optional)
73 * libjaylink / libjaylink-dev (optional)
74 * libgpiod / libgpiod-dev (optional)
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +000075
Idwer Vollering5e410de2009-05-03 23:33:05 +000076On FreeBSD, you need the following ports:
Idwer Vollering5e410de2009-05-03 23:33:05 +000077
Uwe Hermann87c07932009-05-05 16:15:46 +000078 * devel/gmake
79 * devel/libpci
Idwer Vollering5e410de2009-05-03 23:33:05 +000080
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000081On OpenBSD, you need the following ports:
82
83 * devel/gmake
84 * sysutils/pciutils
85
Nico Hubercbbd6012024-08-02 23:17:03 +020086### Building
87
Uwe Hermann87c07932009-05-05 16:15:46 +000088To compile on Linux, use:
Carl-Daniel Hailfinger9abf5292009-05-01 16:34:32 +000089
Uwe Hermann87c07932009-05-05 16:15:46 +000090 make
91
Stefan Tauner8d21ff12015-01-10 09:33:06 +000092To compile on FreeBSD, OpenBSD or DragonFly BSD, use:
Uwe Hermann87c07932009-05-05 16:15:46 +000093
94 gmake
95
Carl-Daniel Hailfinger10572fa2009-08-17 16:30:53 +000096To compile on Nexenta, use:
97
98 make
99
Uwe Hermann87c07932009-05-05 16:15:46 +0000100To compile on Solaris, use:
101
Carl-Daniel Hailfinger10572fa2009-08-17 16:30:53 +0000102 gmake LDFLAGS="-L$pathtolibpci" CC="gcc -I$pathtopciheaders" CFLAGS=-O2
Uwe Hermann87c07932009-05-05 16:15:46 +0000103
Stefan Tauner8d21ff12015-01-10 09:33:06 +0000104To compile on NetBSD (with pciutils, libftdi, libusb installed in /usr/pkg/), use:
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +0000105
106 gmake
107
Carl-Daniel Hailfinger9abf5292009-05-01 16:34:32 +0000108To compile and run on Darwin/Mac OS X:
Uwe Hermann87c07932009-05-05 16:15:46 +0000109
Carl-Daniel Hailfingerf992c192010-10-06 23:16:10 +0000110 Install DirectHW from coresystems GmbH.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000111 DirectHW is available at http://www.coreboot.org/DirectHW .
Carl-Daniel Hailfinger9abf5292009-05-01 16:34:32 +0000112
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +0000113To cross-compile on Linux for DOS:
114
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000115 Get packages of the DJGPP cross compiler and install them:
116 djgpp-filesystem djgpp-gcc djgpp-cpp djgpp-runtime djgpp-binutils
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200117
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000118 As an alternative, the DJGPP web site offers packages for download as well:
Rudolf Marek25fde402017-12-29 16:30:49 +0100119 djcross-binutils-2.29.1-1ap.x86_64.rpm
120 djcross-gcc-7.2.0-1ap.x86_64.rpm
121 djcrx-2.05-5.x86_64.rpm
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200122
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000123 The cross toolchain packages for your distribution may have slightly different
124 names (look for packages named *djgpp*).
Stefan Tauner449abe22013-09-11 23:34:57 +0000125
Rudolf Marek25fde402017-12-29 16:30:49 +0100126 Alternatively, you could use a script to build it from scratch:
127 https://github.com/andrewwutw/build-djgpp
Stefan Tauner449abe22013-09-11 23:34:57 +0000128
Rudolf Marek25fde402017-12-29 16:30:49 +0100129 You will need the libpci and libgetopt library source trees and
130 their compiled static libraries and header files installed in some
131 directory say libpci-libgetopt/, which will be later specified with
Nico Huberc3b02dc2023-08-12 01:13:45 +0200132 LIBS_BASE parameter during flashprog compilation. Easiest way to
133 handle it is to put pciutils, libgetopt and flashprog directories
Rudolf Marek25fde402017-12-29 16:30:49 +0100134 in one subdirectory. There will be an extra subdirectory libpci-libgetopt
135 created, which will contain compiled libpci and libgetopt.
136
Arthur Heymans81deae92026-06-24 23:01:30 +0200137 Download pciutils 3.15.0 and compile it using following command line:
Rudolf Marek25fde402017-12-29 16:30:49 +0100138
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200139 make ZLIB=no DNS=no HOST=i386-djgpp-djgpp CROSS_COMPILE=i586-pc-msdosdjgpp- \
Arthur Heymans81deae92026-06-24 23:01:30 +0200140 PREFIX=/ DESTDIR=$PWD/../libpci-libgetopt install-lib
Rudolf Marek25fde402017-12-29 16:30:49 +0100141
Arthur Heymans81deae92026-06-24 23:01:30 +0200142 Download getopt 2.5 from ftp.math.utah.edu and build the static library:
143
144 tar xzf getopt-2.5.tar.gz
145 cd getopt-2.5
146 printf '%s\n' 'char *gettext(const char *msgid);' >posix/gettext.h
147 sed -i -e 's,env/[gs]etenv\.c,,g' Makefile.in
148 AR=i586-pc-msdosdjgpp-ar RANLIB=i586-pc-msdosdjgpp-ranlib \
149 ./configure --host i586-pc-msdosdjgpp
150 make
Rudolf Marek25fde402017-12-29 16:30:49 +0100151
152 Copy the libgetopt.a to ../libpci-libgetopt/lib and
Arthur Heymans81deae92026-06-24 23:01:30 +0200153 posix/getopt.h to ../libpci-libgetopt/include
Rudolf Marek25fde402017-12-29 16:30:49 +0100154
Nico Huberc3b02dc2023-08-12 01:13:45 +0200155 Enter the flashprog directory.
Rudolf Marek25fde402017-12-29 16:30:49 +0100156
Arthur Heymans81deae92026-06-24 23:01:30 +0200157 make CC=i586-pc-msdosdjgpp-gcc AR=i586-pc-msdosdjgpp-ar \
158 RANLIB=i586-pc-msdosdjgpp-ranlib STRIP=i586-pc-msdosdjgpp-strip \
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200159 LIBS_BASE=../libpci-libgetopt/ HAS_LIBPCI=yes CONFIG_LIBPCI_LDFLAGS=-lpci \
160 strip
Rudolf Marek25fde402017-12-29 16:30:49 +0100161
162 If you like, you can compress the resulting executable with UPX:
163
Nico Huberc3b02dc2023-08-12 01:13:45 +0200164 upx -9 flashprog.exe
Rudolf Marek25fde402017-12-29 16:30:49 +0100165
Nico Huber639d5632024-08-02 23:22:34 +0200166 To run flashprog.exe, download https://flashprog.org/wiki/File:Csdpmi7b.zip and
Stefan Tauner449abe22013-09-11 23:34:57 +0000167 unpack CWSDPMI.EXE into the current directory or one in PATH.
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +0000168
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000169To cross-compile on Linux for Windows:
170
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200171 * Get packages of the MinGW cross compiler and install them:
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000172 mingw32-filesystem mingw32-cross-cpp mingw32-cross-binutils mingw32-cross-gcc
173 mingw32-runtime mingw32-headers
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200174
175 * The cross toolchain packages for your distribution may have slightly different
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000176 names (look for packages named *mingw*).
177 PCI-based programmers (internal etc.) are not supported on Windows.
J. Neuschäfer14da5f72024-04-24 13:40:02 +0200178
179 * Run (change CC= and STRIP= settings where appropriate)
180 `make CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip`
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000181
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000182Processor architecture dependent features:
183
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000184 On non-x86 architectures a few programmers don't work (yet) because they
185 use port-based I/O which is not directly available on non-x86. Those
186 programmers will be disabled automatically if you run "make".
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000187
Stefan Tauner0be072c2016-03-13 15:16:30 +0000188Compiler quirks:
189
190If you are using clang and if you want to enable only one driver, you may hit an
191overzealous compiler warning from clang. Compile with "make WARNERROR=no" to
192force it to continue and enjoy.
193
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000194Installation
195------------
196
Nico Huberc3b02dc2023-08-12 01:13:45 +0200197In order to install flashprog and the manpage into /usr/local, type:
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000198
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000199 make install
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000200
201For installation in a different directory use DESTDIR, e.g. like this:
202
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000203 make DESTDIR=/usr install
204
205If you have insufficient permissions for the destination directory, use sudo
206by adding sudo in front of the commands above.
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000207
208
J. Neuschäfer8ddea572024-04-24 13:38:01 +0200209Branching and release policy
210----------------------------
211
212- Feature development happens on the `main` branch
213- Branch-off points for releases are tagged with tags that start with `p`, such as `p1.0`
214- Release branches have a `.x` suffix, for example `1.0.x`
215- Release tags start with `v`, for example `v1.0` or `v1.0.1`
216- Release candidate tags additionally end with `-rcN`, for example `v1.0-rc1`
217
218
Joerg Mayer7221d5f2009-08-24 13:24:52 +0000219Contact
Uwe Hermanne94dbf22009-05-22 13:18:38 +0000220-------
221
Nico Huberc3b02dc2023-08-12 01:13:45 +0200222The official flashprog website is:
Uwe Hermanne94dbf22009-05-22 13:18:38 +0000223
Nico Huber639d5632024-08-02 23:22:34 +0200224 https://flashprog.org/
Uwe Hermannb6d28322006-12-04 08:15:47 +0000225
Angel Pons1900e1d2021-07-02 12:42:23 +0200226Available contact methods are
Joerg Mayer7221d5f2009-08-24 13:24:52 +0000227
Nico Huber639d5632024-08-02 23:22:34 +0200228 https://flashprog.org/wiki/Contact