Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastboot for fusee: a workflow improvement #1209

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ sept/sept-secondary/KEYS.py
**/build_nintendo_nx_arm
**/build_nintendo_nx_x64
**/build_nintendo_nx_x86
extras
168 changes: 90 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,94 +39,86 @@ clean:
$(MAKE) -C fusee clean
rm -rf out

dist-no-debug: all
$(eval MAJORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MAJOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
MAJORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MAJOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3)
MINORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MINOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3))
$(eval MINORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MINOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| cut -d' ' -f3)
MICROVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MICRO\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3))
$(eval MICROVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MICRO\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3))
$(eval AMSVER = $(MAJORVER).$(MINORVER).$(MICROVER)-$(AMSREV))
rm -rf atmosphere-$(AMSVER)
rm -rf out
mkdir atmosphere-$(AMSVER)
mkdir atmosphere-$(AMSVER)/atmosphere
mkdir atmosphere-$(AMSVER)/sept
mkdir atmosphere-$(AMSVER)/switch
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/010000000000002B
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000034
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/010000000000003C
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000042
mkdir -p atmosphere-$(AMSVER)/atmosphere/fatal_errors
mkdir -p atmosphere-$(AMSVER)/atmosphere/config_templates
mkdir -p atmosphere-$(AMSVER)/atmosphere/config
cp fusee/fusee-primary/fusee-primary.bin atmosphere-$(AMSVER)/atmosphere/reboot_payload.bin
cp fusee/fusee-mtc/fusee-mtc.bin atmosphere-$(AMSVER)/atmosphere/fusee-mtc.bin
cp fusee/fusee-secondary/fusee-secondary-experimental.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
cp fusee/fusee-secondary/fusee-secondary-experimental.bin atmosphere-$(AMSVER)/sept/payload.bin
cp sept/sept-primary/sept-primary.bin atmosphere-$(AMSVER)/sept/sept-primary.bin
cp sept/sept-secondary/sept-secondary.bin atmosphere-$(AMSVER)/sept/sept-secondary.bin
cp sept/sept-secondary/sept-secondary_00.enc atmosphere-$(AMSVER)/sept/sept-secondary_00.enc
cp sept/sept-secondary/sept-secondary_01.enc atmosphere-$(AMSVER)/sept/sept-secondary_01.enc
cp sept/sept-secondary/sept-secondary_dev_00.enc atmosphere-$(AMSVER)/sept/sept-secondary_dev_00.enc
cp sept/sept-secondary/sept-secondary_dev_01.enc atmosphere-$(AMSVER)/sept/sept-secondary_dev_01.enc
cp config_templates/BCT.ini atmosphere-$(AMSVER)/atmosphere/config/BCT.ini
cp config_templates/override_config.ini atmosphere-$(AMSVER)/atmosphere/config_templates/override_config.ini
cp config_templates/system_settings.ini atmosphere-$(AMSVER)/atmosphere/config_templates/system_settings.ini
cp config_templates/exosphere.ini atmosphere-$(AMSVER)/atmosphere/config_templates/exosphere.ini
cp -r config_templates/kip_patches atmosphere-$(AMSVER)/atmosphere/kip_patches
cp -r config_templates/hbl_html atmosphere-$(AMSVER)/atmosphere/hbl_html
cp stratosphere/boot2/boot2.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008/exefs.nsp
cp stratosphere/dmnt/dmnt.nsp atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D/exefs.nsp
cp stratosphere/erpt/erpt.nsp atmosphere-$(AMSVER)/atmosphere/contents/010000000000002B/exefs.nsp
cp stratosphere/eclct.stub/eclct.stub.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/exefs.nsp
cp stratosphere/fatal/fatal.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000034/exefs.nsp
cp stratosphere/creport/creport.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036/exefs.nsp
cp stratosphere/ro/ro.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/exefs.nsp
cp stratosphere/jpegdec/jpegdec.nsp atmosphere-$(AMSVER)/atmosphere/contents/010000000000003C/exefs.nsp
cp stratosphere/pgl/pgl.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000042/exefs.nsp
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags
touch atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags/boot2.flag
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags
touch atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags/boot2.flag
cp troposphere/reboot_to_payload/reboot_to_payload.nro atmosphere-$(AMSVER)/switch/reboot_to_payload.nro
cp troposphere/daybreak/daybreak.nro atmosphere-$(AMSVER)/switch/daybreak.nro
cd atmosphere-$(AMSVER); zip -r ../atmosphere-EXPERIMENTAL-$(AMSVER).zip ./*; cd ../;
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/sept/payload.bin
cd atmosphere-$(AMSVER); zip -r ../atmosphere-$(AMSVER).zip ./*; cd ../;
rm -r atmosphere-$(AMSVER)
mkdir out
mv atmosphere-EXPERIMENTAL-$(AMSVER).zip out/atmosphere-EXPERIMENTAL-$(AMSVER).zip
mv atmosphere-$(AMSVER).zip out/atmosphere-$(AMSVER).zip
| cut -d' ' -f3)
AMSVER = $(MAJORVER).$(MINORVER).$(MICROVER)-$(AMSREV)

out/atmosphere-$(AMSVER): all
rm -rf out/atmosphere-$(AMSVER)
mkdir -p out/atmosphere-$(AMSVER)
mkdir -p out/atmosphere-$(AMSVER)/atmosphere
mkdir -p out/atmosphere-$(AMSVER)/sept
mkdir -p out/atmosphere-$(AMSVER)/switch
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/010000000000002B
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000034
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/010000000000003C
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000042
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/fatal_errors
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/config_templates
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/config
cp fusee/fusee-primary/fusee-primary.bin out/atmosphere-$(AMSVER)/atmosphere/reboot_payload.bin
cp fusee/fusee-mtc/fusee-mtc.bin out/atmosphere-$(AMSVER)/atmosphere/fusee-mtc.bin
cp fusee/fusee-secondary/fusee-secondary-experimental.bin out/atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
cp fusee/fusee-secondary/fusee-secondary-experimental.bin out/atmosphere-$(AMSVER)/sept/payload.bin
cp sept/sept-primary/sept-primary.bin out/atmosphere-$(AMSVER)/sept/sept-primary.bin
cp sept/sept-secondary/sept-secondary.bin out/atmosphere-$(AMSVER)/sept/sept-secondary.bin || true
cp sept/sept-secondary/sept-secondary_00.enc out/atmosphere-$(AMSVER)/sept/sept-secondary_00.enc
cp sept/sept-secondary/sept-secondary_01.enc out/atmosphere-$(AMSVER)/sept/sept-secondary_01.enc
cp sept/sept-secondary/sept-secondary_dev_00.enc out/atmosphere-$(AMSVER)/sept/sept-secondary_dev_00.enc
cp sept/sept-secondary/sept-secondary_dev_01.enc out/atmosphere-$(AMSVER)/sept/sept-secondary_dev_01.enc
cp config_templates/BCT.ini out/atmosphere-$(AMSVER)/atmosphere/config/BCT.ini
cp config_templates/override_config.ini out/atmosphere-$(AMSVER)/atmosphere/config_templates/override_config.ini
cp config_templates/system_settings.ini out/atmosphere-$(AMSVER)/atmosphere/config_templates/system_settings.ini
cp config_templates/exosphere.ini out/atmosphere-$(AMSVER)/atmosphere/config_templates/exosphere.ini
cp -r config_templates/kip_patches out/atmosphere-$(AMSVER)/atmosphere/kip_patches
cp -r config_templates/hbl_html out/atmosphere-$(AMSVER)/atmosphere/hbl_html
cp stratosphere/boot2/boot2.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008/exefs.nsp
cp stratosphere/dmnt/dmnt.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D/exefs.nsp
cp stratosphere/erpt/erpt.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/010000000000002B/exefs.nsp
cp stratosphere/eclct.stub/eclct.stub.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/exefs.nsp
cp stratosphere/fatal/fatal.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000034/exefs.nsp
cp stratosphere/creport/creport.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036/exefs.nsp
cp stratosphere/ro/ro.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/exefs.nsp
cp stratosphere/jpegdec/jpegdec.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/010000000000003C/exefs.nsp
cp stratosphere/pgl/pgl.nsp out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000042/exefs.nsp
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags
touch out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags/boot2.flag
mkdir -p out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags
touch out/atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags/boot2.flag
cp troposphere/reboot_to_payload/reboot_to_payload.nro out/atmosphere-$(AMSVER)/switch/reboot_to_payload.nro
cp troposphere/daybreak/daybreak.nro out/atmosphere-$(AMSVER)/switch/daybreak.nro

out/atmosphere-EXPERIMENTAL-$(AMSVER): out/atmosphere-$(AMSVER)
rm -rf out/atmosphere-EXPERIMENTAL-$(AMSVER)
cp -r out/atmosphere-$(AMSVER) out/atmosphere-EXPERIMENTAL-$(AMSVER)
cp fusee/fusee-secondary/fusee-secondary.bin out/atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
cp fusee/fusee-secondary/fusee-secondary.bin out/atmosphere-$(AMSVER)/sept/payload.bin

dist-no-debug: out/atmosphere-$(AMSVER) out/atmosphere-EXPERIMENTAL-$(AMSVER)
cd out/atmosphere-EXPERIMENTAL-$(AMSVER); zip -r ../atmosphere-EXPERIMENTAL-$(AMSVER).zip ./*; cd ../;
cd out/atmosphere-$(AMSVER); zip -r ../atmosphere-$(AMSVER).zip ./*; cd ../;
cp fusee/fusee-primary/fusee-primary.bin out/fusee-primary.bin

dist: dist-no-debug
$(eval MAJORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MAJOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3))
$(eval MINORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MINOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3))
$(eval MICROVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MICRO\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \
| cut -d' ' -f3))
$(eval AMSVER = $(MAJORVER).$(MINORVER).$(MICROVER)-$(AMSREV))
rm -rf atmosphere-$(AMSVER)-debug
mkdir atmosphere-$(AMSVER)-debug
cp fusee/fusee-primary/fusee-primary.elf atmosphere-$(AMSVER)-debug/fusee-primary.elf
cp fusee/fusee-mtc/fusee-mtc.elf atmosphere-$(AMSVER)-debug/fusee-mtc.elf
cp fusee/fusee-secondary/fusee-secondary-experimental.elf atmosphere-$(AMSVER)-debug/fusee-secondary.elf
cp sept/sept-primary/sept-primary.elf atmosphere-$(AMSVER)-debug/sept-primary.elf
cp sept/sept-secondary/sept-secondary.elf atmosphere-$(AMSVER)-debug/sept-secondary.elf
cp sept/sept-secondary/sept-secondary.elf atmosphere-$(AMSVER)-debug/sept-secondary.elf || true
cp sept/sept-secondary/key_derivation/key_derivation.elf atmosphere-$(AMSVER)-debug/sept-secondary-key-derivation.elf
cp exosphere/loader_stub/loader_stub.elf atmosphere-$(AMSVER)-debug/exosphere-loader-stub.elf
cp exosphere/program/program.elf atmosphere-$(AMSVER)-debug/exosphere-program.elf
Expand Down Expand Up @@ -154,5 +146,25 @@ dist: dist-no-debug
rm -r atmosphere-$(AMSVER)-debug
mv atmosphere-$(AMSVER)-debug.zip out/atmosphere-$(AMSVER)-debug.zip

image: out/sd.img

extras:
mkdir -p extras

out/sd.img: out/atmosphere-$(AMSVER) extras
@dd if=/dev/zero of=out/sd.img bs=1M count=64 status=noxfer
@mformat -i out/sd.img -F -v "Atmosphere"
@mkdir -p out/sd/
# rsync is the best solution that:
# copies directory contents without copying directory itself
# doesn't fail on empty directories
# resolves symbolic links (this is useful for symlinking sysmodules into extras/)
rsync -Lr --delete out/atmosphere-$(AMSVER)/ extras/ out/sd/
rsync -Lr extras/ out/sd/
@cd out/sd; mcopy -i ../sd.img -bsQ ./* '::'
@echo 'Produced out/sd.img.'

flash: image
fastboot -S 2G flash sd out/sd.img reboot

.PHONY: $(TOPTARGETS) $(COMPONENTS)
.PHONY: $(TOPTARGETS) $(COMPONENTS) dist-no-debug dist image flash
4 changes: 4 additions & 0 deletions config_templates/BCT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ stage2_entrypoint = 0xF0000000
; To force-disable nogc, add nogc = 0

; To opt out of using Atmosphere's NCM reimplementation, add disable_ncm = 1

[fastboot]
force_enable = 0
button_timeout_ms = 0
9 changes: 7 additions & 2 deletions exosphere/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ define ATMOSPHERE_ADD_TARGET

ATMOSPHERE_BUILD_CONFIGS += $(strip $1)

$(strip $1): exosphere$(strip $2).bin check_warmboot_$(strip $1)
@cp warmboot/warmboot$(strip $2).bin warmboot$(strip $2).bin
$(strip $1): exosphere$(strip $2).bin warmboot$(strip $2).bin

exosphere$(strip $2).bin: loader_stub/loader_stub$(strip $2).bin
@cp loader_stub/loader_stub$(strip $2).bin exosphere$(strip $2).bin
@printf LENY >> exosphere$(strip $2).bin
@echo "Built exosphere$(strip $2).bin..."

warmboot$(strip $2).bin: warmboot/warmboot$(strip $2).bin
@cp warmboot/warmboot$(strip $2).bin warmboot$(strip $2).bin
@echo "Built warmboot$(strip $2).bin..."

check_program_$(strip $1):
@$$(MAKE) -C program $(strip $1)

Expand All @@ -22,6 +25,8 @@ check_warmboot_$(strip $1):
loader_stub/loader_stub$(strip $2).bin: check_program_$(strip $1)
@$$(MAKE) -C loader_stub $(strip $1)

warmboot/warmboot$(strip $2).bin: check_warmboot_$(strip $1)

clean-$(strip $1): clean-program-$(strip $1) clean-loader_stub-$(strip $1) clean-warmboot-$(strip $1)
@rm -rf exosphere$(strip $2).bin warmboot$(strip $2).bin

Expand Down
7 changes: 3 additions & 4 deletions fusee/fusee-primary/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := src src/sdmmc src/lib src/lib/fatfs src/display
SOURCES := src src/sdmmc src/lib src/lib/fatfs src/display src/fastboot
DATA := data
INCLUDES := include ../../libraries/libvapours/include

Expand All @@ -39,19 +39,18 @@ DEFINES := -D__BPMP__ -DFUSEE_STAGE1_SRC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\

CFLAGS := \
-g \
-O2 \
-Os \
-fomit-frame-pointer \
-ffunction-sections \
-fdata-sections \
-std=gnu11 \
-Werror \
-Wall \
-fstrict-volatile-bitfields \
$(ARCH) $(DEFINES)

CFLAGS += $(INCLUDE)

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++2a

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(TOPDIR)/linker.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
Expand Down
11 changes: 11 additions & 0 deletions fusee/fusee-primary/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ MEMORY
NULL : ORIGIN = 0x00000000, LENGTH = 0x1000
main : ORIGIN = 0x40010000, LENGTH = 0x20000
low_iram : ORIGIN = 0x40003000, LENGTH = 0x8000
dram : ORIGIN = 0xC0000000, LENGTH = 0x40000000
}

SECTIONS
Expand Down Expand Up @@ -150,6 +151,16 @@ SECTIONS
} >main :NONE
__end__ = ABSOLUTE(.) ;

.dram (NOLOAD) :
{
. = ALIGN(32);
PROVIDE (__dram_start__ = ABSOLUTE(.));
*(.framebuffer)
*(.dram)
. = ALIGN(32);
PROVIDE (__dram_end__ = ABSOLUTE(.));
} >dram :NONE

/* ==================
==== Metadata ====
================== */
Expand Down
99 changes: 99 additions & 0 deletions fusee/fusee-primary/src/bct0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "bct0.h"

#include "lib/ini.h"

#include <string.h>

#define CONFIG_LOG_LEVEL_KEY "log_level"

#define STAGE2_NAME_KEY "stage2_path"
#define STAGE2_MTC_NAME_KEY "stage2_mtc_path"
#define STAGE2_ADDRESS_KEY "stage2_addr"
#define STAGE2_ENTRYPOINT_KEY "stage2_entrypoint"

#define FASTBOOT_FORCE_ENABLE_KEY "force_enable"
#define FASTBOOT_BUTTON_TIMEOUT_KEY "button_timeout_ms"

static int bct0_ini_handler(void *user, const char *section, const char *name, const char *value) {
bct0_t *bct0 = (bct0_t*) user;

if (strcmp(section, "config") == 0) {
if (strcmp(name, CONFIG_LOG_LEVEL_KEY) == 0) {
int log_level = bct0->log_level;
sscanf(value, "%d", &log_level);
bct0->log_level = (ScreenLogLevel) log_level;
} else {
return 0;
}
} else if (strcmp(section, "stage1") == 0) {
if (strcmp(name, STAGE2_NAME_KEY) == 0) {
strncpy(bct0->stage2_path, value, sizeof(bct0->stage2_path) - 1);
bct0->stage2_path[sizeof(bct0->stage2_path) - 1] = '\0';
} else if (strcmp(name, STAGE2_MTC_NAME_KEY) == 0) {
strncpy(bct0->stage2_mtc_path, value, sizeof(bct0->stage2_mtc_path) - 1);
bct0->stage2_mtc_path[sizeof(bct0->stage2_mtc_path) - 1] = '\0';
} else if (strcmp(name, STAGE2_ADDRESS_KEY) == 0) {
/* Read in load address as a hex string. */
uintptr_t x;
sscanf(value, "%x", &x);
bct0->stage2_load_address = x;
if (bct0->stage2_entrypoint == 0) {
bct0->stage2_entrypoint = bct0->stage2_load_address;
}
} else if (strcmp(name, STAGE2_ENTRYPOINT_KEY) == 0) {
/* Read in entrypoint as a hex string. */
uintptr_t x;
sscanf(value, "%x", &x);
bct0->stage2_entrypoint = x;
} else {
return 0;
}
} else if (strcmp(section, "fastboot") == 0) {
if (strcmp(name, FASTBOOT_FORCE_ENABLE_KEY) == 0) {
int tmp = 0;
sscanf(value, "%d", &tmp);
bct0->fastboot_force_enable = (tmp != 0);
} else if (strcmp(name, FASTBOOT_BUTTON_TIMEOUT_KEY) == 0) {
int tmp = 0;
sscanf(value, "%d", &tmp);
bct0->fastboot_button_timeout = tmp;
} else {
return 0;
}
} else {
return 0;
}

return 1;
}

int bct0_parse(const char *ini, bct0_t *out) {
/* Initialize some default configuration. */
out->log_level = SCREEN_LOG_LEVEL_NONE;

strcpy(out->stage2_path, "atmosphere/fusee-secondary.bin");
strcpy(out->stage2_mtc_path, "atmosphere/fusee-mtc.bin");
out->stage2_load_address = 0xf0000000;
out->stage2_entrypoint = 0xf0000000;

out->fastboot_force_enable = false;
out->fastboot_button_timeout = 3000;

return ini_parse_string(ini, bct0_ini_handler, out);
}
Loading