• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[DEV][ROM][UNOFFICIAL] LineageOS 18.1 (Android 11) for Raspberry Pi 4 B

Search This thread

shar pi

Member
Oct 12, 2021
5
1
It means that I switched to different bluetooth implementation entirely. I've never managed to reproduce the bluetooth audio stuttering related to Google location services because I rarely get around setting up my device with gapps. So definite maybe until it's been reported either way. Please test and report back.
I've tested, the problem the same.

But I found out, how to "fix it", until reboot.
Disable google play service, and enable them. Everything ok, but until this - audio is stuttering.
 

oguzkarayemis

Member
Oct 5, 2021
6
0
Seems that it has something to do with Chromium WebView. Have you tried the latest build from yesterday (or did this happen with previous builds)? Android system WebView is usually also updated with every build.
Thanks for new build. I did upgrade today. But problem continues from time to time, sadly. I'm very surprised no one having issues like me. I fallowed your instructions in your site, maybe I'm doing something wrong? Also I attached new logs regarding error from new build, I hope it'll be useful: https://drive.google.com/file/d/1ZHkNTy9nAM0AWho36_A8iW-OqFwtNF89/view?usp=sharing
 

shar pi

Member
Oct 12, 2021
5
1
Ok, thanks for reporting. Great that you found a workaround at least. :)

Here is my solution:

1. Clean install
2. Install gapps (pico/nano - no difference)
3. Install su add-on
4. Settings -> System -> Developer options -> Rooted debugging
5. Settings -> System -> Developer options -> USB debugging
6. adb root && adb remount
7. adb shell
8. nano /etc/init.d/90userinit

Bash:
#!/system/bin/sh
# call userinit.sh if present in /data/local

if [ -e /data/local/userinit.sh ];
then
   log -p i -t userinit "Executing /data/local/userinit.sh";
   /system/bin/sh /data/local/userinit.sh;
   setprop lineage.userinit.active 1;
fi

#depends on your boot time, sleep until
#LineageOS is fully loaded and you see your desktop
sleep 30

#use logcat to understand is your restart is on time
log -p i -t userinit "Executing GS restart";

#Google Play Services stop
su -c "pm disable com.google.android.gms";

#this sleep seems not to be necessary
sleep 10

#Google Play Services start
su -c "pm enable com.google.android.gms";

#after Google Play Services start we have to wait 5-10 seconds,
#because if we start music immediately,
#we'll meet awful stuttering for 10-15 seconds
sleep 7

#run spotify
monkey -p com.spotify.music 1

#wait until spotify ui is fully loaded
sleep 7
#play press & enjoy
input keyevent 126
 
  • Like
Reactions: KonstaT

KonstaT

Senior Member
Jan 20, 2016
506
341
KonstaKANG.com
But now I need to find, how to perform it automatically on every boot.

is it possible to perform:
pm disable com.google.android.gms
pm enable com.google.android.gms

after the boot is done?

Here is my solution:

1. Clean install
2. Install gapps (pico/nano - no difference)
3. Install su add-on
4. Settings -> System -> Developer options -> Rooted debugging
5. Settings -> System -> Developer options -> USB debugging
6. adb root && adb remount
7. adb shell
8. nano /etc/init.d/90userinit

Bash:
#!/system/bin/sh
# call userinit.sh if present in /data/local

if [ -e /data/local/userinit.sh ];
then
   log -p i -t userinit "Executing /data/local/userinit.sh";
   /system/bin/sh /data/local/userinit.sh;
   setprop lineage.userinit.active 1;
fi

#depends on your boot time, sleep until
#LineageOS is fully loaded and you see your desktop
sleep 30

#use logcat to understand is your restart is on time
log -p i -t userinit "Executing GS restart";

#Google Play Services stop
su -c "pm disable com.google.android.gms";

#this sleep seems not to be necessary
sleep 10

#Google Play Services start
su -c "pm enable com.google.android.gms";

#after Google Play Services start we have to wait 5-10 seconds,
#because if we start music immediately,
#we'll meet awful stuttering for 10-15 seconds
sleep 7

#run spotify
monkey -p com.spotify.music 1

#wait until spotify ui is fully loaded
sleep 7
#play press & enjoy
input keyevent 126
Came to say that you could look into using some Tasker-like third party application for this or use an init.d script but I see you already figured this out. Well done! :)

