Join Us and become a Member for a Verified Badge to access private areas with the latest PS4 PKGs.
Status
Not open for further replies.

PSXHAX

Staff Member
Verified
Moderator
Following the PS4SDK Setup Windows Guide, today PlayStation 4 developer Zer0xFF shared another PS4SDKs and Setup Tutorial for those interested in PS4 homebrew development.

To quote from his latest Blog Update: PS4SDKs & Setup

There are currently 2 publicly available PS4 ***s the 1st being Cturt's *** & Hito's ***, so which one should you use?

for fork numbers out there you'd be more inclined to go with Cturt's *** as it has 139 forks compared to only 13 for Hito's but that doesn't tell you the half the§ story.

I'm gonna keep this argument simple, Hito's *** while still lacking is more complete, in that it's headers contain both FreeBSD(PS4 is based on FreeBSD) and a subset of PS4 headers, while Cturt's seems for the most part to only contain PS4 headers.
There is also the way both ***'s resolve symbols, in Cturt's *** if you wanted to use any library you need to initialise that library yourself e.g. initLibc(); while Hito's does it automatically, as such the code flows much like it would when you're working on a "Desktop" code.

But what does that mean, it mean with Hito's *** I am able to build freetype2 library from upstream without any modifications, while I wouldn't be able to with Cturt's.

Just so as of now all the tools that @bigboss has created are based on Hito's ***, the library I released is based on Hito's as well and any future release of mine is likely to continue with this trend, to add to that @masterzorag recently released a font library to complement bigboss's libraries aswell, and as such by default he's using Hito's ***. With that said I say this with 99.95% certainty that Hito's *** will be the mainstream PS4 *** for the homebrew community as they both stand right now. Now with that out of the way, you probably guessed which *** I'll be talking about from now on.

(P.S if you're doing official work which will go on to be released on the PSN, you're reading the wrong article my friend :D)

The juicy stuff

Quick note: if you're running Ubuntu you'd most likely get away with using the default clang compiler, if you're contempt with that you'll only have to go through Setting up the *** - Initial Step & call make at the end in $PS4SDK but I'm trying to create a mostly self contained toolchain, as such I will be building clang from source.(If you're not building clang from source, you'll need to modify the cmake toolchain script to work with your setup)

If you're running OSX you will have not choice but to build clang from source and so the following steps will be valid for both Linux based OSes and OSX.

Setting up the *** - Initial Step
  • this will clone hito's *** and cherry-pick changes introduced by bigboss which are needed for homebrew development
Code:
cd ~
git clone https://github.com/ps4dev/ps4sdk.git
cd ps4sdk
PS4SDK=`pwd`
  • The following block is optional in terms of getting the *** setup, but will be required if you plan to create homebrew with any type of interface or gamepad support.
Code:
git remote add bigboss https://github.com/psxdev/ps4sdk.git
git fetch bigboss
git cherry-pick 2c2739d7a1dfeb1f58f496a313bbdce62db2570e
  • The next set of commands will setup ./usr directory which will contain everything related the the PS4SDK, turning it onto a self contained toolchain
Code:
mkdir lib; mkdir usr; cd usr;
ln -s $PS4SDK/lib lib
ln -s $PS4SDK/include include
cd ..
  • if you're Ubuntu/Linux user open ~/.bash_aliases using your favourite editor and add this line to it
    • export PS4SDK=/location/to/ps4sdk
    • this will save you the hassle of having to define $PS4SDK everytime you open your shell terminal
  • if you're on OSX
    • you might need to create .bash_profile and .bash_aliases in ~/
      • in .bash_profile add the following
      if [ -f ~/.bash_aliases ]; then
      . ~/.bash_aliases
      fi
      • in .bash_aliases add
      export PS4SDK=/location/to/ps4sdk
  • close the terminal and open a new window to make sure this worked correctly, to confirm just do echo $PS4SDK and that should printout the location of the ***
  • for now you're done with the ***, but you'll return to it later to build the libraries at the very end
Building Clang From Source
  • building clang is actually straight forward process
  • the following site of commands would clone the required repo to build clang
Code:
cd $PS4SDK
mkdir -p EXPT/crossllvm
cd EXPT/crossllvm
git clone http://llvm.org/git/llvm.git
cd llvm/tools
git clone http://llvm.org/git/clang.git
git clone http://llvm.org/git/lld.git
cd ../projects
git clone http://llvm.org/git/compiler-rt.git
cd ..
  • while the following lines setup the build
