Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fetches a ChromeOS image for ARM and extracts the Widevine and Flash binaries, saving them in a compressed archive
#!/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"
else
echo "Install Wget or cURL" >&2
exit 1
fi
# Find a URL to a suitable arm64 ChromeOS recovery image
CHROMEOS_URL="$($DL_SL https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf | grep -A11 C101PA | sed -n 's/^url=//p')"
CHROMEOS_IMG="$(basename "$CHROMEOS_URL" .zip)"
if [ -e "$CHROMEOS_IMG" ]; then
CHROMEOS_IMG_PATH="./"
DEL_IMG=N
else
CHROMEOS_IMG_PATH="$(mktemp -td ChromeOS-IMG.XXXXXX)"
DEL_IMG=Y
# Fetch the recovery image (2Gb+ on disk after download)
$DL "$CHROMEOS_URL" | zcat > "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
fi
# 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)"
losetup -Pf "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
mount -o ro "${LOOPD}p3" "$MNTPNT"
else
# 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"
fi
# Note the mount point in a variable
MNTPNT="$(lsblk -lo MOUNTPOINT "${LOOPD}p3" | tail -n1)"
fi
# Extract the libs out and copy them to a compressed tar archive
ARCHIVE_NAME="widevine-flash-$(date '+%Y%m%d')_arm64.tgz"
echo "Extracting and compressing files"
tar -C"$MNTPNT" -caf "$ARCHIVE_NAME" opt/google/chrome/libwidevinecdm.so opt/google/chrome/pepper/libpepflashplayer.so --xform 's/pepper/PepperFlash/' --format ustar
echo "Created: $ARCHIVE_NAME"
# Cleanup
if [ "$USER" = "root" ]; then
umount "$MNTPNT"
losetup -d "$LOOPD"
rmdir "$MNTPNT"
else
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"
fi
fi
if [ "$DEL_IMG" = "N" ] || [ "${1:-EMPTY}" = "-k" ]; then
:
else
rm "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
rmdir -v "$CHROMEOS_IMG_PATH"
fi
# Inform the user how to proceed
cat <<EOF
To install the contents of these files on an ARM64 device, copy the tar archive over to the target machine and issue the following:
sudo tar -C/ -xf $ARCHIVE_NAME
EOF
#!/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"
else
echo "Install Wget or cURL" >&2
exit 1
fi
# Find a URL to a suitable armhf ChromeOS recovery image
CHROMEOS_URL="$($DL_SL https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf | grep -A11 CB5-312T | sed -n 's/^url=//p')"
CHROMEOS_IMG="$(basename "$CHROMEOS_URL" .zip)"
if [ -e "$CHROMEOS_IMG" ]; then
CHROMEOS_IMG_PATH="./"
DEL_IMG=N
else
CHROMEOS_IMG_PATH="$(mktemp -td ChromeOS-IMG.XXXXXX)"
DEL_IMG=Y
# Fetch the recovery image (2Gb+ on disk after download)
$DL "$CHROMEOS_URL" | zcat > "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
fi
# 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)"
losetup -Pf "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
mount -o ro "${LOOPD}p3" "$MNTPNT"
else
# 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"
fi
# Note the mount point in a variable
MNTPNT="$(lsblk -lo MOUNTPOINT "${LOOPD}p3" | tail -n1)"
fi
# 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"$MNTPNT" -caf "$ARCHIVE_NAME" opt/google/chrome/libwidevinecdm.so opt/google/chrome/pepper/libpepflashplayer.so --xform 's/pepper/PepperFlash/' --format ustar
echo "Created: $ARCHIVE_NAME"
# Cleanup
if [ "$USER" = "root" ]; then
umount "$MNTPNT"
losetup -d "$LOOPD"
rmdir "$MNTPNT"
else
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"
fi
fi
if [ "$DEL_IMG" = "N" ] || [ "${1:-EMPTY}" = "-k" ]; then
:
else
rm "$CHROMEOS_IMG_PATH/$CHROMEOS_IMG"
rmdir -v "$CHROMEOS_IMG_PATH"
fi
# 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 -C/ -xf $ARCHIVE_NAME
EOF
@ruario

This comment has been minimized.

Copy link

@ruario ruario commented Aug 28, 2019

Umm, the newer script will not actually fetch ARM64 Widevine because even on 64bit ChromeBooks the UI layer is 32bit, thus the widevine is 32bit. There is no source (that I am aware of of 64 bit ARM Widevine)

@teacupx

This comment has been minimized.

Copy link
Owner Author

@teacupx teacupx commented Aug 28, 2019

@ruario

This comment has been minimized.

Copy link

@ruario ruario commented Aug 28, 2019

Certainly will let you know if I see it. I have been trying to find a source for this file for some time.

@ruario

This comment has been minimized.

Copy link

@ruario ruario commented Aug 28, 2019

This is one page to keep an eye on

https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices

You need something in the User ABI column with “aarch64”. You will note that currently aarch64 can only be found in the Kernel ABI column.

@xerdink

This comment has been minimized.

Copy link

@xerdink xerdink commented Jan 22, 2020

Yes, I tested it in jetson tx2 which has aarch64 and chromium failed to load shared library with error elfclass32.. Any solutions do you think?

@ruario

This comment has been minimized.

Copy link

@ruario ruario commented Jan 22, 2020

