Closed tinker2much closed 5 months ago
Huh. That's cool...better 4 times than 0? Thx for the example and log...I've replicated it.
Ah, yes, this is a shortcoming of the way arguments are parsed. Each argument (e.g., section
, dtoverlay
, dtparam
) can be used exactly once in a plugin invocation. If an argument is used more than once, the last value gets used for all of them. 😵
The workaround is to use multiple bootconfig plugins (blah blah obviously not valid commands 🤣)
sudo sdm blah blah blah \
--plugin bootconfig:"section=[pi4]" \
--plugin bootconfig:"dtoverlay=pwm-fan" \
--plugin bootconfig:"dtparam=fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75" \
--plugin bootconfig:"dtparam=fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128" \
--plugin bootconfig:"dtparam=fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192" \
--plugin bootconfig:"dtparam=fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255" \
blah blah blah
Plugin arguments are parsed by sdm by running through the list and assigning each found string to a variable with the name of the argument. In this case, the variable dtparam
is reassigned 4 times, with the final value being the value of the last one found.
Unfortunately, there's no easy way to fix this in sdm without likely creating collateral damage, but the above (somewhat ugly) workaround does the job.
which results in /boot/firmware/config.txt with:
[pi4]
dtoverlay=pwm-fan
dtparam=fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75
dtparam=fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128
dtparam=fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192
dtparam=fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255
The plugin documentation will be updated to explicitly explain this constraint.
The only way that I can see to enable these to be set in a single bootconfig invocation is to add an include
argument that would stuff the contents of the include
file into config.txt appropriately.
Your thoughts appreciated!
So, would the following work too, since "section" and "dtoverlay" are different? That would be a way to slightly shorten it?
sudo sdm blah blah blah \
--plugin bootconfig:"section=[pi4]|dtoverlay=pwm-fan" \
--plugin bootconfig:"dtparam=fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75" \
--plugin bootconfig:"dtparam=fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128" \
--plugin bootconfig:"dtparam=fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192" \
--plugin bootconfig:"dtparam=fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255" \
blah blah blah
I haven't dived into your parsing [ and won't ], so anything I suggest is likely to be annoying and certain to be ignorant. But why not?? ;-)
The following atomic style was where I started, then I realized I could compress things to the 4-line style above:
section=[pi4]
dtoverlay=pwm-fan
dtparam=fan_temp0=55000
dtparam=fan_temp0_hyst=5000
dtparam=fan_temp0_speed=75
dtparam=fan_temp1=62500
dtparam=fan_temp1_hyst=5000
dtparam=fan_temp1_speed=128
dtparam=fan_temp2=70000
dtparam=fan_temp2_hyst=5000
dtparam=fan_temp2_speed=192
dtparam=fan_temp3=77500
dtparam=fan_temp3_hyst=5000
dtparam=fan_temp3_speed=255
Since the pi is happy with me combining distinct variables under one dtparam, I assume that the pi would be happy to have me mash all of the dtparam variables into one line?
section=[pi4]
dtoverlay=pwm-fan
dtparam=cooling_fan=on,fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75,fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128,fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192,fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255
So, since there's only one section, and one dtoverlay, and one dtparam, would you accept:
sudo sdm blah blah blah \
--plugin bootconfig:"section=[pi4]|dtoverlay=pwm-fan|dtparam=cooling_fan=on,fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75,fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128,fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192,fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255" \
blah blah blah
It appears so:
#!/bin/bash
sudo sdm $1 \
--customize \
--apt-options none \
--plugin bootconfig:"section=[pi4]|dtoverlay=pwm-fan|dtparam=cooling_fan=on,fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75,fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128,fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192,fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255" \
exit
yields a config.txt with:
[pi4]
dtoverlay=pwm-fan
dtparam=cooling_fan=on,fan_temp0=55000,fan_temp0_hyst=5000,fan_temp0_speed=75,fan_temp1=62500,fan_temp1_hyst=5000,fan_temp1_speed=128,fan_temp2=70000,fan_temp2_hyst=5000,fan_temp2_speed=192,fan_temp3=77500,fan_temp3_hyst=5000,fan_temp3_speed=255
... but such a line doesn't seem to work on the pi. There's apparently a documented 98-character line length limit (anything more is ignored). In my case it seems the long line is rejected, perhaps it breaks at a syntactically incorrect point. In any case the fan just runs and doesn't get PWM'd to different speeds per temperature. So maybe multiple lines can't be avoided...
Testing now, will report what finally works.
Because I may use this block in multiple burns within the script, I made the lines into variables:
FANPARMS420="from=$MYFILES/pwm-fan.dtbo|to=/boot/firmware/overlays|chown=root:root|chmod=755"
FANPARMS421="section=[pi4]|dtoverlay=pwm-fan"
FANPARMS422="dtparam=fan_temp0=55000,fan_temp0_hyst=3000,fan_temp0_speed=75"
FANPARMS423="dtparam=fan_temp1=62500,fan_temp1_hyst=3000,fan_temp1_speed=128"
FANPARMS424="dtparam=fan_temp2=70000,fan_temp2_hyst=3000,fan_temp2_speed=192"
FANPARMS425="dtparam=fan_temp3=77500,fan_temp3_hyst=3000,fan_temp3_speed=255"
sudo sdm \
...
--burn /dev/$DEVICE \
--expand-root \
--plugin copyfile:"$FANPARMS420" \
--plugin bootconfig:"$FANPARMS421" \
--plugin bootconfig:"$FANPARMS422" \
--plugin bootconfig:"$FANPARMS423" \
--plugin bootconfig:"$FANPARMS424" \
--plugin bootconfig:"$FANPARMS425" \
...
$IMGDIR/${MYIMAGE}32.img
RC=$?
sdm is happy and the pi is happy, so I'm happy
Nice! I'll add a line-length check to the bootconfig plugin to help avoid errors, especially since "extra" characters are just ignored by the system.
Or, to cut down on the number of lines in my script, I can do this?
--plugin copyfile:"$FANPARMS420" --plugin bootconfig:"$FANPARMS421" --plugin bootconfig:"$FANPARMS422" \
--plugin bootconfig:"$FANPARMS423" --plugin bootconfig:"$FANPARMS424" --plugin bootconfig:"$FANPARMS425" \
I would expect that to work.
Don't know if it's of interest to you or not, but you could also set up plugin @files, one per fan profile. For instance, here's fanprofile1.plugins:
bootconfig:dtparam=fan_temp0=55000,fan_temp0_hyst=3000,fan_temp0_speed=75
bootconfig:dtparam=fan_temp1=62500,fan_temp1_hyst=3000,fan_temp1_speed=128
bootconfig:dtparam=fan_temp2=70000,fan_temp2_hyst=3000,fan_temp2_speed=192
bootconfig:dtparam=fan_temp3=77500,fan_temp3_hyst=3000,fan_temp3_speed=255
and then use --plugin @fanprofile1.plugins
.
Keeps the command lines simpler at the expense of having more configuration files. I use plugin lists for my server configs:
apt-cacher-ng:tunnelenable=true
postfix:relayhost=mail.mydomain.com|mailname=mydomain.com|domain=mydomain.com|rootmail=myemail@somewhere.com
logwatch:config=/rpi/etc/logwatch|sendfrom=ps-logwatch<myname@outlook.com>|sendto=bls<myemail@somewhere.com>
ndm:localsrc=/l/work/ndm|config=/rpi/pisrv1/etc/dbndm.json
/l/work/mydomain/host-plugin:host=pisrv1
sdm 12.2 checks for config.txt lines too long. Closing this issue. Please re-open or start a new issue if required.
This sdm command:
results in an odd config.txt (with one line - the last one - being repeated 4 times, instead of four separate lines):
Here's the history: