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

Add Custom config.txt copy to boot loader during update and version check #389

Merged
merged 3 commits into from
Jun 10, 2016

Conversation

ziggimon
Copy link
Contributor

We noticed that our custom config.txt isn't being copied from the system image to the bootloader on updates.

This should allow for a string in the config.txt file to be matched and version checked. So if custom version on system image is higher than on the bootloader it will update it.

Thoughts are welcome.

@HiassofT
Copy link
Member

This looks really dangerous to me. If the user has modified config.txt (eg added codec licence keys) these changes will be silently dropped. Dont't do that!

At the very least you should check if config.txt was modified.. Replacing a stock config.txt with an updated version could be somewhat acceptable, but still I'm not sure if I'd want to have that happening on my systems.

What are your reasons for wanting to change config.txt?

@ziggimon
Copy link
Contributor Author

Our goal was to add primarily dtparam option and possibly clock tweaks. And I completely follow the reasoning of not overwriting they key or other custom settings. I'll look at reworking this to not overwrite the entire file.

@ziggimon
Copy link
Contributor Author

But primarily we noticed that when we added an updated config.txt to our release it wasn't replacing the existing config.txt on the device, so we wanted to add our own config.txt that gets installed via: https://github.com/libreelec/LibreELEC.tv/blob/master/packages/tools/bcm2835-bootloader/package.mk#L53

@HiassofT
Copy link
Member

dtparam/dtoverlay should now also be possible via command-line commands - but I haven't tested that yet myself.

Other than that doing config.txt changes in a kodi addon might be the better solution. Then you could give users more choice about which settings to apply etc.

@ziggimon
Copy link
Contributor Author

We are not using kodi.. See where the PR originates. For our build dtparam is default on to allow for audio on the RPi, so for us we need it default on. No need for the user to fiddle with dtparam settings.

@HiassofT
Copy link
Member

OK, now I noticed the "plexinc" - I have to add that I'm not familiar with it at all :-)

I'd still say doing changes during the update process is the wrong place, the user should have some control over that.

People might be using I2S soundcards on the RPi so silently adding dtparam=audio=on might not be the right choice. Clock tweaking can also be dangerous.

If you want to do post-update (distro-specific) stuff I think it might be best to move that code to a separate post-update-hook script - for example add something like this to the end of update.sh (just before the sync):

[ -f $SYSTEM_ROOT/usr/share/bootloader/post-update-hook.sh ] && sh $SYSTEM_ROOT/usr/share/bootloader/post-update-hook.sh

@ziggimon
Copy link
Contributor Author

That seems more sane. I think I'll have a ponder about how to do it right, though adding a post-update-hook.sh means we will have to add another tweak to add the script. We are really trying not to having downstream changes to the LE base tree in order to allow for other distro's.

Thanks for input.

@MilhouseVH
Copy link
Contributor

Overwriting an existing config.txt is not a good idea for the reasons stated, so this PR as it stands won't be accepted. However if you must modify config.txt then a hook script sounds a better idea - this could be distro-specific and as complicated as you like but leaves mainline LE pretty much unchanged.

@MilhouseVH
Copy link
Contributor

MilhouseVH commented May 24, 2016

You could also consider putting your Plex specific settings in a secondary config file using the directive include distroconfig.txt added to config.txt - see raspberrypi/firmware#414. With a suitable "Do not edit" warning in distroconfig.txt you could then overwrite this file relatively safely.

It would just need distroconfig.txt copied to the image (if it exists in $DISTRO/blah), and then added to update.sh where it would always be copied over to the device if it exists in the image.

@awiouy
Copy link
Collaborator

awiouy commented May 25, 2016

Hello,

I was playing around with the dtoverlay command line. It works fine, but its behaviour is peculiar, eg dtoverlay dtparam audio=on will load on top of previously loaded dtparam dtoverlays, and therefore will only change the effect of audio (to on) but not change the effect of other dtparams, eg LEDs

In summary, you can turn ALSA on/off on demand with the dtoverlay dtparam audio=on/off command, if you have the opportunity to run that command. If you intend to do that often, it may be worth considering removing earlier dtoverlay dtparam audio= overlays, see the dtoverlay -h command (needs extra logic).

