Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b114c5b

Browse files
committedDec 14, 2024··
more elaborate lua test
1 parent 0d7b03c commit b114c5b

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed
 

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ builds/x_finalize_helper.firm: builds/finalize.romfs
1717
clean:
1818
@rm -rf builds
1919
@$(MAKE) -C GodMode9 clean
20-
@rm GodMode9/data/autorun.gm9
20+
@rm GodMode9/data/autorun.lua

‎finalize_helper.lua

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,69 @@
1-
ui.echo("Testing!\n \nThis is a test.\n \nI will now try to verify finalize.romfs.")
1+
ui.show_text("NEW SUPER FINALIZE SCRIPT XL & KNUCKLES")
2+
ui.echo("Testing!\n \nThis is a test.")
23

4+
print("Checking embedded backup...")
5+
local embedded = sys.check_embedded_backup()
6+
if embedded == false then
7+
ui.echo("The embedded backup is required\nto run this script.")
8+
sys.reboot()
9+
elseif embedded == nil then
10+
ui.echo("Unusual situation alert!\n \nThe embedded backup doesn't exist,\n \nand was not auto-created...?")
11+
sys.reboot()
12+
end
13+
14+
print("Checking Raw RTC...")
15+
local rtc_set = false
16+
while not rtc_set do
17+
rtc_set = sys.check_raw_rtc()
18+
if not rtc_set then
19+
local retry = ui.ask("If the Raw RTC is not set,\nthe date in GodMode9 will be incorrect.\n \nRetry?")
20+
if not retry then
21+
sys.reboot()
22+
end
23+
end
24+
end
25+
26+
-- maybe later when we build GM9 without the stock permission prompts
27+
-- we can remove this warning, but for now, let's pre-allow ourselves
28+
-- (makes it easier too in case of finalize.romfs being misplaced in "Nintendo 3DS"
29+
30+
ui.echo("This script needs permission\nto access your SD card software\nto install some stuff.")
31+
local allowed = fs.allow("0:/Nintendo 3DS")
32+
if not allowed then
33+
ui.echo("I was not given permission\nso I guess I'll go away...")
34+
sys.power_off()
35+
end
36+
37+
-- these are not used for anything yet
38+
-- but you could use these with fs.find
39+
local paths = {
40+
"0:/finalize (*).romfs",
41+
"0:/3ds/finalize (*).romfs",
42+
"0:/luma/payloads/finalize (*).romfs",
43+
"0:/luma/finalize (*).romfs",
44+
"0:/DCIM/finalize (*).romfs",
45+
"0:/Nintendo 3DS/finalize (*).romfs",
46+
"0:/finalize.romfs",
47+
"0:/3ds/finalize.romfs",
48+
"0:/luma/payloads/finalize.romfs",
49+
"0:/luma/finalize.romfs",
50+
"0:/DCIM/finalize.romfs",
51+
"0:/Nintendo 3DS/finalize.romfs"
52+
}
53+
54+
print("Getting expected hash...")
55+
-- the use of CURRDIR here lets us run the script directly as long as the txt is next to it
356
local success, hash_expected = pcall(fs.read_file, CURRDIR.."/finalize-romfs-hash.txt", 0, 64)
457
if not success then
558
ui.echo("Failed to read hash txt?\n"..hash_expected)
659
sys.power_off()
760
end
861

962
print("Expected:", hash_expected)
63+
-- this could search several paths for finalize.romfs, but for a test, this path is hardcoded
1064
local success, hash_got = pcall(fs.hash_file, "0:/finalize.romfs", 0, 0)
1165
if not success then
12-
ui.echo("Failed to hash finalize.romfs\n"..hash_got)
66+
ui.echo("Failed to hash finalize.romfs\n"..hash_got)
1367
sys.power_off()
1468
end
1569

@@ -22,3 +76,11 @@ if hash_got == hash_expected then
2276
else
2377
ui.echo("Failure...")
2478
end
79+
80+
local sel = ui.ask_selection("This is where the test ends.\n \nSelect what to do now.\nOr press B to power off.", {"Reboot", "Power off"})
81+
if sel == 1 then
82+
sys.reboot()
83+
elseif sel == 2 then
84+
sys.power_off()
85+
end
86+
sys.power_off()

0 commit comments

Comments
 (0)
Please sign in to comment.