improve build system for uart
This commit is contained in:
@@ -21,20 +21,32 @@
|
|||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
#include <vapours/results/results_common.hpp>
|
#include <vapours/results/results_common.hpp>
|
||||||
|
|
||||||
#define HOC_UART_LOG 1
|
|
||||||
|
#ifndef HOC_UART_LOG
|
||||||
|
#define HOC_UART_LOG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HOC_UART_LOG && !(defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING))
|
||||||
|
#undef HOC_UART_LOG
|
||||||
|
#define HOC_UART_LOG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define HOC_PCV_NVLOG_PATCH 1
|
#define HOC_PCV_NVLOG_PATCH 1
|
||||||
#define HOC_PCV_FORCE_VERBOSITY 1
|
#define HOC_PCV_FORCE_VERBOSITY 1
|
||||||
|
|
||||||
#include "customize.hpp"
|
#include "customize.hpp"
|
||||||
#include "oc_log.hpp"
|
#include "oc_log.hpp"
|
||||||
|
|
||||||
|
#define HOC_IRAM_LOG 0
|
||||||
|
|
||||||
#if (!HOC_UART_LOG) && (defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING))
|
#if (!HOC_UART_LOG) && (defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING))
|
||||||
|
#undef HOC_IRAM_LOG
|
||||||
#define HOC_IRAM_LOG 1
|
#define HOC_IRAM_LOG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
|
#if defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
|
||||||
|
|
||||||
#if defined(HOC_IRAM_LOG)
|
#if HOC_IRAM_LOG
|
||||||
#define LOGGING(...) Log(__VA_ARGS__)
|
#define LOGGING(...) Log(__VA_ARGS__)
|
||||||
#elif HOC_UART_LOG
|
#elif HOC_UART_LOG
|
||||||
#define LOGGING(fmt, ...) AMS_LOG(fmt "\n", ##__VA_ARGS__)
|
#define LOGGING(fmt, ...) AMS_LOG(fmt "\n", ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "oc_common.hpp"
|
#include "oc_common.hpp"
|
||||||
|
|
||||||
#ifdef HOC_IRAM_LOG
|
#if HOC_IRAM_LOG
|
||||||
#include "fatal_handler_bin.h"
|
#include "fatal_handler_bin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ namespace ams::ldr::hoc {
|
|||||||
#define IRAM_LOG_CTX_ADDR 0x4003C000
|
#define IRAM_LOG_CTX_ADDR 0x4003C000
|
||||||
#define IRAM_LOG_MAX_SZ 4096
|
#define IRAM_LOG_MAX_SZ 4096
|
||||||
|
|
||||||
#ifdef HOC_IRAM_LOG
|
#if HOC_IRAM_LOG
|
||||||
void Log(const char *data, ...) {
|
void Log(const char *data, ...) {
|
||||||
static const u32 max_log_sz = sizeof(working_buf) - sizeof(log_ctx_t);
|
static const u32 max_log_sz = sizeof(working_buf) - sizeof(log_ctx_t);
|
||||||
static bool initDone = false;
|
static bool initDone = false;
|
||||||
@@ -139,7 +139,7 @@ namespace ams::ldr::hoc {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ViewLog() {
|
void ViewLog() {
|
||||||
#ifdef HOC_IRAM_LOG
|
#if HOC_IRAM_LOG
|
||||||
if (spl::GetSocType() == spl::SocType_Mariko) {
|
if (spl::GetSocType() == spl::SocType_Mariko) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
136
Source/Atmosphere/stratosphere/loader/system_module.mk
Normal file
136
Source/Atmosphere/stratosphere/loader/system_module.mk
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# pull in common stratosphere sysmodule configuration
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||||
|
CURRENT_DIRECTORY := $(abspath $(dir $(THIS_MAKEFILE)))
|
||||||
|
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk
|
||||||
|
|
||||||
|
ifneq ($(strip $(HOC_UART_LOG)),)
|
||||||
|
export CFLAGS += -DHOC_UART_LOG=$(HOC_UART_LOG)
|
||||||
|
export CXXFLAGS += -DHOC_UART_LOG=$(HOC_UART_LOG)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ATMOSPHERE_SYSTEM_MODULE_TARGETS := kip
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
# rules for different file extensions
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifneq ($(__RECURSIVE__),1)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c)
|
||||||
|
CPPFILES := $(call FIND_SOURCE_FILES,$(SOURCES),cpp)
|
||||||
|
SFILES := $(call FIND_SOURCE_FILES,$(SOURCES),s)
|
||||||
|
|
||||||
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CC)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CXX)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||||
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||||
|
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
|
$(foreach dir,$(AMS_LIBDIRS),-I$(dir)/include) \
|
||||||
|
-I$(CURDIR)/$(ATMOSPHERE_BUILD_DIR)
|
||||||
|
|
||||||
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(foreach dir,$(AMS_LIBDIRS),-L$(dir)/$(ATMOSPHERE_LIBRARY_DIR))
|
||||||
|
|
||||||
|
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
|
||||||
|
|
||||||
|
ifeq ($(strip $(CONFIG_JSON)),)
|
||||||
|
jsons := $(wildcard *.json)
|
||||||
|
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
||||||
|
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
||||||
|
else
|
||||||
|
ifneq (,$(findstring config.json,$(jsons)))
|
||||||
|
export APP_JSON := $(TOPDIR)/config.json
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: clean all check_lib
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: $(ATMOSPHERE_OUT_DIR) $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere/$(ATMOSPHERE_LIBRARY_DIR)/libstratosphere.a
|
||||||
|
@$(MAKE) __RECURSIVE__=1 OUTPUT=$(CURDIR)/$(ATMOSPHERE_OUT_DIR)/$(TARGET) \
|
||||||
|
DEPSDIR=$(CURDIR)/$(ATMOSPHERE_BUILD_DIR) \
|
||||||
|
--no-print-directory -C $(ATMOSPHERE_BUILD_DIR) \
|
||||||
|
-f $(THIS_MAKEFILE)
|
||||||
|
|
||||||
|
$(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere/$(ATMOSPHERE_LIBRARY_DIR)/libstratosphere.a: check_lib
|
||||||
|
@$(SILENTCMD)echo "Checked library."
|
||||||
|
|
||||||
|
ifeq ($(ATMOSPHERE_CHECKED_LIBSTRATOSPHERE),1)
|
||||||
|
check_lib:
|
||||||
|
else
|
||||||
|
check_lib:
|
||||||
|
@$(MAKE) --no-print-directory -C $(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere -f $(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere/libstratosphere.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(ATMOSPHERE_OUT_DIR) $(ATMOSPHERE_BUILD_DIR):
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -fr $(ATMOSPHERE_OUT_DIR) $(ATMOSPHERE_BUILD_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all : $(foreach target,$(ATMOSPHERE_SYSTEM_MODULE_TARGETS),$(OUTPUT).$(target))
|
||||||
|
|
||||||
|
$(OUTPUT).kip : $(OUTPUT).elf
|
||||||
|
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
|
||||||
|
$(OUTPUT).nso : $(OUTPUT).elf
|
||||||
|
|
||||||
|
$(OUTPUT).elf : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES) : $(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere/$(ATMOSPHERE_LIBRARY_DIR)/libstratosphere.a
|
||||||
|
|
||||||
|
%.npdm : %.npdm.json
|
||||||
|
@echo built ... $< $@
|
||||||
|
@npdmtool $< $@
|
||||||
|
@echo built ... $(notdir $@)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# you need a rule like this for each extension you use as binary data
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.bin.o : %.bin
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------------
|
||||||
21
build.sh
21
build.sh
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
EXT=0
|
EXT=0
|
||||||
LDR_MAKE="nx_release"
|
LDR_MAKE="nx_release"
|
||||||
|
LDR_SET=0
|
||||||
NO_EXO=0
|
NO_EXO=0
|
||||||
JOBS=""
|
JOBS=""
|
||||||
DEBUG=0
|
UART_LOGGING=0
|
||||||
|
|
||||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
DIST_DIR="$ROOT_DIR/dist"
|
DIST_DIR="$ROOT_DIR/dist"
|
||||||
@@ -16,10 +17,10 @@ while [ $# -gt 0 ]; do
|
|||||||
;;
|
;;
|
||||||
--ldr=*)
|
--ldr=*)
|
||||||
LDR_MAKE="${1#*=}"
|
LDR_MAKE="${1#*=}"
|
||||||
|
LDR_SET=1
|
||||||
;;
|
;;
|
||||||
-d|--debug)
|
-u|--uart)
|
||||||
DEBUG=1
|
UART_LOGGING=1
|
||||||
LDR_MAKE="nx_audit"
|
|
||||||
;;
|
;;
|
||||||
--no-exo)
|
--no-exo)
|
||||||
NO_EXO=1
|
NO_EXO=1
|
||||||
@@ -39,6 +40,10 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$UART_LOGGING" -eq 1 ] && [ "$LDR_SET" -eq 0 ]; then
|
||||||
|
LDR_MAKE="nx_audit"
|
||||||
|
fi
|
||||||
|
|
||||||
LDR_BUILD_PATH="${LDR_MAKE#nx_}"
|
LDR_BUILD_PATH="${LDR_MAKE#nx_}"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@@ -50,8 +55,8 @@ if [ "$NO_EXO" -eq 1 ]; then
|
|||||||
echo "NO_EXO = 1"
|
echo "NO_EXO = 1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DEBUG" -eq 1 ]; then
|
if [ "$UART_LOGGING" -eq 1 ]; then
|
||||||
echo "DEBUG = 1 (loader build: nx_audit, UART logging enabled)"
|
echo "UART_LOGGING = 1 (loader build: $LDR_MAKE, UART logging enabled)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CORES="$(nproc --all)"
|
CORES="$(nproc --all)"
|
||||||
@@ -87,9 +92,9 @@ mkdir -p "$DEST"
|
|||||||
echo
|
echo
|
||||||
echo "*** Patching loader ***"
|
echo "*** Patching loader ***"
|
||||||
cp -vr "$SRC"/. "$DEST"/
|
cp -vr "$SRC"/. "$DEST"/
|
||||||
echo
|
|
||||||
|
|
||||||
if [ "$NO_EXO" -eq 0 ]; then
|
if [ "$NO_EXO" -eq 0 ]; then
|
||||||
|
echo
|
||||||
echo "*** Patching exosphere ***"
|
echo "*** Patching exosphere ***"
|
||||||
EXO_SRC="Source/Atmosphere-Patches"
|
EXO_SRC="Source/Atmosphere-Patches"
|
||||||
EXO_DEST="build/atmosphere/exosphere/program/source/smc"
|
EXO_DEST="build/atmosphere/exosphere/program/source/smc"
|
||||||
@@ -107,7 +112,7 @@ fi
|
|||||||
echo
|
echo
|
||||||
echo "*** Compiling loader ***"
|
echo "*** Compiling loader ***"
|
||||||
cd build/atmosphere/stratosphere/loader || exit 1
|
cd build/atmosphere/stratosphere/loader || exit 1
|
||||||
make -j$JOBS "$LDR_MAKE"
|
make -j$JOBS HOC_UART_LOG=$UART_LOGGING "$LDR_MAKE"
|
||||||
hactool -t kip1 "out/nintendo_nx_arm64_armv8a/$LDR_BUILD_PATH/loader.kip" --uncompress=hoc.kip
|
hactool -t kip1 "out/nintendo_nx_arm64_armv8a/$LDR_BUILD_PATH/loader.kip" --uncompress=hoc.kip
|
||||||
cd "$ROOT_DIR" # exit
|
cd "$ROOT_DIR" # exit
|
||||||
cp -v build/atmosphere/stratosphere/loader/hoc.kip dist/atmosphere/kips/hoc.kip
|
cp -v build/atmosphere/stratosphere/loader/hoc.kip dist/atmosphere/kips/hoc.kip
|
||||||
|
|||||||
Reference in New Issue
Block a user