Reflashing the Librem 5, Up-to-Date Tutorial

This was really bothering me because the reflashing instructions here, Reflashing the Librem 5 – Purism, and here, Reflashing the Phone, are wrong.

Therefore, here is my new tutorial and post so people can find it in search:

I recommend having a Linux computer running a current version of Debian, but most modern Linux distros will likely work.

Reflashing the Librem 5 is the best way to remove your personal data and put the phone back into factory defaults.

Warning, this procedure will completely erase everything on the device! Make a backup beforehand!

The Librem 5 gets reflashed from a separate 64-bit x86 computer running PureOS (or booted from the live PureOS disk).

Reflashing from that computer is as simple as installing the needed packages:

sudo apt install git python3-jenkins python3-tqdm uuu

Downloading the flashing scripts:

git clone https://source.puri.sm/Librem5/librem5-flash-image.git

And flashing the phone for Evergreen (mass-produced version)

cd librem5-flash-image
sudo ./scripts/librem5-flash-image --variant luks (or --plain) --stable

Luks is the encrypted version and plain is unencrypted. If you simply use --stable, then I believe the default is for the image to be encrypted. Also,

(Additionally, as @Franky Flawless points out, the Byzantium image being fetched from storage.puri.sm has an old timestamp:
Index of /librem5/images/byzantium/2023.06/librem5r4/luks/artifact/
There are a few newer Byzantium images with LUKS, but by default they are not fetched by the script:
https://storage.puri.sm/librem5/images/byzantium/2024.04/librem5r4/luks/artifact/
https://storage.puri.sm/librem5/images/byzantium/latest/librem5r4/luks/artifact/)

Once the script downloads the image, you’ll be prompted to attach the Librem 5 for flashing. The phone itself will not provide an indication of the boot mode – the script will simply continue once you follow these steps:

Ensure that the phone is switched off. Enter the flashing mode by holding volume-up button while turning the phone on.

If it’s not detected, follow these steps:
In sequential order:

  1. Hold the volume-up button.
  2. Hold the power button until the Librem 5 turns on.
  3. Release both buttons once the LED changes to orange.

Turn all Hardware-Kill-Switches off

    Remove battery
    Hold volume-up
    Insert the USB-c cable: (red light blinks, no green light)
    Reinsert the battery: (red light is constantly on, the script will continue)
    Release volume-up

Note: USB Cable
Some USB-C cables may need to be plugged into the phone with a particular orientation. If the instructions above do not appear to work, try flipping the USB-C end of the cable over and replugging it into the phone.

Using the proper USB cable can make a difference and you should try different cords if you are having a problem.

Successful output will look something like this:

uuu (Universal Update Utility) for nxp imx chips – libpureos/1.2.91+0git6b465-62-g9c56e46

Success 1 Failure 0

Remove the USB C cable and hold down the power button for 15-18 seconds to reset the phone.

Your phone should now be running the latest image.

If anyone feels like they need to add something or to have me change something, please do let me know. I wanted to post this to help others.

7 Likes

Correct.

There are missing instructions:

In sequential order:

  1. Hold the volume-up button.
  2. Hold the power button until the Librem 5 turns on.
  3. Release both buttons once the LED changes to orange.

Not quite:

4 Likes

In fact, if you use --stable then by definition it won’t be running the latest image - but using apt thereafter should get it to the most up-to-date state that it can be. So I guess if you want to advocate for --stable then you should insert between

Remove the USB C cable and hold down the power button for 15-18 seconds to reset the phone.

and

Your phone should now be running the latest image.

instructions to the user to force the phone to check for updates and to apply updates if there are any.

3 Likes

I tried this tutorial and it did not work. The script only accepted --variant luks and not --luks. Does this mean I am using the incorrect version of the script?

3 Likes

I suspect it’s just a typo.

2 Likes

The official instructions worked for me, except of that they don’t mention the --stable flag. Without this, it cannot find an image. But the --stable versions seems to be fully encrypted by default,

./scripts/librem5-flash-image --help

says

--variant {plain,luks}
                        Image variant to download ( plain, luks ), default is 'luks'

Besides this, there seem to be newer versions of pureOS, than the one provided b y the script: Latest release and version history overview

3 Likes

I think there has been confusion in the past among some users about which device the applications and scripts get installed on, i.e. the computer, not the L5. Might want to make that explicit in the instructions.

Here, it might be advisable to add “current” before “version,” or even “[version number] or later,” because the uuu package isn’t present in some repos prior to certain versions, which has led to confusion and frustration for some.

4 Likes

Dear Flanders51!!! Than you so much for your tutorial. I’d like just to know if there’s a way to try to reinstall next times avoiding to download and decompression every time!
Thank you :pray:

3 Likes

Add --skip-download as an argument after manually downloading the images.

3 Likes

Thank you!! So where’s the new command to install image?
Where’s image previously downloaded?
Thnak you!!

1 Like

You have to download the images manually from storage.puri.sm, then you can execute the script with the argument I provided to avoid having to download and decompress the images with the script itself.

1 Like

Just this file?

1 Like

Yes, although I forgot you also need a u-boot image from arm01.puri.sm as well for the bootloader:

https://arm01.puri.sm/job/u-boot_builds/job/uboot_librem5_mainline_build/614/

The filename is u-boot-librem5.imx.

1 Like

I’ve to download it into same directory? Is it part of the same command or I’ve to install it using a different command line?

2 Likes

You need to manually decompress the librem5r4.img.xz image, then move that and the u-boot-librem5.imx image to the librem5-flash-image root directory. When you execute the script, you also need to add this argument and option to point to the same directory where the images are located:

--dir ./

If you want to keep the images after the reflashing procedure, add the --skip-cleanup argument.

2 Likes

I’m trying to reflash without encryption, but when I run the command here, it’s telling me the sha256 checksum doesn’t match. (…88fed70 does not match …467672)

./scripts/librem5-flash-image --variant plain --stable

This is for a late release Evergreen phone. It says it downloaded from /byzantium/latest/librem5r4/plain/artifact/librem5r4.img.xz.

Problem with the script, or problem with the checksum?

1 Like

BTW Purism should probably remove the link to the “Text Version” (right under the video) on this page:

https://docs.puri.sm/Librem_5/Troubleshooting/Reflashing.html

…which directs to this blog Reflashing the Librem 5 – Purism

…because that blog is apparently outdated if you need to add --stable now. Wasting a bit of time figuring that out for people who prefer text over a video.

3 Likes

@JCS

Not sure, but there is a workaround in PureOS:

sudo apt install librem5-flash-image
librem5-flash-image

The librem5-flash-image in the PureOS software repository defaults to the plain variant. Otherwise, I can provide more troubleshooting steps if it does not work.

1 Like

Ha, it’s in the Mint and PopOS repos too (I guess Canonical’s).

Now I wonder what the librem5-tweaks package is, but one thing at a time…

So that’s just another version of the same script?

1 Like

Hmm, it says “Looking for librem5r4 plain byzantium image” and then “No matching image found”.

2 Likes