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

From PINE64
Jump to navigation Jump to search
(Linked to the repo)
(update)
Line 1: Line 1:
This article explains what the SPI flash memory in the [[PineTab2]] is and how it is used and recovered.
This article explains what the SPI flash memory in the [[PineTab2]] is and how it is used and recovered.


== TODO ==
== Section will be deleted: Warning template ==
 
* Getting started
** What it is and what it is used for (explanation OSes without bootloader)
** That it is empty (and why)
* Explanation boot order
* Available SPI releases
* How to flash the SPI + lock out risk and incompatibilities
* How to recover the SPI
* Outlook
** Discussion
** Plans
 
== 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.}}
{{Warning|Flashing the SPI flash memory is a dangerous procedure. Please read the article [[PineTab2 SPI]] fully to learn the procedure and consequences.}}
Line 21: Line 8:
== Getting started ==
== 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 as the operating system).
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.
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.
Line 39: Line 26:
* The bootloader might break and prevent the device from booting
* 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]])
* 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 current batch, )
* 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 ==
== Releases ==
Line 75: Line 63:
== Recovery ==
== Recovery ==


== Outlook ==
[[File:PineTab2 USB UARTv2.jpg|thumb|right|400px|Using the USB UART adapter can be required in some cases as explained in the info box about the boot order. 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.

Revision as of 16:39, 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:

  • SPI flash memory
  • eMMC
  • 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

Using the USB UART adapter can be required in some cases as explained in the info box about the boot order. 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.