Posts by fosf0r

    Until the patch is upstreamed, you will have to make your own build system and add it.

    Read all of this before beginning:

    https://forum.libreelec.tv

    1) Install Ubuntu 16.04.x (LTS) server

    Do everything from here on out as non-root.

    2) sudo apt update && sudo apt upgrade

    3) sudo apt install gcc make git unzip wget xz-utils

    4) Clone the LibreELEC github:

    Code
    cd ~
    git clone https://github.com/LibreELEC/LibreELEC.tv.git
    cd ~/LibreELEC.tv

    5) Build the whole system once, without my patches, to make sure your build system is working:

    Code
    PROJECT=Rockchip DEVICE=RK3399 ARCH=arm UBOOT_SYSTEM=rockpro64 make image

    6) Download and copy the two patch files into ~/LibreELEC.tv/projects/Rockchip/patches/linux/rockchip-4.4/

    * linux-8000-pwm-fan.txt

    * linux-8001-dts-pwm.txt

    7) Build it again now that the patch files are in:

    Code
    PROJECT=Rockchip DEVICE=RK3399 ARCH=arm UBOOT_SYSTEM=rockpro64 scripts/clean linux
    PROJECT=Rockchip DEVICE=RK3399 ARCH=arm UBOOT_SYSTEM=rockpro64 make image

    Ok, I was able to get to it faster than I thought.

    I cloned 9.1-dev, then added the two patch files, and it worked without any changes.

    Perhaps your patch files contain extra characters or linefeed/carriage return symbols from when you copied it.

    I have attached the patches as actual files.

    But this board wouldn't let me keep the extension as .patch, so you probably should rename these to .patch

    ( I was able to build the entire image, but I can't test it at all yet. I presume it works, don't see why it wouldn't. )

    linux-8000-pwm-fan.txt

    linux-8001-dts-pwm.txt

    Oh, is it at a different branch now?

    I was using 9.0-devel, now I see yours says 9.1-devel.

    Either, build using:

    Release 9.0.0: Merge pull request #3280 from MilhouseVH/le90_settings_pr120 · LibreELEC/LibreELEC.tv · GitHub

    Or, someone has to look at pwm-fan.c vs the diff and see why it's not applying (maybe someone upstreamed the fix already and my patch is now redundant?)


    It will be a while before I have a chance to rebuild my ELEC kit so I'm not going to be able to fix that patch myself yet.

    Yes, building LibreELEC is an "intermediate" task.

    It is not easy when you are still new to Linux.


    I am new to GitHub, and new to contributing patches, so I don't know how to submit patches yet, but I will learn soon.

    I will eventually try to submit the patch, but I need to clean it up and integrate it with LibreELEC's existing patches.

    ( I'm pretty sure that I have to integrate the DTS bits directly into http://LibreELEC.tv/projects/Rockchip/patches/linux/rockchip-4.4/linux-0005-dts.patch )

    I'll update this thread with the results if I am able to get the patch submitted.

    At full load, my system runs at 101 F / roughly 38.3 C

    n i c e

    Here are the necessary 4 things get pwm-fan for rk3399-rockpro64.

    EDIT: You have to have already setup the build system per the wiki:

    Compile [LibreELEC.wiki]

    These edits are to be done to your build system (not from within LibreELEC).

    (A)

    1. nano ~/LibreELEC.tv/projects/Rockchip/devices/RK3399/linux/rockchip-4.4/linux.aarch64.conf
    2. Add this line: CONFIG_SENSORS_PWM_FAN=y

    (B)

    Create file: ~/LibreELEC.tv/projects/Rockchip/patches/linux/rockchip-4.4/linux-8000-rockpro64-pwm-fan.patch

    (C)

    Create file: ~/LibreELEC.tv/projects/Rockchip/patches/linux/rockchip-4.4/linux-8001-rockpro64-fan0.patch

    (D)

    Now you have to activate the fan.

    I didn't use thermal maps in the DTS (do it yourself) or anything smart/automated, because I just wanted my fan running 100% of the time, so I do the following in LibreELEC's autostart.sh :

    Code
    echo 255 > /sys/class/hwmon/hwmon0/pwm1

    Thanks for your help, I got it working.

    Mainly I was missing: CONFIG_SENSORS_PWM_FAN=y

    Then I also had to patch pwm-fan.c because it was unable to compile.

    I downloaded the patched pwm-fan.c from this:

    UPSTREAM: hwmon: pwm-fan: Use pwm_get_args() where appropriate · ayufan-rock64/linux-kernel@356102c · GitHub

    Then I diff'd it against the one included with LibreELEC and made a .patch and that made it compile + work properly.

    I will be making some patches to submit soon.

    Ok, I even setup the build system and compiled my own working image from scratch.

    But I am having a really hard time getting a pwm-fan entry to work; I think I am not doing the syntax right.

    Can someone provide a diff to rk3399-rockpro64.dts that sets up pwm-fan properly ?

    I thought it would just be like:

    Code
        fan0: pwm-fan {
            compatible = "pwm-fan";
            cooling-min-state = <0>;
            cooling-max-state = <3>;
            #cooling-cells = <2>;
            pwms = <&pwm1 0 10000 0>;
            cooling-levels = <0 102 170 230>;
        };

    But I get syntax errors while parsing the tree, when it tries to compile it to dtb.

    [EDIT: PATCHES TO FIX THIS ARE BELOW]


    Hello,

    Just burned libreelec-rk3399.arm-9.0-nightly-20190201-974f4cb-rockpro64.img.gz

    And it's perfect.

    I just can't get my 2-pin PWM fan enabled.

    ayufan's debian had a sys class object 'hwmon0' which I could echo '255' into and start the fan, but no such device tree object has been initialized in this build.

    I don't have the appropriate cables to re-wire my fan from being a 2-pin molex fan header in order to stick it into the GPIO header.

    Can someone add hwmon0 or any possible way to control PWM fan on the 2-pin fan header to the image?

    I wouldn't even mind building my own image if I have to, but I need to be shown how that works, I guess.

    That's the plan.

    1) Is this build hardcoded to speak to Videostrong hardware, or does it contain the full DTB tree for the tons of rk3399 variants, such that if I threw it on my pine rockpro64, it would figure itself out?

    2) What kernel version is it? ( if it's not exactly 4.4.138 I will be unable to use it, because my designware/synposis "i2s"/bridge driver goes bad past 4.4.138 which is what my rockpro64 uses for HDMI-carried audio I think?; anyway >4.4.138 floods dmesg with 'fail to clear' errors and audio goes -1,000x speed, sounds like a demon when you play a file if using >4.4.138). How would I even begin getting help with that?

    AWESOME!

    Will that VOPB fix make it upstream so everyone's builds will get better?

    Pretty much everyone with any rockchip device is going to need their DTS fixed up.

    ( I also had to enable RKVDEC, RGA, VPU, and so forth, just to be able to decode HEVC/x265/4K@60fps. )

    rk3399 device has two vops. vopl and vopb. vopb supports four windows of 4960x2160p while vopl only supports two 2260x1920p windows.

    I'll have to check the DTS and make hdmi use vopb.

    Keep in mind I don't own this board and hence I have no ability to test this board.

    Oh wow, thank you for this, I didn't realize you could even choose which VOP in the DTS.

    I'm going to switch mine later today and undo my VOP source hack.

    Once you know what the DTS edit is, please let me know, I'll immediately test it on my pine rockpro64 rk3399 board.

    My VOP is indeed using the little version, and when I look at my DTS, it's not immediately obvious to me how to select the big VOP.


    Thanks all for explanation but if we take the look on the my first post we see what early build not have samba, 4K, CEC, sound problems.

    This BOX under native installed Android 7.1 and latest KODI working fine. Only one issue. Framerate auto switching. This is my cause to open observance to find alternatives.

    Positive moment in the last NP build is very good downscaling speed and network cashing for 4K content. I dont have freezing and dropout. Maybe new drivers for Ethernet and hardware acceleration is implemented.

    samba: install it yourself

    framerate switching: that has always worked, just not for >1080p

    4K: VOP problem is getting fixed now

    if having CEC problems: I suggest rolling backwards to ayufan kernel 4.4.138-1100

    if having sound problems: same; I suggest rolling backwards to ayufan kernel 4.4.138-1100

    That was me, I'm running ayufan's rockpro64 debian minimal (ayufan 4.4.138-1100 kernel version)

    But I'm in rockpro64, not rock64, not rk3388, so sorry for any confusion.

    However there is a lot of crossover so sometimes things are the same on both boards.

    Anyway, I had to edit my DTB with dtedit to enable rkvdec.

    With the rockpro64 store's medium heatsink + fan, I get about 50C constant when playing 3840x2160@60

    edit: the CPUs and heat are quite similar between the two, only diff being rk3399 has 2 extra A57 cores but they're not optimized until kernel mainline support gets better since those two are part of the weird "big.LITTLE" architecture

    Edit: I should have mentioned, I accomplished this on ayufan's debian images, not any libreELEC ones, with a ROCKPRO64, not a rock64, sorry about the confusion. I bet the majority of these things are similar though.

    I flashed bionic-minimal-rockpro64-0.7.11-1075-arm64.img.xz

    And then downgraded it to kernel 4.4.138 of my own building.

    4.4.154 is messed up for me, at least on ayufan.


    ( Small note: I use "joe" as my editor. You might be using "nano". I don't know how to use any other editors than joe, so I can't tell you commands for your editor. )

    First, make sure you are able to mount your boot device (emmc or SD card) filesystem on another Linux system, because if your system crashes from making this change, you won't be able to get back in to undo the changes.

    To recover from this, you would have to mount partition 7 on another system and edit /boot/extlinux/extlinux.conf to either point to the original devicetreedir of /boot/dtbs/4.4.x-stuff/ or to point fdt to your backup copy of /boot/dtb-4.4.x-stuff.

    - - - -

    Backing up current settings:

    Run dtedit

    That will launch your current default editor.

    Don't make any changes, just immediately exit the editor.

    That will cause ayufan's scripts to send your current DTB to a file in /boot

    Now please ls -al /boot and see if you see a file called /boot/dtb-4.4.x-stuff (where "stuff" is whatever your filename is, I don't know it since I built my own.)

    Make a backup of that file.

    cp /boot/dtb-4.4.x-stuff /boot/dtb-4.4.x-stuff-WORKING

    Also note the "source" file is there too, only difference is the "s" in the filename:

    /boot/dts-4.4.x-stuff

    Also make a backup copy of that source file if you want.

    - - -

    The main event:

    Now use your editor and edit the source for the dtb:

    /boot/dts-4.4.x-stuff

    While editing that file, search for rkvdec

    Within the rkvdec braces { }, find status = "disabled"

    And change that to status = "okay"

    Save and exit the editor.

    ayufan's scripts will automatically recompile the changes into /boot/dtb-4.4.x-stuff

    (You did back yours up first right?)

    Now you may want to edit /boot/extlinux/extlinux.conf

    And make sure there aren't multiple kernels, and make sure that the fdt line is present and points at that file.


    ----------


    RECOVERY IF IT FAILS:


    Here is my entire extlinux.conf so you can compare to your own.

    My device hostname is called 'kodiplex' since I was building both of those programs, and my customized 4.4.138 kernel is tagged 'kodiplex' too so it is literally version "4.4.138-kodiplex" for me, just ignore that and substitute with the proper ayufan name and version that yours is.

    If your extlinux.conf is using "devicetreedir" instead of "fdt" then your edit will NOT take effect

    The below is what it looks like for me, with the edit in place, working.

    If yours doesn't boot, scroll down to the next code block and fix the fdt line like I show below:

    Code
    timeout 10
    menu title select kernel
    label kernel-4.4.138-kodiplex
    kernel /boot/vmlinuz-4.4.138-kodiplex
    initrd /boot/initrd.img-4.4.138-kodiplex
    fdt /boot/dtb-4.4.138-kodiplex
    append rw panic=10 init=/sbin/init coherent_pool=1M ethaddr=${ethaddr} eth1addr=${eth1addr} serial=${serial#} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 root=LABEL=linux-root rootwait rootfstype=ext4


    The line you should fix in extlinux.conf if your system fails to boot is the fdt one, you'd set it to point to the "WORKING" copy that you made before editing all of this:

    Code
    fdt /boot/dtb-4.4.138-ayufan-stuff-WORKING


    Alternatively, if /boot/dtbs/ is present, you could delete the whole "fdt" line and replace it with a "devicetreedir" line to get your system back to normal again:

    Code
    devicetreedir /boot/dtbs/dtb-4.4.138-ayufan-stuff/

    ! All your mileage may vary, since I quit using a lot of ayufan's automation/packages and began building my own kernel and software !

    It's probably that the rkvdec device tree is disabled (among other things, including VPU and RGA).

    At least on my setup, it is.

    (rockpro64 on ayufan 4.4.138-1100)

    You can have it enabled in the kernel, you can have libmpp installed, and you can have mpv compiled to use hwdec=rkmpp, but....:

    rkvdec@ff660000 status = "disabled" in my /sys/firmware/fdt

    I know that it's needed for x265/HEVC/etc.