PINE64
Program SPI NOR Flash on Pinebook Pro with u-boot on micro SD Card - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=111)
+--- Forum: Pinebook Pro Tutorials (https://forum.pine64.org/forumdisplay.php?fid=117)
+--- Thread: Program SPI NOR Flash on Pinebook Pro with u-boot on micro SD Card (/showthread.php?tid=11567)



Program SPI NOR Flash on Pinebook Pro with u-boot on micro SD Card - hmuller - 09-21-2020

Hello again!

Administrative: I apologize in advance for posting the actual instructions offsite as I have yet to figure out how to format headings using bbcode. If I ever figure it out or it becomes possible I will bring the content back over here. The instructions may be found at the link at the end of this post.

This process allows you to program/erase the Pinebook Pro (PBP) SPI NOR flash (flash) using u-boot on a micro SD card. 
  • The user is still required to remove the back cover to turn the eMMC switch off and the UART switch on.
  • The user is also required to connect to the PBP over USB serial UART from a host machine (Rock64 with keyboard and monitor for example).
  • You cannot use this process to recover from writing bad images to the flash though, you would still have to short the pins on the flash to boot from SD card again in this instance.
It is possible automatically write to flash using a boot.scr script (i tested this) but this is left as an exercise for the user. This also highlights why I think it is preferable for SD card to be at the bottom of the boot order and not at the top.

The mainline u-boot version as of this writing is 2020.10-rc4-g9de3126e. These are some observations I have made that you may find useful:
  • The SPI flash is not automatically detected. I am not a u-boot expert yet but I assume it is because an alias for 'spi0 = $spi1' is missing from the device tree. And I additionally assume this is because rk3399-pinebook-pro-u-boot.dtsi does not #include rk3399-pinebook-pro.dts. I tested this theory by temporarily adding the alias to rk3399-pinebook-pro.dts and the SPI was detected (should have also tested by adding the #include to rk3399-pinebook-pro-u-boot.dtsi).
  • CONFIG_ENV_OFFSET is set too low. CONFIG_ENV_OFFSET is automatically set to 0x140000. uboot.itb is written to 0x60000 and its current size is 949936 (928K) bytes which overlaps with 0x140000. If you want to safely saveenv you will need to set CONFIG_ENV_OFFSET to 0x150000. You could also place it at the end of SPI ((16M bytes - 1 byte) - 32K bytes).
You can find the instructions at this link:

https://gist.github.com/hxmuller/f1091f9b04b583db0d56b6f893747482

Please reply to this thread for any questions or comments on the document found at the link above. Thanks!