How to Flash the Firmware

What to do if you erased all your flash?

The methods are described in chinese manuals under the 'firmware update' or similar directories. The SN9866x series chip supports flashing u-boot and hw-settings directly from sd card. Note that 60x series doesn't support this feature. All you need is to prepare an sd card with the first partition formatted to FAT32, obtain FIRMWARE_660R_F.bin file from the build system and put it on the first partition of sd card. Hold the reset button of the device and power it on. You can see in the terminal window connected to the serial line that update is started. Alternatively, you can hold ESC key in your terminal while powering the device on. You should see the BROM's prompt: >>. Then type s.

There is a method to flash u-boot over a serial line using ymodem but I were not successful with it. See Notes on Ymodem

See Building a Self-Burninig Firmware Image for more information.

I had succesfully flashed FIRMWARE_660R_F.bin that comes with SN986_1.50_P2P_TUTK_043a_20160308_1000 sdk. The hw-settings of this firmware are exactly the same as in stock rom.

Vendor's Firmware Image Structure

Structure of the U-Boot Image

This is how U-Boot is stored in the packed fw file and in the flash:

<offset>  <size>   <desccription>
00000000  4B     - 32-bit unsigned, size of (u-boot + padding + crc16)
00000004  ~258K  - u-boot.bin, original image produced by u-boot make
000xxxxx  <16B   - padding, filled w/ 0xff, sizeof(u-boot.bin+padding)%16==0
000xxxyy  4B     - 32-bit unsigned, crc16/modbus of (u-boot.bin+padding)