Couple of notes on the above. It would be better practice to create a separate script for this. E.g. /system/etc/init.d/50myscript or call it whatever you like. Set permission on the file to make it executable ('chmod 755 /system/etc/init.d/50myscript'). You don't need to install su add-on for this (as you use 'adb root') nor does the script need to call 'su' as scripts in init.d are already executed as root.

Bash:
#!/system/bin/sh

#depends on your boot time, sleep until
#LineageOS is fully loaded and you see your desktop
sleep 30

#use logcat to understand is your restart is on time
log -p i -t userinit "Executing GS restart";

#Google Play Services stop
pm disable com.google.android.gms

#this sleep seems not to be necessary
sleep 10

#Google Play Services start
pm enable com.google.android.gms

#after Google Play Services start we have to wait 5-10 seconds,
#because if we start music immediately,
#we'll meet awful stuttering for 10-15 seconds
sleep 7

#run spotify
monkey -p com.spotify.music 1

#wait until spotify ui is fully loaded
sleep 7
#play press & enjoy
input keyevent 126
 
Last edited:

shar pi

Member
Oct 12, 2021
5
1
Came to say that you could look into using some Tasker-like third party application for this or use an init.d script but I see you already figured this out. Well done! :)

Couple of notes on the above. It would be better practice to create a separate script for this. E.g. /system/etc/init.d/50myscript or call it whatever you like. Set permission on the file to make it executable ('chmod 755 /system/etc/init.d/50myscript'). You don't need to install su add-on for this (as you use 'adb root') nor does the script need to call 'su' as scripts in init.d are already executed as root.

Bash:
#!/system/bin/sh

#depends on your boot time, sleep until
#LineageOS is fully loaded and you see your desktop
sleep 30

#use logcat to understand is your restart is on time
log -p i -t userinit "Executing GS restart";

#Google Play Services stop
pm disable com.google.android.gms

#this sleep seems not to be necessary
sleep 10

#Google Play Services start
pm enable com.google.android.gms

#after Google Play Services start we have to wait 5-10 seconds,
#because if we start music immediately,
#we'll meet awful stuttering for 10-15 seconds
sleep 7

#run spotify
monkey -p com.spotify.music 1

#wait until spotify ui is fully loaded
sleep 7
#play press & enjoy
input keyevent 126

Thank you very much! I will fix the solution according to your suggestions in the evening
 

c3497605

Member
Oct 6, 2019
22
6
YouTube at 1080p should work just fine without any dropped frames. There's known to be problems with 1080p60 videos.

V4L2 codec support for Android is being worked on by various companies (including Google) so I'm sure we'll get there eventually (though it still might take an Android version or few).
Android 12 source code has been released lately. Do you know if they made any progress regarding V4L2 driver support?
 

KonstaT

Senior Member
Jan 20, 2016
506
341
KonstaKANG.com

stason.s7

