Today we are going to see how to flash the stock image of CM4 Stack to return it to factory conditions.
I am intensively testing the new CM4 Stack. Besides having a great time, well, you know how games are… I have misconfigured it… things happen.
In this case, it is time to flash the device again to leave it as good as new, as if it had just come out of the factory.
You have the process explained here https://docs.m5stack.com/en/quick_start/cm4stack/arduino but, between things being in English, and the screenshots in Chinese or Japanese, I’m not entirely sure.
But, the process is much easier than it seems, so I’m going to explain it in a mini tutorial, so that if you have to do it, you do it without fear.
Tools we need
Before performing the flashing, we need to download these tools.
- Factory image of the CM4Stack https://m5stack.oss-cn-shenzhen.aliyuncs.com/cm4stack/cm4stack_images/canary/2023-03-08-CM4StackOS-canary-2023-02-21-raspios-bullseye-armhf.gz
- RpiBoot https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe
- Panasonic SD Formatter https://www.waveshare.net/w/upload/d/d7/Panasonic_SDFormatter.zip
The first one is, logically, the manufacturer’s image for the CM4Stack. It contains all the installation files that your CM4 Stack had when it came from the factory.
Make sure it is the latest version, because if you read this post in a year, the link is likely not to be updated.
The other two tools are standard, and you may even have them downloaded and used them previously.
RpiBoot is used to connect Raspberry devices that have eMMC (instead of SD) by USB to a computer, and it appears as a USB drive. So you can write the files.
SD Formatter is an SD card formatter, which is widely used in the electronics world to ensure that the card is formatted correctly.
Flashing the CM4 Stack
With these three things on the computer, the process is very simple.
Step 1: With the CM4 turned off, without power, press the boot button and connect it via USB-C to a USB on the computer. Once you have connected it, it will turn on, and you can release the button (you don’t need to hold it down for long). It is also not necessary to power with the charger, only with the USB is enough.
Step 2: On the computer you will hear the typical sound that new software has been connected. You may see some screen of an unformatted drive, do you want to format it, blah blah. Ignore them all.
Now start the RpiBoot application that you have downloaded. A console application will appear where you can see the configuration process. After that, a drive will appear on your computer, with a space of about 256MB. It’s the boot of your CM4.
Step 3: We take SD Formatter, and format this partition. Important, you must select the “FORMAT SIZE ADJUSTMENT” option. To do this, you click on the options button, and in the window that appears, select ON from the drop-down menu. Sometimes it fails to format. Don’t worry, try again and it’s done. The first time I almost always get an error, and the second time it works.
Step 4: Open Raspberry Pi Image. Select the image you have downloaded, the network drive, and click “Burn”. Be patient, as the process takes a few minutes.
Optionally, but highly recommended, take advantage of being in Raspberry Pi Image to configure the options (at the bottom, click on the “gear” button). You can set the Hostname, enable SSH, change username and password, and set your WiFi password.
That’s how easy it is to flash the CM4 Stack and return it to factory settings. And next time, be more careful (me first, as I can’t afford to reformat!)