Homebrew Homebrew as CIA freezes at boot

ThatBenderGuy

Well-Known Member
OP
Member
Joined
Dec 16, 2013
Messages
150
Trophies
0
Age
31
XP
348
Country
United States
So I am currently working on just a generic testing homebrew and every time I install it as a CIA to my homemenu it just freezes on the boot animation (The 3DS logo with the red pulses). I am using makerom to compile my cia file.

Here is my main.c
Code:
#include <3ds.h>
#include <sf2d.h>
#include <stdio.h>

extern const struct {
    unsigned int width;
    unsigned int height;
    unsigned int bytes_per_pixel;
    unsigned char pixel_data[];
} muffet;

touchPosition touch;

bool touchInBox(touchPosition t, int x, int y, int w, int h)
{
    int tx = touch.px;
    int ty = touch.py;
    u32 kDown = hidKeysDown();
    if(kDown & KEY_TOUCH && tx > x && tx < x+w && ty > y && ty < y+h)
    {
        return true;
    }else
    {
        return false;
    }
}

int main(int argc, char **argv)
{
    //Initialize the sf2d lib
    sf2d_init();
    //Set the background color
    sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

    sf2d_texture *test_image = sf2d_create_texture_mem_RGBA8(muffet.pixel_data, muffet.width, muffet.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
 
    gfxInitDefault();
    hidInit();
 
    // Main loop
    while (aptMainLoop())
    {
        //Scan all the inputs. This should be done once for each frame
        hidScanInput();
        hidTouchRead(&touch);
     
        //hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
        //hidKeysHeld returns information about which buttons are currently pressed (regardless if they were pressed or not pressed in the previous frame)
        //hidKeysUp returns information about which buttons are not pressed but were pressed in the previous frame
        u32 kDown = hidKeysDown();
        u32 kHeld = hidKeysHeld();
        u32 kUp = hidKeysUp();
     
        sf2d_start_frame(GFX_TOP, GFX_LEFT);
        sf2d_draw_texture(test_image, 0, 0);
        sf2d_end_frame();
     
        if (kDown & KEY_START) break; // break in order to return to hbmenu
     
        //Swap the buffers
        sf2d_swapbuffers();
    }
    sf2d_free_texture(test_image);
    sf2d_fini();
 
    hidExit();
    gfxExit();
    return 0;
}

my Makefile
Code:
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
#   If not set, it attempts to use one of the following (in this order):
#     - <Project name>.png
#     - icon.png
#     - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET        :=    $(notdir $(CURDIR))
BUILD        :=    build
SOURCES        :=    source source/textures
DATA        :=    data
INCLUDES    :=    include

APP_TITLE    :=    FirstProject
APP_DESCRIPTION        :=    The homebrew app used in chapter 4 of the guide
APP_AUTHOR    :=    Jacob Bender (ThatBenderGuy)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH    :=    -march=armv6k -mtune=mpcore -mfloat-abi=hard

CFLAGS    :=    -g -Wall -O2 -mword-relocations \
            -fomit-frame-pointer -ffast-math \
            $(ARCH)

CFLAGS    +=    $(INCLUDE) -DARM11 -D_3DS

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

ASFLAGS    :=    -g $(ARCH)
LDFLAGS    =    -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS    := -lsf2d -lcitro3d -lctru -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS    := $(CTRULIB) $(CURDIR)/../LIBS/libsf2d


#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT    :=    $(CURDIR)/$(TARGET)
export TOPDIR    :=    $(CURDIR)

export VPATH    :=    $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
            $(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR    :=    $(CURDIR)/$(BUILD)

CFILES        :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES    :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES        :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.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) \
            -I$(CURDIR)/$(BUILD)

export LIBPATHS    :=    $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

ifeq ($(strip $(ICON)),)
    icons := $(wildcard *.png)
    ifneq (,$(findstring $(TARGET).png,$(icons)))
        export APP_ICON := $(TOPDIR)/$(TARGET).png
    else
        ifneq (,$(findstring icon.png,$(icons)))
            export APP_ICON := $(TOPDIR)/icon.png
        endif
    endif
else
    export APP_ICON := $(TOPDIR)/$(ICON)
endif

ifeq ($(strip $(NO_SMDH)),)
    export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif

.PHONY: $(BUILD) clean all

#---------------------------------------------------------------------------------
all: $(BUILD)

$(BUILD):
    @echo Building ...
    @[ -d $@ ] || mkdir -p $@
    @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
    @echo clean ...
    @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(TARGET)-strip.elf $(TARGET).cia $(TARGET).3ds
#---------------------------------------------------------------------------------
$(TARGET)-strip.elf: $(BUILD)
    @$(STRIP) --strip-all $(TARGET).elf -o $(TARGET)-strip.elf
#---------------------------------------------------------------------------------
cci: $(TARGET)-strip.elf
    @makerom -f cci -rsf resources/$(TARGET).rsf -target d -exefslogo -elf $(TARGET)-strip.elf -o $(TARGET).3ds
    @echo "built ... sf2d_sample.3ds"
#---------------------------------------------------------------------------------
cia: clean all
    @echo Building CIA file ...
    @arm-none-eabi-strip $(OUTPUT).elf
    @makerom -f cia -o $(OUTPUT).cia -DAPP_ENCRYPTED=false -DAPP_TITLE=$(TARGET) -rsf $(OUTPUT).rsf -target t -exefslogo -elf $(OUTPUT).elf -icon icon.bin -banner banner.bin
    @echo "built ... $(TARGET).cia"
#---------------------------------------------------------------------------------
send: $(BUILD)
    @3dslink $(TARGET).3dsx
#---------------------------------------------------------------------------------
run: $(BUILD)
    @citra $(TARGET).3dsx
#---------------------------------------------------------------------------------
copy_cia: $(TARGET).cia
    @cp $(TARGET).cia /mnt/GATEWAYNAND
    sync

#---------------------------------------------------------------------------------
else

DEPENDS    :=    $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
$(OUTPUT).3dsx    :    $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx    :    $(OUTPUT).elf
endif

$(OUTPUT).elf    :    $(OFILES)

#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o    :    %.bin
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)

# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o    :    %.vsh
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
    @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
    @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
    @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
    @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
    @rm ../$(notdir $<).shbin

-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

and my rsf file
Code:
BasicInfo:
  Title                   : $(APP_TITLE)
  ProductCode             : $(APP_PRODUCT_CODE)
  Logo                    : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem

RomFs:
  RootPath: $(APP_ROMFS)

TitleInfo:
  Category                : $(APP_CATEGORY)
  UniqueId                : $(APP_UNIQUE_ID)

Option:
  UseOnSD                 : true # true if App is to be installed to SD
  FreeProductCode         : true # Removes limitations on ProductCode
  MediaFootPadding        : false # If true CCI files are created with padding
  EnableCrypt             : $(APP_ENCRYPTED) # Enables encryption for NCCH and CIA
  EnableCompress          : true # Compresses where applicable (currently only exefs:/.code)
AccessControlInfo:
  CoreVersion                   : 2

  # Exheader Format Version
  DescVersion                   : 2
  # Minimum Required Kernel Version (below is for 4.5.0)
  ReleaseKernelMajor            : "02"
  ReleaseKernelMinor            : "33"

  # ExtData
  UseExtSaveData                : false # enables ExtData    
  #ExtSaveDataId                : 0x300 # only set this when the ID is different to the UniqueId

  # FS:USER Archive Access Permissions
  # Uncomment as required
  FileSystemAccess:
   - CategorySystemApplication
   - CategoryHardwareCheck
   - CategoryFileSystemTool
   - Debug
   - TwlCardBackup
   - TwlNandData
   - Boss
   - DirectSdmc
   - Core
   - CtrNandRo
   - CtrNandRw
   - CtrNandRoWrite
   - CategorySystemSettings
   - CardBoard
   - ExportImportIvs
   - DirectSdmcWrite
   - SwitchCleanup
   - SaveDataMove
   - Shop
   - Shell
   - CategoryHomeMenu
   - SeedDB
  IoAccessControl:
   - FsMountNand
   - FsMountNandRoWrite
   - FsMountTwln
   - FsMountWnand
   - FsMountCardSpi
   - UseSdif3
   - CreateSeed
   - UseCardSpi

  # Process Settings
  MemoryType                    : $(APP_MEMORY_TYPE) # Application/System/Base
  SystemMode                    : $(APP_SYSTEM_MODE) # 64MB(Default)/96MB/80MB/72MB/32MB
  IdealProcessor                : 0
  AffinityMask                  : 1
  Priority                      : 16
  MaxCpu                        : 0x9E # Default
  HandleTableSize               : 0x200
  DisableDebug                  : false
  EnableForceDebug              : false
  CanWriteSharedPage            : true
  CanUsePrivilegedPriority      : false
  CanUseNonAlphabetAndNumber    : true
  PermitMainFunctionArgument    : true
  CanShareDeviceMemory          : true
  RunnableOnSleep               : false
  SpecialMemoryArrange          : true

  # New3DS Exclusive Process Settings
  SystemModeExt                 : $(APP_SYSTEM_MODE_EXT) # Legacy(Default)/124MB/178MB  Legacy:Use Old3DS SystemMode
  CpuSpeed                      : $(APP_CPU_SPEED) # 268MHz(Default)/804MHz
  EnableL2Cache                 : false # false(default)/true
  CanAccessCore2                : true

  # Virtual Address Mappings
  IORegisterMapping:
   - 1ff00000-1ff7ffff   # DSP memory
  MemoryMapping:
   - 1f000000-1f5fffff:r # VRAM

  # Accessible SVCs, <Name>:<ID>
  SystemCallAccess:
    ControlMemory: 1
    QueryMemory: 2
    ExitProcess: 3
    GetProcessAffinityMask: 4
    SetProcessAffinityMask: 5
    GetProcessIdealProcessor: 6
    SetProcessIdealProcessor: 7
    CreateThread: 8
    ExitThread: 9
    SleepThread: 10
    GetThreadPriority: 11
    SetThreadPriority: 12
    GetThreadAffinityMask: 13
    SetThreadAffinityMask: 14
    GetThreadIdealProcessor: 15
    SetThreadIdealProcessor: 16
    GetCurrentProcessorNumber: 17
    Run: 18
    CreateMutex: 19
    ReleaseMutex: 20
    CreateSemaphore: 21
    ReleaseSemaphore: 22
    CreateEvent: 23
    SignalEvent: 24
    ClearEvent: 25
    CreateTimer: 26
    SetTimer: 27
    CancelTimer: 28
    ClearTimer: 29
    CreateMemoryBlock: 30
    MapMemoryBlock: 31
    UnmapMemoryBlock: 32
    CreateAddressArbiter: 33
    ArbitrateAddress: 34
    CloseHandle: 35
    WaitSynchronization1: 36
    WaitSynchronizationN: 37
    SignalAndWait: 38
    DuplicateHandle: 39
    GetSystemTick: 40
    GetHandleInfo: 41
    GetSystemInfo: 42
    GetProcessInfo: 43
    GetThreadInfo: 44
    ConnectToPort: 45
    SendSyncRequest1: 46
    SendSyncRequest2: 47
    SendSyncRequest3: 48
    SendSyncRequest4: 49
    SendSyncRequest: 50
    OpenProcess: 51
    OpenThread: 52
    GetProcessId: 53
    GetProcessIdOfThread: 54
    GetThreadId: 55
    GetResourceLimit: 56
    GetResourceLimitLimitValues: 57
    GetResourceLimitCurrentValues: 58
    GetThreadContext: 59
    Break: 60
    OutputDebugString: 61
    ControlPerformanceCounter: 62
    CreatePort: 71
    CreateSessionToPort: 72
    CreateSession: 73
    AcceptSession: 74
    ReplyAndReceive1: 75
    ReplyAndReceive2: 76
    ReplyAndReceive3: 77
    ReplyAndReceive4: 78
    ReplyAndReceive: 79
    BindInterrupt: 80
    UnbindInterrupt: 81
    InvalidateProcessDataCache: 82
    StoreProcessDataCache: 83
    FlushProcessDataCache: 84
    StartInterProcessDma: 85
    StopDma: 86
    GetDmaState: 87
    RestartDma: 88
    DebugActiveProcess: 96
    BreakDebugProcess: 97
    TerminateDebugProcess: 98
    GetProcessDebugEvent: 99
    ContinueDebugEvent: 100
    GetProcessList: 101
    GetThreadList: 102
    GetDebugThreadContext: 103
    SetDebugThreadContext: 104
    QueryDebugProcessMemory: 105
    ReadProcessMemory: 106
    WriteProcessMemory: 107
    SetHardwareBreakPoint: 108
    GetDebugThreadParam: 109
    ControlProcessMemory: 112
    MapProcessMemory: 113
    UnmapProcessMemory: 114
    CreateCodeSet: 115
    CreateProcess: 117
    TerminateProcess: 118
    SetProcessResourceLimits: 119
    CreateResourceLimit: 120
    SetResourceLimitValues: 121
    AddCodeSegment: 122
    Backdoor: 123
    KernelSetState: 124
    QueryProcessMemory: 125

  # Service List
  # Maximum 34 services (32 if firmware is prior to 9.6.0)
  ServiceAccessControl:
   - APT:U
   - ac:u
   - am:net
   - boss:U
   - cam:u
   - cecd:u
   - cfg:nor
   - cfg:u
   - csnd:SND
   - dsp::DSP
   - frd:u
   - fs:USER
   - gsp::Gpu
   - gsp::Lcd
   - hid:USER
   - http:C
   - ir:rst
   - ir:u
   - ir:USER
   - mic:u
   - ndm:u
   - news:s
   - nwm::EXT
   - nwm::UDS
   - ptm:sysm
   - ptm:u
   - pxi:dev
   - soc:U
   - ssl:C
   - y2r:u


