162306a36Sopenharmony_ci============================== 262306a36Sopenharmony_ciUpgrading BIOS using spi-intel 362306a36Sopenharmony_ci============================== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciMany Intel CPUs like Baytrail and Braswell include SPI serial flash host 662306a36Sopenharmony_cicontroller which is used to hold BIOS and other platform specific data. 762306a36Sopenharmony_ciSince contents of the SPI serial flash is crucial for machine to function, 862306a36Sopenharmony_ciit is typically protected by different hardware protection mechanisms to 962306a36Sopenharmony_ciavoid accidental (or on purpose) overwrite of the content. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciNot all manufacturers protect the SPI serial flash, mainly because it 1262306a36Sopenharmony_ciallows upgrading the BIOS image directly from an OS. 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciThe spi-intel driver makes it possible to read and write the SPI serial 1562306a36Sopenharmony_ciflash, if certain protection bits are not set and locked. If it finds 1662306a36Sopenharmony_ciany of them set, the whole MTD device is made read-only to prevent 1762306a36Sopenharmony_cipartial overwrites. By default the driver exposes SPI serial flash 1862306a36Sopenharmony_cicontents as read-only but it can be changed from kernel command line, 1962306a36Sopenharmony_cipassing "spi_intel.writeable=1". 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciPlease keep in mind that overwriting the BIOS image on SPI serial flash 2262306a36Sopenharmony_cimight render the machine unbootable and requires special equipment like 2362306a36Sopenharmony_ciDediprog to revive. You have been warned! 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciBelow are the steps how to upgrade MinnowBoard MAX BIOS directly from 2662306a36Sopenharmony_ciLinux. 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci 1) Download and extract the latest Minnowboard MAX BIOS SPI image 2962306a36Sopenharmony_ci [1]. At the time writing this the latest image is v92. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci 2) Install mtd-utils package [2]. We need this in order to erase the SPI 3262306a36Sopenharmony_ci serial flash. Distros like Debian and Fedora have this prepackaged with 3362306a36Sopenharmony_ci name "mtd-utils". 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci 3) Add "spi_intel.writeable=1" to the kernel command line and reboot 3662306a36Sopenharmony_ci the board (you can also reload the driver passing "writeable=1" as 3762306a36Sopenharmony_ci module parameter to modprobe). 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci 4) Once the board is up and running again, find the right MTD partition 4062306a36Sopenharmony_ci (it is named as "BIOS"):: 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci # cat /proc/mtd 4362306a36Sopenharmony_ci dev: size erasesize name 4462306a36Sopenharmony_ci mtd0: 00800000 00001000 "BIOS" 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci So here it will be /dev/mtd0 but it may vary. 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci 5) Make backup of the existing image first:: 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci # dd if=/dev/mtd0ro of=bios.bak 5162306a36Sopenharmony_ci 16384+0 records in 5262306a36Sopenharmony_ci 16384+0 records out 5362306a36Sopenharmony_ci 8388608 bytes (8.4 MB) copied, 10.0269 s, 837 kB/s 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci 6) Verify the backup:: 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci # sha1sum /dev/mtd0ro bios.bak 5862306a36Sopenharmony_ci fdbb011920572ca6c991377c4b418a0502668b73 /dev/mtd0ro 5962306a36Sopenharmony_ci fdbb011920572ca6c991377c4b418a0502668b73 bios.bak 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci The SHA1 sums must match. Otherwise do not continue any further! 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci 7) Erase the SPI serial flash. After this step, do not reboot the 6462306a36Sopenharmony_ci board! Otherwise it will not start anymore:: 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci # flash_erase /dev/mtd0 0 0 6762306a36Sopenharmony_ci Erasing 4 Kibyte @ 7ff000 -- 100 % complete 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci 8) Once completed without errors you can write the new BIOS image:: 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci # dd if=MNW2MAX1.X64.0092.R01.1605221712.bin of=/dev/mtd0 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci 9) Verify that the new content of the SPI serial flash matches the new 7462306a36Sopenharmony_ci BIOS image:: 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci # sha1sum /dev/mtd0ro MNW2MAX1.X64.0092.R01.1605221712.bin 7762306a36Sopenharmony_ci 9b4df9e4be2057fceec3a5529ec3d950836c87a2 /dev/mtd0ro 7862306a36Sopenharmony_ci 9b4df9e4be2057fceec3a5529ec3d950836c87a2 MNW2MAX1.X64.0092.R01.1605221712.bin 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci The SHA1 sums should match. 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci 10) Now you can reboot your board and observe the new BIOS starting up 8362306a36Sopenharmony_ci properly. 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ciReferences 8662306a36Sopenharmony_ci---------- 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci[1] https://firmware.intel.com/sites/default/files/MinnowBoard%2EMAX_%2EX64%2E92%2ER01%2Ezip 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci[2] http://www.linux-mtd.infradead.org/ 91