1*4882a593Smuzhiyun============================== 2*4882a593SmuzhiyunUpgrading BIOS using intel-spi 3*4882a593Smuzhiyun============================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunMany Intel CPUs like Baytrail and Braswell include SPI serial flash host 6*4882a593Smuzhiyuncontroller which is used to hold BIOS and other platform specific data. 7*4882a593SmuzhiyunSince contents of the SPI serial flash is crucial for machine to function, 8*4882a593Smuzhiyunit is typically protected by different hardware protection mechanisms to 9*4882a593Smuzhiyunavoid accidental (or on purpose) overwrite of the content. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunNot all manufacturers protect the SPI serial flash, mainly because it 12*4882a593Smuzhiyunallows upgrading the BIOS image directly from an OS. 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunThe intel-spi driver makes it possible to read and write the SPI serial 15*4882a593Smuzhiyunflash, if certain protection bits are not set and locked. If it finds 16*4882a593Smuzhiyunany of them set, the whole MTD device is made read-only to prevent 17*4882a593Smuzhiyunpartial overwrites. By default the driver exposes SPI serial flash 18*4882a593Smuzhiyuncontents as read-only but it can be changed from kernel command line, 19*4882a593Smuzhiyunpassing "intel-spi.writeable=1". 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunPlease keep in mind that overwriting the BIOS image on SPI serial flash 22*4882a593Smuzhiyunmight render the machine unbootable and requires special equipment like 23*4882a593SmuzhiyunDediprog to revive. You have been warned! 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunBelow are the steps how to upgrade MinnowBoard MAX BIOS directly from 26*4882a593SmuzhiyunLinux. 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun 1) Download and extract the latest Minnowboard MAX BIOS SPI image 29*4882a593Smuzhiyun [1]. At the time writing this the latest image is v92. 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun 2) Install mtd-utils package [2]. We need this in order to erase the SPI 32*4882a593Smuzhiyun serial flash. Distros like Debian and Fedora have this prepackaged with 33*4882a593Smuzhiyun name "mtd-utils". 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun 3) Add "intel-spi.writeable=1" to the kernel command line and reboot 36*4882a593Smuzhiyun the board (you can also reload the driver passing "writeable=1" as 37*4882a593Smuzhiyun module parameter to modprobe). 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun 4) Once the board is up and running again, find the right MTD partition 40*4882a593Smuzhiyun (it is named as "BIOS"):: 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun # cat /proc/mtd 43*4882a593Smuzhiyun dev: size erasesize name 44*4882a593Smuzhiyun mtd0: 00800000 00001000 "BIOS" 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun So here it will be /dev/mtd0 but it may vary. 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun 5) Make backup of the existing image first:: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun # dd if=/dev/mtd0ro of=bios.bak 51*4882a593Smuzhiyun 16384+0 records in 52*4882a593Smuzhiyun 16384+0 records out 53*4882a593Smuzhiyun 8388608 bytes (8.4 MB) copied, 10.0269 s, 837 kB/s 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun 6) Verify the backup: 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun # sha1sum /dev/mtd0ro bios.bak 58*4882a593Smuzhiyun fdbb011920572ca6c991377c4b418a0502668b73 /dev/mtd0ro 59*4882a593Smuzhiyun fdbb011920572ca6c991377c4b418a0502668b73 bios.bak 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun The SHA1 sums must match. Otherwise do not continue any further! 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun 7) Erase the SPI serial flash. After this step, do not reboot the 64*4882a593Smuzhiyun board! Otherwise it will not start anymore:: 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun # flash_erase /dev/mtd0 0 0 67*4882a593Smuzhiyun Erasing 4 Kibyte @ 7ff000 -- 100 % complete 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun 8) Once completed without errors you can write the new BIOS image: 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun # dd if=MNW2MAX1.X64.0092.R01.1605221712.bin of=/dev/mtd0 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun 9) Verify that the new content of the SPI serial flash matches the new 74*4882a593Smuzhiyun BIOS image:: 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun # sha1sum /dev/mtd0ro MNW2MAX1.X64.0092.R01.1605221712.bin 77*4882a593Smuzhiyun 9b4df9e4be2057fceec3a5529ec3d950836c87a2 /dev/mtd0ro 78*4882a593Smuzhiyun 9b4df9e4be2057fceec3a5529ec3d950836c87a2 MNW2MAX1.X64.0092.R01.1605221712.bin 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun The SHA1 sums should match. 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun 10) Now you can reboot your board and observe the new BIOS starting up 83*4882a593Smuzhiyun properly. 84*4882a593Smuzhiyun 85*4882a593SmuzhiyunReferences 86*4882a593Smuzhiyun---------- 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun[1] https://firmware.intel.com/sites/default/files/MinnowBoard%2EMAX_%2EX64%2E92%2ER01%2Ezip 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun[2] http://www.linux-mtd.infradead.org/ 91