Neo TeAm Forum

The 10th. NEO Project for N64 => The 10th. NEO Project for N64 Dev kit. => N64 development section => Topic started by: ChillyWilly on January 20, 2010, 01:32:06 PM

Title: N64 Development Tools
Post by: ChillyWilly on January 20, 2010, 01:32:06 PM
Okay, if you want to work on N64 homebrew, you need decent tools. You need a compiler, and some libraries. I just finished making an up-to-date toolchain, using it to compile a few libraries and scummvm as a test.

This is the big one - the toolchain. This is gcc 4.4.2 with bintools 2.20. It's compiled for x86 under Xubuntu 9.04, but it should work on any reasonably recent distro in 32 or 64 bits. It has a few libraries already in the SDK directory - namely, the ones needed to compile scummvm.
n64dev-20100119.7z (http://www.fileden.com/files/2009/2/3/2304902/n64dev-20100119.7z)

It's organize like most of my toolchains - copy the n64dev directory to wherever you want it, and set a few envvars before using it.

Code: [Select]
export N64DEV=/home/jlfenton/Tools/n64dev
export PATH=$N64DEV/mips64/bin:$N64DEV/bin:$PATH
export LD_LIBRARY_PATH=$N64DEV/mips64/bin

Obviously, you'd change the path to n64dev to wherever you copied it. Here's the source for the libraries included so far.

libn64-20100119.zip (http://www.fileden.com/files/2009/2/3/2304902/libn64-20100119.zip)
tremor-20100119.zip (http://www.fileden.com/files/2009/2/3/2304902/tremor-20100119.zip)
zlib-20100119.zip (http://www.fileden.com/files/2009/2/3/2304902/zlib-20100119.zip)

As I add more libraries, they'll get added to this post. The normal way to compile these is to do

Code: [Select]
make
make install

If there is a Makefile.n64 file present, then do

Code: [Select]
make -f Makefile.n64
make install -f Makefile.n64

If you wish to build your own toolchain, here's the makefile I made to do that. It's derived from the makefile used to build the toolchain for the Dreamcast.

make-tools-20100119.zip (http://www.fileden.com/files/2009/2/3/2304902/make-tools-20100119.zip)

Note: each library will have it's own license. Please abide by them. For example, the libn64 library is GPL v3. You cannot use it for closed source programs. I can use it for the menu because, like most other code here, the menu is MIT licensed, which is compatible with the GPL license. If you aren't sure what is or is not compatible, consult the GNU page on the matter.

http://www.gnu.org/licenses/license-list.html

If you want an example of making a major app with this, look at scummvm. First checkout the latest code from their repo.

Code: [Select]
svn co https://scummvm.svn.sourceforge.net/svnroot/scummvm scummvm
You'll find most of the N64 code in "backends/platforms/n64". I changed the Makefile just a smidgen to work with the layout of my toolchain. The makefile I used to compile scummvm is:

Code: [Select]
TOOLPATH = $(N64DEV)/mips64
LIBN64PATH = $(TOOLPATH)/sdk
GCCN64PREFIX = $(TOOLPATH)/bin/

srcdir = ../../..
VPATH = $(srcdir)

CC = $(GCCN64PREFIX)gcc
CXX = $(GCCN64PREFIX)g++
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)g++
OBJCOPY = $(GCCN64PREFIX)objcopy
AR = $(GCCN64PREFIX)ar cru
RANLIB = $(GCCN64PREFIX)ranlib

DEFINES += -D__N64__ -DLIMIT_FPS -DNONSTANDARD_PORT -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE \
-DDISABLE_COMMAND_LINE -DDISABLE_FANCY_THEMES -DDISABLE_DOSBOX_OPL -DENABLE_VKEYBD -DUSE_ZLIB
LIBS += -lpakfs -lframfs -ln64 -ln64utils -lromfs

DEFINES += -D_ENABLE_DEBUG_
#DEFINES += -D_NORMAL_N64_DELAY_

USE_LIBMAD=0
USE_LIBOGG=1

ifeq ($(USE_LIBMAD),1)
DEFINES += -DUSE_MAD
LIBS += -lmad
endif
ifeq ($(USE_LIBOGG), 1)
DEFINES += -DUSE_VORBIS -DUSE_TREMOR
LIBS += -lvorbisidec
endif

LIBS += -lm -lstdc++ -lc -lgcc -lz -lnosys

CXXFLAGS = -g -O2 -fomit-frame-pointer -march=vr4300 -mtune=vr4300 -mno-extern-sdata -fno-rtti -fno-exceptions \
-Wno-multichar -Wshadow -I$(LIBN64PATH)/include -I$(TOOLPATH)/include -I./ -I$(srcdir) -I$(srcdir)/engines
LDFLAGS = -g -march=vr4300 -mtune=vr4300 -nodefaultlibs -nostartfiles -mno-crt0 \
-L$(LIBN64PATH)/lib -L$(TOOLPATH)/lib $(LIBS) -T $(TOOLPATH)/lib/n64ld_cpp.x -Xlinker -Map -Xlinker scummvm.map

TARGET = scummvm
DEPDIR = .deps
CXX_UPDATE_DEP_FLAG = -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP
MKDIR = mkdir -p
RM = rm -f
RM_REC = rm -rf

VERBOSE_BUILD=0
HAVE_GCC3=1
DISABLE_SCALERS=1
DISABLE_HQ_SCALER=1
USE_MT32EMU=0
USE_RGB_COLOR=0

ENABLED=STATIC_PLUGIN

#ENABLE_SCUMM = $(ENABLED)
#ENABLE_SCUMM_7_8 = $(ENABLED)
#ENABLE_HE = $(ENABLED)
#ENABLE_AGI = $(ENABLED)
#ENABLE_AGOS = $(ENABLED)
#ENABLE_AGOS2 = $(ENABLED)
#ENABLE_CINE = $(ENABLED)
#ENABLE_CRUISE = $(ENABLED)
#ENABLE_DRACI = $(ENABLED)
#ENABLE_DRASCULA = $(ENABLED)
#ENABLE_GOB = $(ENABLED)
#ENABLE_GROOVIE = $(ENABLED)
#ENABLE_GROOVIE2 = $(ENABLED)
#ENABLE_IHNM = $(ENABLED)
#ENABLE_KYRA = $(ENABLED)
#ENABLE_LOL = $(ENABLED)
ENABLE_LURE = $(ENABLED)
#ENABLE_M4 = $(ENABLED)
#ENABLE_MADE = $(ENABLED)
#ENABLE_PARALLACTION = $(ENABLED)
#ENABLE_QUEEN = $(ENABLED)
#ENABLE_SAGA = $(ENABLED)
#ENABLE_SAGA2 = $(ENABLED)
#ENABLE_SCI = $(ENABLED)
#ENABLE_SCI32 = $(ENABLED)
ENABLE_SKY = $(ENABLED)
#ENABLE_SWORD1 = $(ENABLED)
#ENABLE_SWORD2 = $(ENABLED)
#ENABLE_TEENAGENT = $(ENABLED)
#ENABLE_TINSEL = $(ENABLED)
#ENABLE_TOUCHE = $(ENABLED)
#ENABLE_TUCKER = $(ENABLED)

OBJS := nintendo64.o osys_n64_base.o osys_n64_events.o osys_n64_utilities.o pakfs_save_manager.o framfs_save_manager.o

include $(srcdir)/Makefile.common

MODULE_DIRS += ./

all: $(TARGET).v64

$(TARGET).v64: $(TARGET).bin ROMFS.img bootcode
cat bootcode $(TARGET).bin ROMFS.img > $(TARGET).v64
./pad_rom.sh

ROMFS.img:
genromfs -f ./ROMFS.img -d ./ROMFS -V romtest

$(TARGET).elf: $(OBJS)
$(LD) -o $(TARGET).elf $(OBJS) $(LDFLAGS)

$(TARGET).bin : $(TARGET).elf
$(OBJCOPY) $(TARGET).elf $(TARGET).bin -O binary

spotless : distclean
$(RM) *.bin *.elf *.v64 *.img *.bak *.tmp *.map

The finished result ran fine on my N64 Myth. If you want to learn more about scummvm, visit their web page at:
http://www.scummvm.org/
Title: Re: N64 Development Tools
Post by: Dr.neo on January 20, 2010, 02:54:32 PM
nice info mate  ~sm-37.gif~
Title: Re: N64 Development Tools
Post by: wraggster on January 20, 2010, 05:00:06 PM
awesome, i personally cant wait to see if anyone will port any emulators/games to the N64.

I know theres Snes, Nes, GB, GG/SMS and MSX Emulators, i must actually try them too, but it would be awesome to see whats doable on the N64.

I wish i was a coder, i would have a go at porting stuff myself
Title: Re: N64 Development Tools
Post by: wraggster on January 20, 2010, 05:04:05 PM
With all these new carts that Neoflash are releasing i personally think that maybe the coders competitions should incorporate comps for n64/pce engine/snes/ds/gba and maybe even dump the PSP
Title: Re: N64 Development Tools
Post by: Conle on January 20, 2010, 05:08:39 PM
Thanks for this ChillyWilly! ::sm-24.gif::
I was waiting silently to release your full setup  ~sm-43.gif~ ~sm-42.gif~
Title: Re: N64 Development Tools
Post by: Conle on January 20, 2010, 11:48:44 PM
Okay i will contribute first!

Here are 3 of my libraries :

ELIB - Event library v2.0 ( An advanced & Function stackless event library with exclusive/signal callback support)

LIB Utility v1.1 - Contains all low level support code , like string handling& parsing/comparisons/Binary utilities and everything that you will  ever need.
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

LIB IO V1.0 - A very portable IO library
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

All my libraries don't require any linked library at all. 8)
(Except LIB IO , which is up to you!)

Edit : http://www.neoflash.com/forum/index.php/topic,5962.0.html
Title: Re: N64 Development Tools
Post by: ChillyWilly on January 21, 2010, 02:03:34 AM
Okay i will contribute first!

Here are 3 of my libraries :

ELIB - Event library v2.0 ( An advanced & Function stackless event library with exclusive/signal callback support)

LIB Utility v1.1 - Contains all low level support code , like string handling& parsing/comparisons/Binary utilities and everything that you will  ever need.
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

LIB IO V1.0 - A very portable IO library
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

All my libraries don't require any linked library at all. 8)
(Except LIB IO , which is up to you!)

Nice! Higher level libraries make the programmer's job easier as well. I was hoping you'd have those ready. Now to combine everything together to get the skeleton code for the menu going. Then we can work it into a working product.
 :D

Do you think these libs should go in the opening post, or do we want higher level libraries in their own thread/post?
Title: Re: N64 Development Tools
Post by: Conle on January 21, 2010, 02:25:05 AM
Do you think these libs should go in the opening post, or do we want higher level libraries in their own thread/post?

I believe a separate thread strictly for releases(tools/libraries/code snippets/docs) would be much better in order to keep this thread clean from related questions/requests/etc.
Title: Re: N64 Development Tools
Post by: ChillyWilly on January 21, 2010, 03:20:47 AM
I believe a separate thread strictly for releases(tools/libraries/code snippets/docs) would be much better in order to keep this thread clean from related questions/requests/etc.

Sounds good. Cleaner is better for tech threads.  8)
Title: Re: N64 Development Tools
Post by: Conle on January 21, 2010, 03:51:41 AM
Sounds good. Cleaner is better for tech threads.  8)
:D

By the way , i will release LIB Util v1.2 tomorrow , since i have to provide interface code for :
-Whitespace detection
-Whitespace skipping
-Int <-> String conversions

Of course all these without using any library at all.
Title: Re: N64 Development Tools
Post by: ChillyWilly on January 21, 2010, 03:58:03 AM
By the way , i will release LIB Util v1.2 tomorrow , since i have to provide interface code for :
-Whitespace detection
-Whitespace skipping
-Int <-> String conversions

Nice! I'll probably still be hammering out code, so it's not a problem. When you have it ready tomorrow, start a new sticky thread for libraries and stuff.
Title: Re: N64 Development Tools
Post by: Conle on January 21, 2010, 04:11:16 AM
Nice! I'll probably still be hammering out code, so it's not a problem. When you have it ready tomorrow, start a new sticky thread for libraries and stuff.


Okay i will do it  ~sm-42.gif~
If you need anything specific to add let me know. ::sm-29.gif::
Title: Re: N64 Development Tools
Post by: mic_ on January 25, 2010, 04:27:08 PM
Quote
It's compiled for x86 under Xubuntu 9.04, but it should work on any reasonably recent distro in 32 or 64 bits.
I run this little distro called Windows.. doesn't seem to be supported.  ;)
Title: Re: N64 Development Tools
Post by: ChillyWilly on January 26, 2010, 02:44:26 AM
I run this little distro called Windows.. doesn't seem to be supported.  ;)

Nope! I suggest using linux in a virtual environment if you just have to stick with Windows. Another thing you could do is set up an old system with linux - that's what I do with Windows: my main system is linux and the old system gets XP.
 ::sm-29.gif::

Your other choice is to hunt around the net for a Windows cross-compiler for MIPS that isn't a hundred years old.
Title: Re: N64 Development Tools
Post by: mic_ on January 26, 2010, 03:04:41 AM
Yeah, I've already got a PSP toolchain for Windows. Just thought I'd point out that far from everyone runs Linux.
Title: Re: N64 Development Tools
Post by: Conle on January 26, 2010, 03:10:04 AM

Linux won yet another fight 8)
Title: Re: N64 Development Tools
Post by: the|Gamer on January 26, 2010, 03:44:29 AM
BTW what do you think is Linux on the N64 possible :D
I mean text based?
Title: Re: N64 Development Tools
Post by: Conle on January 27, 2010, 03:13:11 PM
BTW what do you think is Linux on the N64 possible :D
I mean text based?


Yes it is possible.
Also with graphics its possible with ram expansion even if the n64 has
unified memory architecture.
There are some techniques to make textures smaller in size when you upload them to the video ram.I think its called "pixel swizzling".
So yes, with "pixel swizzling" & conversion to 8bit textures you can have a lot of room for a full port with graphics.

But better wait for ChillyWilly's reply if you want more accurate answer.
 ::sm-29.gif::
Title: Re: N64 Development Tools
Post by: ChillyWilly on January 29, 2010, 01:59:09 AM
I seem to remember a site on trying to get linux running on the N64. Didn't look into that too much as I'm more concerned with the menu right now. Given the memory constraints of the N64, linux might not be a good choice. Something more memory efficient like AROS might be better. If you really want linux, you could probably get a 2.2 kernel running on it. Once there's SD card support for the N64 Myth, that might be a good time to experiment with it.
Title: Re: N64 Development Tools
Post by: sanni on March 29, 2010, 07:55:43 PM
I've found a book called "The C Programming Language Second Edition", it seems to be ok.
First thing to do is:
Code: [Select]
#include <studio.h>
main()
{
printf("hello, world\n");
}

I also downloaded xubuntu-9.04 and installed it on VMWare. Then I placed your toolchain in my Home directory and typed the envvars into the commandline.
I saved above code to hello.c and typed: gcc hello.c
It made a file called a.out which I can run in the commandline via ./a.out

It doesn't run on my N64. I have to somehow convert it to a rom that has a header and so on.  ~sm-64.gif~.gif
Does anybody know how to do this?
Title: Re: N64 Development Tools
Post by: the|Gamer on March 29, 2010, 08:08:25 PM
Hohoho something intresting:

http://anythinglinux.blogspot.com/2007/05/n64-linux-project.html
Title: Re: N64 Development Tools
Post by: Conle on March 29, 2010, 08:45:20 PM
I've found a book called "The C Programming Language Second Edition", it seems to be ok.
First thing to do is:
Code: [Select]
#include <studio.h>
main()
{
printf("hello, world\n");
}

I also downloaded xubuntu-9.04 and installed it on VMWare. Then I placed your toolchain in my Home directory and typed the envvars into the commandline.
I saved above code to hello.c and typed: gcc hello.c
It made a file called a.out which I can run in the commandline via ./a.out

It doesn't run on my N64. I have to somehow convert it to a rom that has a header and so on.  ~sm-64.gif~.gif
Does anybody know how to do this?


This will not work on other platform but PC.

To use this with n64 you must use the N64 sdk , initialize the HW , then initialize the video & load up the font , then you can print some text.
Also you need a proper loop otherwise your app will exit before you can see anything  ~sm-67.gif~.gif
Title: Re: N64 Development Tools
Post by: sanni on April 05, 2010, 07:36:59 AM
I'm happy  ::sm-18.gif::

(http://www.abload.de/img/helloww1sf.jpg)

I found everything I needed in the test.v64 demo app for libdragon (http://www.dragonminded.com/?loc=n64dev/libdragon).  ::sm-22.gif::
Title: Re: N64 Development Tools
Post by: ChillyWilly on April 05, 2010, 07:49:40 AM
Nice find! Now we have a couple of different devkits to work from.  ~sm-76.gif~.gif
Title: Re: N64 Development Tools
Post by: ChillyWilly on April 28, 2010, 12:25:23 PM
I found everything I needed in the test.v64 demo app for libdragon (http://www.dragonminded.com/?loc=n64dev/libdragon).  ::sm-22.gif::

You should have mentioned the changes needed to make this devkit work. The libs are compiled at the wrong optimization level, the mkdfs tool doesn't work on PCs due to endian issues, and the examples use the wrong address for the embedded dfs file.

Here's a properly altered version that actually works.
libdragon-src-20100427.zip (http://www.fileden.com/files/2009/2/3/2304902/libdragon-src-20100427.zip)
libdragon-20100427.7z (http://www.fileden.com/files/2009/2/3/2304902/libdragon-20100427.7z)

So now I have two devkits - hkz's libn64 (in the opening post), and libdragon.  8)
Title: Re: N64 Development Tools
Post by: Conle on April 28, 2010, 07:06:53 PM
Excellent!!  :D  ;D
Title: Re: N64 Development Tools
Post by: sanni on April 29, 2010, 03:52:25 AM
 :-\, thats why I can't get the code samples to run on my N64.
I tried 3 different linuxes(ubuntu/xubuntu/mint) and also different versions of the libtools and gcc but couldn't get the filesystem to work, I though I messed up the compiling. Also wrote a email to the author but he never replied.

So thank you very much  :-* :-*
Now I will try to add an image to my allmighty hello world program  ~sm-59.gif~.gif  ~sm-79.gif~.gif
Title: Re: N64 Development Tools
Post by: ChillyWilly on April 29, 2010, 05:07:22 AM
Try the test proggy in the examples drawer and make sure it works. Then look at it as it shows how to make/use the dfs files.
Title: Re: N64 Development Tools
Post by: sanni on May 02, 2010, 07:48:52 AM
I've made you a game  ~sm-79.gif~.gif

You are a penguin and have to eat melons to gain energy, walking around will burn fat so you lose energy, if your energy drops below zero you're game over.

Controls:
DPAD - move
A Button - eat melons

Has more bugs than levels though  ~sm-66.gif~.gif

Edit:

Updated it  ~sm-57.gif~.gif
Now it has a Titlescreen and after you are Gameover you can restart without resetting the N64 and you also get more life depending how many times you died.
It has about 100 random levels.
Everytime you die and continue you will get a new set of 100 random levels, if you just reset the N64 nothing will change though.
So if you want you can always play the same 100 levels over on over.
Also you have now 1-9 melons to eat pro level.

Bugs:
- The "collision detection" sucks that bad that sometimes you will eat allmost all melons on the screen at once.
Title: Re: N64 Development Tools
Post by: ChillyWilly on May 02, 2010, 08:45:26 AM
Pretty slick, but you need a better random... the melon always appears in the same places from one game to the next.
Title: Re: N64 Development Tools
Post by: 64scener on May 03, 2010, 03:41:05 AM
haha... awesome :-)
Title: Re: N64 Development Tools
Post by: Conle on July 12, 2010, 02:46:39 PM
Here is libdragon compiled for 64bit : http://www.sendspace.com/file/090nbt  (95MB)
Without this you cant compile anything using the 32bit compiled version since it complains about libmpfr.so.1
 ~sm-57.gif~.gif
Title: Re: N64 Development Tools
Post by: DragonMinded on July 18, 2010, 02:51:40 PM
Not to be incredibly pedantic, but "libdragon" is simply the development library used to provide hardware support on the N64.  The toolchains are separate from that.  What you have provided is a pre-compiled version of the toolchain usable on 64-bit Linux systems that also includes the libdragon library and samples ready to use (nice touch on the bundle actually).  It is preferred if you simply submit a patch to the original buildscripts so that others may build their own 64 bit edition (not everyone is running a vanilla Linux install on x86).

Obligatory penguins that are marginally relevant:  ~sm-41.gif~  ~sm-58.gif~.gif
Title: Re: N64 Development Tools
Post by: Conle on July 18, 2010, 03:25:56 PM
Not to be incredibly pedantic, but "libdragon" is simply the development library used to provide hardware support on the N64.  The toolchains are separate from that.  What you have provided is a pre-compiled version of the toolchain usable on 64-bit Linux systems that also includes the libdragon library and samples ready to use (nice touch on the bundle actually).  It is preferred if you simply submit a patch to the original buildscripts so that others may build their own 64 bit edition (not everyone is running a vanilla Linux install on x86).

Obligatory penguins that are marginally relevant:  ~sm-41.gif~  ~sm-58.gif~.gif

Hi!

There is already a 32bit precompiled lib on the forums , so i thought to provide the 64bit also.
Regarding making a patch , its not actually needed. The only thing i had to do was to remove "-Werror" from
some of the tools that im not going to use for now , since they were failing to compile and the main script
was going crazy.The errors where actually conversion errors , like , here's a quick example :

This
Code: [Select]
mkdfs.c

/* Offset from start of filesystem */
inline int32_t sector_offset(void *sector)
{
    uint32_t x = (uint32_t)sector - (uint32_t)dfs;

    return x;
}

Must be changed to this:
Code: [Select]
/* Offset from start of filesystem */
inline int32_t sector_offset(void *sector)
{
    return  (int32_t)( ((uint32_t)sector) - ((uint32_t)dfs) );
}
Title: Re: N64 Development Tools
Post by: mic_ on August 23, 2010, 11:05:25 PM
Is there a reason why the prefixed (mips64-elf-) binaries aren't included in the toolchain zip? The bin directory contains 3 files (bin2c, bin2o and genromfs), while the mips64/bin directory contains the unprefixed gcc/binutils binaries.
Title: Re: N64 Development Tools
Post by: Conle on August 23, 2010, 11:20:05 PM
Is there a reason why the prefixed (mips64-elf-) binaries aren't included in the toolchain zip? The bin directory contains 3 files (bin2c, bin2o and genromfs), while the mips64/bin directory contains the unprefixed gcc/binutils binaries.

mic , check the latest libdragon update in the mailing list , uncomment the lines from the sh script(found in tools dir) that download and extract the proper libs
, set the install path , then run the script.

Now go 1 directory back , and do a: make && make install

To do all these you need a linux machine(Or a virtual machine like VirtualBox).You'd need to make a new sdk for windows in case you're trying to compile from win system.

ps -- We need a new thread with all the updates  :)
Title: Re: N64 Development Tools
Post by: mic_ on August 23, 2010, 11:22:18 PM
I'm doing this on a Linux machine obviously :P

I'll try the scripts you mentioned.
Title: Re: N64 Development Tools
Post by: mic_ on August 23, 2010, 11:31:10 PM
It fails to connect to sourceware.org during the downloading phase. It might because of the proxy server though (about which I can't do anything). I'll try again later on another machine.
Title: Re: N64 Development Tools
Post by: Conle on August 23, 2010, 11:34:34 PM
Here's all the necessary steps :

Edit /tools/build :

Code: [Select]
# EDIT THIS LINE TO CHANGE YOUR INSTALL PATH!
export INSTALL_PATH= INSTALL PATH HERE!

# Set up path for newlib to compile later
export PATH=$PATH:$INSTALL_PATH/bin

# Versions
export BINUTILS_V=2.19.51
export GCC_V=4.4.0
export NEWLIB_V=1.17.0

# Download stage
wget -c ftp://sourceware.org/pub/binutils/snapshots/binutils-$BINUTILS_V.tar.bz2
wget -c http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gcc/gcc-$GCC_V/gcc-$GCC_V.tar.gz
wget -c ftp://sources.redhat.com/pub/newlib/newlib-$NEWLIB_V.tar.gz

# Extract stage
tar -xvjf binutils-$BINUTILS_V.tar.bz2
tar -xvzf gcc-$GCC_V.tar.gz
tar -xvzf newlib-$NEWLIB_V.tar.gz

Now edit the makefiles in mksprite/,mkdfs/,dumpdfs/ and remove -Werror

And now run the script :
Code: [Select]
sh build


Go 1 directory back and export the installation path(You have to export this path everytime that you compile code):
Code: [Select]
export N64_INST=/home/username/n64dev/libdragon/mips64-elf

Finally make and install the libraries:
Code: [Select]
make
make install

You're all set now :)
Title: Re: N64 Development Tools
Post by: Conle on August 23, 2010, 11:35:30 PM
It fails to connect to sourceware.org during the downloading phase. It might because of the proxy server though (about which I can't do anything). I'll try again later on another machine.

Hmm , it must be your proxy for sure  :(
Title: Re: N64 Development Tools
Post by: Conle on August 23, 2010, 11:39:48 PM
Found some mirrors with a quick google search :

Binutils:
http://sources-redhat.mirrors.airband.net/binutils/snapshots/binutils-2.19.51.tar.bz2

Gcc 4.4.0:
http://ftp.gnu.org/gnu/gcc/gcc-4.4.0/gcc-4.4.0.tar.gz

newlib 1.17.0:
ftp://sources.redhat.com/pub/newlib/newlib-1.17.0.tar.gz

Now just comment back the download stage and just let the script to extract them.
Hope it works  ~sm-70.gif~.gif
Title: Re: N64 Development Tools
Post by: ChillyWilly on August 24, 2010, 03:54:55 AM
Is there a reason why the prefixed (mips64-elf-) binaries aren't included in the toolchain zip? The bin directory contains 3 files (bin2c, bin2o and genromfs), while the mips64/bin directory contains the unprefixed gcc/binutils binaries.

They are. You're looking in the wrong bin dir. It's the way I like to setup my toolchains: the root of the toolchain for a console has a bin directory with tools related to the toolchain, but not part of gcc. Then there is the gcc toolchain directory. When you look in that directory, you see the "normal" gcc toolchain layout.
Title: Re: N64 Development Tools
Post by: smccd on January 06, 2015, 08:26:04 PM
 ~sm-56.gif~.gif

I apologize for necroing an older thread, but it's the most relevant.

Has anyone compiled libdragon's /tools directory under windows? I'm having a great deal of trouble, and would appreciate if anyone who did posted a zip with the three (dumpdfs, mkdfs, mksprite).

Thanks in advance!!
Title: Re: N64 Development Tools
Post by: mic_ on January 06, 2015, 08:41:43 PM
If you have cygwin installed, building dumpdfs and mkdfs should be as simple as going to the respective directories and running "make".
Trying to make mksprite generates some build errors, and I'm not sure why. It could be that it relies on an old version of libpng.
Title: Re: N64 Development Tools
Post by: sanni on January 06, 2015, 10:09:53 PM
About the mksprite errors:
I figured out how to fix this... the issue resided in the Makefile. After some digging, I was able to make it compile with this makefile:

Code: [Select]
INSTALLDIR = $(N64_INST)
CFLAGS = -std=gnu99 -O2 -Wall -I../../include -lpng

all: mksprite convtool

mksprite: mksprite.c
$(CC) $< -o $@ $(CFLAGS)

convtool: convtool.c
$(CC) $< -o $@ $(CFLAGS)

install: mksprite convtool
install -D --mode=755 mksprite $(INSTALLDIR)/bin
install -D --mode=755 convtool $(INSTALLDIR)/bin

.PHONY: clean install

clean:
rm -rf mksprite
rm -rf convtool


Basically, remove -Werror from the CFLAGS variable and add the lines under mksprite and convtool.


That way I could compile them without error but they still don't want to work for me somehow

Quote

C:\devKitN64\libdragon\tools>make
make -C dumpdfs
make[1]: Entering directory `/c/devKitN64/libdragon/tools/dumpdfs'
cc -std=gnu99 -O2 -Wall -I../../include    dumpdfs.c   -o dumpdfs
make[1]: Leaving directory `/c/devKitN64/libdragon/tools/dumpdfs'
make -C mkdfs
make[1]: Entering directory `/c/devKitN64/libdragon/tools/mkdfs'
cc -std=gnu99 -O2 -Wall -Werror -I../../include    mkdfs.c   -o mkdfs
make[1]: Leaving directory `/c/devKitN64/libdragon/tools/mkdfs'
make -C mksprite
make[1]: Entering directory `/c/devKitN64/libdragon/tools/mksprite'
cc mksprite.c -o mksprite -std=gnu99 -O2 -Wall -I../../include -lpng
cc convtool.c -o convtool -std=gnu99 -O2 -Wall -I../../include -lpng
convtool.c: In function 'main':
convtool.c:15:9: warning: variable 'ret' set but not used [-Wunused-but-set-vari
able]
     int ret;
         ^
make[1]: Leaving directory `/c/devKitN64/libdragon/tools/mksprite'
gcc -o chksum64 chksum64.c
gcc -o n64tool n64tool.c

C:\devKitN64\libdragon\tools>

When I tried to compile a rom I get the following error then:
Quote
C:\devKitN64\libdragon\examples\dfsdemo>make clean
rm -f *.v64 *.elf *.o *.bin *.dfs

C:\devKitN64\libdragon\examples\dfsdemo>make
C:/devKitN64/mips64-elf/bin/mips64-elf-gcc -std=gnu99 -march=vr4300 -mtune=vr430
0 -O2 -G0 -Wall -Werror -IC:/devKitN64/mips64-elf/include -IC:/devKitN64/mips64-
elf/mips64-elf/include   -c -o dfsdemo.o dfsdemo.c
C:/devKitN64/mips64-elf/bin/mips64-elf-ld -o dfsdemo.elf dfsdemo.o -G0 -LC:/devK
itN64/mips64-elf/lib -LC:/devKitN64/mips64-elf/mips64-elf/lib -ldragon -lmikmod
-lc -lm -ldragonsys -Tn64ld.x
C:/devKitN64/mips64-elf/bin/mkdfs test.dfs ./filesystem/
Adding './filesystem/aurora.mod' to filesystem image.
Adding './filesystem/BUTTERFL.XM' to filesystem image.
Adding './filesystem/CTGOBLIN.S3M' to filesystem image.
Adding './filesystem/resonance2.mod' to filesystem image.
Adding './filesystem/squired.xm' to filesystem image.
Adding './filesystem/SUNDANCE.MOD' to filesystem image.
C:/devKitN64/mips64-elf/bin/mips64-elf-objcopy dfsdemo.elf dfsdemo.bin -O binary

rm -f dfsdemo.v64
C:/devKitN64/mips64-elf/bin/n64tool -b -l 8M -t "DragonFS Demo" -h C:/devKitN64/
mips64-elf/lib/header -o dfsdemo.v64 dfsdemo.bin -s 1M test.dfs
Couldn't pad image!
C:/devKitN64/mips64-elf/bin/chksum64 dfsdemo.v64
CHKSUM64 V1.2   Copyright (C) 1997 Andreas Sterbenz (stan@sbox.tu-graz.ac.at)
This program is released under the terms of the GNU public license. NO WARRANTY

The image 'dfsdemo.v64' is in V64 (byte-swapped) format.
Old Checksum:        ED 42 A2 D4  7A 71 CD 91
Calculated Checksum: 56 4D F1 7B  E3 8A 8E CB
New checksum successfully written.

C:\devKitN64\libdragon\examples\dfsdemo>

And the rom can't access the filesystem. The Linux toolchain works though.

Anyway, here are the compiled tools, maybe someone can figure out what I am doing wrong

Title: Re: N64 Development Tools
Post by: Conle on January 06, 2015, 11:04:54 PM
Regarding the n64tool's error that trashes the image after the hdr+bin are merged ,try to replace output_zeros in n64tool with this (it  makes absolutely no sense for that function to expect alignment
 since the input is already the required bytes to pad the size! ...bad naming...) :

Code: [Select]
int output_zeros(FILE* f,int amount) {
for (;amount > 0;--amount)
fputc(0,f);

return 0;
}

For example , imagine the case of sizeof(hdr+bin) being aligned , then merged with unaligned fs data , resulting in non aligned remainder , which
makes the code to jump to this case:
Quote
if(amount & 3 != 0)
{
/* Don't support odd word alignments */
return -1;
}

All calls to that function expect (int)0 for positive result , without explicit statement in the comparison , which may result in different code for the jump instruction being generated between different gcc versions....



Title: Re: N64 Development Tools
Post by: sanni on January 08, 2015, 11:40:24 PM
Did some more testing, it seems like the culprit is mkdfs. I compiled the same libdragon dfsdemo example both with my Windows and Linux setup.

The testfile that goes into the filesystem folder is 660KB. The resulting dfs file compiled in Linux is 672KB and when I compile the example in Windows it's only 4KB. So yeah, that sure won't work.
In Linux I compiled the mkdfs executable with gcc 4.8.2 and in Windows with gcc 4.8.1.

Maybe it simply doesn't like Windows 8.1 x64  ~sm-73.gif~.gif
Title: Re: N64 Development Tools
Post by: Conle on January 09, 2015, 02:56:41 AM
Did some more testing, it seems like the culprit is mkdfs. I compiled the same libdragon dfsdemo example both with my Windows and Linux setup.

The testfile that goes into the filesystem folder is 660KB. The resulting dfs file compiled in Linux is 672KB and when I compile the example in Windows it's only 4KB. So yeah, that sure won't work.
In Linux I compiled the mkdfs executable with gcc 4.8.2 and in Windows with gcc 4.8.1.

Maybe it simply doesn't like Windows 8.1 x64  ~sm-73.gif~.gif

2 things to check:
1.
Can you try to replace all sector calculations on pointers with ptrdiff_t instead uint32_t  or either do the calculations on actual pointers and then return the typecasted diff?
I find it odd that the author decided to use actual malloc'd pointers typecasted to u32 then return the difference between segments....

2.Directory separator code handling for windows build is missing(actually there's no win build :P ) ...Check add_directory function