1
0
Fork
You've already forked flashprog
0
Fork of flashprog - Upstream: https://review.sourcearcade.org/flashprog
  • C 96%
  • Makefile 1.8%
  • Shell 1.2%
  • Meson 1%
Nico Huber dbf50334a1 linux_mtd: Use sizeof() instead of strlen() on constant string
Newer Clang warns about using strlen() to calculate an array length
(results in a variable-length array w/o GNU extensions).
Change-Id: I30bef896104b315082d2d74984f3e43557d24656
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/333
Reviewed-by: Felix Singer <felixsinger@posteo.net>
2025年12月09日 20:53:39 +00:00
Documentation serprog: Add SPI Mode and CS Mode commands 2024年03月26日 20:46:04 +00:00
include flashchips: Add GigaDevice GD25LF128E 166MHz, 1.8V part 2025年02月27日 20:58:30 +00:00
Makefile.d Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
platform platform/meson: Port pciutils/pci.h workaround to Meson 2024年04月26日 19:48:54 +00:00
util ich_descriptors_tool: Change region name EC/BMC -> EC_BMC 2025年02月24日 10:56:47 +00:00
.editorconfig Add an .editorconfig file 2023年12月27日 17:19:55 +00:00
.envrc Add .envrc 2025年01月31日 11:40:27 +00:00
.gitattributes Convert flashrom to git 2017年06月23日 06:08:36 +00:00
.gitignore Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
.gitreview Add a .gitreview file 2023年12月27日 17:20:07 +00:00
82802ab.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
amd_imc.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
amd_spi100.c Add missing copyright notices to recently created files 2025年02月23日 17:01:45 +00:00
at45db.c spi: Prepare for multi i/o and dummy bytes 2024年07月22日 10:08:47 +00:00
atahpt.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
atapromise.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
atavia.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
bitbang_spi.c bitbang_spi: Implement multi-i/o 2024年07月22日 10:08:47 +00:00
board_enable.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
buspirate_spi.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
cbtable.c physmap: rename to hwaccess_physmap, create own header 2023年01月29日 12:29:02 +00:00
ch341a_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
ch347_spi.c ch347_spi: Add 'spimode' parameter 2024年08月19日 10:58:13 +00:00
chipset_enable.c ichspi: Add Intel Arrow Lake support 2024年11月10日 13:58:05 +00:00
cli.c Add missing copyright notices to recently created files 2025年02月23日 17:01:45 +00:00
cli_classic.c layout: Show a warning if no region is included 2025年02月24日 10:59:09 +00:00
cli_common.c cli_common: Rename local `optarg' variable 2024年11月21日 20:31:44 +00:00
cli_config.c Add missing copyright notices to recently created files 2025年02月23日 17:01:45 +00:00
cli_output.c cli: Move some declarations into cli.h 2024年11月03日 17:54:48 +00:00
cli_wp.c Add missing copyright notices to recently created files 2025年02月23日 17:01:45 +00:00
COPYING Add a dedicated license 2007年09月08日 14:36:01 +00:00
custom_baud.c serial: Call set_custom_baudrate() thrice 2023年03月06日 23:36:26 +00:00
custom_baud_darwin.c serial: Add Darwin/macOS support for custom and >230400 baudrates 2023年03月06日 23:36:26 +00:00
custom_baud_linux.c serial: Call set_custom_baudrate() thrice 2023年03月06日 23:36:26 +00:00
dediprog.c dediprog: Use dual-i/o default only for SF600Plus-G2 2025年03月03日 16:16:09 +00:00
developerbox_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
digilent_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
dirtyjtag_spi.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
dmi.c hwaccess: move mmio functions into hwaccess_physmap 2023年01月29日 12:29:02 +00:00
Doxyfile Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
drkaiser.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
dummyflasher.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
edi.c spi: Prepare for multi i/o and dummy bytes 2024年07月22日 10:08:47 +00:00
en29lv640b.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
flashchips.c flashchips: Explicitly zero-initialize in .qpi_read_params 2025年03月03日 16:16:09 +00:00
flashprog-config.8.tmpl cli: Add new `config' CLI for status/config registers 2024年11月03日 17:54:48 +00:00
flashprog-write-protect.8.tmpl cli: Add new write-protect CLI 2024年11月03日 17:54:48 +00:00
flashprog.8.tmpl cli: Add new write-protect CLI 2024年11月03日 17:54:48 +00:00
flashprog.c Provide no-op probe function, always returning 1 2025年02月23日 17:23:14 +00:00
fmap.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
ft2232_spi.c spi: Prepare for multi i/o and dummy bytes 2024年07月22日 10:08:47 +00:00
ft4222_spi.c Add FT4222H support 2024年07月22日 10:08:47 +00:00
gfxnvidia.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
helpers.c Add FT4222H support 2024年07月22日 10:08:47 +00:00
helpers_fileio.c flashrom.c: Move write_buf_to_file() to helpers_fileio.c 2023年01月29日 12:29:02 +00:00
hwaccess_physmap.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
hwaccess_x86_io.c libpayload: Fix compiling bugs 2023年01月29日 12:29:02 +00:00
hwaccess_x86_msr.c hwaccess_x86_msr: rename msr function to msr_xxx 2023年01月29日 12:29:02 +00:00
ich_descriptors.c ichspi: Add Intel Arrow Lake support 2024年11月10日 13:58:05 +00:00
ichspi.c ichspi: Properly add Emmitsburg PCH 2024年11月10日 13:58:05 +00:00
internal.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
it87spi.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
it8212.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
jedec.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
jlink_spi.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
known_boards.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
layout.c layout: Show a warning if no region is included 2025年02月24日 10:59:09 +00:00
libflashprog.c libflashprog: Run programmer_shutdown() on failed setup 2024年11月06日 11:12:38 +00:00
libflashprog.map layout: Implement flashprog_layout_get_region_range() 2024年11月03日 17:54:48 +00:00
linux_gpio2_spi.c linux_gpio2_spi: Implement multi i/o 2024年07月22日 10:08:47 +00:00
linux_gpio_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
linux_mtd.c linux_mtd: Use sizeof() instead of strlen() on constant string 2025年12月09日 20:53:39 +00:00
linux_spi.c linux_spi: Use default_spi_read()/_write_256() 2024年03月27日 08:32:15 +00:00
Makefile install: Install binary into bin/, not sbin/ 2024年11月10日 14:20:08 +00:00
Makefile.include Makefile.include: Add line continuations between $(eval) calls 2023年03月18日 13:21:47 +00:00
mcp6x_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
memory_bus.c memory_bus.c: Add missing copyright notice 2025年02月24日 08:00:28 +00:00
meson.build install: Install binary into bin/, not sbin/ 2024年11月10日 14:20:08 +00:00
meson_options.txt Install udev rules 2024年11月02日 10:30:21 +00:00
mstarddc_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
ni845x_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
nic3com.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
nicintel.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
nicintel_eeprom.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
nicintel_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
nicnatsemi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
nicrealtek.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
ogp_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
opaque.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
parallel.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
pcidev.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
pickit2_spi.c Let the flash context directly point to the used master 2024年03月09日 10:40:04 +00:00
pony_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
print.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
print_wiki.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
processor_enable.c Remove address from GPLv2 headers 2018年04月24日 20:21:41 +00:00
programmer.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
programmer_table.c Add FT4222H support 2024年07月22日 10:08:47 +00:00
rayer_spi.c bitbang_spi: Move API into its own header file 2024年07月22日 10:08:47 +00:00
README.md README: Update flashprog.org URLs 2024年08月08日 21:58:11 +00:00
satamv.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
satasii.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
sb600spi.c sb600spi: Request more lspci details 2025年02月24日 10:56:47 +00:00
serial.c serial: Add Darwin/macOS support for custom and >230400 baudrates 2023年03月06日 23:36:26 +00:00
serprog.c serprog: Refine flushing before synchronization 2024年03月09日 10:50:41 +00:00
sfdp.c spi: Prepare for multi i/o and dummy bytes 2024年07月22日 10:08:47 +00:00
shell.nix Add .envrc 2025年01月31日 11:40:27 +00:00
spi.c Implement QPI support 2024年07月22日 10:08:47 +00:00
spi25.c spi25: Fix cosmetic debug-print error due to unitialized buffer 2025年02月24日 14:18:46 +00:00
spi25_prepare.c Add missing copyright notices to recently created files 2025年02月23日 17:01:45 +00:00
spi25_statusreg.c spi25_statusreg: Prefer volatile status register writes 2024年11月03日 17:54:48 +00:00
spi95.c spi: Prepare for multi i/o and dummy bytes 2024年07月22日 10:08:47 +00:00
sst28sf040.c libflashrom: Return progress state to the library user 2024年03月27日 08:32:15 +00:00
sst49lfxxxc.c Remove address from GPLv2 headers 2018年04月24日 20:21:41 +00:00
sst_fwhub.c Fix -Wsign-compare trouble 2019年07月31日 08:26:59 +00:00
stlinkv3_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
stm50.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
test_build.sh test_build.sh: Compare output for -L of Make and Meson builds 2024年07月12日 20:54:09 +00:00
udelay.c udelay: Lower the sleep vs delay threshold 2024年03月09日 13:21:35 +00:00
usbblaster_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
usbdev.c usbdev.c: Add missing <inttypes.h> include 2019年10月22日 23:24:16 +00:00
w29ee011.c Rebrand to flashprog and update URLs 2023年09月18日 19:24:39 +00:00
w39.c Remove address from GPLv2 headers 2018年04月24日 20:21:41 +00:00
wbsio_spi.c memory_mapped: Reduce decode_sizes to a single max_rom_decode 2024年03月09日 10:30:24 +00:00
writeprotect.c Introduce FLASHPROG_FLAG_NON_VOLATILE_WRSR 2024年11月03日 17:54:48 +00:00
writeprotect_ranges.c writeprotect_ranges.c: add more range functions 2022年12月30日 01:16:55 +01:00

