commit 9630a08649249598c1d172f15bff56ee49fbf0bd
parent 3d7c017623a8de95a13c383a990e4d35e0633e18
Author: Daniel Barlow <dan@telent.net>
Date: Fri, 18 Sep 2026 18:12:12 +0100
rewrite boot.lua to work on turris omnia
does it work on other devices as well? don't know. hope so
Diffstat:
| M | boot.lua | | | 81 | ++++++++++++++++++++++++------------------------------------------------------- |
1 file changed, 24 insertions(+), 57 deletions(-)
diff --git a/boot.lua b/boot.lua
@@ -1,20 +1,29 @@
--- different devices have different u-boot prompts. this cavorting is
--- so we can (fairly) reliably tell when u-boot is ready to
--- accept more input, without depending on the prompt
-
-write("setenv ready REA; setenv ready ${ready}DY\r") msleep(100)
function send_command(s, timeout)
- write(s .. "; echo ${ready}\r\n")
- local ok, matched = expect("READY|BusyBox", timeout)
- if not ok then
- error("timeout after sending ".. s)
- end
- print("got " .. matched)
- if matched:match("BusyBox") then
- return false
- end
- return true
+-- print("sending " .. string.gsub(s, "([^%g])", function(s) return string.format("{%02x}", string.byte(s)) end) .. "\r\n")
+ local s = s .. "\r"
+ while write(s) < #s do
+ print("partioal write")
+ s = string.sub(#s + 1)
+ end
+
+ local l, matched
+ local total=0
+ local count = 0
+
+ repeat
+ l, matched = read(1,1000)
+ if matched and matched:match("BusyBox") then
+ return false
+ end
+ total = total + l
+ if l == 0 then
+ -- print(string.format("reached idle after %d bytes for for %10q\r\n", total, s))
+ return true
+ end
+ until false
+
+ return true
end
function send_script(f)
@@ -29,45 +38,3 @@ send_script(f)
f:close()
--- # This is for use with minicom, but needs you to configure it to
--- # use expect as its "Script program" instead of runscript. Try
--- # Ctrl+A O -> Filenames and paths -> D
-
--- fconfigure stderr -buffering none
--- fconfigure stdout -buffering none
-
--- proc waitprompt { } {
--- expect {
--- "BusyBox" { puts stderr "DONE\r"; exit 0 }
--- "READY" { puts stderr ";;; READY\r"; }
--- timeout { puts stderr ";;; timed out waiting after $line\r" }
--- }
--- }
-
--- proc sendline { line } {
--- send "$line; echo \$ready \r"
--- sleep 0.1
--- }
-
--- log_user 0
--- log_file -a -open stderr
-
--- set f [open "result/boot.scr"]
-
--- send "setenv ready REA\r"
--- sleep 0.1
--- send "setenv ready \${ready}DY\r"
--- sleep 0.1
-
--- set timeout 300
--- expect_before timeout abort
--- while {[gets $f line] >= 0} {
--- puts stderr ";;; next line $line\r"
--- puts stderr ";;; waiting for prompt\r"
--- puts stderr ";;; sending\r"
--- sendline $line
--- waitprompt
--- }
-
--- puts stderr "done\r\n"
--- close $f