Code Monkey home page Code Monkey logo

Comments (10)

gitbls avatar gitbls commented on September 7, 2024

Huh. That's cool...better 4 times than 0? Thx for the example and log...I've replicated it.

from sdm.

gitbls avatar gitbls commented on September 7, 2024

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!

from sdm.

tinker2much avatar tinker2much commented on September 7, 2024

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

from sdm.

gitbls avatar gitbls commented on September 7, 2024

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

from sdm.

tinker2much avatar tinker2much commented on September 7, 2024

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

from sdm.

tinker2much avatar tinker2much commented on September 7, 2024

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

from sdm.

gitbls avatar gitbls commented on September 7, 2024

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.

from sdm.

tinker2much avatar tinker2much commented on September 7, 2024

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" \

from sdm.

gitbls avatar gitbls commented on September 7, 2024

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|[email protected]
logwatch:config=/rpi/etc/logwatch|sendfrom=ps-logwatch<[email protected]>|sendto=bls<[email protected]>
ndm:localsrc=/l/work/ndm|config=/rpi/pisrv1/etc/dbndm.json
/l/work/mydomain/host-plugin:host=pisrv1

from sdm.

gitbls avatar gitbls commented on September 7, 2024

sdm 12.2 checks for config.txt lines too long. Closing this issue. Please re-open or start a new issue if required.

from sdm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.