Check and Repair "Forced Read Only Mode" on Macronix eMMC (errata) - Linux
Introductionβ
This document provides instructions on how to check whether a Toradex SoM is at risk of triggering the Forced Read Only Mode issue that affects some Macronix eMMC (MX52LM04A11XUI) production batches and, if it is the case, repair it. The potentially affected products are the Apalis iMX6 and Colibri iMX6 with this eMMC. If you received affected modules, the Toradex team will (if not have already) contact you directly informing the serial number of affected modules.
If the module is at risk, it is highly recommended that the procedure described in the section Instructions to Repair is executed to ensure that the module will work according to the factory specification. The repair procedure wonβt affect the user content stored on the eMMC. If the chosen procedure fails for some reason, please contact Toradex for further assistance.
This article complies with the typographic conventions.
Requirementsβ
- Potentially affected Apalis iMX6 or Colibri iMX6
- Serial (exclusive) connection to Linux and bootloader terminal
- USB stick or SD card
Instructions to Checkβ
In order to run the check tool, the module needs to be running linux kernel >= 5.4. For older kernel versions, you need to either run the automatic fix image or use recovery mode.
- Download the eMMC check tool package from Toradex.
- Extract the package and copy the contents of the
/check_package
directory to the module to be checked. - Go to the
/check_package
folder and run therun_check.sh
script on the module:
# ./run_check.sh
This eMMC is NOT at risk of Forced Read Only Mode
The script output can also be:
# ./run_check.sh
This eMMC is at risk of Forced Read Only Mode.
Please execute FFU Repair Tool to fix this issue.
In this case, please follow the Instructions to Repair to ensure that your module has been properly fixed.
Instructions to Repairβ
Setupβ
For the repair procedure to work, itβs necessary that the affected eMMC is not used to boot the module. For this reason, the user can choose to either:
Download and Run the Automatic Fix Imageβ
In case the user chooses to download the ready-made image, follow the instructions below to execute the procedure. First, download the appropriate image package based on your module:
External Media Preparationβ
To prepare the external media for booting, the first step is to get your SD card or USB stick and insert it into your Linux PC. On the Linux terminal, execute:
$ dmesg | grep sd
You should see the device you just attached as one of the last messages. Please compare the size of the detected device with the expected USB or SD card device size to be sure you have the right device name. After finding the correct device, execute the following command and select the correct image depending on your specific module:
$ zcat <name_of_downloaded_image>.wic.gz | sudo dd of=/dev/sd<x> bs=4M
Boot the imageβ
For the module to boot from the external media instead of the internal eMMC, the user needs to change some u-boot variables.
Here are the commands that need to be executed on the u-boot prompt:
For USB thumb drive:
> setenv boot_scripts boot.scr
> setenv bootcmd 'run bootcmd_usb0'
or for SD card you will need to check whatβs the correct mmc device for your carrier board:
> setenv boot_scripts boot.scr
> mmc list
Apalis iMX6 # mmc list
FSL_SDHC: 1
FSL_SDHC: 2
FSL_SDHC: 0 (eMMC)
> mmc dev 1
MMC: no card present
> mmc dev 2
switch to partitions #0, OK
mmc2 is current device
> setenv bootcmd 'run bootcmd_mmc2'
After the module starts booting from the external media, the check and repair procedure should run automatically, and at the end, the user will be presented with this message:
U-Boot 2020.07-5.3.0+git.68f97c8d17f0 (Jul 06 2021 - 15:50:15 +0000)
CPU: Freescale i.MX6DL rev1.4 at 792MHz
CPU: Industrial temperature grade (-40C to 105C) at 48C
Reset cause: WDOG
DRAM: 512 MiB
PMIC: device id: 0x10, revision id: 0x21, programmed
MMC: FSL_SDHC: 1, FSL_SDHC: 0
Loading Environment from MMC... OK
In: serial
Out: serial
Err: serial
Model: Toradex Colibri iMX6 DualLite 512MB IT V1.1Y, Serial# 10995589
Net: eth0: ethernet@2188000
Hit any key to stop autoboot: 0
Your eMMC has been repaired successfully. Your module is ready for use.
Boot will continue with Easy Installer in 10 seconds.
Use Recovery Modeβ
To run the procedure from Recovery Mode you should proceed with the following steps:
Download the tool package;
Decompress it, and copy it to a USB stick or SD card;
Insert the external media on the target device
Put the device in recovery mode following the procedures detailed in the recovery instructions. It's important to choose the 5.7.0 version, when you reach the step: loading the Toradex easy installer tool.
After the easy installer booted, type the following commands on the serial console:
# mount /dev/sda<x> /home/root
# cd /home/root
# sh run_fix.sh
The procedure should run automatically and display this output if it finishes successfully:
This eMMC is at risk of Forced Read Only Mode.
Please execute FFU Repair Tool to fix this issue.
Running automatically FFU Repair Tool:
FFU_REPAIR: Executing step 1 ... OK
FFU_REPAIR: Executing step 2 ... OK
FFU_REPAIR: Executing step 3 ... OK
FFU_REPAIR: Executing step 4 ... OK
Your eMMC has been repaired successfully. Your module is ready for use.
The module can be safely powered off now.
How to Force the Module into Write-Protected Modeβ
Below are the steps needed to reproduce this issue in your module. This can be useful in case you need to test your software in a read-only system created by this issue.
There are two approaches: use the mmc-utils software to put the eMMC into write-protected mode or use a script to write and read from memory until the issue is triggered. If you want to test how your software behaves with this issue, the mmc-utils approach is recommended, since the read-only mode lasts only until the next reboot. Using the second method will trigger the eMMC issue and then you will need to follow the Instructions to Repair section to repair the module.
Be aware that the module will enter read-only mode and you will need to follow the Instructions to Repair your module, otherwise, your module will be bricked.
First Method: Using mmc-utils (Recommended)β
The steps below are required to compile mcc-utils with Yocto, install it and then run the software.
- Set up everything needed for Yocto, as described in Build a Reference Image with Yocto Project/OpenEmbedded article.
- Go to your
oe-core/build/
folder and edit the fileconf/local.conf
. - Select the right
MACHINE
variable: Colibri iMX6 or Apalis iMX6. Close and save the file. - Inside the
oe-core/build/
, run the command below.
$ bitbake mmc-utils
- Wait for the process to finish.
- The compiled ipk package will be inside
oe-core/build/deploy/ipk/armv7at2hf-neon/
folder. - Copy the package
mmc-utils_0.1+git0+73d6c59af8-r0_armv7at2hf-neon.ipk
. Note that the hash in the name of the package can be different depending on which commit it is based on. In general, themmc-utils_0.1*
file should be copied, either by SCP or using a USB stick. - Inside the module, install the package by running
# opkg install mmc-utils_0.1+git0+d7b343fd26-r0_armv7at2hf-neon.ipk
- To put the boot partition in write-protected mode until the next reboot, run
# mmc writeprotect boot set /dev/emmc
- Next, to put the rest of the eMMC storage in write-protected mode, first run
# mmc writeprotect user get /dev/emmc
- The output should be as follows (depending on the size of the eMMC)
Write Protect Group size in blocks/bytes: 8192/4194304
Write Protect Groups 0-931 (Blocks 0-7634943), No Write Protection
- In the example above, the blocks go from 0 to 7634943. To set all blocks in write-protected mode, run the command bellow with the max numbers of block plus 1 (for example, 7634943 + 1).
# mmc writeprotect user set pwron 0 7634944 /dev/emmc
Now the eMMC will be in write-protected mode until the next reboot and all the tests can be executed.
Second Method: Script to force the right conditionsβ
For this method to work, some prerequisites are needed:
- The eMMC on the module is affected (confirmed by the
run_check.sh
script in Instructions to Check section). - Your eMMC could not have been used for writing more than 4 GB of data approximately. Otherwise, this script will not work.
The first method is recommended since the write-protected mode will last until the next reboot. This second method can put your module into an unrecoverable state until you follow the Instructions to Repair.
To reproduce this error in your board, some scripts are needed to simulate read and write conditions that could trigger the permanent write-protection mode.
Download the neccessary scripts.
Descompress these scripts and copy them to your module, with a USB stick, or SD Card, or using the network with the SCP command.
Execute
./a-macronix-prep.sh
script and, when it finishes, reboot your module.Execute
./b-macronix-read.sh
script. This step can take almost 30 minutes to complete, please, be patient. It will execute several read operations until it finishes. Do not reboot your module after this script finishes.Execute
./c-macronix-write.sh
script. After it finishes, the module should be in permanent write-protection mode.Execute
./d-macronix-read-csd.sh
to validate the write-protect bit in the CSD register.
Now you can execute the ./run_check.sh
script to verify the permanent write-protection mode, as describe in Instructions to Check section.