SystemControlInfo:
  SaveDataSize: 0KB # Change if the app uses savedata
  RemasterVersion: $(APP_VERSION_MAJOR)
  StackSize: 0x40000

  # Modules that run services listed above should be included below
  # Maximum 48 dependencies
  # <module name>:<module titleid>
  Dependency:
    ac: 0x0004013000002402
    #act: 0x0004013000003802
    am: 0x0004013000001502
    boss: 0x0004013000003402
    camera: 0x0004013000001602
    cecd: 0x0004013000002602
    cfg: 0x0004013000001702
    codec: 0x0004013000001802
    csnd: 0x0004013000002702
    dlp: 0x0004013000002802
    dsp: 0x0004013000001a02
    friends: 0x0004013000003202
    gpio: 0x0004013000001b02
    gsp: 0x0004013000001c02
    hid: 0x0004013000001d02
    http: 0x0004013000002902
    i2c: 0x0004013000001e02
    ir: 0x0004013000003302
    mcu: 0x0004013000001f02
    mic: 0x0004013000002002
    ndm: 0x0004013000002b02
    news: 0x0004013000003502
    #nfc: 0x0004013000004002
    nim: 0x0004013000002c02
    nwm: 0x0004013000002d02
    pdn: 0x0004013000002102
    ps: 0x0004013000003102
    ptm: 0x0004013000002202
    #qtm: 0x0004013020004202
    ro: 0x0004013000003702
    socket: 0x0004013000002e02
    spi: 0x0004013000002302
    ssl: 0x0004013000002f02

