Difference between revisions of "User:Fxc/Draft:PineTab2 SPI"

From PINE64
Jump to navigation Jump to search
(→‎Recovery: clarified)
(→‎Boot order: Fixed list style)
Line 16: Line 16:
The RK3566 SoC searches for the U-Boot SPL in a fixed order:
The RK3566 SoC searches for the U-Boot SPL in a fixed order:


* SPI flash memory
# SPI flash memory
* eMMC
# eMMC
* MicroSD card
# MicroSD card


The subsequent boot order in the U-Boot SPL can then be changed in software. Example: There is the U-Boot bootloader installed on the eMMC (the internal memory of the PineTab2), which tries to boot from a microSD card if it finds a bootable medium and it will otherwise load the installation from the eMMC. Another example: There is the U-Boot bootloader installed to the eMMC, which tries to first boot from microSD card and then from the eMMC.
The subsequent boot order in the U-Boot SPL can then be changed in software. Example: There is the U-Boot bootloader installed on the eMMC (the internal memory of the PineTab2), which tries to boot from a microSD card if it finds a bootable medium and it will otherwise load the installation from the eMMC. Another example: There is the U-Boot bootloader installed to the eMMC, which tries to first boot from microSD card and then from the eMMC.

Revision as of 16:45, 22 June 2023

This article explains what the SPI flash memory in the PineTab2 is and how it is used and recovered.

Section will be deleted: Warning template

Warning: Flashing the SPI flash memory is a dangerous procedure. Please read the article PineTab2 SPI fully to learn the procedure and consequences.


Getting started

The PineTab2 includes an SPI flash memory. An SPI flash memory is a non-volatile memory that uses Serial Peripheral Interface (SPI) protocol for communication. The memory can be used to store a bootloader on it. This is an important hardware functionality, because it can be used to modify the boot order (see the section #Boot order) and to store the bootloader away and independent from any operating system (on the SPI flash memory as dedicated memory, instead on the same disk like the operating system).

The SPI on the currently shipped PineTab2 batch is shipped and will likely contain a bootloader in future batches to simplify the booting procedure for users in the future.

Boot order

The RK3566 SoC searches for the U-Boot SPL in a fixed order:

  1. SPI flash memory
  2. eMMC
  3. MicroSD card

The subsequent boot order in the U-Boot SPL can then be changed in software. Example: There is the U-Boot bootloader installed on the eMMC (the internal memory of the PineTab2), which tries to boot from a microSD card if it finds a bootable medium and it will otherwise load the installation from the eMMC. Another example: There is the U-Boot bootloader installed to the eMMC, which tries to first boot from microSD card and then from the eMMC.

In practice, this has several implications for the user that need to be considered:

  • The bootloader might break and prevent the device from booting
  • If the bootloader on the eMMC or SPI breaks and stops, you must disable the SPI and the eMMC to make the device boot from a microSD card to recover your installation (see section #Recovery)
  • Bypassing the eMMC and SPI requires an UART adapter with a bypass switch (it is included in the currently shipped batch at the time of June 2023)
  • Future batches might ship with a different bootloader and/or different settings on the SPI than what you're currently using and/or plan to use
  • Incompatibilities can be introduced by flashing the SPI

Releases

The following bootloader releases are currently available for the SPI flash memory:

Flashing

A word of warning: Flashing the SPI is not recommended by the author(s) of the article. Instead it is recommended to do any development and testing solely using microSD cards and to keep the SPI in the condition at delivery. The flashing procedure has the risk of locking you out from your device because the SPI has the highest boot priority. If the bootloader on the SPI stops booting it will prevent the device from booting any further. In this state it can be only recovered by using the UART adapter with the bypass switch as explained in the section #Recovery. Additionally, bootloaders such as U-Boot flashed on the SPI will introduce incompatibilities in some operating systems, for example if they are based on AOSP.

Checklist of things you require for flashing the SPI on the PineTab2

  • A fully charged PineTab2 connected to a charger
  • A confirmed to work UART adapter with a bypass switch, in case anything goes wrong
  • A fully working and stable operating system
  • Experience with the command line
  • A full understanding of the involved procedure and the risks

Steps to flash the SPI:

  1. Read and understand the explanation about the boot order, the procedure to recover a faulty flash and the involved risks
  2. Test that your UART adapter with a bypass switch is fully working and the bypass switch successfully bypasses the SPI and the eMMC
  3. Power on your device without the UART adapter
  4. Install flashcp if it is not installed already
  5. Download a listed release. Verify multiple times that the correct file is downloaded and that it is compatible with your device. Other devices might have a similar name or the filename might be similar to incompatible files.
  6. Verify that the download was complete and successful using the provided checksum of the corresponding release
  7. Understand and then run the command flashcp -v -p u-boot-rockchip-spi.bin /dev/mtd0, with u-boot-rockchip-spi.bin being an example for a U-Boot release. It has to be stored in the directory you're running the command in. NOTE: This command does not verify if the SPI was flashed successful. The step is down AT OWN RISK!
  8. Wait for the command to successfully flash your SPI

If there is any question regarding a step or if one step is not clear enough please ask in the PineTab channel on the bridged community chat before doing the step. If the procedure was not successful please read the #Recovery section.

Recovery

The USB UART adapter with the eMMC and SPI bypass switch. The adapter is shipped with the PineTab2 in the box which is also containing the charging cable. The switch to disable the eMMC and SPI is located on the top right of the image.

To bypass the SPI and to force the device to boot from the microSD card, the SPI (and eMMC) can be disabled by using the debug UART adapter shipped with the device in the box also containing the charging cable. Set the SD BOOT MASKROM switch on the adapter to the position ON and plug it into the USB/PD charging port.

Then power on the tablet with a flashed microSD card (which includes a bootloader) and unplug the debug board or set the switch to the position OFF again when the factory image is started, otherwise the factory image won't find the SPI.

The zeorize the SPI likely located under /dev/mtd0. If the path of the SPI memory can't be found in the devfs, the bypass switch was still set to ON after booting the microSD card.