2013-11-17 21:32:01
Compiling flashrom on MacOS PPC
flashrom is a tool for reading and writing flash chips. It can be used to debrick systems from small routers up to desktop PCs (BIOS) and more.
Unfortunately it does not compile on MacOS PPC although it works on many different OS like Linux, *BSD, MacOS Intel and even Windows. Nevertheless it makes sense to use it on this old architecture in example if you have a FTDI cable or programmer with an FTDI chip connected to your old Mac to write a new image to a flash chip.
All you need is an additional Makefile which does a basic setup by including the "main" Makefile and then compiles flashrom:
# additional Makefile.darwinppc for building flashrom # on Darwin/PPC # lib deps must be installed by i.e. mac ports CFLAGS = -O2 -Wall -Wshadow WARNERROR = no CONFIG_INTERNAL = no CONFIG_SERPROG = no CONFIG_RAYER_SPI = no CONFIG_PONY_SPI = no CONFIG_NIC3COM = no CONFIG_GFXNVIDIA = no CONFIG_SATASII = no CONFIG_ATAHPT = no CONFIG_FT2232_SPI = yes CONFIG_USBBLASTER_SPI = no CONFIG_DRKAISER = no CONFIG_NICREALTEK = no CONFIG_NICNATSEMI = no CONFIG_NICINTEL = no CONFIG_NICINTEL_SPI = no CONFIG_OGP_SPI = no CONFIG_BUSPIRATE_SPI = no CONFIG_DEDIPROG = no CONFIG_SATAMV = no CONFIG_LINUX_SPI = no CONFIG_PRINT_WIKI = no %.o: %.c $(CC) -MMD $(CFLAGS) $(CPPFLAGS) \ $(FLASHROM_CFLAGS) $(FEATURE_CFLAGS) \ $(SVNDEF) -o $@ -c $< ALL: darwinppc include Makefile config: @echo 'FEATURES := yes' >.features @echo 'FTDISUPPORT := yes' >>.features @echo 'FT232H := yes' >>.features @echo 'UTSNAME := yes' >>.features darwinppc: config $(PROGRAM)$(EXEC_SUFFIX) @echo @echo Trying to execute flashrom... @echo ./flashrom -p ft2232_spi:type=232H,divisor=32
Install libusb and libftdi, put this makefile in the flashrom directory and type
make -f Makefile.darwinppc
After it was compiled you can write a flash chip with i.e. the FTDI cable C232HM-DDHSL-0 by a command like this:
# time ./flashrom -p ft2232_spi:type=232H,divisor=32 \ -c MX25L6406E/MX25L6436E -w dump.rom flashrom v0.9.7-r1711 on Darwin 8.11.0 (Power Macintosh) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... OK. Found Macronix flash chip "MX25L6406E/MX25L6436E" (8192 kB, SPI) on ft2232_spi. Reading old flash chip contents... done. Erasing and writing flash chip... Erase/write done. Verifying flash... VERIFIED. real 7m1.731s user 0m12.288s sys 0m22.984s
Here's an example of writing a 128MBit chip:
# ./flashrom -p ft2232_spi:type=232H,divisor=4 -w flash.raw flashrom v0.9.7-r1764 on Darwin 8.11.0 (Power Macintosh) flashrom is free software, get the source code at http://www.flashrom.org Calibrating delay loop... OK. Found Winbond flash chip "W25Q128.V" (16384 kB, SPI) on ft2232_spi. Reading old flash chip contents... done. Erasing and writing flash chip... Warning: Chip content is identical to the requested image. Erase/write done.
Warning: If you have installed an FTDI VCP driver (virtual com port) then this driver will take control over a FT232H chip. In this case you must disable the FT232H chip (product ID 0x6014/24596dez) in the VCP driver. This is the patch:
--- tmp/FTDIUSBSerialDriver.kext/Contents/Info.plist \ 2012-08-08 14:01:40.000000000 +0200 +++ /System/Library/Extensions/FTDIUSBSerialDriver.kext/\ Contents/Info.plist 2013-11-17 10:48:54.000000000 +0100 @@ -2014,25 +2014,6 @@ <key>idVendor</key> <integer>1027</integer> </dict> - <key>FT232H</key> - <dict> - <key>CFBundleIdentifier</key> - <string>com.FTDI.driver.FTDIUSBSer.. - <key>IOClass</key> - <string>FTDIUSBSerialDriver</string> - <key>IOProviderClass</key> - <string>IOUSBInterface</string> - <key>bConfigurationValue</key> - <integer>1</integer> - <key>bInterfaceNumber</key> - <integer>0</integer> - <key>bcdDevice</key> - <integer>2304</integer> - <key>idProduct</key> - <integer>24596</integer> - <key>idVendor</key> - <integer>1027</integer> - </dict> <key>FT4232H_A</key> <dict> <key>CFBundleIdentifier</key>
(Update 2014-01-14: Makefile fix and Winbond example.)