flashprog

flashprog is a utility for detecting, reading, writing, verifying and erasing flash chips. It is often used to flash BIOS/EFI/coreboot/firmware images in-system using a supported mainboard, but it also supports flashing of network cards (NICs), SATA controller cards, and other external devices which can program flash chips.

It supports a wide range of flash chips (most commonly found in SOIC8, DIP8, SOIC16, WSON8, PLCC32, DIP32, TSOP32, and TSOP40 packages), which use various protocols such as LPC, FWH, parallel flash, or SPI.

Be careful when using flashprog on laptops! The embedded controller (EC) present in older laptops (~pre 2011) might interact badly with any attempts to communicate with the flash chip and may brick your laptop.

Please make a backup of your flash chip before writing to it.

Please see the flashprog(8) manpage.

Source Packaging

To package flashprog and remove dependencies on Git, either use make export or make tarball

'make export' will export all flashprog files from the Git repository at revision HEAD into a directory named "$EXPORTDIR/flashprog-$RELEASENAME" and will additionally add a "versioninfo.inc" file in that directory to contain the Git revision of the exported tree and a date for the manual page.

'make tarball' will simply tar up the result of make export and compress it with bzip2.

The snapshot tarballs are the result of 'make tarball' and require no further processing.

Build Instructions

To build flashprog you need to install the following software:

  • git (if you check out the source from the repository)
  • build utilities: meson or make and a C compiler (build-essential or similar depending on OS/distribution)
  • pkg-config to find library dependencies
  • pciutils+libpci (if you want support for mainboard or PCI device flashing)
  • libusb 1.0 development package (if you want support for USB programmers, except BusPirate and serprog based)
  • libftdi 1.0 development package (if you want support for FT2232H or programmers based on it)
  • libjaylink development package (if you want support for J-LINK programmers)
  • libgpiod development package (if you want support for GPIO bitbanging under Linux)

