Skip to content

Commit

Permalink
fix toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
ariahiro64 committed Sep 23, 2021
1 parent aa1af6a commit d407f16
Show file tree
Hide file tree
Showing 82 changed files with 469 additions and 94 deletions.
7 changes: 7 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@
*properties.json
/.vs
/.vscode

/toolchain/*
/lib/*
/include/*
/temp
*.zip
toolchain/
102 changes: 63 additions & 39 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,61 +1,85 @@
#
# Copyright (c) 2017 The Altra64 project contributors
# Copyright (c) 2020 The Altra64 project contributors
# See LICENSE file in the project root for full license information.
#

ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
CHKSUM64PATH = $(ROOTDIR)/bin/chksum64
MKDFSPATH = $(ROOTDIR)/bin/mkdfs
N64TOOL = $(ROOTDIR)/bin/n64tool
ifdef SystemRoot
FIXPATH = $(subst /,\,$1)
RM = DEL /Q
else
FIXPATH = $1
RM = rm -f
endif

ROOTDIR = $(CURDIR)
SRCDIR = $(ROOTDIR)/src
OBJDIR = $(ROOTDIR)/obj
BINDIR = $(ROOTDIR)/bin
LIBDIR = $(ROOTDIR)/lib
RESDIR = $(ROOTDIR)/res

CHKSUM64 = $(ROOTDIR)/toolchain/libdragon/tools/chksum64.exe
MKDFS = $(ROOTDIR)/toolchain/libdragon/tools/mkdfs.exe
N64TOOL = $(ROOTDIR)/toolchain/libdragon/tools/n64tool.exe

HEADERNAME = header.ed64
HEADERTITLE = "EverDrive OS"
PROG_NAME = OS64P

SRCDIR = ./src
INCDIR = ./inc
RESDIR = ./res
OBJDIR = ./obj
BINDIR = ./bin
TOOLSDIR = ./tools
INCLUDE_DIRS = -I$(ROOTDIR)/inc -I$(ROOTDIR)/include -I$(ROOTDIR)/toolchain/gcc-toolchain-mips64/include -I$(ROOTDIR)/toolchain/gcc-toolchain-mips64/mips64-elf/include -I$(ROOTDIR)/toolchain/libdragon/include

LINK_FLAGS = -O1 -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lmad -lyaml -lc -lm -ldragonsys -lnosys $(LIBS) -Tn64.ld
PROG_NAME = OS64
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O1 -I$(INCDIR) -I$(ROOTDIR)/include -I$(ROOTDIR)/mips64-elf/include -lpthread -lrt -D_REENTRANT -DUSE_TRUETYPE $(SET_DEBUG)
COMMON_FLAGS = -std=gnu17 -march=vr4300 -mtune=vr4300 -Wall -Wrestrict -Wno-pointer-sign -D_REENTRANT -DUSE_TRUETYPE $(INCLUDE_DIRS) $(SET_DEBUG)
COMMON_FLAGS += -DED64PLUS
FLAGS_VT = -O0 $(COMMON_FLAGS)
FLAGS = -O2 $(COMMON_FLAGS)
ASFLAGS = -mtune=vr4300 -march=vr4300
CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
LINK_FLAGS = -G0 -L$(ROOTDIR)/lib -L$(ROOTDIR)/toolchain/gcc-toolchain-mips64/mips64-elf/lib -L$(ROOTDIR)/toolchain/libdragon/lib -ldragon -lmad -lyaml -lm -lc -ldragonsys -Tn64ld.x

GCCN64PREFIX = $(ROOTDIR)/toolchain/gcc-toolchain-mips64/bin/mips64-elf-
CC = $(GCCN64PREFIX)gcc.exe
AS = $(GCCN64PREFIX)as.exe
LD = $(GCCN64PREFIX)ld.exe
OBJCOPY = $(GCCN64PREFIX)objcopy

SOURCES := $(wildcard $(SRCDIR)/*.c)
OBJECTS = $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)

$(PROG_NAME).v64: $ $(PROG_NAME).elf $(PROG_NAME).dfs
$(OBJCOPY) $(BINDIR)/$(PROG_NAME).elf $(BINDIR)/$(PROG_NAME).bin -O binary
rm -f $(BINDIR)/$(PROG_NAME).v64
$(N64TOOL) -l 4M -t $(HEADERTITLE) -h $(RESDIR)/$(HEADERNAME) -o $(BINDIR)/$(PROG_NAME).v64 $(BINDIR)/$(PROG_NAME).bin -s 1M $(BINDIR)/$(PROG_NAME).dfs
$(CHKSUM64PATH) $(BINDIR)/$(PROG_NAME).v64
SRC = $(wildcard $(SRCDIR)/*.c)

OBJ = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))

all: $(PROG_NAME).v64

release: $(PROG_NAME).v64

$(PROG_NAME).elf : $(OBJECTS)
@mkdir -p $(BINDIR)
$(LD) -o $(BINDIR)/$(PROG_NAME).elf $(OBJECTS) $(LINK_FLAGS)
debug: SET_DEBUG=-DDEBUG
debug: $(PROG_NAME).v64

send: $(PROG_NAME).v64
$(TOOLSDIR)/up.bat

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@

copy: $(PROG_NAME).v64
sh $(TOOLSDIR)/upload.sh
$(PROG_NAME).v64: $(PROG_NAME).elf $(PROG_NAME).dfs
$(OBJCOPY) $(BINDIR)/$(PROG_NAME).elf $(BINDIR)/$(PROG_NAME).bin -O binary
$(N64TOOL) -l 4M -t $(HEADERTITLE) -h $(RESDIR)/$(HEADERNAME) -o $(BINDIR)/$(PROG_NAME).v64 $(BINDIR)/$(PROG_NAME).bin -s 1M $(BINDIR)/$(PROG_NAME).dfs
$(CHKSUM64) $(BINDIR)/$(PROG_NAME).v64

$(PROG_NAME).elf : $(OBJ) $(OBJS)
$(LD) -o $(BINDIR)/$(PROG_NAME).elf $(OBJ) $(OBJS) $(LINK_FLAGS)

$(PROG_NAME).dfs:
$(MKDFSPATH) $(BINDIR)/$(PROG_NAME).dfs $(RESDIR)/filesystem/
$(MKDFS) $(BINDIR)/$(PROG_NAME).dfs $(RESDIR)/filesystem/

all: $(PROG_NAME).v64
$(OBJDIR)/gscore.o: $(SRCDIR)/gscore.c
$(CC) $(FLAGS_VT) -c $(SRCDIR)/gscore.c -o $(OBJDIR)/gscore.o

debug: $(PROG_NAME).v64
$(OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(FLAGS) -c $< -o $@

debug: SET_DEBUG=-DDEBUG
$(OBJDIR)/%.o : $(SRCDIR)/%.s
$(AS) $(ASFLAGS) $< -o $@


clean:
rm -f $(BINDIR)/*.v64 $(BINDIR)/*.elf $(OBJDIR)/*.o $(BINDIR)/*.bin $(BINDIR)/*.dfs
$(info "Cleaning $(PROG_NAME)...")
@$(RM) $(call FIXPATH,$(BINDIR)/$(PROG_NAME).v64)
@$(RM) $(call FIXPATH,$(BINDIR)/$(PROG_NAME).bin)
@$(RM) $(call FIXPATH,$(BINDIR)/$(PROG_NAME).elf)
@$(RM) $(call FIXPATH,$(OBJ))
29 changes: 5 additions & 24 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,13 @@ originally written by saturnu, and released on the
[Everdrive64 forum](http://krikzz.com/forum/index.php?topic=816.0).

## Building

If you want to build the menu, you need an n64 toolchain. When using windows 10 or Ubuntu, installation is totally automated through a script.

### Dependencies (installed automatically)
* Windows 10 (Aniversary Update or above) / Ubuntu 16.04 (or above)
* [libdragon](https://github.com/DragonMinded/libdragon)
* [libmikmod (with n64 driver)](https://github.com/networkfusion/libmikmod)
* [libmad-n64](https://github.com/networkfusion/libmad-n64)
* [libyaml](http://pyyaml.org/wiki/LibYAML)

### Build the Toolchain

*You may skip this step if it's already installed.*

Clone this `Altra64` repo to a directory of your choice.

On Windows 10:
* Ensure that ["Windows Subsystem For Linux (Ubuntu)"](https://msdn.microsoft.com/en-gb/commandline/wsl/install_guide) is installed.
* browse to the tools directory and double click on ```setup-wsfl.cmd```.

On Ubuntu, browse to the tools directory and run the command ```$ chmod +x ./setup-linux.sh;source ./setup-linux.sh```


### Build `Altra64`
If this is the first time building, ensure you create the following folders in the root directory `bin` `obj` and `lib`
To install the dependencies run: `update-libs.ps1`

To build the Rom
To build the ROM

from the projects root directory,
On Windows 10 run
Expand All @@ -44,7 +25,7 @@ on linux
```
$ make
```
If it all worked, you will find `OS64.v64` in the `Altra64` bin directory.
If it all worked, you will find `OS64P.V64` in the `Altra64` bin directory.

### Debug Build `Altra64`
To build the debug version of the Rom
Expand All @@ -58,7 +39,7 @@ on linux
```
$ make debug
```
If it all worked, you will find `OS64.v64` in the `Altra64` bin directory.
If it all worked, you will find `OS64P.V64` in the `Altra64` bin directory.


### Clean `Altra64`
Expand Down
68 changes: 68 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
jobs:
- job: Windows
pool:
vmImage: 'vs2017-win2016'

variables:
outputStorageUri: ''
outputStorageContainerSasToken: ''
binaryVersion: '$(Year:yy)$(DayOfYear)$(Rev:r)'

steps:
- task: PowerShell@2
inputs:
targetType: 'filePath' # Optional. Options: filePath, inline
filePath: 'update-libs.ps1' # Required when targetType == FilePath
#arguments: # Optional
#errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue
failOnStderr: false # Optional
#workingDirectory: # Optional
displayName: Install tool-chain and libs

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$path = "$($Env:BUILD_SOURCESDIRECTORY)\inc\version.h"
# should possibly be setting this through the make file!
$versionStr = '#define OS_BUILD_VERSION "' + $Env:Build_BuildNumber + '"'
(Get-Content $path).Replace('#define OS_BUILD_VERSION "0"',$versionStr) | Set-Content $path
errorActionPreference: 'stop'
failOnStderr: 'false'
displayName: Update build version

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# needs converting to proper powershell or bash!
cmd.exe /c "set PATH=%PATH%;%BUILD_SOURCESDIRECTORY%\gcc-toolchain-mips64\bin"
cmd.exe /c "md bin"
cmd.exe /c "md obj"
If ($Env.Build_SourceBranchName -eq "master") {
cmd.exe /c "make"
}
Else {
cmd.exe /c "make debug"
}
errorActionPreference: 'stop'
failOnStderr: 'false'
displayName: 'Build ROM'
continueOnError: false

- task: CopyFiles@2
inputs:
sourceFolder: $(Build.SourcesDirectory)
contents: 'bin\*.v64'
targetFolder: $(Build.ArtifactStagingDirectory)
flattenFolders: true
displayName: 'Copy ROM'
continueOnError: false

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'binaries'
publishLocation: 'Container'
displayName: Publish Build Artifacts
continueOnError: false
107 changes: 107 additions & 0 deletions bin/ejectjs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

@if (@X)==(@Y) @end /* JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
::pause
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */

function printHelp(){

WScript.Echo( WScript.ScriptName + " - ejects a device");
WScript.Echo(" ");
WScript.Echo(WScript.ScriptName + " {LETTER|*}");
WScript.Echo(" * will eject all ejectable drives");
}

if (WScript.Arguments.Length < 1 ) {
printHelp();
WScript.Quit(0);
}

if (WScript.Arguments.Item(0).length>1) {
WScript.Echo("You need to pass an a drive letter or *");
WScript.Quit(1);
}


var ShellObj=new ActiveXObject("Shell.Application");
var myComputer=ShellObj.NameSpace(17);//https://docs.microsoft.com/en-us/windows/win32/api/shldisp/ne-shldisp-shellspecialfolderconstants
var myComputerItems = myComputer.Items();

var usbType="USB Drive";
var cdType="CD Drive";

var usbVerbFB=6;
var cdVerbFB=4;

var toEject=WScript.Arguments.Item(0);


function callVerbFromBottom(item,indexFromBottom){
var itemVerbs=item.Verbs();
var verb=itemVerbs.Item(itemVerbs.Count-indexFromBottom);
verb.DoIt();
item.InvokeVerb(verb.Name.replace("&",""));
}

function ejectAll(){
for (var i=0;i<myComputerItems.Count;i++){
var item=myComputerItems.Item(i);
var itemType=myComputer.GetDetailsOf(myComputerItems.Item(i),1);
var itemName=myComputer.GetDetailsOf(myComputerItems.Item(i),0);

if(itemType===usbType){
callVerbFromBottom(item,usbVerbFB);
}

if(itemType===cdType){
callVerbFromBottom(item,cdVerbFB);
}
}
}

