mirror of
https://github.com/raspberrypi/rpi-eeprom.git
synced 2026-01-20 21:13:36 +08:00
rpi-eeprom-config/update: Exit cleanly when not run on rpi4
Some users might forcibly install this on a board that isn't an rpi4. Exit early, and explain why the program can't be run. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
This commit is contained in:
@@ -32,6 +32,15 @@ FILE_HDR_LEN = 20
|
|||||||
FILENAME_LEN = 12
|
FILENAME_LEN = 12
|
||||||
TEMP_DIR = None
|
TEMP_DIR = None
|
||||||
|
|
||||||
|
def rpi4():
|
||||||
|
compatible_path = "/sys/firmware/devicetree/base/compatible"
|
||||||
|
if os.path.exists(compatible_path):
|
||||||
|
with open(compatible_path, "rb") as f:
|
||||||
|
compatible = f.read().decode('utf-8')
|
||||||
|
if "bcm2711" in compatible:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def exit_handler():
|
def exit_handler():
|
||||||
"""
|
"""
|
||||||
Delete any temporary files.
|
Delete any temporary files.
|
||||||
@@ -327,10 +336,12 @@ images.
|
|||||||
parser.add_argument('eeprom', nargs='?', help='Name of EEPROM file to use as input')
|
parser.add_argument('eeprom', nargs='?', help='Name of EEPROM file to use as input')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
if (args.edit or args.apply is not None) and os.getuid() != 0:
|
if (args.edit or args.apply is not None) and os.getuid() != 0:
|
||||||
exit_error("--edit/--apply must be run as root")
|
exit_error("--edit/--apply must be run as root")
|
||||||
|
|
||||||
|
if (args.edit or args.apply is not None) and not rpi4():
|
||||||
|
exit_error("--edit/--apply must run on a Raspberry Pi 4")
|
||||||
|
|
||||||
if args.edit:
|
if args.edit:
|
||||||
edit_config(args.eeprom)
|
edit_config(args.eeprom)
|
||||||
elif args.apply is not None:
|
elif args.apply is not None:
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ checkDependencies() {
|
|||||||
echo "BCM2711 detected"
|
echo "BCM2711 detected"
|
||||||
else
|
else
|
||||||
# Not a BCM2711, no EEPROMs to update.
|
# Not a BCM2711, no EEPROMs to update.
|
||||||
|
echo "This tool only works with a Raspberry Pi 4"
|
||||||
exit ${EXIT_SUCCESS}
|
exit ${EXIT_SUCCESS}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user