Member
Feb 8, 2017
8
0
Depends on the display. DSI displays (including the official 7" one) are not supported with KMS driver in 5.4 kernel. For DPI panels this is the answer (https://forums.raspberrypi.com/view...sid=3a386bb3231047b80b65258acf0c4b64#p1854781).

Such a pity. Wanted to try Android on RPi. I have a 5" dsi display, connected to a standart display port.
Actually, I have HDMI+GPIO 3.5" display in a drawer too, but as I can remember it has very low resolution and very small, so I doubt if it could be at least a little comfortable in using.
 

KonstaT

Senior Member
Jan 20, 2016
506
341
KonstaKANG.com
Such a pity. Wanted to try Android on RPi. I have a 5" dsi display, connected to a standart display port.
Actually, I have HDMI+GPIO 3.5" display in a drawer too, but as I can remember it has very low resolution and very small, so I doubt if it could be at least a little comfortable in using.
Older builds that have SwiftShader software renderer are still an option (my LineageOS 16 build uses it by default, LineageOS 17 has an option to use it).
 

stason.s7

Member
Feb 8, 2017
8
0
Only HDMI displays are supported out-of-the-box with this build.

Depends on the display. DSI displays (including the official 7" one) are not supported with KMS driver in 5.4 kernel. For DPI panels this is the answer (https://forums.raspberrypi.com/view...sid=3a386bb3231047b80b65258acf0c4b64#p1854781).
3.5" hdmi+gpio with mpi3508 and virtual resolution up to 1080p (unreadable on such scale), actually works with
hdmi_group=1
hdmi_mode=67
and 640x480 in resolution.txt
Touch works, but very laggy. It looks like Up and Down are swapped with Left and Right.
Older builds that have SwiftShader software renderer are still an option (my LineageOS 16 build uses it by default, LineageOS 17 has an option to use it).
Thank you, may be will try it later with 5" (though I've heard that SwiftShader is pretty slow).
 
Last edited:

KonstaT

Senior Member
Jan 20, 2016
506
341
KonstaKANG.com
3.5" hdmi+gpio with mpi3508 and virtual resolution up to 1080p (unreadable on such scale), actually works with
hdmi_group=1
hdmi_mode=67
and 640x480 in resolution.txt
Touch works, but very laggy. It looks like Up and Down are swapped with Left and Right.

Thank you, may be will try it later with 5" (though I've heard that SwiftShader is pretty slow).
Cool. hdmi_* options in config.txt are not used with KMS (but still needed if you want to use TWRP recovery that doesn't use hw accelerated graphics). There's some overlay parameters you can use to rotate the touch input (https://github.com/lineage-rpi/andr...mmit/8a6bf037e6ef397bb3752c55095b3998a906e692).

SwiftShader is certainly slower than hw accelerated graphics but it also performs better the lower resolution you use. It depends on the use case how usable you'll find it.
 

EpicLPer

Senior Member
Aug 29, 2012
692
385
26
Scheibbs
epiclper.com

KonstaT

Senior Member
Jan 20, 2016
506
341
KonstaKANG.com
I did check and they've made some progress at https://android.googlesource.com/platform/external/v4l2_codec2/. I haven't gotten around testing anything, though.
Does not seem to be working on Android 12 with AOSP master and gerrit patches.

Code:
10-11 18:38:47.809   246  1586 E V4L2Device: No devices supporting H264 for type: 0
10-11 18:38:47.809   246  1586 E V4L2Decoder: Failed to open device for H264
10-11 18:38:47.809   246  1586 E V4L2DecodeComponent: Failed to create V4L2Decoder for H264
10-11 18:38:47.810   271  1582 E MediaCodec: Codec reported err 0x80000000, actionCode 0, while in state 5/STARTING
10-11 18:38:47.811   271  1582 D SurfaceUtils: disconnecting from surface 0xabc80018, reason disconnectFromSurface
10-11 18:38:47.811   271  1581 E NuPlayerDecoder: Failed to start [c2.v4l2.avc.decoder] decoder (err=-2147483648)

Code:
console:/ # v4l2-ctl -d /dev/video10 -D                                    
Driver Info:
        Driver name      : bcm2835-codec
        Card type        : bcm2835-codec-decode
        Bus info         : platform:bcm2835-codec
        Driver version   : 5.10.63
        Capabilities     : 0x84204000
                Video Memory-to-Memory Multiplanar
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04204000
                Video Memory-to-Memory Multiplanar
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : bcm2835-codec
        Model            : bcm2835-codec
        Serial           : 0000
        Bus info         : platform:bcm2835-codec
        Media version    : 5.10.63
        Hardware revision: 0x00000001 (1)
        Driver version   : 5.10.63
Interface Info:
        ID               : 0x0300000c
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : bcm2835-codec-decode-source
        Function         : V4L2 I/O
        Pad 0x01000002   : 0: Source
          Link 0x02000008: to remote pad 0x1000004 of entity 'bcm2835-codec-decode-proc': Data, Enabled, Immutable

console:/ # v4l2-ctl -d /dev/video10 --list-formats                        
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'YU12' (Planar YUV 4:2:0)
        [1]: 'YV12' (Planar YVU 4:2:0)
        [2]: 'NV12' (Y/CbCr 4:2:0)
        [3]: 'NV21' (Y/CrCb 4:2:0)
        [4]: 'RGBP' (16-bit RGB 5-6-5)

console:/ # v4l2-ctl -d /dev/video11 -D                                    
Driver Info:
        Driver name      : bcm2835-codec
        Card type        : bcm2835-codec-encode
        Bus info         : platform:bcm2835-codec
        Driver version   : 5.10.63
        Capabilities     : 0x84204000
                Video Memory-to-Memory Multiplanar
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04204000
                Video Memory-to-Memory Multiplanar
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : bcm2835-codec
        Model            : bcm2835-codec
        Serial           : 0000
        Bus info         : platform:bcm2835-codec
        Media version    : 5.10.63
        Hardware revision: 0x00000001 (1)
        Driver version   : 5.10.63
Interface Info:
        ID               : 0x0300001a
        Type             : V4L Video
Entity Info:
        ID               : 0x0000000f (15)
        Name             : bcm2835-codec-encode-source
        Function         : V4L2 I/O
        Pad 0x01000010   : 0: Source
          Link 0x02000016: to remote pad 0x1000012 of entity 'bcm2835-codec-encode-proc': Data, Enabled, Immutable

console:/ # v4l2-ctl -d /dev/video11 --list-formats                        
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'H264' (H.264, compressed)
        [1]: 'MJPG' (Motion-JPEG, compressed)

As discussed on disq.us/p/2flnqg7 H.264 might require Pi firmware (i.e. using fake/firmware FKMS vs. KMS used on Android). v4l2_codec only has dec/enc for H.264/VP8/VP9. Pi 4 has hw decoders for H.264/H.265 so that only leaves H.264. I guess memory allocation is expected to be a problem, too.

Edit. Confirmation from a Raspberry Pi engineer that H.264 works with KMS. https://github.com/raspberrypi/linux/issues/4651#issuecomment-950947950
 
Last edited:
  • Like
Reactions: c3497605

c3497605

Member
Oct 6, 2019
22
6
console:/ # v4l2-ctl -d /dev/video10 --list-formats
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture Multiplanar

[0]: 'YU12' (Planar YUV 4:2:0)
[1]: 'YV12' (Planar YVU 4:2:0)
[2]: 'NV12' (Y/CbCr 4:2:0)
[3]: 'NV21' (Y/CrCb 4:2:0)
[4]: 'RGBP' (16-bit RGB 5-6-5)
This is the device used for decoding right? It doesn't list any format except uncompressed video.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    New builds. Add-ons have also been updated for the new TWRP so download the latest ones on those as well.


    -add support for BME280/BMP280 temperature/pressure/humidity sensors
    -add option to select HDMI-CEC device
    -add option to show virtual volume down, volume up, and power keys on navigation bar
    -add option for old TCP-based ADB over network
    -show IP address and port for ADB/SSH/VNC options
    -fix resizing data partition that broke with previous build
    -update to TWRP 3.6.0_11-0-KonstaKANG
    -update to Mesa 21.3.0
    -update to Linux 5.4.161 kernel and patch known vulnerabilities (CVE-xxxx-xxxx, and more)
    -Android security patch level: 5 November 2021 (merged)

    ---


    -add support for BME280/BMP280 temperature/pressure/humidity sensors
    -add option to select HDMI-CEC device
    -show IP address and port for SSH/VNC options
    -setup wizard improvements for TV devices (merged)
    -fix resizing data partition that broke with previous build
    -update to TWRP 3.6.0_11-0-KonstaKANG
    -update to Mesa 21.3.0
    -update to Linux 5.4.161 kernel and patch known vulnerabilities (CVE-xxxx-xxxx, and more)
    -Android security patch level: 5 November 2021 (merged)
    1
    Just wanted to say thanks for this image, I've been running this (32bit ATV version, I don't fancy reinstalling all the apps just yet!) for a few weeks now on my TV and it's been working well with my gyro mouse. I've had a few rare crashes but as a daily use it's been great!

    Looking forward to getting hardware decoding, sometimes there can be a delay in audio decoding and certain 1080p+ content struggles but it's replaced LibreElec for me now. Good job!
    1
    Is there any hope for HW Video decoding support?
    Not on this build. It requires using newer stuff that are not available for Android 11.

    Latest LineageOS 19 (Android 12) build already has proof of concept level support for H.264 hardware video decoding. It's 1080p only due to hardcoded buffer sizes and something gets still messed up somewhere in the pipeline because colors are not correct. Still proves the point that it can work but it's still going to take a lot of time and work (not just on this hardware but in general).
  • 24
    Here’s my build of LineageOS 18.1 for Raspberry Pi 4 Model B, Pi 400, and Compute Module 4. It is unofficial and unsupported by the LineageOS team. It’s for advanced users only. Pi 4 model with at least 2GB of RAM is required to run this build.

    Important! This image includes parts that are licensed under non-commercial license (Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International). You may use this build freely in personal/educational/etc use. Commercial use is not allowed with this build!

    Screenshot_20210104-104810_Settings.png


    https://konstakang.com/devices/rpi4/LineageOS18/

    There is also Android TV version available.
    Screenshot_20210306-163341_Settings.png


    https://konstakang.com/devices/rpi4/LineageOS18-ATV/

    Working:
    • Audio (HDMI, 3.5mm jack, USB microphones, bluetooth speakers/headphones, etc)
    • Audio DAC (using GPIO DACs e.g. Hifiberry DAC+)
    • Bluetooth (and bluetooth tethering)
    • Camera (using official Pi camera modules & UVC USB webcams)
    • GPIO
    • GPS (using external USB modules e.g. U-Blox 7)
    • Ethernet
    • Hardware accelerated graphics (V3D, OpenGL & Vulkan)
    • HDMI display (and HDMI-CEC)
    • I2C
    • IR remotes (using external GPIO IR modules e.g. TSOP4838)
    • RTC (using external GPIO I2C modules e.g. DS3231)
    • Sensors (using external GPIO I2C modules e.g. MPU6050, LSM6DS3, LSM303DLHC & BME280/BMP280 accelerometer/gyroscope/magnetometer/temperature/pressure/humidity)
    • Serial console (using external GPIO serial console adapters e.g. PL2303)
    • SPI
    • Touchscreen/multi-touch (USB touchscreens, Waveshare SPI touchscreens)
    • USB (mouse, keyboard, storage, etc)
    • USB-C (ADB, MTP, PTP, USB tethering)
    • Wifi (and wifi tethering)

    Not working:
    • Hardware video decoding & encoding (software decoding & encoding works)

    Issues:
    • Stock camera app is not working - many third party camera apps seem to work
    • SELinux is in permissive mode
    • and more…

    Sources:

    Thanks:
    • Peter Yoon and android-rpi project
    • Roman Stratiienko and GloDroid project
    • AOSP reference board developers (dragonboard, hikey, yukawa)
    • E. Anholt for V3D graphics driver
    • Maxime Ripard for Pi 4 KMS driver
    • Android-x86 project
    • LineageOS team and everyone who has contributed to LineageOS 18.1
    5
    New build.

    -add support for LSM303DLHC accelerometer & magnetometer sensor
    -add separate TWRP flashable su add-on (see FAQ)
    -allow switching display off with power button
    -add support for USB-C (ADB, MTP, PTP, USB-tethering)
    -enable bluetooth tethering
    -add settings option for mouse back button feature
    -update to TWRP 3.5.0_9-0-KonstaKANG
    -update to Mesa 20.3.4
    -update to Linux 5.4.98 kernel and patch known vulnerabilities (CVE-xxxx-xxxx, and more)
    -Android security patch level: 5 February 2021 (merged)
    4
    How to install:
    1. Follow the official Raspberry Pi instructions for writing the image to the SD card.

    FAQ:

    FAQ is getting quite long and difficult to maintain in several different places. You can find the always up-to-date FAQs here:
    https://konstakang.com/devices/rpi4/LineageOS18/
    https://konstakang.com/devices/rpi4/LineageOS18-ATV/
    4
    New builds.


    -add support for Vulkan
    -rework bluetooth (thanks to android-rpi)
    -update to Mesa 21.1.8
    -update to Linux 5.4.152 kernel and patch known vulnerabilities (CVE-xxxx-xxxx, and more)
    -Android security patch level: 1 October 2021 (merged)

    ---


    -add support for Vulkan
    -rework bluetooth (thanks to android-rpi)
    -switch to new two-panel settings UI (merged)
    -update to Mesa 21.1.8
    -update to Linux 5.4.152 kernel and patch known vulnerabilities (CVE-xxxx-xxxx, and more)
    -Android security patch level: 1 October 2021 (merged)
    4
    New build.

    -add initial support for HDMI-CEC
    -add built-in VNC server
    -update to Mesa 21.0.2
    -update to Linux 5.4.111 kernel and patch known vulnerabilities (CVE-xxxx-xxxx, and more)
    -Android security patch level: 5 April 2021 (merged)