Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu 20.04 support #6

Open
aep opened this issue Sep 1, 2021 · 4 comments
Open

ubuntu 20.04 support #6

aep opened this issue Sep 1, 2021 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@aep
Copy link

aep commented Sep 1, 2021

Hi,

i couldnt figure out yet how to get it working on ubuntu 20.04

the latest kernel there is 5.4.0-1042-raspi
the module compiles fine but it requires changing the regex in dkms.conf

the bigger challange is getting the dtb to compile. right now it just doesnt... and i dont understand how its supposed to work

root@ubuntu:/usr/src/cm4io-fan-0.1.1# dkms install cm4io-fan/0.1.1

emc2301.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-1042-raspi/updates/dkms/

Running the post_install script:
cm4io-fan.dtbo:
 - Installation
   - Installing to /boot/firmware/overlays/
cp: cannot stat '/var/lib/dkms/cm4io-fan/0.1.1/5.4.0-1042-raspi/aarch64/module/cm4io-fan.dtbo': No such file or directory

depmod....

DKMS: install completed.


none of the makefiles contain any call to dtc, so i'm not sure how this works in the first place

calling dtc directly wont work either, since the dts is not valid syntax.

root@ubuntu:/usr/src/cm4io-fan-0.1.1/overlays# dtc  -O dtb -o /boot/firmware/overlays/emc2301.dtbo cm4io-fan-overlay.dts 
Error: cm4io-fan-overlay.dts:4.1-2 syntax error
FATAL ERROR: Unable to parse input tree

@aep
Copy link
Author

aep commented Sep 1, 2021

made a new dts, this works for me

/dts-v1/;
/plugin/;


/ {


    fragment@2 {
        target = <&i2c1>;
        __overlay__ {
            status = "okay";
            fanctrl:  emc2301@2f {
                reg = <0x2f>;
                compatible = "microchip,emc2301";
                #cooling-cells = <0x02>;

                fan@0 {
                    min-rpm = /bits/ 16 <3500>;
                    max-rpm = /bits/ 16 <5500>;
                };
            };
        };
    };
};


@sdwilsh
Copy link
Contributor

sdwilsh commented Nov 24, 2021

The invalid syntax is just the #include, which I imagine isn't supported in 5.4. If you get rid of that line (and replacing THERMAL_NO_LIMIT with 4294967295), you can get it to compile, with warnings, however:

$ dtc  -O dtb -o emc2301.dtbo overlays/cm4io-fan-overlay.dts
overlays/cm4io-fan-overlay.dts:22.17-30: Warning (reg_format): /fragment@1/__overlay__/emc2301@2f:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
overlays/cm4io-fan-overlay.dts:26.29-29.19: Warning (unit_address_vs_reg): /fragment@1/__overlay__/emc2301@2f/fan@0: node has a unit name, but no reg property
emc2301.dtbo: Warning (pci_device_reg): Failed prerequisite 'reg_format'
emc2301.dtbo: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
emc2301.dtbo: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
emc2301.dtbo: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
emc2301.dtbo: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
overlays/cm4io-fan-overlay.dts:21.33-30.15: Warning (avoid_default_addr_size): /fragment@1/__overlay__/emc2301@2f: Relying on default #address-cells value
overlays/cm4io-fan-overlay.dts:21.33-30.15: Warning (avoid_default_addr_size): /fragment@1/__overlay__/emc2301@2f: Relying on default #size-cells value
emc2301.dtbo: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avoid_default_addr_size'
emc2301.dtbo: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'

We can make those warnings go away with this patch (I think I got the addressing right, but admittedly I have very little idea of what I'm doing):

diff --git a/overlays/cm4io-fan-overlay.dts b/overlays/cm4io-fan-overlay.dts
index 64856b1..bf053d2 100644
--- a/overlays/cm4io-fan-overlay.dts
+++ b/overlays/cm4io-fan-overlay.dts
@@ -18,12 +18,14 @@
     fragment@1 {
         target = <&i2c_csi_dsi>;
         __overlay__ {
+            #address-cells = <0x01>;
+            #size-cells = <0x00>;
             fanctrl: emc2301@2f {
                 reg = <0x2f>;
                 compatible = "microchip,emc2301";
                 #cooling-cells = <0x02>;

-                fan0: fan@0 {
+                fan0: fan {
                     min-rpm = /bits/ 16 <3500>;
                     max-rpm = /bits/ 16 <5500>;
                 };

That doesn't fix things though, as the build still outputs cp: cannot stat '/var/lib/dkms/cm4io-fan/0.1.1/build/overlays/cm4io-fan.dtbo': No such file or directory. The overlay folder doesn't even exist, and I'm not really sure how to debug the DKMS build system to figure out why it seems as though the dtc compile fails, but the build happily carries on.

@sdwilsh
Copy link
Contributor

sdwilsh commented Nov 25, 2021

#11 gets things into a better place for 21.10, which is the suggested version to install (currently) for CM4 support of Ubuntu Server.

@neggles neggles added enhancement New feature or request help wanted Extra attention is needed labels Jan 11, 2022
@neggles
Copy link
Owner

neggles commented Jan 11, 2022

There are a lot of changes between 5.4 and 5.10-and-up kernels that made implementing this driver a lot simpler and easier, and I don't have the necessary knowhow to backport this to 5.4, unfortunately.

5.4 support for the CM4 is rather lacking in general, to be honest. I'd recommend upgrading to 21.10 as @sdwilsh has suggested. I've not used Ubuntu on a Pi at all myself - I stick to more lightweight OSes - but if Ubuntu on the Pi offers HWE kernels like it does on x86_64, you should be able to bring yourself up to 5.11 that way (assuming you don't need to stay on 5.4 for some reason or another).

The dtoverlay issue is going to come down to the older device tree bindings (and possibly older base device tree) in the older Ubuntu build. As for why dtc can fail but the dkms build still succeeds, that's a very good question because it definitely shouldn't... will investigate when I have time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants