[SOLVED W/PATCHES] Fan support for RK3399 rockpro64

  • [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.

    Edited once, last by fosf0r ().

  • 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
    1. fan0: pwm-fan {
    2. compatible = "pwm-fan";
    3. cooling-min-state = <0>;
    4. cooling-max-state = <3>;
    5. #cooling-cells = <2>;
    6. pwms = <&pwm1 0 10000 0>;
    7. cooling-levels = <0 102 170 230>;
    8. };

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

  • I'm no device tree expert but...

    I've been playing with the Temps and Fan control on my RK3399 ODROID N1, here is what I have extra in the .dts


    You will need a patch like linux-0009-pwn-fan-enable-rk339-rockpro64.patch and save into this directory:


    LibreELEC.tv/projects/Rockchip/patches/linux/rockchip-4.4/


    hastebin


    I also changed the Kernel config:

    LibreELEC.tv/projects/Rockchip/devices/RK3399/linux/rockchip-4.4/linux.aarch64.conf

    Change the Thermal section to:


    hastebin


    This also has to be enabled:

    Code
    1. # CONFIG_PMBUS is not set
    2. CONFIG_SENSORS_PWM_FAN=y
    3. # CONFIG_SENSORS_SHT15 is not set


    Issues I'm facing is the Fan run's 24/7 even with extra Hardkernel device tree trip points & cooling maps in the rk3399.dtsi

    I do get an nice cool SoC tho idling at 32 C


    More research & tweaking needs to be done.





    Other info for reference:

    rockchip-thermal.txt


    RK_VIRTUAL_THERMAL


    is needed in the Kernel config if you do NOT have a TSADC (rk3399's do have a TSADC)


    https://github.com/rockchip-linux/kernel/blob/release-4.4/drivers/thermal/kconfig#l215

  • 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/[email protected] · 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.

  • Ah yes that pwm-get_args patch - forgot I had that one as well - already.


    HINT: if you put .patch after the commit Hash - Github with auto generate a patch for you... for quick testing.

    eg from the above link....


    356102c69b4ec19058847147f790cac0b3406fd9.patch


    Also works for GitHub Pull Requests containing multiple commits...

    eg:


    3288.patch



    Managed finally to get the Trip points & Cooling back into the actual N1 device tree and successfully compiling now.


    There is this interesting thread:


    Eliminating the crazy (fan) chirp


    And you can play around with the Fan with this patch:


    hastebin




    I'm also testing Overclocking a RK3399 N1:


    Exploring CPU Voltage & undervolting


    hastebin

  • 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.



    (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
    1. echo 240 > /sys/class/hwmon/hwmon0/pwm1

    Edited once, last by fosf0r: (Setup cooling-levels to be real PWM duty cycles, 0%, 50%, 75%, 100% ().

  • fosf0r

    Changed the title of the thread from “Fan support for RK3399 rockpro64” to “[SOLVED W/PATCHES] Fan support for RK3399 rockpro64”.
  • Could someone from the LE team push the pwm-fan.c fix upstream and enable pwm sensors by default in the kernel options going forward, etc ?