From d8c9015763af8a7e270fb362435d725fbbb09aee Mon Sep 17 00:00:00 2001 From: ff66theone <142222230+ff66theone@users.noreply.github.com> Date: Sun, 27 Apr 2025 21:16:23 +0200 Subject: [PATCH] Fix #3682 Potential fix for #3682, declaration of `eeprom` moved to main chunk. --- .../assets/opencomputers/loot/openos/bin/flash.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/bin/flash.lua b/src/main/resources/assets/opencomputers/loot/openos/bin/flash.lua index f8ecf4762..e4116dd11 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/bin/flash.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/bin/flash.lua @@ -1,9 +1,15 @@ local component = require("component") local shell = require("shell") local fs = require("filesystem") +local eeprom = component.eeprom local args, options = shell.parse(...) +-- No funtion available to check if the EEPROM is read-only +if not eeprom.setLabel(eeprom.getLabel()) then + io.write("WARNING : read-only EEPROM, BIOS can't be flashed to it.\n\n") +end + if #args < 1 and not options.l then io.write("Usage: flash [-qlr] [] [label]\n") io.write(" q: quiet mode, don't ask questions.\n") @@ -13,12 +19,10 @@ if #args < 1 and not options.l then end local function printRom() - local eeprom = component.eeprom io.write(eeprom.get()) end local function readRom() - local eeprom = component.eeprom local fileName = shell.resolve(args[1]) if not options.q then if fs.exists(fileName) then @@ -53,8 +57,6 @@ local function writeRom() io.write("Beginning to flash EEPROM.\n") end - local eeprom = component.eeprom - if not options.q then io.write("Flashing EEPROM " .. eeprom.address .. ".\n") io.write("Please do NOT power down or restart your computer during this operation!\n")