Discussion

AXP209 temperature disappeared in mainline kernel

11 3896
Fab  
Edited by Fab at Thu May 14, 2015 07:03

I just upgraded to mainline kernel 4.1 using the mripard repo, sunxi-next branch. I ported the old .config using "make older config" and used the bananapi dts file in the repo.
Everything works fine except that the CONFIG_AXP_HWMON flag is disappeared, and I no longer have a directory
/sys/bus/i2c/devices/0-0034/
where I used to read the temperature.

Anybody know how to configure the mainline kernel (or to modify the dts file) to get that back?

Thanks a lot
The temperature sensor of the PMU (AXP209) cannot be read out in the mainline kernel without additional patches. Correntin Labbe has a patch for that on his site: http://sunxi.montjoie.ovh/ (scroll to the bottom)
I haven't tried this patch though.

However, there is another temperature sensor on the Bananapi, or to be more precise, on the A20 SoC (embedded in the touchscreen controller), that you can easily read out:
  1. cat /sys/devices/virtual/thermal/thermal_zone0/temp
Copy the Code
This is, btw, also the temperature that is being used by the cpufreq driver to achieve thermal throttling (prevent overheating the cpu by limiting the frequency if it gets too hot).

Fab  
Thanks silent creek. I have no thermal directory under /sys/devices/virtual.

I also miss the frequency directory under
/sys/devices/system/cpu/cpu0

Do you know which flags I need to enable in the kernel?

Thanks

I once had the problem that the thermal directory was missing - that was beause I tried to reuse a config from Kernel 3.19 with make silentoldconfig. In that case the THERMAL options in the configuration were missing. Try to look for CONFIG_THERMAL=y and CONFIG_CPU_THERMAL=y.

In case you use an old configuration, you could start by using the defconfig targets sunxi_defconfig or multi_v7_defconfig (the latter includes more drivers like USB storabe and Simple Framebuffer output) to make sure you get all the latest modules and drivers available for A20 based devices.

If that still doesn't helpt, I'd try the official mainline or stable kernel instead of the sunxi-next branch which might miss stuff that will be merged through other channels. I can at least confirm that reading the temperature works for Kernel 4.0.x (running 4.0.3 at the moment). There is of course the chance, that by changes in the device tree files, the naming of the devices or nides may differ with a newer version, but it should still be there, just at a different location in that case.

Now, about the missing CPU properties... that I don't know how that can be. Here I'd really try the stable branch first.

If neccessary, I can provide you my configuration for version 4.0 for testing.

Fab  
Edited by Fab at Fri May 15, 2015 07:27

Thanks a lot! Indeed that flag is not set, I will try that.

Which repo/branch do you recommend?

If you could please post your .config and dts file that would be great, I might learn a lot comparing with mine.

The reason I am looking at temperature and frequency is that during boot there are couple of error messages about missing cpu frequency property. Then, the cpu becomes very hot very quickly, even if idle. I suspect it is running too fast, but I have no way to verify.

Forgot to mention, it is a Lamobo R1, not a bananapi.

I'm using the official kernel from www.kernel.org
I'm on the stable branch (4.0), but if you like the bleeding edge version, you can also try the 4.1 release candidates - I suppose they are stable enough, too.

I'm also using the dts that comes with each version of the official kernel (found in arch/arm/boot) and I would higly recommend to stick to that. If you use an older dts or dtb file with a newer kernel, this will likely break stuff when a newer sunxi driver depends on an updated dts. Of course, if you have to make adjustments to your dts, i.e. for a custom GPIO configuration, you can do that, but you should make your changes on top of the dts file that comes with that kernel version.

I will look up my config tonight.


Fab  
Thanks
Enabled those two flags and now the file ../thermal_zone0/temp is there, but if I try to print it with "cat", I get an error.
The "mode" file in the same directory contains "disabled".

Edited by silentcreek at Fri May 15, 2015 20:31

Ok, I checked my config and I guess you would have to add a few more THERMAL related options.

Here is my current configuration for Kernel 4.0.3:
http://pastebin.com/ihCPGmeG
If you search for all occurences of THERMAL, compare that to what you have enabled.

However, if you want to try to use this configuration on a newer version (4.1-rc3 or the sunxi-next branch), a better way would be to use the following defconfig file:
http://pastebin.com/r71pzF4Y
If you save it as my_custom_defconfig and place it in arch/arm/configs of your source tree, then you can run
  1. make my_custom_defconfig
Copy the Code
and it will generate a .config file non-interactively, including default values for features introduced in newer versions than 4.0.
(As opposed to make oldconfig that will ask you a lot of questions about new features...)

And just to be clear (even if that means repeating myself): Make sure that you use a dts file that comes with your kernel source (at least as a basis) to make sure the drivers work as expected.

P.S.: A few remarks on my configuration: I use this for simple server applications - no other devices than hard drives and flash drives (and sometimes a keyboard) attached. So don't expect all kinds of devices (like e.g. wifi adaptors or soundcards, etc.) to work out of the box with this. And even though iptables/netfilter (firewall) support is enabled, certain features to make the device act as a router are not enabled. Furthemore, I have the AppArmor security framework enabled by default. You might not need that and can disable this - even though it usually doesn't harm even if it is enabled as long as you don't have application profiles installed. Use it as a reference, or basis - but don't take it for granted that it would be suitable for all types of applications.

Fab  
Thanks a lot! Will try tonight.

Regarding your point on dtb, I am using the dtb as generated by the make with my kernel source. It is the bananapi dtb, as there is not one for Lamobo, but sunxi be site states it should be fine. The only thing perhaps I am doing wrong, I am not updating/recompiling the dtb file every time I change a flag in the config, as I do not imagine the dtb file would be affected by those flags. May be going forward I will recompile that too.

Fab  
All right. Done a big merge of your config and mine. Now everyhting works: temperature sensors, frequency readings and scaling. Thank you, you are a star!

Now, good practice would want that I investigate the flags one by one to check which is the one that made it work, but, considering it takes me 2 hours to recompile every time, I guess I might just be happy with this success and move on.

Thanks again, you saved me lot of time!

You have to log in before you can reply Login | Sign Up

Points Rules