Compilation with a limited set of programmer drivers is possible. make will output hints how to disable programmers with missing dependencies.

Package names for the above vary across OS distributions:

On Linux et al, look for the following packages:

  • git
  • gcc
  • meson / make
  • pkg-config / pkgconf (not needed if none of the below are used)
  • pciutils / libpci (optional)
  • pciutils-devel / pciutils-dev / libpci-dev (optional)
  • libusb / libusb-1.0-0-dev (optional)
  • libftdi / libftdi1-dev (optional)
  • libjaylink / libjaylink-dev (optional)
  • libgpiod / libgpiod-dev (optional)

On FreeBSD, you need the following ports:

  • devel/gmake
  • devel/libpci

On OpenBSD, you need the following ports:

  • devel/gmake
  • sysutils/pciutils

Building

To compile on Linux, use:

make

To compile on FreeBSD, OpenBSD or DragonFly BSD, use:

gmake

To compile on Nexenta, use:

make

To compile on Solaris, use:

gmake LDFLAGS="-L$pathtolibpci" CC="gcc -I$pathtopciheaders" CFLAGS=-O2

To compile on NetBSD (with pciutils, libftdi, libusb installed in /usr/pkg/), use:

gmake

To compile and run on Darwin/Mac OS X:

Install DirectHW from coresystems GmbH. DirectHW is available at http://www.coreboot.org/DirectHW .

