Skip to content

Commit 02be0fa

Browse files
committed
Ver1.1
1 parent 1d0a787 commit 02be0fa

File tree

7 files changed

+121
-108
lines changed

7 files changed

+121
-108
lines changed

.gitignore

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
*.DS_Store
2-
*.o
3-
repos.json
4-
settings.json
5-
build/*
6-
sdroot
7-
build_*
8-
*.dol
9-
*.3dsx
10-
*.rpx
11-
*.nro
12-
*.elf
13-
*.nacp
1+
*.DS_Store
2+
*.o
3+
repos.json
4+
settings.json
5+
build/*
6+
sdroot
7+
build_*
8+
*.dol
9+
*.3dsx
10+
*.rpx
11+
*.nro
12+
*.elf
13+
*.nacp
1414
.vscode

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ include $(DEVKITPRO)/libnx/switch_rules
4040

4141
APP_TITLE := AA-Reboot
4242
APP_AUTHOR := ThatFinn
43-
APP_VERSION := 1.0
43+
APP_VERSION := 1.1
4444
ICON := source/Icon.jpg
4545
TARGET := $(notdir $(CURDIR))
4646
BUILD := build

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# AA-Reboot
2-
A switch homebrew to reboot into hekate
3-
4-
Make sure you have a hekate.bin file at the root of your sd card!
1+
# AA-Reboot
2+
A switch homebrew to reboot into hekate
3+
4+
It will boot the /bootloader/update.bin payload to boot into hekate.
5+
Make sure hekate is installed on your switch, otherwise it will crash or show a black screen!
6+
7+
If you want a different payload, place a payload named "hekate.bin" on the root of your sd card (OPTIONAL)
8+
9+
PLEASE REPOT ANY ISSUES!

application.lst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
-CSn
2-
/home/Home/Music/application/application.elf
1+
-CSn
2+
/home/Home/Music/application/application.elf

banner.jpg

14.3 KB
Loading

icon.jpg

14.8 KB
Loading

source/main.c

Lines changed: 96 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,96 @@
1-
#include <string.h>
2-
#include <stdio.h>
3-
#include <stdbool.h>
4-
5-
#include <switch.h>
6-
7-
#define IRAM_PAYLOAD_MAX_SIZE 0x2F000
8-
#define IRAM_PAYLOAD_BASE 0x40010000
9-
10-
static alignas(0x1000) u8 g_reboot_payload[IRAM_PAYLOAD_MAX_SIZE];
11-
static alignas(0x1000) u8 g_ff_page[0x1000];
12-
static alignas(0x1000) u8 g_work_page[0x1000];
13-
14-
void do_iram_dram_copy(void *buf, uintptr_t iram_addr, size_t size, int option) {
15-
memcpy(g_work_page, buf, size);
16-
17-
SecmonArgs args = {0};
18-
args.X[0] = 0xF0000201; /* smcAmsIramCopy */
19-
args.X[1] = (uintptr_t)g_work_page; /* DRAM Address */
20-
args.X[2] = iram_addr; /* IRAM Address */
21-
args.X[3] = size; /* Copy size */
22-
args.X[4] = option; /* 0 = Read, 1 = Write */
23-
svcCallSecureMonitor(&args);
24-
25-
memcpy(buf, g_work_page, size);
26-
}
27-
28-
void copy_to_iram(uintptr_t iram_addr, void *buf, size_t size) {
29-
do_iram_dram_copy(buf, iram_addr, size, 1);
30-
}
31-
32-
void copy_from_iram(void *buf, uintptr_t iram_addr, size_t size) {
33-
do_iram_dram_copy(buf, iram_addr, size, 0);
34-
}
35-
36-
static void clear_iram(void) {
37-
memset(g_ff_page, 0xFF, sizeof(g_ff_page));
38-
for (size_t i = 0; i < IRAM_PAYLOAD_MAX_SIZE; i += sizeof(g_ff_page)) {
39-
copy_to_iram(IRAM_PAYLOAD_BASE + i, g_ff_page, sizeof(g_ff_page));
40-
}
41-
}
42-
43-
static void reboot_to_payload(void) {
44-
clear_iram();
45-
46-
for (size_t i = 0; i < IRAM_PAYLOAD_MAX_SIZE; i += 0x1000) {
47-
copy_to_iram(IRAM_PAYLOAD_BASE + i, &g_reboot_payload[i], 0x1000);
48-
}
49-
50-
splSetConfig((SplConfigItem)65001, 2);
51-
}
52-
53-
int main(int argc, char **argv)
54-
{
55-
56-
bool can_reboot = true;
57-
Result rc = splInitialize();
58-
if (R_FAILED(rc)) {
59-
consoleInit(NULL);
60-
printf("Failed to initialize spl: 0x%x\n", rc);
61-
can_reboot = false;
62-
} else {
63-
FILE *f = fopen("sdmc:/hekate.bin", "rb");
64-
if (f == NULL) {
65-
66-
consoleInit(NULL);
67-
printf("Failed to open hekate.bin!\n");
68-
can_reboot = false;
69-
} else {
70-
fread(g_reboot_payload, 1, sizeof(g_reboot_payload), f);
71-
fclose(f);
72-
}
73-
}
74-
// Main loop
75-
while(appletMainLoop())
76-
{if (can_reboot) {
77-
reboot_to_payload();
78-
}
79-
}
80-
81-
if (can_reboot) {
82-
splExit();
83-
}
84-
85-
consoleExit(NULL);
86-
return 0;
87-
}
88-
1+
#include <string.h>
2+
#include <stdio.h>
3+
#include <stdbool.h>
4+
5+
#include <switch.h>
6+
7+
#define IRAM_PAYLOAD_MAX_SIZE 0x2F000
8+
#define IRAM_PAYLOAD_BASE 0x40010000
9+
10+
static alignas(0x1000) u8 g_reboot_payload[IRAM_PAYLOAD_MAX_SIZE];
11+
static alignas(0x1000) u8 g_ff_page[0x1000];
12+
static alignas(0x1000) u8 g_work_page[0x1000];
13+
14+
void do_iram_dram_copy(void *buf, uintptr_t iram_addr, size_t size, int option) {
15+
memcpy(g_work_page, buf, size);
16+
17+
SecmonArgs args = {0};
18+
args.X[0] = 0xF0000201; /* smcAmsIramCopy */
19+
args.X[1] = (uintptr_t)g_work_page; /* DRAM Address */
20+
args.X[2] = iram_addr; /* IRAM Address */
21+
args.X[3] = size; /* Copy size */
22+
args.X[4] = option; /* 0 = Read, 1 = Write */
23+
svcCallSecureMonitor(&args);
24+
25+
memcpy(buf, g_work_page, size);
26+
}
27+
28+
void copy_to_iram(uintptr_t iram_addr, void *buf, size_t size) {
29+
do_iram_dram_copy(buf, iram_addr, size, 1);
30+
}
31+
32+
void copy_from_iram(void *buf, uintptr_t iram_addr, size_t size) {
33+
do_iram_dram_copy(buf, iram_addr, size, 0);
34+
}
35+
36+
static void clear_iram(void) {
37+
memset(g_ff_page, 0xFF, sizeof(g_ff_page));
38+
for (size_t i = 0; i < IRAM_PAYLOAD_MAX_SIZE; i += sizeof(g_ff_page)) {
39+
copy_to_iram(IRAM_PAYLOAD_BASE + i, g_ff_page, sizeof(g_ff_page));
40+
}
41+
}
42+
43+
static void reboot_to_payload(void) {
44+
clear_iram();
45+
46+
for (size_t i = 0; i < IRAM_PAYLOAD_MAX_SIZE; i += 0x1000) {
47+
copy_to_iram(IRAM_PAYLOAD_BASE + i, &g_reboot_payload[i], 0x1000);
48+
}
49+
50+
splSetConfig((SplConfigItem)65001, 2);
51+
}
52+
53+
int main(int argc, char **argv)
54+
{
55+
56+
bool can_reboot = true;
57+
Result rc = splInitialize();
58+
if (R_FAILED(rc)) {
59+
consoleInit(NULL);
60+
printf("Failed to initialize spl: 0x%x\n", rc);
61+
can_reboot = false;
62+
} else {
63+
FILE *f = fopen("sdmc:/hekate.bin", "rb");
64+
if (f == NULL) {
65+
consoleInit(NULL);
66+
FILE *c = fopen("sdmc:/bootloader/update.bin", "rb");
67+
if (c == NULL) {
68+
69+
consoleInit(NULL);
70+
printf("Failed to open update.bin!\n");
71+
can_reboot = false;
72+
} else {
73+
fread(g_reboot_payload, 1, sizeof(g_reboot_payload), c);
74+
fclose(c);
75+
}
76+
77+
} else {
78+
fread(g_reboot_payload, 1, sizeof(g_reboot_payload), f);
79+
fclose(f);
80+
}
81+
}
82+
// Main loop
83+
while(appletMainLoop())
84+
{if (can_reboot) {
85+
reboot_to_payload();
86+
}
87+
}
88+
89+
if (can_reboot) {
90+
splExit();
91+
}
92+
93+
consoleExit(NULL);
94+
return 0;
95+
}
96+

0 commit comments

Comments
 (0)