Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Zero/dev/maskrom"

< Zero‎ | dev
(Created page with "{{zero_header}} {{Languages|zero/install/eMMC_erase}} Radxa Zero > Development Guide > Enter maskrom mode === Work In Prog...")
 
(Enable maskrom)
 
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{zero_header}}
 
{{zero_header}}
  
{{Languages|zero/install/eMMC_erase}}
+
{{Languages|zero/dev/maskrom}}
  
 
  [[zero | Radxa Zero]] > [[zero/dev | Development Guide]] > [[zero/dev/maskrom | Enter maskrom mode]]
 
  [[zero | Radxa Zero]] > [[zero/dev | Development Guide]] > [[zero/dev/maskrom | Enter maskrom mode]]
  
=== Work In Progress... ===
+
=== Description ===
  
This guide describes how to completely erase Radxa Zero's eMMC. Unlike normal PC where they have a well established and documented way of booting, in embedded world it is a bit chaotic and everyone carries their own bootloader and boot sequence. As such it's best to wipe the eMMC completely and have a clean environment before flashing a new image to eMMC.
+
This guide describes how to enter maskrom mode on Radxa Zero. Maskrom mode is a special boot mode for Radxa Zero. In this mode CPU will not boot off eMMC or microSD but will instead side load binaries from USB OTG port. This allows you to perform many low level maintenance tasks.
  
== Requirement ==
+
=== Requirement ===
  
 
* Radxa Zero
 
* Radxa Zero
Line 15: Line 15:
 
* USB A to C cable or C to C cable, depending on your host
 
* USB A to C cable or C to C cable, depending on your host
  
== Windows ==
+
=== Enable maskrom ===
  
===== Step 1: Install drivers =====
+
First locate the USB boot button on the bottom of Zero:
  
Press and hold the USB boot button on the Zero, plug in the USB to PC.
+
[[File:Zero_usb_boot.jpg | 300px]]
  
