Burning iPXE into Intel network adapter

# install required packages
apt-get install -y build-essential liblzma-dev git linux-headers-$(uname -r)
 
# list controller
#lspci -nn | grep Ethernet
 
# get device id
lspci -nn | grep Ethernet | cut -d"[" -f3 | cut -d"]" -f1 | tr -d ":"
 
# v1 (intel 100 mbit, WORKING)
 
# build ipxe rom
git clone git://git.ipxe.org/ipxe.git /tmp/ipxe
 
# preconfigure boot server (local, www.panticz.de)
cat <<EOF> /tmp/ipxe/src/boot.ipxe
#!ipxe
 
dhcp && chain http://\${next-server}/\${mac} || chain http://preseed.panticz.de/\${mac}
EOF
 
# compile
cd /tmp/ipxe/src
make bin/80861229.rom EMBED=boot.ipxe
 
# download bootdisc
wget http://boot.ipxe.org/burn/dosboot.img -O /tmp/dosboot.img
 
# download intel flash tool
wget http://downloadmirror.intel.com/11271/eng/PRORPL.exe -P /tmp
cabextract /tmp/PRORPL.exe -d /tmp
 
# copy intel flash tool to bootdisc
mcopy -i /tmp/dosboot.img /tmp/IBAUtil.exe ::
 
# copy rom to bootdisc
cp /tmp/ipxe/src/bin/80861229.rom /tmp/80861229.iba
mcopy -i /tmp/dosboot.img /tmp/80861229.iba ::
 
# create flash.bat
echo "ibautil -restore -all" > /tmp/flash.bat
mcopy -i /tmp/dosboot.img /tmp/flash.bat ::
 
# reboot boot from image and run "flash"
 
 
# v2 (intel 1000 mbit nic, BROKEN)
wget http://downloadmirror.intel.com/19186/eng/PREBOOT.EXE -O /tmp/PREBOOT.EXE
mcopy -i /tmp/dosboot.img /tmp/APPS/BootUtil/DOS/BootUtil.exe ::
 
cp ../BootIMG.FLB .
 
mcopy -i /tmp/dosboot.img /tmp/ipxe/src/bin/80861229.rom ::
 
 
cd /tmp
# broken? # cabextract -d preboot PREBOOT.EXE
file-roller -e /tmp/ PREBOOT.EXE
 
mcopy -i /tmp/dosboot.img /tmp/APPS/BootUtil/DOS/BootUtil.exe ::
 
# LINUX
scp -r /tmp/APPS/BootUtil/Linux_x64/ root@192.168.1.185:/root
scp /tmp/ipxe/src/bin/80861229.rom root@192.168.1.185:/root
 
scp -r /tmp/intel/PREBOOT root@192.168.1.185:/root
 
# on client with intel nic
apt-get install -y wget build-essential linux-headers-$(uname -r)
cd /root/Linux_x64/
chmod a+x install
./install
 
 
 cp /root/80861229.rom .
 
#-FLASHENABLE # -DEFCFG #
./bootutil64e -NIC 1 -RESTOREIMAGE -FILE 80861229.rom
 
cd ~/PREBOOT/APPS/BootUtil/Linux_x64
chmod a+x bootutil64e 
./bootutil64e
 
 
 
 
./bootutil64e -NIC 1 -UP pxe
 
 
 
# usb / pxe boot (broken?)
syslinux.cfg
LABEL dosboot
LINUX memdisk
INITRD dosboot.img
 
 
 
# v2
 
 
 
 
cp /tmp/ipxe/src/bin/80861229.rom /tmp/80861229.iba
mcopy -i /tmp/dosboot.img /tmp/80861229.iba ::
 
 
# restore original intel imape
root@localhost:~/PREBOOT/APPS/BootUtil/Linux_x64# ./bootutil64e -NIC 1  -RESTOREIMAGE -FILE 12294003.FLB 
 
 
 
# v3
mcopy -i /tmp/dosboot.img /tmp/IBAUtil.exe ::
mcopy -i /tmp/dosboot.img /tmp/ipxe/src/bin/80861229.rom ::
 
# v4
wget -q https://downloadmirror.intel.com/19186/eng/Preboot.tar.gz -O /tmp/Preboot.tar.gz
tar -xzf /tmp/Preboot.tar.gz -C /tmp/
# fix /bin/sh on ubuntu
sed -i 's|/bin/sh|/bin/bash|g' /tmp/APPS/BootUtil/Linux_x64/DRIVER/install
cd /tmp/APPS/BootUtil/Linux_x64/DRIVER
./install 
cd /tmp/APPS/BootUtil/Linux_x64/DRIVER/iqvlinux/src/linux/driver
sed -i 's|/bin/sh|/bin/bash|g' ./nalinstall
./nalinstall
modprobe iqvlinux
chmod +x /tmp/APPS/BootUtil/Linux_x64/bootutil64e
# backup image  (broken?)
/tmp/APPS/BootUtil/Linux_x64/bootutil64e -NIC 1 -SAVEIMAGE -FILE 80861502.org
# flash (broken?)
/tmp/APPS/BootUtil/Linux_x64/bootutil64e -NIC 1  -RESTOREIMAGE -FILE /tmp/ipxe/src/bin/80861229.rom

Links
http://ipxe.org/howto/romburning
http://ipxe.org/howto/romburning/intel
http://panticz.de/ipxe
http://www.syslinux.org/wiki/index.php/MEMDISK
http://etherboot.org/wiki/romburning/intel