Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5097

Raspberry Pi OS • Re: /boot/config.txt symlink changed to file

$
0
0
Now -

Code:

def FixBootFilename(filename):  if not os.path.islink(filename):    n = filename.rfind("/")    firmware = filename[:n] + "/firmware" + filename[n:]    if os.path.isfile(firmware):      filename = firmware  return filename
The biggest challenge was finding what code needed changing.
I may be wrong but that isn't going to work on RPiOS Legacy (Bullseye). It'll return "/boot/firmware/something" when it should return "/boot/something".

I'd probably do something like this (untested):

Code:

import os.pathif os.path.exists('/boot/firmware') and os.path.ismount('/boot/firmware'):    boot_partition = '/boot/firmware'else:    boot_partition = '/boot'with open(os.path.join(boot_partition, 'config.txt')) as f:    [...]
Still doesn't cover all possible cases but should work on both Bookworm and Legacy.

Statistics: Posted by thagrol — Tue Jan 30, 2024 5:02 pm



Viewing all articles
Browse latest Browse all 5097

Trending Articles