| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 1 | flashprog |
| 2 | ========= |
| Ronald G. Minnich | 1e5003f | 2002-04-10 18:02:07 +0000 | [diff] [blame] | 3 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 4 | flashprog is a utility for detecting, reading, writing, verifying and erasing |
| Carl-Daniel Hailfinger | 1ebf845 | 2009-08-18 23:50:14 +0000 | [diff] [blame] | 5 | flash chips. It is often used to flash BIOS/EFI/coreboot/firmware images |
| 6 | in-system using a supported mainboard, but it also supports flashing of network |
| Uwe Hermann | c7e8a0c | 2009-05-19 14:14:21 +0000 | [diff] [blame] | 7 | cards (NICs), SATA controller cards, and other external devices which can |
| 8 | program flash chips. |
| Uwe Hermann | e74b9f8 | 2009-04-10 14:41:29 +0000 | [diff] [blame] | 9 | |
| Stefan Tauner | 23e10b8 | 2016-01-23 16:16:49 +0000 | [diff] [blame] | 10 | It supports a wide range of flash chips (most commonly found in SOIC8, DIP8, |
| 11 | SOIC16, WSON8, PLCC32, DIP32, TSOP32, and TSOP40 packages), which use various |
| 12 | protocols such as LPC, FWH, parallel flash, or SPI. |
| Uwe Hermann | 42eb17f | 2008-01-18 17:48:51 +0000 | [diff] [blame] | 13 | |
| Nico Huber | 5b4695c | 2024-08-02 22:56:25 +0200 | [diff] [blame] | 14 | Be careful when using flashprog on laptops! The embedded controller (EC) present in |
| 15 | older laptops (~pre 2011) might interact badly with any attempts to communicate with the |
| Stefan Tauner | 23e10b8 | 2016-01-23 16:16:49 +0000 | [diff] [blame] | 16 | flash chip and may brick your laptop. |
| Carl-Daniel Hailfinger | 2702376 | 2010-04-28 15:22:14 +0000 | [diff] [blame] | 17 | |
| 18 | Please make a backup of your flash chip before writing to it. |
| 19 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 20 | Please see the flashprog(8) manpage. |
| Stefan Reinauer | 009c51b | 2010-01-03 23:50:28 +0000 | [diff] [blame] | 21 | |
| Uwe Hermann | 2dc5f42 | 2006-11-20 20:32:35 +0000 | [diff] [blame] | 22 | |
| Nico Huber | 79451f1 | 2024-08-02 22:51:55 +0200 | [diff] [blame] | 23 | Source Packaging |
| 24 | ---------------- |
| Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 25 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 26 | To package flashprog and remove dependencies on Git, either use |
| Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 27 | make export |
| 28 | or |
| 29 | make tarball |
| 30 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 31 | 'make export' will export all flashprog files from the Git repository at |
| 32 | revision HEAD into a directory named "$EXPORTDIR/flashprog-$RELEASENAME" |
| Nico Huber | 6891709 | 2017-11-13 20:12:58 +0100 | [diff] [blame] | 33 | and will additionally add a "versioninfo.inc" file in that directory to |
| 34 | contain the Git revision of the exported tree and a date for the manual |
| 35 | page. |
| Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 36 | |
| Nico Huber | 6891709 | 2017-11-13 20:12:58 +0100 | [diff] [blame] | 37 | 'make tarball' will simply tar up the result of make export and compress |
| 38 | it with bzip2. |
| Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 39 | |
| Nico Huber | 6891709 | 2017-11-13 20:12:58 +0100 | [diff] [blame] | 40 | The snapshot tarballs are the result of 'make tarball' and require no |
| 41 | further processing. |
| Carl-Daniel Hailfinger | a23041c | 2009-06-12 14:49:10 +0000 | [diff] [blame] | 42 | |
| 43 | |
| Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 44 | Build Instructions |
| Stefan Reinauer | 06b2c4d | 2005-12-01 10:51:08 +0000 | [diff] [blame] | 45 | ------------------ |
| 46 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 47 | To build flashprog you need to install the following software: |
| Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 48 | |
| Nico Huber | cbbd601 | 2024-08-02 23:17:03 +0200 | [diff] [blame] | 49 | * 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 Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 52 | * pciutils+libpci (if you want support for mainboard or PCI device flashing) |
| Nico Huber | cbbd601 | 2024-08-02 23:17:03 +0200 | [diff] [blame] | 53 | * 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 Reinauer | 06b2c4d | 2005-12-01 10:51:08 +0000 | [diff] [blame] | 57 | |
| Nico Huber | cbbd601 | 2024-08-02 23:17:03 +0200 | [diff] [blame] | 58 | Compilation with a limited set of programmer drivers is possible. `make` will |
| 59 | output hints how to disable programmers with missing dependencies. |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 60 | |
| Nico Huber | cbbd601 | 2024-08-02 23:17:03 +0200 | [diff] [blame] | 61 | ### Package names for the above vary across OS distributions: |
| 62 | |
| 63 | On 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 Reinauer | 06b2c4d | 2005-12-01 10:51:08 +0000 | [diff] [blame] | 75 | |
| Idwer Vollering | 5e410de | 2009-05-03 23:33:05 +0000 | [diff] [blame] | 76 | On FreeBSD, you need the following ports: |
| Idwer Vollering | 5e410de | 2009-05-03 23:33:05 +0000 | [diff] [blame] | 77 | |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 78 | * devel/gmake |
| 79 | * devel/libpci |
| Idwer Vollering | 5e410de | 2009-05-03 23:33:05 +0000 | [diff] [blame] | 80 | |
| Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 81 | On OpenBSD, you need the following ports: |
| 82 | |
| 83 | * devel/gmake |
| 84 | * sysutils/pciutils |
| 85 | |
| Nico Huber | cbbd601 | 2024-08-02 23:17:03 +0200 | [diff] [blame] | 86 | ### Building |
| 87 | |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 88 | To compile on Linux, use: |
| Carl-Daniel Hailfinger | 9abf529 | 2009-05-01 16:34:32 +0000 | [diff] [blame] | 89 | |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 90 | make |
| 91 | |
| Stefan Tauner | 8d21ff1 | 2015-01-10 09:33:06 +0000 | [diff] [blame] | 92 | To compile on FreeBSD, OpenBSD or DragonFly BSD, use: |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 93 | |
| 94 | gmake |
| 95 | |
| Carl-Daniel Hailfinger | 10572fa | 2009-08-17 16:30:53 +0000 | [diff] [blame] | 96 | To compile on Nexenta, use: |
| 97 | |
| 98 | make |
| 99 | |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 100 | To compile on Solaris, use: |
| 101 | |
| Carl-Daniel Hailfinger | 10572fa | 2009-08-17 16:30:53 +0000 | [diff] [blame] | 102 | gmake LDFLAGS="-L$pathtolibpci" CC="gcc -I$pathtopciheaders" CFLAGS=-O2 |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 103 | |
| Stefan Tauner | 8d21ff1 | 2015-01-10 09:33:06 +0000 | [diff] [blame] | 104 | To compile on NetBSD (with pciutils, libftdi, libusb installed in /usr/pkg/), use: |
| Carl-Daniel Hailfinger | b63b067 | 2010-07-02 17:12:50 +0000 | [diff] [blame] | 105 | |
| 106 | gmake |
| 107 | |
| Carl-Daniel Hailfinger | 9abf529 | 2009-05-01 16:34:32 +0000 | [diff] [blame] | 108 | To compile and run on Darwin/Mac OS X: |
| Uwe Hermann | 87c0793 | 2009-05-05 16:15:46 +0000 | [diff] [blame] | 109 | |
| Carl-Daniel Hailfinger | f992c19 | 2010-10-06 23:16:10 +0000 | [diff] [blame] | 110 | Install DirectHW from coresystems GmbH. |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 111 | DirectHW is available at http://www.coreboot.org/DirectHW . |
| Carl-Daniel Hailfinger | 9abf529 | 2009-05-01 16:34:32 +0000 | [diff] [blame] | 112 | |
| Carl-Daniel Hailfinger | 50415d2 | 2010-03-21 14:54:57 +0000 | [diff] [blame] | 113 | To cross-compile on Linux for DOS: |
| 114 | |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 115 | Get packages of the DJGPP cross compiler and install them: |
| 116 | djgpp-filesystem djgpp-gcc djgpp-cpp djgpp-runtime djgpp-binutils |
| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 117 | |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 118 | As an alternative, the DJGPP web site offers packages for download as well: |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 119 | 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äfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 122 | |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 123 | The cross toolchain packages for your distribution may have slightly different |
| 124 | names (look for packages named *djgpp*). |
| Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 125 | |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 126 | Alternatively, you could use a script to build it from scratch: |
| 127 | https://github.com/andrewwutw/build-djgpp |
| Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 128 | |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 129 | 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 Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 132 | LIBS_BASE parameter during flashprog compilation. Easiest way to |
| 133 | handle it is to put pciutils, libgetopt and flashprog directories |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 134 | in one subdirectory. There will be an extra subdirectory libpci-libgetopt |
| 135 | created, which will contain compiled libpci and libgetopt. |
| 136 | |
| Nico Huber | 639d563 | 2024-08-02 23:22:34 +0200 | [diff] [blame] | 137 | Download pciutils 3.5.6 and apply https://flashprog.org/wiki/File:Pciutils-3.5.6.patch.gz |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 138 | Compile pciutils, using following command line: |
| 139 | |
| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 140 | make ZLIB=no DNS=no HOST=i386-djgpp-djgpp CROSS_COMPILE=i586-pc-msdosdjgpp- \ |
| 141 | PREFIX=/ DESTDIR=$PWD/../libpci-libgetopt \ |
| 142 | STRIP="--strip-program=i586-pc-msdosdjgpp-strip -s" install install-lib |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 143 | |
| Nico Huber | 639d563 | 2024-08-02 23:22:34 +0200 | [diff] [blame] | 144 | Download and compile with 'make' https://flashprog.org/wiki/File:Libgetopt.tar.gz |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 145 | |
| 146 | Copy the libgetopt.a to ../libpci-libgetopt/lib and |
| 147 | getopt.h to ../libpci-libgetopt/include |
| 148 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 149 | Enter the flashprog directory. |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 150 | |
| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 151 | make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip \ |
| 152 | LIBS_BASE=../libpci-libgetopt/ HAS_LIBPCI=yes CONFIG_LIBPCI_LDFLAGS=-lpci \ |
| 153 | strip |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 154 | |
| 155 | If you like, you can compress the resulting executable with UPX: |
| 156 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 157 | upx -9 flashprog.exe |
| Rudolf Marek | 25fde40 | 2017-12-29 16:30:49 +0100 | [diff] [blame] | 158 | |
| Nico Huber | 639d563 | 2024-08-02 23:22:34 +0200 | [diff] [blame] | 159 | To run flashprog.exe, download https://flashprog.org/wiki/File:Csdpmi7b.zip and |
| Stefan Tauner | 449abe2 | 2013-09-11 23:34:57 +0000 | [diff] [blame] | 160 | unpack CWSDPMI.EXE into the current directory or one in PATH. |
| Stefan Reinauer | 06b2c4d | 2005-12-01 10:51:08 +0000 | [diff] [blame] | 161 | |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 162 | To cross-compile on Linux for Windows: |
| 163 | |
| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 164 | * Get packages of the MinGW cross compiler and install them: |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 165 | mingw32-filesystem mingw32-cross-cpp mingw32-cross-binutils mingw32-cross-gcc |
| 166 | mingw32-runtime mingw32-headers |
| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 167 | |
| 168 | * The cross toolchain packages for your distribution may have slightly different |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 169 | names (look for packages named *mingw*). |
| 170 | PCI-based programmers (internal etc.) are not supported on Windows. |
| J. Neuschäfer | 14da5f7 | 2024-04-24 13:40:02 +0200 | [diff] [blame] | 171 | |
| 172 | * Run (change CC= and STRIP= settings where appropriate) |
| 173 | `make CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip` |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 174 | |
| Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 175 | Processor architecture dependent features: |
| 176 | |
| Carl-Daniel Hailfinger | 60d9bd2 | 2012-08-09 23:34:41 +0000 | [diff] [blame] | 177 | On non-x86 architectures a few programmers don't work (yet) because they |
| 178 | use port-based I/O which is not directly available on non-x86. Those |
| 179 | programmers will be disabled automatically if you run "make". |
| Carl-Daniel Hailfinger | 9e3a6c4 | 2010-10-08 12:40:09 +0000 | [diff] [blame] | 180 | |
| Stefan Tauner | 0be072c | 2016-03-13 15:16:30 +0000 | [diff] [blame] | 181 | Compiler quirks: |
| 182 | |
| 183 | If you are using clang and if you want to enable only one driver, you may hit an |
| 184 | overzealous compiler warning from clang. Compile with "make WARNERROR=no" to |
| 185 | force it to continue and enjoy. |
| 186 | |
| Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 187 | Installation |
| 188 | ------------ |
| 189 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 190 | In order to install flashprog and the manpage into /usr/local, type: |
| Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 191 | |
| Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 192 | make install |
| Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 193 | |
| 194 | For installation in a different directory use DESTDIR, e.g. like this: |
| 195 | |
| Carl-Daniel Hailfinger | a472b8b | 2009-10-03 17:08:02 +0000 | [diff] [blame] | 196 | make DESTDIR=/usr install |
| 197 | |
| 198 | If you have insufficient permissions for the destination directory, use sudo |
| 199 | by adding sudo in front of the commands above. |
| Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 200 | |
| 201 | |
| J. Neuschäfer | 8ddea57 | 2024-04-24 13:38:01 +0200 | [diff] [blame] | 202 | Branching and release policy |
| 203 | ---------------------------- |
| 204 | |
| 205 | - Feature development happens on the `main` branch |
| 206 | - Branch-off points for releases are tagged with tags that start with `p`, such as `p1.0` |
| 207 | - Release branches have a `.x` suffix, for example `1.0.x` |
| 208 | - Release tags start with `v`, for example `v1.0` or `v1.0.1` |
| 209 | - Release candidate tags additionally end with `-rcN`, for example `v1.0-rc1` |
| 210 | |
| 211 | |
| Joerg Mayer | 7221d5f | 2009-08-24 13:24:52 +0000 | [diff] [blame] | 212 | Contact |
| Uwe Hermann | e94dbf2 | 2009-05-22 13:18:38 +0000 | [diff] [blame] | 213 | ------- |
| 214 | |
| Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 215 | The official flashprog website is: |
| Uwe Hermann | e94dbf2 | 2009-05-22 13:18:38 +0000 | [diff] [blame] | 216 | |
| Nico Huber | 639d563 | 2024-08-02 23:22:34 +0200 | [diff] [blame] | 217 | https://flashprog.org/ |
| Uwe Hermann | b6d2832 | 2006-12-04 08:15:47 +0000 | [diff] [blame] | 218 | |
| Angel Pons | 1900e1d | 2021-07-02 12:42:23 +0200 | [diff] [blame] | 219 | Available contact methods are |
| Joerg Mayer | 7221d5f | 2009-08-24 13:24:52 +0000 | [diff] [blame] | 220 | |
| Nico Huber | 639d563 | 2024-08-02 23:22:34 +0200 | [diff] [blame] | 221 | https://flashprog.org/wiki/Contact |