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 f8ecf4762a..867562b877 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/bin/flash.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/bin/flash.lua @@ -1,6 +1,7 @@ local component = require("component") local shell = require("shell") local fs = require("filesystem") +local eeprom = component.eeprom local args, options = shell.parse(...) @@ -13,12 +14,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 @@ -40,6 +39,11 @@ local function readRom() end local function writeRom() + -- No funtion available to check if the EEPROM is read-only + if not eeprom.setLabel(eeprom.getLabel()) then + io.write("WARNING : read-only EEPROM, the BIOS can't be flashed to it.\n\n") + end + local file = assert(io.open(args[1], "rb")) local bios = file:read("*a") file:close() @@ -50,11 +54,11 @@ local function writeRom() repeat local response = io.read() until response and response:lower():sub(1, 1) == "y" + -- Reset the EEPROM component in case it has been replaced. + eeprom = component.getPrimary("eeprom") 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")