Skip to content

Instantly share code, notes, and snippets.

@teacupx
Forked from ruario/1-README.md
Created December 30, 2018 19:30
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save teacupx/9393507ad6250429707f0318b04f1a3b to your computer and use it in GitHub Desktop.
Save teacupx/9393507ad6250429707f0318b04f1a3b to your computer and use it in GitHub Desktop.
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
@teacupx
Copy link
Author

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
Copy link

ruario commented Jan 22, 2020

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

@xerdink
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link

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
Copy link

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

@Niek
Copy link

Niek commented Jul 31, 2021

There's a fair amount of aarch64 Chromebooks, but all of them are running in user ABI arm. See https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices for a complete list. I doubt there will be a full aarch64 Chrome OS anytime soon.

@Botspot
Copy link

Botspot commented May 20, 2022

@Niek
Copy link

Niek commented May 20, 2022

Google is finally working on ARM64 widevine! https://chromium.googlesource.com/chromium/src.git/+/2868ab1359c64c5e063f259d46bd655bd8ad8bf2

Do you have a link to the CDM file? https://dl.google.com/widevine-cdm/4.10.2449.0-linux-arm64.zip is still 404.

@Botspot
Copy link

Botspot commented May 20, 2022

Do you have a link to the CDM file? https://dl.google.com/widevine-cdm/4.10.2449.0-linux-arm64.zip is still 404.

No, and I don't think it's public yet. The latest ChromeOS images that I could find (v101) still had arm32 userspace and widevine.
We'll have to keep our eyes open for an image-drop.

@chexo3
Copy link

chexo3 commented Sep 11, 2022

Where should we look for this? I’m using a PineBook Pro (aarch64) that doesn’t officially support Widevine. I am not above using a reverse engineered Widevine either.

@Santos-Jefferson
Copy link

Any update on this?

@theofficialgman
Copy link

ChromeOS ARM64 userspace has hit the beta channel for some boards
https://groups.google.com/a/chromium.org/g/chromium-os-dev/c/GdZ0mebutXw

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.

@Niek
Copy link

Niek commented Feb 9, 2023

ChromeOS ARM64 userspace has hit the beta channel for some boards https://groups.google.com/a/chromium.org/g/chromium-os-dev/c/GdZ0mebutXw

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.

Good one! I checked the trogdor boards and picked a random one from recovery.json, the Libera-Merdeka Chromebook C100/C110/C120/C150 with hwidmatch=^PAZQUEL-HGNV .*. I found the ID of this device in this list: 9023C063-08D6-4A4F-908C-BCF97DE8BA69. Now we can make a request to the Omaha update service to get the latest dev-channel image:

$ curl https://tools.google.com/service/update2 -d '<?xml version="1.0" encoding="UTF-8"?>
<request protocol="3.0" ismachine="1">
  <app appid="{9023C063-08D6-4A4F-908C-BCF97DE8BA69}" track="dev-channel" board="trogdor-signed-mp-v7keys" hardware_class="PAZQUEL-OPNA " delta_okay="false">
    <updatecheck/>
  </app>
</request>'
<?xml version="1.0" encoding="UTF-8"?><response protocol="3.0" server="prod"><daystart elapsed_days="5883" elapsed_seconds="7637"/><app appid="{9023C063-08D6-4A4F-908C-BCF97DE8BA69}" cohort="1:4h:" cohortname="trogdor_pazquel_dev" status="ok"><updatecheck _eol_date="22067" _firmware_version="1.1" _firmware_version_0="1.1" _firmware_version_1="1.1" _firmware_version_2="1.1" _firmware_version_3="1.1" _firmware_version_4="1.1" _kernel_version="1.1" _kernel_version_0="1.1" _kernel_version_1="1.1" _kernel_version_2="1.1" _kernel_version_3="1.1" _kernel_version_4="1.1" status="ok"><urls><url codebase="http://edgedl.me.gvt1.com/edgedl/chromeos/trogdor/15329.8.0/dev-channel/"/><url codebase="http://dl.google.com/chromeos/trogdor/15329.8.0/dev-channel/"/><url codebase="https://edgedl.me.gvt1.com/edgedl/chromeos/trogdor/15329.8.0/dev-channel/"/><url codebase="https://dl.google.com/chromeos/trogdor/15329.8.0/dev-channel/"/></urls><manifest version="15329.8.0"><actions><action event="install" run="chromeos_15329.8.0_trogdor_dev-channel_full_mp-v7.bin-gyzwiyjsgrstofwmrqotalztdgqyfxjj.signed"/><action ChromeOSVersion="15329.8.0" ChromeVersion="111.0.5563.8" IsDeltaPayload="false" MaxDaysToScatter="14" MetadataSignatureRsa="RJCWBhCiroW0+vTuI7j8/p8mjoOd3hDf8deDDPWbzSMNZGSQywHQbAJ9vPsnUtNr85RgSv+URQcrKznhY+J+GYQ8qGlSk42yRZ/Br7G4R+7cfS6WgpVart8E+Sv6GB3T/OQvX16jXsqLUbJ1CQvK76G/CFkfLT5vueRInTxFDUZJNZHJgmSX47EjL2hmRV/0kholGvt+FKvcO91GgIAecQxb9SBg7/Bc/qyPvTpqyhwu/KVKvozMrTFYjWpWvWRsTaiaSfwGkegc5cw5J1NdK9bTWMnnLHE+pjLiSF6G/EiIxX/lJlsP54jDwhwvg5rcW97R5GcO5ObCayrC8oJWxw==" MetadataSize="66328" event="postinstall" sha256="H3k+NT3BMvhSEJHfdY6VI7q1lrQEwjHEexoY8AcUxdM="/></actions><packages><package fp="3.1f793e353dc132f8521091df758e9523bab596b404c231c47b1a18f00714c5d3" hash_sha256="1f793e353dc132f8521091df758e9523bab596b404c231c47b1a18f00714c5d3" name="chromeos_15329.8.0_trogdor_dev-channel_full_mp-v7.bin-gyzwiyjsgrstofwmrqotalztdgqyfxjj.signed" required="true" size="1273013509"/></packages></manifest></updatecheck></app></response>%

