Reflashing your device
The process for reflashing an AutoPi device differs a little depending on the device version you have and the OS you are running. The steps in this guide were tested on Pop-os 6.1 (a Debian-derived Linux distribution) and Windows 10. The general workflow for the reflashing process is:
- Download the AutoPi OS image
- Set up Balena Ethcher (or alternative)
- Connect the device storage media
- Pre-CM4 devices (versions 3.0 - 6.3)
- CM4 devices (version 7.x+)
- Perform the flash
- Set up the device
#1. Download the AutoPi OS image
Make sure that you select the right image for your device:
- Generation 2 devices: autopi_core_gen2_*.img.gz image
- Generation 3 (TMU): autopi_core_tmu_*.img.gz image
- Generation 4 (CM4): autopi_core_CM4_*.img.gz image
You can get the latest AutoPi Core image from the autopi-core releases page.
#2. Set up Balena Ethcher (or alternative)
We recommend using Etcher for flashing - it will take the GZ image directly and flash it. If using Windows, the
installation can be done through a regular .exe file. For Linux, follow the steps on Balena's Etcher repository. We've noticed that the first command does not always work on the first try. If that happens, update your package list through
sudo apt update and try again.
for Linux users
On Linux, we are installing by adding the Balena package repository and installing through our package manager, but keep in mind than an .AppImage file is available on Balena's website.
#3. Connect the device storage media
#3.a. Pre-CM4 devices
Your device contains an SD card with the AutoPi Core preinstalled. The SD card is located inside the device. You will need to unscrew the device to access and remove the SD card. For that you can follow the Upgrade/Replace Your Raspberry Pi Computer guide. Once you have the SD card in hand, place it in an SD card reader and connect it to your computer.
#3.b. CM4 devices
On Compute Module 4 devices there is no SD card. The Operating System is stored on a flash chip embedded on the Raspberry Pi board. This means that reflashing is a little more complicated than just taking an SD card out of the AutoPi device and flashing it through an SD card reader. These are the steps you'll need to take:
- Set up rpiboot (allows your computer to read/write the Raspberry Pi's flash memory)
- Put the device into EMMC FLASHING state
- Connect the device with a usb cable
#3.b.1. Setting up rpiboot
Rpiboot is a utility provided by Raspberry Pi that allows your computer to read and write the flash chip. Most of the steps below need to be done only once per host computer. After the initial setup, all you should be required to do for this step is run the rpiboot utility.
Download the rpiboot installer and go through the setup. Once the installation is complete, run the newly added rpiboot program, which you can find in the Start menu.
More details on the rpiboot setup for Windows can be found on the Raspberry Pi Documentation site. But keep in mind that where the documentation is talking about jumper cables, on the AutoPi board, that means changing the device state.
Follow the setup steps in the Raspberry Pi usbboot documentation. Once you've started the rpiboot utility, your computer will start looking for a connected Compute Module device. The setup should look something like pictured below:
#3.b.2. Put the device into the EMMC FLASHING state
To do this, your device will need to be receiving power from either a vehicle, or a power supply with an adapter cable (the USB port can not be used for power). Details for button location and state transitions can be found in the AutoPi CM4 TMU documentation.
To put the task in more simple terms: press the button (located in one of the holes on the side of the device) until the blue LED starts flashing very fast. If you've just plugged your device into power, wait until the blue LED turns solid. Then do a short press of the button, to do a gentle shutdown. Once the blue LED turns dim, it has gone into hibernation. From here long press the button until the LED starts flashing slowly (approx 1 flash per second). The device is now in the USER SETUP state. After another long press, the LED should start flashing rapidly, at which point the device is in the correct EMMC FLASHING state.
#3.b.3. Connect the device with a Micro-USB cable
Once you have both the rpiboot utility running on your computer and the device is in the correct state, you can connect the 2. Plug the micro-USB end of the cable into the exposed micro-USB port on the side of the device (the regular USB type-A ports on the back of the device can not be used for flashing), and the other end into your computer. If everything has gone according to plan, the rpiboot utiliy has now detected the device and mounted the device partitions if there are any. That should look something like pictured below:
At this point you can access the internal file system of the AutoPi's Raspberry Pi through the mounted drives. On this Linux distribution the mounting points are
/media/<user>/rootfs. On Windows you should be able to see at least one of the partitions in the File Explorer.
#4. Flashing the device
Using Balena Etcher or alternative, select the image file you downloaded earlier, and the storage device. Once that's done, click flash and wait for it to complete. It's worth noting, that if it fails on the first try, try again.
It is unsafe to remove the device from power while it is on or booting. The safest point when to unplug the device from power is right after unmounting.
Once the flashing is complete, unmount the storage device. After that you can remove the SD card from its reader and put it back into the AutoPi device. If using a CM4 device, unplug the CM4 device's USB cable and press the button to put the device into hibernation, then a short press to start up the device.
#5. Set up the device
Once you have flashed your device, you will need to have it re-accepted in the AutoPi Cloud. To do so, you need to first have the device boot up and connect to the internet. After that, log in to my.autopi.io. You should immediately see a notification letting you know that the device's key isn't accepted.
If you are a business customer and have a dedicated environment, there is an extra step that you need to take. Look at this guide for more information.
Another way of accepting the key is to go to the Settings page and navigating to your device's general settings. There you should be able to see that the "Key state" field says unaccepted and a green "Accept" button should be showing. Clicking on the button, accepts the key.
When your device comes online the first time, the WiFi hotspot will have the following setup:
Remember to update your device from the Cloud after you reflash it, as that will ensure that all the configuration values are properly configured (like the WiFi, SSID and password), and that the device has the correct authentication token for uploading data to the cloud.
If you'd like to discuss this topic with us or other fellow community members, you can do so on our community page dedicated for this guide: Guide: Reflashing your device