Skip to content

Instantly share code, notes, and snippets.

Last active February 7, 2024 18:46
Show Gist options
  • Save ruario/19a28d98d29d34ec9b184c42e5f8bf29 to your computer and use it in GitHub Desktop.
Save ruario/19a28d98d29d34ec9b184c42e5f8bf29 to your computer and use it in GitHub Desktop.
A script that fetches a ChromeOS image for ARM32 and extracts the Widevine binary, saving it in a compressed archive for use with Vivaldi

The included script '' fetches a ChromeOS image for ARM and extracts the Widevine binary, saving it in a compressed archive. Since it downloads a fairly large file (2Gb+ on disk after download) it is recommended that you run the script on a machine that has plenty of disk space.

To install the resultant archive, issue the following on your ARM machine–after copying over the archive if needed:

sudo tar Cfx / widevine-flash-20200124_armhf.tgz

(Where 'widevine-flash-20200124_armhf.tgz' is updated to reflect the actual name of the created archive)

After install of these libraries, issue the following two commands and restart Vivaldi–assumes bash as your shell:

mkdir -p ~/.config/vivaldi{,-snapshot}/WidevineCdm
echo '{"Path":"/opt/WidevineCdm"}' | tee ~/.config/vivaldi/WidevineCdm/latest-component-updated-widevine-cdm > ~/.config/vivaldi-snapshot/WidevineCdm/latest-component-updated-widevine-cdm

(Triple click to select each complete line above)

This created package is designed to work on Vivaldi 2.10 (not pure Chromium 79+, which would require patches to detect Widevine on ARM).