Code:
mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PS4SDK/usr -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-scei-ps4 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCOMPILER_RT_BUILD_BUILTINS:BOOL=OFF -DCOMPILER_RT_BUILD_SANITIZERS:BOOL=OFF -DCOMPILER_RT_CAN_EXECUTE_TESTS:BOOL=OFF -DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=OFF -DCLANG_BUILD_EXAMPLES:BOOL=ON -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_C_FLAGS="-Wdocumentation -Wno-documentation-deprecated-sync" -DCMAKE_CXX_FLAGS="-std=c++11 -Wdocumentation -Wno-documentation-deprecated-sync" -DLLVM_LIT_ARGS="-v" ..
  • finally these lines start the build
Code:
# Ubuntu:
export PM=$(grep -c processor /proc/cpuinfo)
# OSX:
export PM=4

make -j${PM}
make install -j${PM}
  • build time will vary based on your PC specs
    • My Ryzen 7 1700 took ~20mins on 16 threads
    • My Macbook Air i5 took ~an hour on 4 threads
Building binutils From Source
  • the following few lines will clone, setup build, build and install binutils to your PS4SDK
Code:
cd $PS4SDK/EXPT
git clone git://sourceware.org/git/binutils-gdb.git binutils
cd binutils
./configure --prefix="$PS4SDK/usr" --target="x86_64-pc-freebsd9" \
   --disable-nls \
   --disable-dependency-tracking \
   --disable-werror \
   --enable-ld \
   --enable-lto \
   --enable-plugins \
   --enable-poison-system-directories
make
make install
  • next you'd just need to rename ld to orbis-ld and have a copy in ./usr/bin/
    • (I wouldn't recommend copying bins to /usr/bin manually in your regular setup but since this is a standalone isolated from system bins there isn't much harm to be done)
Code:
cd $PS4SDK/usr/x86_64-pc-freebsd9/bin
cp ld orbis-ld
cp -R $PS4SDK/usr/x86_64-pc-freebsd9/lib/ $PS4SDK/usr/lib/
cp -R $PS4SDK/usr/x86_64-pc-freebsd9/bin/* $PS4SDK/usr/bin/
Setting up the *** - Final Setup
  • check that you're using the correct clang by typing clang -v in the terminal and you should get something like this
clang version 6.0.0 (http://llvm.org/git/clang.git ca559e03cc2cedb2c76340f055f784dddac9f83f) (http://llvm.org/git/llvm.git f8e00e2dc29429bf81f0e437c7e96750f05d62f5)
Target: x86_64-scei-ps4
Thread model: posix
InstalledDir: /home/zer0/ps4sdk//usr/bin
  • Note Target: x86_64-scei-ps4
    • if you didn't get that type PATH=$PS4SDK/usr/bin:$PATH and try again
  • if everything checks out continue with cd $PS4SDK then make -j{PM}
    • Ubuntu: there is no harm in running export PM=$(grep -c processor /proc/cpuinfo) again to make sure it's set before calling make -j{PM}

    • OSX: export PM=4 then callmake -j{PM}

    • give it few minutes and you're all set
Start building with ***

you can do this directly with Makefile or CMake.
My personal advise is cmake
  • cmake
    • instructions have been posted in this article and you can skip to "download PS4-CMake-Toolchain" under "How-To-Use"
  • Makefile
    • Hito has provided few sample projects for us here that you can have a look at
    • but to summaries
      • create a folder for your project e.g PS4Test
      • download this Makefile and place it inside PS4Test
      • create folders include and source inside PS4Test
      • place your headers into include and your code into source
      • Note: if you're using Makefile, you'd need to call PATH=$PS4SDK/usr/bin:$PATH everytime you start your shell terminal to make sure make picks the correct compiler
        • you could set it up like we did earlier for PS4SDK but I highly advise against it, as it can break your native build system
Thanks

Thanks to bigboss, as this post is directly based on his instructions.

You can always contact me @Zer0xFF if you have any queries, questions or concerns.

PS4SDKs & Setup Tutorial for PS4 Homebrew Development by Zer0xFF.jpg
 
Status
Not open for further replies.
Back
Top