So the resulting image is: http://edgedl.me.gvt1.com/edgedl/chromeos/trogdor/15329.8.0/dev-channel/chromeos_15329.8.0_trogdor_dev-channel_full_mp-v7.bin-gyzwiyjsgrstofwmrqotalztdgqyfxjj.signed

I don't have time to figure out how to extract the contents of this file, but that should be possible. The file format is described here: https://chromium.googlesource.com/aosp/platform/system/update_engine/+/HEAD/#update-payload-file-specification

@theofficialgman
Copy link

theofficialgman commented Feb 14, 2023

@Niek lucky for use someone else has already written a tool to extract these payloads, I used https://github.com/tobyxdd/android-ota-payload-extractor

https://github.com/theofficialgman/testing/releases/download/gmans-releases/WidevineCdm.tar.gz

I can't seem to get it working though on chromium

@chexo3
Copy link

chexo3 commented Feb 15, 2023 via email

@theofficialgman
Copy link

unforuntatly it working with nothing but chromeOS right now

firstly you have this problem as described here: https://thebrokenrail.com/2022/12/31/xfinity-stream-on-linux.html#how-do-i-actually-do-this you have to patch and rebuid your system GLIBC in order to even allow the library to load (no small feat)

and then you have the problem that since arm64 widevine doesn't normally exist for linux, browsers (all of that I have found except for rpm fusion chromium-freeworld) have widevine loading disabled and don't even attempt to load it.

@chexo3
Copy link

chexo3 commented Feb 15, 2023

At this point I wonder if it'd be easier to patch the CDM itself

Or just create some sort of shim that does the same thing

Like, it might be easier to just defeat the DRM altogether.

@Botspot
Copy link

Botspot commented Feb 15, 2023

Interesting resource on how glibc was patched in PiOS: raspberrypi/Raspberry-Pi-OS-64bit#11 (comment)

@Niek
Copy link

Niek commented Feb 15, 2023

Thanks for the extracted tarball, @theofficialgman! Seems like the URL will be: https://dl.google.com/widevine-cdm/4.10.2557.0-cros-arm64.zip (404 at the time of writing).

When trying to load the library I get a symbol lookup error undefined symbol: __aarch64_ldadd4_acq_rel on Ubuntu 22.04. On Ubuntu 22.10 I get the DT_RELR without GLIBC_ABI_DT_RELR dependency error mentioned before. Instead of patching glibc, this could probably be resolved with a small LD_PRELOADed library. Ideally, the ChromeOS toolchain will update to a newer glibc version so this error won't happen in future builds.

@Botspot
Copy link

Botspot commented Feb 15, 2023

I've requested assistance from RPi developers over on this github repo: raspberrypi/Raspberry-Pi-OS-64bit#248

@theofficialgman
Copy link

Thanks for the extracted tarball, @theofficialgman! Seems like the URL will be: https://dl.google.com/widevine-cdm/4.10.2557.0-cros-arm64.zip (404 at the time of writing).

I have never seen any other chromeos (cros) links there. only windows and linux (win x64 and arm64, and linux x64)

@jollySleeper
Copy link

Thank You @teacupx @theofficialgman and all the guys involved in this thread ❤️ .
I was successfully able to run widewine needed playback on Kodi 19.4 on Arm64 with some modification to Input Stream Helper Plugin using the libwidevinecdm.so aarch64 version.

Widewine CDM on Kodi for Arm64 is a thing now.
Thanks to all of you again <3

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