#!/bin/sh -eu
# Make sure we have wget or curl
available () {
command -v "$1" >/dev/null 2>&1
if available wget; then
DL="wget -O-"
DL_SL="wget -qO-"
elif available curl; then
DL="curl -L"
DL_SL="curl -s"
echo "Install Wget or cURL" >&2
exit 1
# Find a URL to a suitable armhf ChromeOS recovery image
CHROMEOS_URL="$($DL_SL | grep -A11 CB5-312T | sed -n 's/^url=//p')"
CHROMEOS_IMG="$(basename "$CHROMEOS_URL" .zip)"
if [ -e "$CHROMEOS_IMG" ]; then
# Fetch the recovery image (2Gb+ on disk after download)
# Note the next free loop device in a variable
LOOPD="$(losetup -f)"
# If root, we can mount silently (no popup windows after mount)
if [ "$USER" = "root" ]; then
MNTPNT="$(mktemp -d -t ChromeOS.XXXXXX)"
mount -o ro "${LOOPD}p3" "$MNTPNT"
# Associate all the partitions on the disk image with loop devices:
udisksctl loop-setup -rf "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
sleep 1
# Mount the third partition of the disk image (if the previous did not do it automatically)
if ! lsblk -lo MOUNTPOINT "${LOOPD}p3" | tail -n1 | grep -q \.; then
udisksctl mount -b "${LOOPD}p3"
# Note the mount point in a variable
MNTPNT="$(lsblk -lo MOUNTPOINT "${LOOPD}p3" | tail -n1)"
# Copy over files and make manifest
CHRFILES="$(mktemp -d -t ChromeOS_Files.XXXXXX)"
install -Dm644 "$MNTPNT"/opt/google/chrome/ "$CHRFILES"/opt/WidevineCdm/_platform_specific/linux_arm/
WVVER="$(grep -Eaom1 '([0-9]+\.){3}[0-9]+' "$CHRFILES"/opt/WidevineCdm/_platform_specific/linux_arm/"
WVMGR="$(echo $WVVER | cut -d. -f1)"
WVMIN="$(echo $WVVER | cut -d. -f2)"
echo "{\"version\":\"$WVVER\",\"x-cdm-codecs\":\"vp8,vp9.0,avc1,av01\",\"x-cdm-host-versions\":\"$WVMIN\",\"x-cdm-interface-versions\":\"$WVMIN\",\"x-cdm-module-versions\":\"$WVMGR\"}" > "$CHRFILES"/opt/WidevineCdm/manifest.json
# Extract the libs out and copy them to a compressed tar archive
ARCHIVE_NAME="widevine-flash-$(date '+%Y%m%d')_armhf.tgz"
echo "Extracting and compressing files"
tar -C"$CHRFILES" -caf "$ARCHIVE_NAME" opt/WidevineCdm/manifest.json opt/WidevineCdm/_platform_specific/linux_arm/ --format ustar --owner 0 --group 0
rm -r "$CHRFILES"
echo "Created: $ARCHIVE_NAME"
# Cleanup
if [ "$USER" = "root" ]; then
umount "$MNTPNT"
losetup -d "$LOOPD"
rmdir "$MNTPNT"
ALLMNTS="$(lsblk -lo NAME,MOUNTPOINT "$LOOPD" | sed -n '/\//s/^\(loop[0-9]\+p[0-9]\+\).*/\1/p')"
echo "$ALLMNTS" | xargs -I{} -n1 udisksctl unmount -b /dev/{}
if [ "$LOOPD" != "$(losetup -f)" ]; then
udisksctl loop-delete -b "$LOOPD"
if [ "$DEL_IMG" = "N" ] || [ "${1:-EMPTY}" = "-k" ]; then
# Inform the user how to proceed
cat <<EOF
To install the contents of these files on an ARMhf device, copy the tar archive over to the target machine and issue the following:
sudo tar Cfx / $ARCHIVE_NAME
After install of these libraries, issue the following two commands and restart Vivaldi:
mkdir -p ~/.config/vivaldi/WidevineCdm
echo '{"Path":"/opt/WidevineCdm"}' > ~/.config/vivaldi/WidevineCdm/latest-component-updated-widevine-cdm
Copy link

/ 23:32:58
--2022-10-19 23:33:05--
CA certificate ("/etc/ssl/certs/ca-certificates.crt") loaded
Unlocking (… 2a00:1450:400d:80a::200e,
Connecting to ([2a00:1450:400d:80a::200e]:443… connected.
HTTP request sent, waiting for response... 200 OK
Length: 1290184868 (1.2G) [application/zip]
Save to "STDOUT"

  • 100%[============================================== ========>] 1.20G 13.5MB/s time 65s

2022-10-19 23:34:11 (18.9 MB/s) -- written to stdout [1290184868/1290184868]

Mapped file /tmp/ChromeOS-IMG.1mWSXd/chromeos_14989.107.0_elm_recovery_stable-channel_mp-v2.bin as /dev/loop2.
Mounted /dev/loop2p3 at /run/media/gyurmo/ROOT-A
install: stat '/run/media/gyurmo/ROOT-A/opt/google/chrome/' failed: No such file or directory

Copy link

dja001 commented Jan 17, 2023

Yup, it appears that this file has moved.

I could get it to work by changing :

install -Dm644 "$MNTPNT"/opt/google/chrome/ "$CHRFILES"/opt/WidevineCdm/_platform_specific/linux_arm/
install -Dm644 "$MNTPNT"/opt/google/chrome/WidevineCdm/_platform_specific/cros_arm/ "$CHRFILES"/opt/WidevineCdm/_platform_specific/linux_arm/

You will also want to adjust the links as discussed by @iisti above.

on line ~56.

Copy link

dja001 commented Jan 17, 2023

Anyone would have a suggestion for flash?

I am trying to get tidal's web player to work and, now that Widevine is working, I think it's flash that is preventing this site from working properly.

Copy link

ChromeOS ARM64 userspace has hit the beta channel for some boards

I am posting this here for greater visibility. If anyone has a trogdor based chromebook, the beta for chromeOS should be using an ARM64 userspace RIGHT NOW.

Recovery images are not available for this and probably won't be for a few more months until it hits stable. If anyone here sees this and has a trogdor based chromebook please use the beta channel and check for an arm64 widevine module.

trogdor may not be the only device with ARM64 userspace on the beta. cherry, corsola, jacuzzi, and kevin also have ARM64 userspace preparred in the CI but its not be confirmed whether or not these devices are using ARM64 userspace now or not.

Copy link

Thaodan commented Feb 11, 2023

The Image contains arm64 widevine, it can be extracted using the ota unpacker.

Copy link

Did Google remove widevine from the image?

Copy link

False alarm, it's been moved:

ubuntu@oracle-vm:/media/ubuntu/ROOT-A/opt/google/chrome/WidevineCdm/_platform_specific/cros_arm$ ls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment