Potential fix for #3682, declaration of `eeprom` moved to main chunk.
This commit is contained in:
ff66theone 2025-04-27 21:16:23 +02:00 committed by GitHub
parent a181c38991
commit d8c9015763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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] [<bios.lua>] [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")