function ejectByLetter(letter) {
var driveFound=false;
for (var i=0;i<myComputerItems.Count;i++){
var item=myComputerItems.Item(i);
var itemType=myComputer.GetDetailsOf(myComputerItems.Item(i),1);
var itemName=myComputer.GetDetailsOf(myComputerItems.Item(i),0);

if(
itemName.indexOf(":") !== -1 &&
itemName.indexOf("(") !== -1 &&
itemName.indexOf(")") !== -1
) {
//the item is a some kind of drive
var itemDriveLetter=itemName.substring(
itemName.indexOf(")") - 1 ,
itemName.indexOf(")") - 2
);

if(itemDriveLetter.toUpperCase()===letter.toUpperCase()) {
if(itemType===usbType) {
callVerbFromBottom(item,usbVerbFB);
} else if (itemType===cdType) {
callVerbFromBottom(item,cdVerbFB);
} else {
WScript.Echo("Drive "+ letter + " does not support ejectuation");
WScript.Quit(2);
}
driveFound=true;
break; //drive letter has been found , no more iteration needed.
}
}
}

if(!driveFound){
WScript.Echo("Drive " + letter +" has not been found");
WScript.Quit(3);
}
}

if(toEject==="*") {
ejectAll();
} else {
ejectByLetter(toEject);
}
21 changes: 5 additions & 16 deletions build.cmd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
::
:: Copyright (c) 2017 The Altra64 project contributors
:: See LICENSE file in the project root for full license information.
::