my only guesses is that something's not right in either my RSF file or my main.c
 
Last edited by ThatBenderGuy,

ksanislo

Well-Known Member
Member
Joined
Feb 23, 2016
Messages
386
Trophies
0
Location
Seattle, WA
XP
512
Country
United States
So, I'm not entirely sure what the problem is here, but you might want to consider using Steveice10's buildtools package to make your elf/3dsx/cia all at once, you can basically just throw the buildtools folder along side your source folder, and then grab the Makefile from FBI's source and tweak it to set your own name/developer info/titleid and lib requirements. It will make the building of the cia super easy and you can be sure that it's not part of the problem

As for the freeze on startup, you may want to try starting from one of the known working non-sf2d examples, something like https://github.com/devkitPro/3ds-examples/blob/master/graphics/bitmap/24bit-color/source/main.c

And then move on to the fancier stuff after you've got things working.
 

ThatBenderGuy

Well-Known Member
OP
Member
Joined
Dec 16, 2013
Messages
150
Trophies
0
Age
31
XP
348
Country
United States
So, I'm not entirely sure what the problem is here, but you might want to consider using Steveice10's buildtools package to make your elf/3dsx/cia all at once, you can basically just throw the buildtools folder along side your source folder, and then grab the Makefile from FBI's source and tweak it to set your own name/developer info/titleid and lib requirements. It will make the building of the cia super easy and you can be sure that it's not part of the problem

As for the freeze on startup, you may want to try starting from one of the known working non-sf2d examples, something like https://github.com/devkitPro/3ds-examples/blob/master/graphics/bitmap/24bit-color/source/main.c

And then move on to the fancier stuff after you've got things working.
I tried moving buildtools to the same folder that my source folder is in, used FBI's make file and get this error

Code:
E:\3DS_Stuff\HB_Dev\FirstProject>make
fatal: Not a git repository (or any of the parent directories): .git
build/source/main.o
In file included from c:/devkitPro/libctru/include/3ds.h:19:0,
                 from source/main.c:1:
c:/devkitPro/libctru/include/3ds/synchronization.h:6:22: fatal error: sys/lock.h: No such file or directory
 #include <sys/lock.h>
                      ^
compilation terminated.
make: *** [build/source/main.o] Error 1
 
Last edited by ThatBenderGuy,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    BigOnYa @ BigOnYa: Sounds good actually.