Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(...)

Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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")
Expand Down