How to make powerd works in FREEBSD 12.1 STABLE over RPI-B

Miguel

New Member


Messages: 11

Greetings to the whole community in this my first post!
I have used powerd as a daemon since version 10.2 on my RPI-B but when upgrading to FREEBSD 12 I can't get it to work.
If i run
Bash:
powerd
powerd: no cpufreq (4) support - aborting: No such file or directory
it seems that this feature is not enabled by default
I also can't find any CPU when running
Bash:
dmesg | grep cpu
What do I need to add to activate this service?
 

trev

Aspiring Daemon

Reaction score: 177
Messages: 818

If you haven't compiled the kernel with cpufreq support, you can simply load the kernel module with kldload cpufreq and/or add it to your /boot/loader.conf.local.

As for the missing CPU, try grep CPU /var/run/dmesg.boot.
 
OP
OP
M

Miguel

New Member


Messages: 11

Thanks for your reply.
My custom kernel does not have cpufreq support, I have followed the suggested steps but nothing happens.
If I run
Bash:
kldload cpufreq
kldload: can't load cpufreq: No such file or directory
It seems that the module does not exist
 
OP
OP
M

Miguel

New Member


Messages: 11

Bash:
uname -a
FreeBSD prototipo.local 12.1-STABLE FreeBSD 12.1-STABLE r354027 RPI-B  arm
 

acheron

Aspiring Daemon

Reaction score: 226
Messages: 600

I just gave a quick look, this is the compat string to find cpufreq on the rpi:
Code:
static struct ofw_compat_data compat_data[] = {
    { "broadcom,bcm2835-vc",    1 },
    { "broadcom,bcm2708-vc",    1 },
    { "brcm,bcm2709",    1 },
    { "brcm,bcm2835",    1 },
    { "brcm,bcm2836",    1 },
    { "brcm,bcm2837",    1 },
    { NULL, 0 }
};

This is the interesting part of the fdt on 11.2 (obtained with ofwdump -ap):
Code:
snip   
    Node 0x1e28: vchiq
      compatible:
        62 72 6f 61 64 63 6f 6d 2c 62 63 6d 32 38 33 35 2d 76 63 68
        69 71 00
        'broadcom,bcm2835-vchiq'
snip
and the one in 12.0:
Code:
snip   
    Node 0x3890: vchiq
      compatible:
        62 72 63 6d 2c 62 63 6d 32 38 33 35 2d 76 63 68 69 71 00
        'brcm,bcm2835-vchiq'
snip
Adding brcm,bcm2835-vchiq to the compat list should solve this issue.
 

acheron

Aspiring Daemon

Reaction score: 226
Messages: 600

It doesn't work. I just noticed that there is no cpu node with newer fdt...
on 11.2:
Code:
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
bcm2835_cpufreq0: <CPU Frequency Control> on cpu0
nothing on 12.0
 

acheron

Aspiring Daemon

Reaction score: 226
Messages: 600

Warning, I don't know what I'm doing.
I was able to "restore" the cpu node with an overlay, and the cpufreq device is there:

Code:
uname -a
FreeBSD rpi-b 13.0-CURRENT FreeBSD 13.0-CURRENT #0 r353798

cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
bcm2835_cpufreq0: <CPU Frequency Control> on cpu0
This is the overlay, I called it cpu.dtso:
Code:
/dts-v1/;
/plugin/;

/ {
        compatible = "brcm,bcm2835";
};


&{/} {
        cpus {
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                cpu@0 {
                        compatible = "arm,1176jzf-s";
                        device_type = "cpu";
                        reg = <0x0>;
                        clock-frequency = <0x29b92700>;
                };
        };
}
Compile it:
dtc -I dts -O dtb -b0 -@ -o cpu.dtbo cpu.dtso

Copy it to the sdcard in /boot/dtb/overlays
Add this to /boot/loader.conf:
Code:
fdt_overlays="cpu.dtbo"
And reboot.
 
OP
OP
M

Miguel

New Member


Messages: 11

I have followed all the steps.
dmesg now display the missing bcm2835_cpufreq
Bash:
dmesg > dmesg.txt
(attached)
and there is already frequency control for the CPU.
Bash:
root@prototipo:/home/pi # powerd -v
powerd: unable to determine AC line status
load   6%, current freq 1000 MHz ( 0), wanted freq  968 MHz
load   7%, current freq 1000 MHz ( 0), wanted freq  937 MHz
load  10%, current freq 1000 MHz ( 0), wanted freq  907 MHz
load   0%, current freq 1000 MHz ( 0), wanted freq  878 MHz
changing clock speed from 1000 MHz to 900 MHz
load   4%, current freq  900 MHz ( 1), wanted freq  850 MHz
load   0%, current freq  900 MHz ( 1), wanted freq  823 MHz
load   0%, current freq  900 MHz ( 1), wanted freq  797 MHz
changing clock speed from 900 MHz to 800 MHz
load   4%, current freq  800 MHz ( 2), wanted freq  772 MHz
load   0%, current freq  800 MHz ( 2), wanted freq  747 MHz
^C
This issue is solved :)
thank you very much
 

Attachments

OP
OP
M

Miguel

New Member


Messages: 11

that's what I was thinking
may be wrong this value?
Code:
clock-frequency = <0x29b92700>
29b92700(hex) is 700.000.000 decimal
 

acheron

Aspiring Daemon

Reaction score: 226
Messages: 600

Not sure. I decompiled the dts from the 11.2 iso and copy pasted the result in the dtso...
 

acheron

Aspiring Daemon

Reaction score: 226
Messages: 600

Can you post the result of sysctl dev.cpu.0.freq_levels. This is what I have:
dev.cpu.0.freq_levels: 700/-1 600/-1 500/-1 400/-1 300/-1
 
OP
OP
M

Miguel

New Member


Messages: 11

Here is...
Bash:
sysctl dev.cpu.0.freq_levels
dev.cpu.0.freq_levels: 1000/-1 900/-1 800/-1 700/-1 600/-1 500/-1 400/-1 300/-1
This is a Raspberry Pi Zero I suppose they must be the same values as for a RPI-B
 

acheron

Aspiring Daemon

Reaction score: 226
Messages: 600

clock-frequency doesn't seem to be used in sys/arm/broadcom/bcm2835. I think you can delete the line and it'll still work.
 
Top