PS3 [HELP] Including libraries in a homebrew

LuanTeles

Developer
PSX-Place Supporter
Hey guys, i have my homebrew setup and working, but i'm having some isues trying to figure out how to include a default library of the SDK

Here's the MAKE.bat


Code:
@echo off
set PS3SDK=/c/PSDK3v2
set WIN_PS3SDK=C:/PSDK3v2
set PATH=%WIN_PS3SDK%/mingw/msys/1.0/bin;%WIN_PS3SDK%/mingw/bin;%WIN_PS3SDK%/ps3dev/bin;%WIN_PS3SDK%/ps3dev/ppu/bin;%WIN_PS3SDK%/ps3dev/spu/bin;%WIN_PS3SDK%/mingw/Python27;%PATH%;
set PSL1GHT=%PS3SDK%/psl1ght
set PS3DEV=%PS3SDK%/ps3dev

make pkg

del *.elf>nul
del *.self>nul
del /q/s build>nul
rd /S/Q build>nul
pause

And the makefile


Code:
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(PSL1GHT)),)
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
endif

include $(PSL1GHT)/ppu_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
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET        :=    $(notdir $(CURDIR))
BUILD        :=    build
SOURCES        :=    source
DATA        :=    data
INCLUDES    :=    include
PKGFILES    :=    $(CURDIR)/release

TITLE        :=     PS3™ 4K Pro Lite
APPID        :=    PS34KPROL
CONTENTID    :=    UP0001-$(APPID)_00-0000000000000000
ICON0        :=    $(CURDIR)/release/ICON0.PNG

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

# aditional scetool flags (--self-ctrl-flags, --self-cap-flags...)
SCETOOL_FLAGS    +=    -2 0A
SCETOOL_FLAGS    +=    --self-ctrl-flags 4000000000000000000000000000000000000000000000000000000000000002
SCETOOL_FLAGS    +=    --self-cap-flags 00000000000000000000000000000000000000000000007B0000000100000000

CFLAGS        =    -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE)
CXXFLAGS    =    $(CFLAGS)

LDFLAGS        =    $(MACHDEP) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS    :=    -lNoRSX -lgcm_sys -lrsx -lsysutil -lio -lm -lfreetype -lz -lpixman-1 -lrt -llv2 -lsysfs -lsysmodule -lpng -lpngdec -ljpgdec

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS    := $(PORTLIBS)

#---------------------------------------------------------------------------------
# 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 VPATH    :=    $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
                    $(foreach dir,$(DATA),$(CURDIR)/$(dir))

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

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

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES        :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES    :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES        :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES        :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES    :=    $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin)))
PNGFILES    :=    $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.png)))
JPGFILES    :=    $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.jpg)))
TTFFILES    :=    $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
VCGFILES    :=    $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg)))
FCGFILES    :=    $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg)))

#---------------------------------------------------------------------------------
# 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)) \
            $(addsuffix .o,$(TTFFILES)) \
            $(addsuffix .o,$(VPOFILES)) \
            $(addsuffix .o,$(FPOFILES)) \
            $(addsuffix .o,$(PNGFILES)) \
            $(addsuffix .o,$(JPGFILES)) \
                    $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
                    $(sFILES:.s=.o) $(SFILES:.S=.o)

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE    :=    -I$(PORTLIBS)/include/freetype2 \
            $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
                    $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
                    $(LIBPSL1GHT_INC) \
                    -I$(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS    :=    $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
                    $(LIBPSL1GHT_LIB)

export OUTPUT    :=    $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

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

#---------------------------------------------------------------------------------
clean:
    @echo clean ...
    @rm -fr $(BUILD) *.elf *.self *.pkg

#---------------------------------------------------------------------------------
run:
    ps3load $(OUTPUT).self

#---------------------------------------------------------------------------------
pkg:    $(BUILD) $(OUTPUT).pkg

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

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

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).self: $(OUTPUT).elf
$(OUTPUT).elf:    $(OFILES)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
#---------------------------------------------------------------------------------
%.bin.o    :    %.bin
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)

#---------------------------------------------------------------------------------
%.ttf.o    :    %.ttf
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)

#---------------------------------------------------------------------------------
%.vpo.o    :    %.vpo
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)