To cross-compile on Linux for DOS:

Get packages of the DJGPP cross compiler and install them: djgpp-filesystem djgpp-gcc djgpp-cpp djgpp-runtime djgpp-binutils

As an alternative, the DJGPP web site offers packages for download as well: djcross-binutils-2.29.1-1ap.x86_64.rpm djcross-gcc-7.2.0-1ap.x86_64.rpm djcrx-2.05-5.x86_64.rpm

The cross toolchain packages for your distribution may have slightly different names (look for packages named djgpp).

Alternatively, you could use a script to build it from scratch: https://github.com/andrewwutw/build-djgpp

You will need the libpci and libgetopt library source trees and their compiled static libraries and header files installed in some directory say libpci-libgetopt/, which will be later specified with LIBS_BASE parameter during flashprog compilation. Easiest way to handle it is to put pciutils, libgetopt and flashprog directories in one subdirectory. There will be an extra subdirectory libpci-libgetopt created, which will contain compiled libpci and libgetopt.

Download pciutils 3.5.6 and apply https://flashprog.org/wiki/File:Pciutils-3.5.6.patch.gz Compile pciutils, using following command line:

make ZLIB=no DNS=no HOST=i386-djgpp-djgpp CROSS_COMPILE=i586-pc-msdosdjgpp- \
 PREFIX=/ DESTDIR=$PWD/../libpci-libgetopt \
 STRIP="--strip-program=i586-pc-msdosdjgpp-strip -s" install install-lib

Download and compile with 'make' https://flashprog.org/wiki/File:Libgetopt.tar.gz

Copy the libgetopt.a to ../libpci-libgetopt/lib and getopt.h to ../libpci-libgetopt/include

Enter the flashprog directory.

make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip
LIBS_BASE=../libpci-libgetopt/ HAS_LIBPCI=yes CONFIG_LIBPCI_LDFLAGS=-lpci
strip

If you like, you can compress the resulting executable with UPX:

upx -9 flashprog.exe

To run flashprog.exe, download https://flashprog.org/wiki/File:Csdpmi7b.zip and unpack CWSDPMI.EXE into the current directory or one in PATH.

To cross-compile on Linux for Windows:

  • Get packages of the MinGW cross compiler and install them: mingw32-filesystem mingw32-cross-cpp mingw32-cross-binutils mingw32-cross-gcc mingw32-runtime mingw32-headers

  • The cross toolchain packages for your distribution may have slightly different names (look for packages named mingw). PCI-based programmers (internal etc.) are not supported on Windows.

  • Run (change CC= and STRIP= settings where appropriate) make CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip

Processor architecture dependent features:

On non-x86 architectures a few programmers don't work (yet) because they use port-based I/O which is not directly available on non-x86. Those programmers will be disabled automatically if you run "make".

Compiler quirks:

If you are using clang and if you want to enable only one driver, you may hit an overzealous compiler warning from clang. Compile with "make WARNERROR=no" to force it to continue and enjoy.

Installation

In order to install flashprog and the manpage into /usr/local, type:

make install

For installation in a different directory use DESTDIR, e.g. like this:

make DESTDIR=/usr install

If you have insufficient permissions for the destination directory, use sudo by adding sudo in front of the commands above.

Branching and release policy

  • Feature development happens on the main branch
  • Branch-off points for releases are tagged with tags that start with p, such as p1.0
  • Release branches have a .x suffix, for example 1.0.x
  • Release tags start with v, for example v1.0 or v1.0.1
  • Release candidate tags additionally end with -rcN, for example v1.0-rc1

Contact

The official flashprog website is:

https://flashprog.org/

Available contact methods are

https://flashprog.org/wiki/Contact