set PATH=%~dp0toolchain\gcc-toolchain-mips64\bin
@echo off
set "SystemPath=%SystemRoot%\\System32"
IF EXIST %WINDIR%\\sysnative\\reg.exe (
set "SystemPath=%SystemRoot%\Sysnative"
echo. "32-bit process..."
)

set env="/usr/local/libdragon"

IF %1.==. (
echo. "no parameter"
%SystemPath%\\bash --verbose -c "export N64_INST=%env%; make"
::echo. "no parameter"
make
) ELSE (
echo. "parameter: %1"
%SystemPath%\\bash --verbose -c "export N64_INST=%env%; make %1"
::echo. "parameter: %1"
make -d %1
)

:pause
Empty file modified doc/functions.txt
100644 → 100755
Empty file.
Empty file modified inc/chksum64.h
100644 → 100755
Empty file.
Empty file modified inc/cic.h
100644 → 100755
Empty file.
Empty file modified inc/debug.h
100644 → 100755
Empty file.
Empty file modified inc/diskio.h
100644 → 100755
Empty file.
Empty file modified inc/errors.h
100644 → 100755
Empty file.
Empty file modified inc/everdrive.h
100644 → 100755
Empty file.
Empty file modified inc/ff.h
100644 → 100755
Empty file.
Empty file modified inc/ffconf.h
100644 → 100755
Empty file.
Empty file modified inc/font_patch/font.h
100644 → 100755
Empty file.
Empty file modified inc/font_patch/info.txt
100644 → 100755
Empty file.
Empty file modified inc/hashtable.h
100644 → 100755
Empty file.
Empty file modified inc/image.h
100644 → 100755
Empty file.
Empty file modified inc/ini.h
100644 → 100755
Empty file.
Empty file modified inc/integer.h
100644 → 100755
Empty file.
Empty file modified inc/main.h
100644 → 100755
Empty file.
Empty file modified inc/mem.h
100644 → 100755
Empty file.
Empty file modified inc/memorypak.h
100644 → 100755
Empty file.
Loading

0 comments on commit d407f16

Please sign in to comment.