blob: 01e96c6b4f2e5204c936222bad00ee5b3411d76d [file] [log] [blame]
Uwe Hermann2dc5f422006-11-20 20:32:35 +00001-------------------------------------------------------------------------------
Nico Huberc3b02dc2023-08-12 01:13:45 +02002flashprog README
Uwe Hermann2dc5f422006-11-20 20:32:35 +00003-------------------------------------------------------------------------------
Ronald G. Minnich1e5003f2002-04-10 18:02:07 +00004
Nico Huberc3b02dc2023-08-12 01:13:45 +02005flashprog is a utility for detecting, reading, writing, verifying and erasing
Carl-Daniel Hailfinger1ebf8452009-08-18 23:50:14 +00006flash chips. It is often used to flash BIOS/EFI/coreboot/firmware images
7in-system using a supported mainboard, but it also supports flashing of network
Uwe Hermannc7e8a0c2009-05-19 14:14:21 +00008cards (NICs), SATA controller cards, and other external devices which can
9program flash chips.
Uwe Hermanne74b9f82009-04-10 14:41:29 +000010
Stefan Tauner23e10b82016-01-23 16:16:49 +000011It supports a wide range of flash chips (most commonly found in SOIC8, DIP8,
12SOIC16, WSON8, PLCC32, DIP32, TSOP32, and TSOP40 packages), which use various
13protocols such as LPC, FWH, parallel flash, or SPI.
Uwe Hermann42eb17f2008-01-18 17:48:51 +000014
Nico Huberc3b02dc2023-08-12 01:13:45 +020015Do not use flashprog on laptops (yet)! The embedded controller (EC) present in
Stefan Tauner23e10b82016-01-23 16:16:49 +000016many laptops might interact badly with any attempts to communicate with the
17flash chip and may brick your laptop.
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +000018
19Please make a backup of your flash chip before writing to it.
20
Nico Huberc3b02dc2023-08-12 01:13:45 +020021Please see the flashprog(8) manpage.
Stefan Reinauer009c51b2010-01-03 23:50:28 +000022
Uwe Hermann2dc5f422006-11-20 20:32:35 +000023
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000024Packaging
25---------
26
Nico Huberc3b02dc2023-08-12 01:13:45 +020027To package flashprog and remove dependencies on Git, either use
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000028make export
29or
30make tarball
31
Nico Huberc3b02dc2023-08-12 01:13:45 +020032'make export' will export all flashprog files from the Git repository at
33revision HEAD into a directory named "$EXPORTDIR/flashprog-$RELEASENAME"
Nico Huber68917092017-11-13 20:12:58 +010034and will additionally add a "versioninfo.inc" file in that directory to
35contain the Git revision of the exported tree and a date for the manual
36page.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000037
Nico Huber68917092017-11-13 20:12:58 +010038'make tarball' will simply tar up the result of make export and compress
39it with bzip2.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000040
Nico Huber68917092017-11-13 20:12:58 +010041The snapshot tarballs are the result of 'make tarball' and require no
42further processing.
Carl-Daniel Hailfingera23041c2009-06-12 14:49:10 +000043
44
Uwe Hermannd1129ac2009-05-28 15:07:42 +000045Build Instructions
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +000046------------------
47
Nico Huberc3b02dc2023-08-12 01:13:45 +020048To build flashprog you need to install the following software:
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +000049
50 * pciutils+libpci (if you want support for mainboard or PCI device flashing)
James Lairdc60de0e2013-03-27 13:00:23 +000051 * libusb (if you want FT2232, Dediprog or USB-Blaster support)
52 * libftdi (if you want FT2232 or USB-Blaster support)
Marc Schink3578ec62016-03-17 16:23:03 +010053 * libjaylink (if you want support for SEGGER J-Link and compatible devices)
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +000054
Idwer Vollering5e410de2009-05-03 23:33:05 +000055Linux et al:
Uwe Hermann87c07932009-05-05 16:15:46 +000056
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +000057 * pciutils / libpci
Uwe Hermann87c07932009-05-05 16:15:46 +000058 * pciutils-devel / pciutils-dev / libpci-dev
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000059 * zlib-devel / zlib1g-dev (needed if libpci was compiled with libz support)
Steve Markgraf61899472023-01-09 23:06:52 +010060 * libgpiod-dev (if you want support for Linux GPIO devices)
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +000061
Idwer Vollering5e410de2009-05-03 23:33:05 +000062On FreeBSD, you need the following ports:
Idwer Vollering5e410de2009-05-03 23:33:05 +000063
Uwe Hermann87c07932009-05-05 16:15:46 +000064 * devel/gmake
65 * devel/libpci
Idwer Vollering5e410de2009-05-03 23:33:05 +000066
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000067On OpenBSD, you need the following ports:
68
69 * devel/gmake
70 * sysutils/pciutils
71
Uwe Hermann87c07932009-05-05 16:15:46 +000072To compile on Linux, use:
Carl-Daniel Hailfinger9abf5292009-05-01 16:34:32 +000073
Uwe Hermann87c07932009-05-05 16:15:46 +000074 make
75
Stefan Tauner8d21ff12015-01-10 09:33:06 +000076To compile on FreeBSD, OpenBSD or DragonFly BSD, use:
Uwe Hermann87c07932009-05-05 16:15:46 +000077
78 gmake
79
Carl-Daniel Hailfinger10572fa2009-08-17 16:30:53 +000080To compile on Nexenta, use:
81
82 make
83
Uwe Hermann87c07932009-05-05 16:15:46 +000084To compile on Solaris, use:
85
Carl-Daniel Hailfinger10572fa2009-08-17 16:30:53 +000086 gmake LDFLAGS="-L$pathtolibpci" CC="gcc -I$pathtopciheaders" CFLAGS=-O2
Uwe Hermann87c07932009-05-05 16:15:46 +000087
Stefan Tauner8d21ff12015-01-10 09:33:06 +000088To compile on NetBSD (with pciutils, libftdi, libusb installed in /usr/pkg/), use:
Carl-Daniel Hailfingerb63b0672010-07-02 17:12:50 +000089
90 gmake
91
Carl-Daniel Hailfinger9abf5292009-05-01 16:34:32 +000092To compile and run on Darwin/Mac OS X:
Uwe Hermann87c07932009-05-05 16:15:46 +000093
Carl-Daniel Hailfingerf992c192010-10-06 23:16:10 +000094 Install DirectHW from coresystems GmbH.
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000095 DirectHW is available at http://www.coreboot.org/DirectHW .
Carl-Daniel Hailfinger9abf5292009-05-01 16:34:32 +000096
Carl-Daniel Hailfinger50415d22010-03-21 14:54:57 +000097To cross-compile on Linux for DOS:
98
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +000099 Get packages of the DJGPP cross compiler and install them:
100 djgpp-filesystem djgpp-gcc djgpp-cpp djgpp-runtime djgpp-binutils
101 As an alternative, the DJGPP web site offers packages for download as well:
Rudolf Marek25fde402017-12-29 16:30:49 +0100102 djcross-binutils-2.29.1-1ap.x86_64.rpm
103 djcross-gcc-7.2.0-1ap.x86_64.rpm
104 djcrx-2.05-5.x86_64.rpm
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000105 The cross toolchain packages for your distribution may have slightly different
106 names (look for packages named *djgpp*).
Stefan Tauner449abe22013-09-11 23:34:57 +0000107
Rudolf Marek25fde402017-12-29 16:30:49 +0100108 Alternatively, you could use a script to build it from scratch:
109 https://github.com/andrewwutw/build-djgpp
Stefan Tauner449abe22013-09-11 23:34:57 +0000110
Rudolf Marek25fde402017-12-29 16:30:49 +0100111 You will need the libpci and libgetopt library source trees and
112 their compiled static libraries and header files installed in some
113 directory say libpci-libgetopt/, which will be later specified with
Nico Huberc3b02dc2023-08-12 01:13:45 +0200114 LIBS_BASE parameter during flashprog compilation. Easiest way to
115 handle it is to put pciutils, libgetopt and flashprog directories
Rudolf Marek25fde402017-12-29 16:30:49 +0100116 in one subdirectory. There will be an extra subdirectory libpci-libgetopt
117 created, which will contain compiled libpci and libgetopt.
118
Nico Huberc3b02dc2023-08-12 01:13:45 +0200119 Download pciutils 3.5.6 and apply http://flashprog.org/File:Pciutils-3.5.6.patch.gz
Rudolf Marek25fde402017-12-29 16:30:49 +0100120 Compile pciutils, using following command line:
121
122 make ZLIB=no DNS=no HOST=i386-djgpp-djgpp CROSS_COMPILE=i586-pc-msdosdjgpp- \
123 PREFIX=/ DESTDIR=$PWD/../libpci-libgetopt \
124 STRIP="--strip-program=i586-pc-msdosdjgpp-strip -s" install install-lib
125
Nico Huberc3b02dc2023-08-12 01:13:45 +0200126 Download and compile with 'make' http://flashprog.org/File:Libgetopt.tar.gz
Rudolf Marek25fde402017-12-29 16:30:49 +0100127
128 Copy the libgetopt.a to ../libpci-libgetopt/lib and
129 getopt.h to ../libpci-libgetopt/include
130
Nico Huberc3b02dc2023-08-12 01:13:45 +0200131 Enter the flashprog directory.
Rudolf Marek25fde402017-12-29 16:30:49 +0100132
Nico Huberda095992023-03-17 13:02:31 +0000133 make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip \
134 LIBS_BASE=../libpci-libgetopt/ HAS_LIBPCI=yes CONFIG_LIBPCI_LDFLAGS=-lpci \
135 strip
Rudolf Marek25fde402017-12-29 16:30:49 +0100136
137 If you like, you can compress the resulting executable with UPX:
138
Nico Huberc3b02dc2023-08-12 01:13:45 +0200139 upx -9 flashprog.exe
Rudolf Marek25fde402017-12-29 16:30:49 +0100140
Nico Huberc3b02dc2023-08-12 01:13:45 +0200141 To run flashprog.exe, download http://flashprog.org/File:Csdpmi7b.zip and
Stefan Tauner449abe22013-09-11 23:34:57 +0000142 unpack CWSDPMI.EXE into the current directory or one in PATH.
Stefan Reinauer06b2c4d2005-12-01 10:51:08 +0000143
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000144To cross-compile on Linux for Windows:
145
146 Get packages of the MinGW cross compiler and install them:
147 mingw32-filesystem mingw32-cross-cpp mingw32-cross-binutils mingw32-cross-gcc
148 mingw32-runtime mingw32-headers
149 The cross toolchain packages for your distribution may have slightly different
150 names (look for packages named *mingw*).
151 PCI-based programmers (internal etc.) are not supported on Windows.
152 Run (change CC= and STRIP= settings where appropriate)
153 make CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip
154
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000155Processor architecture dependent features:
156
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000157 On non-x86 architectures a few programmers don't work (yet) because they
158 use port-based I/O which is not directly available on non-x86. Those
159 programmers will be disabled automatically if you run "make".
Carl-Daniel Hailfinger9e3a6c42010-10-08 12:40:09 +0000160
Stefan Tauner0be072c2016-03-13 15:16:30 +0000161Compiler quirks:
162
163If you are using clang and if you want to enable only one driver, you may hit an
164overzealous compiler warning from clang. Compile with "make WARNERROR=no" to
165force it to continue and enjoy.
166
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000167Installation
168------------
169
Nico Huberc3b02dc2023-08-12 01:13:45 +0200170In order to install flashprog and the manpage into /usr/local, type:
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000171
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000172 make install
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000173
174For installation in a different directory use DESTDIR, e.g. like this:
175
Carl-Daniel Hailfingera472b8b2009-10-03 17:08:02 +0000176 make DESTDIR=/usr install
177
178If you have insufficient permissions for the destination directory, use sudo
179by adding sudo in front of the commands above.
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000180
181
J. Neuschäfer8ddea572024-04-24 13:38:01 +0200182Branching and release policy
183----------------------------
184
185- Feature development happens on the `main` branch
186- Branch-off points for releases are tagged with tags that start with `p`, such as `p1.0`
187- Release branches have a `.x` suffix, for example `1.0.x`
188- Release tags start with `v`, for example `v1.0` or `v1.0.1`
189- Release candidate tags additionally end with `-rcN`, for example `v1.0-rc1`
190
191
Joerg Mayer7221d5f2009-08-24 13:24:52 +0000192Contact
Uwe Hermanne94dbf22009-05-22 13:18:38 +0000193-------
194
Nico Huberc3b02dc2023-08-12 01:13:45 +0200195The official flashprog website is:
Uwe Hermanne94dbf22009-05-22 13:18:38 +0000196
Nico Huberc3b02dc2023-08-12 01:13:45 +0200197 http://www.flashprog.org/
Uwe Hermannb6d28322006-12-04 08:15:47 +0000198
Angel Pons1900e1d2021-07-02 12:42:23 +0200199Available contact methods are
Joerg Mayer7221d5f2009-08-24 13:24:52 +0000200
Nico Huberc3b02dc2023-08-12 01:13:45 +0200201 https://www.flashprog.org/Contact