Download and install [https://github.com/pbatard/libwdi/releases/download/b755/zadig-2.6.exe Zagdig].
+
Hold this button, then plug Zero into your computer. You can let go the button when you see power LED is on.
Confirm that the device is <code>GX-CHIP</code>, USB ID is <code>1B8E:C003</code> and choose '''libusb-win32''', then click '''Install Driver'''.
+
  
[[File:Zagdig-libusb.png]]
+
On Windows, you can open Device Manager and find the device:
  
[https://dl.google.com/android/repository/usb_driver_r13-windows.zip Download the Android driver] from Google.
+
[[File:Windows-GX-CHIP.png]]
  
Unzip it and right click the '''.inf''' file to install the driver.
+
On Linux, you can run <code>lsusb</code> to confirm the device is indeed in maskrom mode:
  
[[File:Install-win-android-driver.png]]
+
Bus 001 Device 048: ID 1b8e:c003 Amlogic, Inc. GX-CHIP
  
===== Step 2: Use RZ USB helper =====
+
=== Install required tools ===
  
RZ USB helper is a Windows tool made by Radxa for easy OS installing. Download it from [https://dl.radxa.com/zero/tools/windows/RZ_USB_Boot_Helper_V1.0.0.zip Radxa DL] and unzip everything to a convenient location.
+
===== Windows =====
  
First locate the USB boot button on the Zero:
+
Download and install [https://zadig.akeo.ie/ Zagdig] for USB device driver. Make sure that the device is <code>GX-CHIP</code>, USB ID is <code>1B8E:C003</code> and choose '''libusb-win32''', then click '''Install Driver'''.
  
[[File:Zero_usb_boot.jpg | 300px]]
+
[[File:Zagdig-libusb.png]]
  
Hold the button while connect you Radxa Zero to PC. '''Maskrom mode''' should be detected by the tool.
+
Additionally you can install '''fastboot with '''nexus-tools''' by running the following command in PowerShell:
  
[[File:Rz-usb-helper-maskrom.png | 500px]]
+
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.ps1'))
  
Then select the '''factory-loader.img''' from the unzipped folder and click '''Run'''.
+
You will also need [https://dl.google.com/android/repository/usb_driver_r13-windows.zip the Android driver] from Google.
  
[[File:Rz-usb-helper-fastboot.png | 500px]]
+
Unzip it and right click the '''.inf''' file to install the driver.
  
Finally, click '''Erase''' to erase the eMMC completely.
+
[[File:Install-win-android-driver.png]]
  
[[File:Rz-usb-helper-erase.png | 500px]]
+
'''fastboot''' is for installing Android, or manually clear eMMC bootloader. If you do not need those you can skip this step.
  
== Linux & macOS  ==
+
RZ USB Boot Helper is a Windows tool made by Radxa for maskrom sideloading. Download it from [https://dl.radxa.com/zero/tools/windows/RZ_USB_Boot_Helper_V1.0.0.zip Radxa DL] and unzip everything to a convenient location.
For Linux and macOS, we use amlogic boot tool to download the bootloader and boot the Zero into the fastboot mode to erase the eMMC.
+
  
===== Step 1: Install pyamlboot tool =====
+
The tool will list the current mode on its interface. Right now we have '''Maskrom mode''':
  
macOS:
+
[[File:Rz-usb-helper-maskrom.png | 500px]]
    $ brew install python lsusb libusb
+
    $ pip3 install pyamlboot
+
  
Linux:
+
===== Linux(Ubuntu) & macOS  =====
    $ sudo apt install python3-pip
+
    $ sudo pip3 install pyamlboot
+
  
Here we are using <code>apt</code> package manager. Please refer to your distro's documentation for help on your distro's package manager.
+
On *nix platform we can use Amlogic boot tool to side load binary. Run following commands in a new terminal:
  
===== Step 2: Install fastboot =====
+
macOS:
 +
brew install python lsusb libusb
 +
pip3 install pyamlboot
  
Nexus Tools is an installer for the Android SDK Platform Tools package, which includes ADB, Fastboot, and other applications. We use Nexus Tools to install fastboot. If you already have fastboot installed, you can skip this step.
+
Ubuntu:
 +
sudo apt update
 +
sudo apt install python3-pip
 +
sudo pip3 install pyamlboot
  
    $ bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
+
Additionally you can install '''fastboot''' with '''nexus-tools''':
  
After it finishes,
+
bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
  
    $ which fastboot
+
'''fastboot''' is for installing Android, or manually clear eMMC bootloader. If you do not need those you can skip this step.
  
should return you the install location.
+
=== Side loading binaries ===
  
===== Step 3: Boot into fastboot mode =====
+
On Windows, once the tool detected maskrom mode, you can choose binary with '''Select''' button then side load with '''Run'''button:
  
Press and hold the USB boot button on Zero, plug in it to your computer. '''lsusb''' should see something like:
+
[[File:Rz-usb-helper-fastboot.png | 500px]]
  
    Bus 001 Device 075: ID '''1b8e:c003''' Amlogic, Inc. GX-CHIP
+
On *nix you can use '''boot-g12.py''' tool instead:
  
Download the fastboot loader and run it on Zero
+
macOS:
 +
boot-g12.py rz-fastboot-loader.bin
  
    $ wget https://dl.radxa.com/zero/images/loader/rz-fastboot-loader.bin
+
Ubuntu:
    $ boot-g12.py rz-fastboot-loader.bin # macOS
+
sudo boot-g12.py rz-fastboot-loader.bin
    $ sudo boot-g12.py rz-fastboot-loader.bin # Linux
+
  
It should output something similar to this:
+
Some precomplied loaders are provided on [https://dl.radxa.com/zero/images/loader/ Radxa website]. Below is a brief description on some of them:
<pre>
+
Firmware Version :
+
ROM: 3.2 Stage: 0.0
+
Need Password: 0 Password OK: 1
+
Writing rz-fastboot-loader.bin at 0xfffa0000...
+
[DONE]
+
Running at 0xfffa0000...
+
[DONE]
+
AMLC dataSize=16384, offset=65536, seq=0...
+
[DONE]
+
AMLC dataSize=49152, offset=393216, seq=1...
+
[DONE]
+
AMLC dataSize=16384, offset=229376, seq=2...
+
[DONE]
+
AMLC dataSize=49152, offset=245760, seq=3...
+
[DONE]
+
AMLC dataSize=49152, offset=294912, seq=4...
+
[DONE]
+
AMLC dataSize=16384, offset=65536, seq=5...
+
[DONE]
+
AMLC dataSize=1406320, offset=81920, seq=6...
+
[DONE]
+
[BL2 END]
+
</pre>
+
  
Now lsusb should show the following device:
+
* [https://dl.radxa.com/zero/images/loader/factory-loader.img factory-loader.img]: used to erase eMMC on Windows. Not recommended.
 
+
* [https://dl.radxa.com/zero/images/loader/radxa-zero-erase-emmc.bin radxa-zero-erase-emmc.bin]: automatically erase eMMC, then present eMMC as a USB storage device. This is the recommended way to load a new Linux image.
    Bus 001 Device 076: ID '''18d1:0d02''' Google Inc. USB download gadget  Serial: 1234567890
+
* [https://dl.radxa.com/zero/images/loader/rz-fastboot-loader.bin rz-fastboot-loader.bin]: enable fastboot mode. This cannot be used to install our official Android.
 
+
* [https://dl.radxa.com/zero/images/loader/android-bootloader.img android-bootloader.img]: this is the same <b>bootloader.img</b> from our official Android image. Some distro uses this bootloader.
===== Step 4: Wipe the eMMC =====
+
* [https://dl.radxa.com/zero/images/loader/rz-udisk-loader.bin rz-udisk-loader.bin]: expose embedded eMMC as a USB Mass Storage device.
 
+
* [https://dl.radxa.com/zero/images/loader/u-boot.bin u-boot.bin]: mainline U-Boot bootloader for USB boot. Won't work if you flashed it to eMMC/microSD.
macOS:
+
* [https://dl.radxa.com/zero/images/loader/u-boot.bin.sd.bin u-boot.bin.sd.bin]: mainline U-Boot bootloader for eMMC/microSD boot. Please refer to [[Zero/dev/u-boot#Run_U-boot | this guide]] to see how to flash it when OS is already installed.
    $ fastboot devices
+
    1234567890 fastboot
+
    $ fastboot flashing unlock_critical
+
    $ fastboot flashing unlock
+
    $ fastboot erase bootloader
+
    $ fastboot erase bootloader-boot0
+
    $ fastboot erase bootloader-boot1
+
    $ fastboot reboot # reboot into maskrom mode
+
  
Linux:
+
Once Radxa Zero enters into maskrom mode, it will reboot into maskrom mode until the power is cut. As such, it is recommended to completely shut down, unplug, and replug Radxa Zero when you are finish with the maintenance task.
Run <code>sudo -i</code> and <code>exit</code> before and after the macOS command sequences.
+
  
Power cycle your Zero. lsusb should show the following:
+
=== Troubleshooting ===
  
    Bus 001 Device 075: ID '''1b8e:c003''' Amlogic, Inc. GX-CHIP
+
* Q: RZ USB Boot Helper says "Not detected".
 +
* A: Please make sure your USB driver is installed and Zero is in maskrom mode. You should see the following device in your Device Manager:
  
the eMMC is wiped and Zero is in maskrom mode now. You can [[zero/install/eMMC#Linux_.26_macOS | install other OS to eMMC]] now.
+
[[File:libusb.png]]
  
If you want to flash Android, please follow the step 1-3 again to enter fastboot mode, which is required for flashing Android. You can then follow [[zero/install/eMMC | the guide]] to continue.
+
* Q: RZ USB Boot Helper's Erase button is disabled.
 +
* A: You can use [https://dl.radxa.com/zero/images/loader/radxa-zero-erase-emmc.bin radxa-zero-erase-emmc.bin] to erase eMMC. It will wipe the device once you click "Run" button.

Latest revision as of 21:03, 26 November 2022

 Radxa Zero >  Development Guide >  Enter maskrom mode

Description

This guide describes how to enter maskrom mode on Radxa Zero. Maskrom mode is a special boot mode for Radxa Zero. In this mode CPU will not boot off eMMC or microSD but will instead side load binaries from USB OTG port. This allows you to perform many low level maintenance tasks.

Requirement

  • Radxa Zero
  • A PC/laptop running Windows, Linux, or macOS
  • USB A to C cable or C to C cable, depending on your host

Enable maskrom

First locate the USB boot button on the bottom of Zero:

Zero usb boot.jpg

Hold this button, then plug Zero into your computer. You can let go the button when you see power LED is on.

On Windows, you can open Device Manager and find the device:

Windows-GX-CHIP.png

On Linux, you can run lsusb to confirm the device is indeed in maskrom mode:

Bus 001 Device 048: ID 1b8e:c003 Amlogic, Inc. GX-CHIP

Install required tools

Windows

Download and install Zagdig for USB device driver. Make sure that the device is GX-CHIP, USB ID is 1B8E:C003 and choose libusb-win32, then click Install Driver.

Zagdig-libusb.png

Additionally you can install fastboot with nexus-tools by running the following command in PowerShell:

iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.ps1'))

You will also need the Android driver from Google.

Unzip it and right click the .inf file to install the driver.

Install-win-android-driver.png

fastboot is for installing Android, or manually clear eMMC bootloader. If you do not need those you can skip this step.

RZ USB Boot Helper is a Windows tool made by Radxa for maskrom sideloading. Download it from Radxa DL and unzip everything to a convenient location.

The tool will list the current mode on its interface. Right now we have Maskrom mode:

Rz-usb-helper-maskrom.png

Linux(Ubuntu) & macOS

On *nix platform we can use Amlogic boot tool to side load binary. Run following commands in a new terminal:

macOS:

brew install python lsusb libusb
pip3 install pyamlboot

Ubuntu:

sudo apt update
sudo apt install python3-pip
sudo pip3 install pyamlboot

Additionally you can install fastboot with nexus-tools:

bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)

fastboot is for installing Android, or manually clear eMMC bootloader. If you do not need those you can skip this step.

Side loading binaries

On Windows, once the tool detected maskrom mode, you can choose binary with Select button then side load with Runbutton:

Rz-usb-helper-fastboot.png

On *nix you can use boot-g12.py tool instead:

macOS:

boot-g12.py rz-fastboot-loader.bin

Ubuntu:

sudo boot-g12.py rz-fastboot-loader.bin

Some precomplied loaders are provided on Radxa website. Below is a brief description on some of them:

  • factory-loader.img: used to erase eMMC on Windows. Not recommended.
  • radxa-zero-erase-emmc.bin: automatically erase eMMC, then present eMMC as a USB storage device. This is the recommended way to load a new Linux image.
  • rz-fastboot-loader.bin: enable fastboot mode. This cannot be used to install our official Android.
  • android-bootloader.img: this is the same bootloader.img from our official Android image. Some distro uses this bootloader.
  • rz-udisk-loader.bin: expose embedded eMMC as a USB Mass Storage device.
  • u-boot.bin: mainline U-Boot bootloader for USB boot. Won't work if you flashed it to eMMC/microSD.
  • u-boot.bin.sd.bin: mainline U-Boot bootloader for eMMC/microSD boot. Please refer to this guide to see how to flash it when OS is already installed.

Once Radxa Zero enters into maskrom mode, it will reboot into maskrom mode until the power is cut. As such, it is recommended to completely shut down, unplug, and replug Radxa Zero when you are finish with the maintenance task.

Troubleshooting

  • Q: RZ USB Boot Helper says "Not detected".
  • A: Please make sure your USB driver is installed and Zero is in maskrom mode. You should see the following device in your Device Manager:

Libusb.png

  • Q: RZ USB Boot Helper's Erase button is disabled.
  • A: You can use radxa-zero-erase-emmc.bin to erase eMMC. It will wipe the device once you click "Run" button.