#---------------------------------------------------------------------------------
%.fpo.o    :    %.fpo
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)

#---------------------------------------------------------------------------------
%.jpg.o    :    %.jpg
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)
#---------------------------------------------------------------------------------
%.png.o    :    %.png
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    @$(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
 
I need the following


#include <cell/cell_fs.h>
#include <cell/fs/cell_fs_file_api.h>

but the compiler gives me

fatal error: cell/cell_fs.h: No such file or directory
fatal error: cell/fs/cell_fs_file_api.h: No such file or directory

What i'm missing?
 
@aldostools @bguerville @bucanero

BTW i'm using it in a fork of the XMBM Team Installer, do i need to add something in the make file or something? the libraries are here as it is called from the PS3HEN and i can compile it just fine, so it's something in this setup
 
Code:
#include <cell/cell_fs.h>
#include <cell/fs/cell_fs_file_api.h>

This code is for the official SDK, not psl1ght sdk, the file system io header files are different iirc and the code you wish to use that refers to those headers would probably have to be modified for psl1ght too.
 
Code:
#include <cell/cell_fs.h>
#include <cell/fs/cell_fs_file_api.h>

This code is for the official SDK, not psl1ght sdk, the file system io header files are different iirc and the code you wish to use that refers to those headers would probably have to be modified for psl1ght too.

Yeap, i just realized, i'm trying to figure out how to trigger the file system check and the rebuild database

About the database one, i already know how to create the file but not the content that must have the following bytes
00 00 03 E9
 
Well, i tried to adapt the code

This is what i have now

File system check

Official SDK
Code:
static int fs_check()
{
    int ret;
    ret = cellFsUtilMount("CELL_FS_UTILITY:HDD0", "CELL_FS_SIMPLEFS", "/dev_simple_hdd0", 0, 0, 0, 0);

    if(ret != CELL_OK)
    {
        ShowMessage("msg_hdd_mount_error", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
        return ret;
    }
    else
    {
        int fd;
        ret = cellFsOpen("/dev_simple_hdd0", CELL_FS_O_RDWR, &fd, 0, 0);

        if(ret != CELL_OK)
        {
            ShowMessage("msg_hdd_open_error", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
            return ret;
        }
        else
        {
            uint64_t pos;
            cellFsLseek(fd, 0x10520 ,0, &pos);
 
            int buf;
            uint64_t nrw;
            cellFsRead(fd, &buf, 4, &nrw);

            buf = buf | 4;

            cellFsLseek(fd, 0x10520, 0, &pos);
            cellFsWrite(fd, &buf, 4, &nrw);
            cellFsClose(fd);
        }

        cellFsUtilUnMount("/dev_simple_hdd0", 0);

        return CELL_OK;
    }
}

PSL1GHT: (NOT WORKING)

Code:
void fs_check()
{
    sysFsMount("CELL_FS_UTILITY:HDD0", "CELL_FS_SIMPLEFS", "/dev_simple_hdd0", 0);
    int fd;
    sysFsOpen("/dev_simple_hdd0", SYS_O_RDWR, &fd, 0, 0);
 
    uint64_t pos;
    sysFsLseek(fd, 0x10520 ,0, &pos);
    int buf;
    uint64_t nrw;
    sysFsRead(fd, &buf, 4, &nrw);
    buf |= 4;
    sysFsLseek(fd, 0x10520, 0, &pos);
    sysFsWrite(fd, &buf, 4, &nrw);
    sysFsClose(fd);
    sysFsUnmount("/dev_simple_hdd0");
}

BTW i'm calling it here


Code:
Mess.Dialog(MSG_YESNO_DYES, "Do you want to optimize the system?\n\n• Select 'Yes' to reboot the system and rebuild the database and file system.\n• Select 'No' to reboot the system.");
            if (Mess.GetResponse(MSG_DIALOG_BTN_YES)==1)
            {
                rtype="soft";
                rebuild_db();
                fs_check();
                PF.printf("- Deleting turnoff file\r\n");
                sysFsUnlink((char*)"/dev_hdd0/tmp/turnoff");
                PF.printf("- Rebooting system\r\n");
                Graphics->NoRSX_Exit(); //This will uninit the NoRSX lib
                reboot_sys(rtype); //reboot
            }
 
Last edited:
And for the rebuild database

Official SDK:
Code:
void rebuild_db()
{
    int fd;
    cellFsOpen("/dev_hdd0/mms/db.err", CELL_FS_O_RDWR | CELL_FS_O_CREAT, &fd, NULL, 0);

    uint64_t nrw;
    int rebuild_flag = 0x000003E9;
    cellFsWrite(fd, &rebuild_flag, 4, &nrw);
    cellFsClose(fd);

}

PSL1GHT (TESTED AND WORKING)
Code:
void rebuild_db()
{
    int fd;
    sysFsOpen("/dev_hdd0/mms/db.err", SYS_O_RDWR | SYS_O_CREAT, &fd, NULL, 0);

    uint64_t nrw;
    int rebuild_flag = 0x000003E9;
    sysFsWrite(fd, &rebuild_flag, 4, &nrw);
    sysFsClose(fd);
}
 
Last edited:
what
Well, i tried to adapt the code

This is what i have now

File system check

Official SDK
Code:
static int fs_check()
{
    int ret;
    ret = cellFsUtilMount("CELL_FS_UTILITY:HDD0", "CELL_FS_SIMPLEFS", "/dev_simple_hdd0", 0, 0, 0, 0);

    if(ret != CELL_OK)
    {
        ShowMessage("msg_hdd_mount_error", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
        return ret;
    }
    else
    {
        int fd;
        ret = cellFsOpen("/dev_simple_hdd0", CELL_FS_O_RDWR, &fd, 0, 0);

        if(ret != CELL_OK)
        {
            ShowMessage("msg_hdd_open_error", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
            return ret;
        }
        else
        {
            uint64_t pos;
            cellFsLseek(fd, 0x10520 ,0, &pos);
 
            int buf;
            uint64_t nrw;
            cellFsRead(fd, &buf, 4, &nrw);

            buf = buf | 4;

            cellFsLseek(fd, 0x10520, 0, &pos);
            cellFsWrite(fd, &buf, 4, &nrw);
            cellFsClose(fd);
        }

        cellFsUtilUnMount("/dev_simple_hdd0", 0);

        return CELL_OK;
    }
}

PSL1GHT: (NOT WORKING)

Code:
void fs_check()
{
    sysFsMount("CELL_FS_UTILITY:HDD0", "CELL_FS_SIMPLEFS", "/dev_simple_hdd0", 0);
    int fd;
    sysFsOpen("/dev_simple_hdd0", SYS_O_RDWR, &fd, 0, 0);
 
    uint64_t pos;
    sysFsLseek(fd, 0x10520 ,0, &pos);
    int buf;
    uint64_t nrw;
    sysFsRead(fd, &buf, 4, &nrw);
    buf |= 4;
    sysFsLseek(fd, 0x10520, 0, &pos);
    sysFsWrite(fd, &buf, 4, &nrw);
    sysFsClose(fd);
    sysFsUnmount("/dev_simple_hdd0");
}

@Evilnat am i missing something? i took the code from your xai plugin and tried to adapt to PSL1GHT
 
Well, just rebooting the system without deleting the dev_hdd0/tmp/turnoff does the same as the fs_check, maybe i'll stick with that

and about the rebuild_database, just deleting the dev_hdd0/mms/db does the same as the db.err
 
Last edited:
@Evilnat the fs_check is not ideal, the user can cancel it, can you please see if you find the flag that enables the one that can't be cancelled?

The current one says


Code:
<Text name="msg_filesystem_corrupt_restart_check_restore_not_turn_off_properly">The system was not turned off properly the last time it was used.
The file system on the system storage may be corrupted.

This system will restart, check the file system and restore it if it is corrupted. If the file system is corrupted, it may take 2 to 3 hours to complete.</Text>

Also, if the turn off warning is set to off on debug settings, it will also not be triggered

The one that can't be cancelled is

Code:
<Text name="msg_errror_hdd_broken_filesystem">The file system on the system storage is corrupted and will be restored.</Text>

This can be done by creating dev_hdd0/BackupRestoreState.dat, it need some specific bytes in it otherwise it will failed to recognize the HDD and it will be stuck, needing to format the system
 
Last edited:

Similar threads

Back
Top