@orhaneee If you ran a 32bit arm distro or multiarch (32/64) you could use the 32bit arm binary. Failing those options… no

There is no source of 64bit arm widevine. The only source for widevine on arm at all is chromeos images and whilst several of these have a 64bit kernel, they all have a 32bit userland (see my link above for evidence of this).

Unless a pure 64bit arm ChromeOS is released or Google/Widevine start offering a 64bit standalone widevine package (as they do with x86 and x64), there is now obvious way to resolve this. Widevine is, after all, a proprietary binary blob. There is no public source that would allow you to compile your own.

@teacupx

This comment has been minimized.

Copy link
Owner Author

@teacupx teacupx commented Jan 22, 2020

@orhaneee
You can also run a armhf docker image with Chromium, on your arm64 system. I have created a script for automating this: https://github.com/teacupx/docker-chromium-armhf

@ruario

This comment has been minimized.

Copy link

@ruario ruario commented Jan 22, 2020

@teacupx Oh nice, thanks for linking. Will try and check it out at some point

@xerdink

This comment has been minimized.

Copy link

@xerdink xerdink commented Jan 22, 2020

@ruario yes, you are right. my user space is 64 bit as you guess and the shared library that chromeos is using 32 bit. then, you see my error. I don't have if they will distribute 64 bit widevine..

@teacupx thank you it is nice but the problem is I am using my yocto image and on a Qt application which requires qtwebengine..

@RaviBeagle

This comment has been minimized.

Copy link

@RaviBeagle RaviBeagle commented Oct 4, 2020

You can also run a armhf docker image with Chromium, on your arm64 system. I have created a script for automating this: https://github.com/teacupx/docker-chromium-armhf

With this docker image, can I use the widevine-flash_armhf.sh script to get he Widevine CDM and does work on a ARM64 system, say Jetson Nano ?

@teacupx

This comment has been minimized.

Copy link
Owner Author

@teacupx teacupx commented Oct 4, 2020

It should. I haven't tested it since I did it, so I don't know if newer versions broke something.
Notice that you either need to provide the widevine lib as a Deb package, or copy it manually to the created docker container. If you are using some Mali binary for graphic acceleration, you need to copy it too, in armhf format.

@RaviBeagle

This comment has been minimized.

Copy link

@RaviBeagle RaviBeagle commented Oct 5, 2020

Sure. I have deleted that post. Is there another gist available ?
Could you tell me if the extracted libwidevinecdm.so and libwidevinecdm.so should be in /opt as extracted or in /usr/lib/chromium-browser (in the Docker container) ?

@teacupx

This comment has been minimized.

Copy link
Owner Author

@teacupx teacupx commented Oct 5, 2020

You can use the issue tracker of the Docker container for questions related to it.
Also, if you want to see a working solution, here is one (download the tar file and look under the chromium-streaming package): https://forum.armbian.com/topic/9310-rk3328-media-script-rock64-renegade/
It includes the debs with the widevine lib and the GPU drivers, for Rockchip RK3328 boards. I also made similar solutions for other boards supported by Armbian, but not for the Jetson Nano, sorry.

@RaviBeagle

This comment has been minimized.

Copy link

@RaviBeagle RaviBeagle commented Oct 8, 2020

I give up. This is all too damn hard and a waste of time. Do we need a manifest.json file for Chromium 79+ to work ?
The flash library is detected "Pepper Flash detected".

I have the latest libwidevine that I took from the latest Chromebook for arm Acer Chromebook Spin 311 (CP311-3H)

and I have it put in this locations

/usr/lib/chromium-browser/
/usr/lib/chromium-browser/WidevineCdm
/opt/google/chrome
/opt/google/chrome/WidevineCdm

The chromium that gets installed in docker is Version 85.0.4183.121 (Official Build) Built on Ubuntu , running on Ubuntu 18.04 (32-bit)

Why does it not detect the library ?

@teacupx

This comment has been minimized.

Copy link
Owner Author

@teacupx teacupx commented Oct 8, 2020

Do we need a manifest.json file for Chromium 79+ to work ?

I had never heard such a thing, for me it just works with an apt install chromium.

You can also login into the bionic docker container, and install the older version of chromium.

Also, you can try use the widevine Deb package from the link I posted above. Maybe you are missing some symlinks.

BTW putting the lib in /opt/chrome makes no sense for chromium.

Why does it not detect the library ?

You can try to launch it from console and see the logs. As I said, you may be missing some symlinks. Try the Deb package I mentioned.

@RaviBeagle

This comment has been minimized.

Copy link

@RaviBeagle RaviBeagle commented Oct 8, 2020

I used the deb package and various other combinations. But no avail. So i gave up on chromium altogether. I believe we cant use above chromium 79. I installed vivaldi with the same docker image

https://gist.github.com/ruario/19a28d98d29d34ec9b184c42e5f8bf29

Widevine is enabled now. Yet still not able to play prime video as it might be missing ffmpeg plugins.

@Mis012

This comment has been minimized.

Copy link

@Mis012 Mis012 commented Oct 24, 2020

Correct, I also noticed it. I'm just waiting for some arm64 Chrome OS to be released, in order to update the script. If you learn about such release, I'd appreciate if you can let me know. Regards.

how about deleting it for now? already fell for it twice

@grepwood

This comment has been minimized.

Copy link

@grepwood grepwood commented Jun 10, 2021

Google: won't make widevine for aarch64
Piracy: stonks

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