Maybe this is worth a little shell which turns audio on, if aplay -l does not find devices. I could do that before tomorrow.

@ziggimon
Copy link
Contributor Author

ziggimon commented Jun 1, 2016

@MilhouseVH I actually like that idea about adding an included config. That would allow us to test out changes internally before shipping them and ensuring that we don't overwrite the keys users add to the config.txt. I think refactoring to do it that way may make more sense. I'll take a look at doing it that way.

@MilhouseVH
Copy link
Contributor

MilhouseVH commented Jun 1, 2016

I'll take a look at doing it that way.

Yes, I agree.

Some things to be aware of: Conditional Filters (see "CONDITIONAL FILTERS" section here, and also issues raspberrypi/firmware#320 and raspberrypi/firmware#593, in particular comment raspberrypi/firmware#320 (comment) relating to the behaviour of [all]).

For example, if the user adds the following to the beginning of config.txt:

[pi1]
arm_freq=1000
gpu_mem=128

[pi2]
arm_freq=1100
gpu_mem=320

[pi3]
arm_freq=1400
gpu_mem=320

then, if you have the following at the end of the config.txt

include distroconfig.txt

your distroconfig.txt file will only be included when the SD card is in a Pi3 - it won't be included for a Pi1 or Pi2.

In order that your include is always loaded, regardless of filter, then having the following at the end of config.txt should work:

[all]
include include distroconfig.txt

I'm also assuming the config loaded last overrides any other values - if you include your distroconfig.txt file at the beginning of config.txt then potentially any values you set could be overridden by the user within config.txt (which may or may not be desirable).

@ziggimon
Copy link
Contributor Author

ziggimon commented Jun 1, 2016

I love those conditionals, was not aware of those.. We just won in yatzee or something.. We have been looking at a way to do conditional frequencies for rpi2/3 as we have some gpu tweaks that help our UI be smoother. Thanks!

@ziggimon ziggimon force-pushed the update-fix-config-txt branch from 8ba9fca to 80b04b5 Compare June 3, 2016 09:41
@ziggimon
Copy link
Contributor Author

ziggimon commented Jun 3, 2016

So I changed it to use a distroconfig.txt file. Curious on feedback on this.

################################################################################

[all]
include distroconfig.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure about this one. I think you should be adding this to your own DISTRO specific config.txt. However, if the include causes no error if it doesn't exist, then maybe there's no harm (and means a distroconfig.txt could be added later, if required). Worst case, we add a "common" distroconfig.txt that is blank?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the logic in that, however if a user moved from upstream LE to a custom distribution then the overrides would require a full clean install. Thats why I pitched having it in the upstream config file. That way we could avoid shipping our own config.txt and only ship a distroconfig.txt file in the case we wanted to override the upstream version.

@ziggimon
Copy link
Contributor Author

Made some suggested changes. Input most welcome.


# Add distro config file.
if [ -f $SYSTEM_ROOT/usr/share/bootloader/distroconfig.txt ]; then
cp $SYSTEM_ROOT/usr/share/bootloader/distroconfig.txt $BOOT_ROOT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! :)

Can you make it cp -p like all the other copies in this file. Also, you need to rebase this file after #437.

@ziggimon ziggimon force-pushed the update-fix-config-txt branch from a22e27c to 4ba6949 Compare June 10, 2016 11:30
@ziggimon
Copy link
Contributor Author

Should be rebased now.

@MilhouseVH MilhouseVH merged commit b44cdc7 into LibreELEC:master Jun 10, 2016
@popcornmix
Copy link
Contributor

Not directly related to this PR, but I think the base config.txt needs updating:
decode_DTS / decode_DDP haven't been supported for years and should be removed
The overclock suggestions are Pi 1 specific and would underclock Pi2/Pi3 so should be removed/updated.
The overscan settings only affect the splash screen (using a console framebuffer) and have no effect on Kodi, so should probably be removed as more likely to cause confusion than help.

If you want something useful in there, then some commented out examples of overlays for common I2S sound cards and GPIO LIRC would be good. Details here.

@MilhouseVH
Copy link
Contributor

I'll take a look at it, thanks @popcornmix.

chewitt added a commit that referenced this pull request Aug 29, 2016
mkimage: add fogotten distroconfig.txt after #389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants