Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When disk signature invalid try the next LUN instead of giving up on the entire port #993

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6fb142c
Fixes issue #991. If disk has invalid signature, for example a Wii-U-…
cyberstudio10 Mar 21, 2022
6fd3b03
Update credits according to GitHub's contributor list
cyberstudio10 Mar 21, 2022
3af36e1
Since the update check directly references the GitHub repository, CI …
cyberstudio10 Mar 21, 2022
1ce080e
Correct loader path
cyberstudio10 Mar 21, 2022
c5d1967
loader.dol
Mar 21, 2022
403c410
Second place with a list of contributors, used by main.c to write a n…
cyberstudio10 Mar 21, 2022
7aba39f
loader.dol
cyberstudio10 Mar 21, 2022
2ab8549
When loader writes its own meta.xml it is now able to write the curre…
cyberstudio10 Mar 22, 2022
118c2bb
loader.dol
cyberstudio10 Mar 22, 2022
35188ae
Pass down GitHub CI workflow sequence number to be the MINOR_VERSION …
cyberstudio10 Mar 22, 2022
e5dc72a
loader.dol 7.7
cyberstudio10 Mar 22, 2022
8e84886
NintendontVersion.h has to be automatically committed, too, because t…
cyberstudio10 Mar 22, 2022
cef494a
Use devkitppc tag 20210619 because that's the oldest with both devkit…
cyberstudio10 Mar 22, 2022
a024307
loader.dol v7.9
cyberstudio10 Mar 22, 2022
451304f
We shall use the date/time of the last commit as the date/time in met…
cyberstudio10 Mar 23, 2022
5e1a9e7
loader.dol v7.10
cyberstudio10 Mar 23, 2022
cbc998a
Move version number change from loader level to top level
cyberstudio10 Mar 23, 2022
d742680
Need to define where NintendontVersion.h is
cyberstudio10 Mar 23, 2022
e394181
loader.dol v7.12
cyberstudio10 Mar 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'Make Nintendont'
description: 'Compiles Nintendont'

runs:
using: 'docker'
# Oldest tag I can find with both devkitARM and devkitPPC.
image: 'devkitpro/devkitppc:20210619'
entrypoint: make
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Compile Nintendont
uses: ./.github/actions
# The build process updates NintendontVersion.h with minor version set to be
# the GitHub CI workflow number. More importantly, we get the main binary,
# loader.dol. Both of them needs to be committed back to the repo because
# the online update feature fetches directly from the repo. Assume major
# version is 7, update common/include/NintendontVersion.h too for a major
# version change.
- name: Commit loader.dol
run: |
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor }}@users.noreply.github.com'
git add -f loader/loader.dol common/include/NintendontVersion.h
( git commit -m "loader.dol v7.${{ github.run_number }}" && git push ) || true
- uses: actions/upload-artifact@v1
with:
name: Nintendont
path: build/
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
*.o
*.bin
*.elf
build/
codehandler/*.h
kernel/asm/*.h
kernel/kernel.map
loader/build/
loader/data/kernel.zip
nintendont/boot.dol
fatfs/*.a
codehandler/*.h
codehandler/*.h
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ SUBPROJECTS := multidol kernel/asm resetstub \
fatfs/libfat-arm.a fatfs/libfat-ppc.a \
codehandler kernel kernelboot \
loader/source/ppc/PADReadGC loader/source/ppc/IOSInterface loader
# This is where titles.txt and icon.png will be copied to
ARTIFACTS := build/app/Nintendont
NINTENTDONTVERSION_H := common/include/NintendontVersion.h
.PHONY: all forced clean $(SUBPROJECTS)

all: loader
all: nintendontversion loader copy_files
forced: clean all

# change version number
nintendontversion:
@echo " "
@echo "Update version number (if available)"
@echo " "
if [ -n "$(GITHUB_RUN_NUMBER)" ]; then \
sed -i 's/#define NIN_MINOR_VERSION.*$$/#define NIN_MINOR_VERSION\t\t\t$(GITHUB_RUN_NUMBER)/' $(NINTENTDONTVERSION_H); \
fi

multidol:
@echo " "
@echo "Building Multi-DOL loader"
Expand Down Expand Up @@ -86,6 +98,16 @@ loader: multidol resetstub fatfs/libfat-ppc.a kernel kernelboot loader/source/pp
@echo " "
$(MAKE) -C loader

# After building, assemble a build directory. GitHub will zip it and it can be
# downloaded and extracted to a SD card or HDD.
copy_files:
@echo " "
@echo "Copying files"
@echo " "
mkdir -p $(ARTIFACTS)
cp -p nintendont/icon.png nintendont/titles.txt $(ARTIFACTS)
unzip -d build/controllers -q -n controllerconfigs/controllers.zip

clean:
@echo " "
@echo "Cleaning all subprojects..."
Expand Down
8 changes: 5 additions & 3 deletions common/include/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#define META_NAME "Nintendont"
#define META_AUTHOR "FIX94, crediar"

#define META_LONG1 "Commiters: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan \r\n\r\n Project website: https://github.com/FIX94/Nintendont "
#define META_LONG2 "Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device."
#if !defined(META_DATETIME)
# define META_DATETIME "20160710000000"
#endif
#define META_LONG1 "Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device."
#define META_LONG2 " Project website: https://github.com/FIX94/Nintendont\r\n\r\nCommitters: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan, nastys, carnage702, AnthonyRyuki, DankRank, Chickoodel, akemin-dayo, SuperrSonic, KoldMonster12, cheatfreak47, capnfunky77, cesarmades, crazycaveman, Wolfy76700, AndyCasaceli, ShadowOne333, Aurelio92, darkalemanbr, jmapjp, sailormoon, Dr-Crow, cyberstudio10, corey-underdown"
#define META_SHORT "Gamecube Loader"

#define META_XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>"
Expand Down
7 changes: 5 additions & 2 deletions common/include/NintendontVersion.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#ifndef __NINTENDONT_VERSION_H__
#define __NINTENDONT_VERSION_H__

#define NIN_MAJOR_VERSION 6
#define NIN_MINOR_VERSION 498
/* Minor version to be automatically filled in by GitHub CI. Any major version
* change will have to update main.yml. Online updates fetch this file directly
* from the repo and scanf these version numbers. */
#define NIN_MAJOR_VERSION 7
#define NIN_MINOR_VERSION 12

#define NIN_VERSION ((NIN_MAJOR_VERSION << 16) | NIN_MINOR_VERSION)

Expand Down
26 changes: 24 additions & 2 deletions loader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,34 @@ include $(DEVKITPPC)/wii_rules
# 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
# ARTIFACTS is to package a zip for the user to unpack to their SD card/HDD
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
SOURCES += source/unzip
DATA := data
INCLUDES := include ../fatfs
ARTIFACTS := ../build/apps/Nintendont
NINTENTDONTVERSION_H := ../common/include/NintendontVersion.h

#---------------------------------------------------------------------------------
# metadata
#---------------------------------------------------------------------------------
# If dol does not come from FIX94 we identify source on the screen
NIN_SPECIAL_VERSION := $(if $(and $(GITHUB_REPOSITORY_OWNER),$(findstring FIX94,$(GITHUB_REPOSITORY_OWNER))),,\"-$(GITHUB_REPOSITORY_OWNER)\")
# As preprocessor defines, DATETIME is unquoted, META_DATETIME is quoted
DATETIME := $(shell git show -s --format=%cI | grep -o -E "[[:digit:]]*" - | head -n 6 | paste -sd '')

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

ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY
CFLAGS := -O3 -g -std=gnu89 -Wno-format-truncation \
-Wall $(MACHDEP) $(INCLUDE) -DDEBUG -DDEBUG_MODULE_PATCH -DARCH_IS_BIG_ENDIAN
-Wall $(MACHDEP) $(INCLUDE) -DDEBUG -DDEBUG_MODULE_PATCH -DARCH_IS_BIG_ENDIAN \
-DNIN_SPECIAL_VERSION=$(NIN_SPECIAL_VERSION) \
-DMETA_DATETIME=\"$(DATETIME)\"
CXXFLAGS := $(CFLAGS)

# NOTE: Do NOT change to := - needed for proper expansion of $(CURDIR) later.
Expand Down Expand Up @@ -103,10 +116,19 @@ export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
# 1, build loader.dol
# 2, output meta.xml using C preprocessor on a template
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@cp $(OUTPUT).dol ../nintendont/boot.dol
@[ -d $(ARTIFACTS) ] || mkdir -p $(ARTIFACTS)
@cp -p $(OUTPUT).dol $(ARTIFACTS)/boot.dol
$(CC) -E -traditional -P \
-include $(NINTENTDONTVERSION_H) \
-DDATETIME=$(DATETIME) \
../metaxml.sx \
| sed -n '/^<?xml/,$$p' \
> $(ARTIFACTS)/meta.xml

#---------------------------------------------------------------------------------
clean:
Expand Down
Binary file modified loader/loader.dol
Binary file not shown.
2 changes: 1 addition & 1 deletion loader/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static void updateMetaXml(void)
"\t<name>" META_NAME "</name>\r\n"
"\t<coder>" META_AUTHOR "</coder>\r\n"
"\t<version>%d.%d%s</version>\r\n"
"\t<release_date>20160710000000</release_date>\r\n"
"\t<release_date>" META_DATETIME "</release_date>\r\n"
"\t<short_description>" META_SHORT "</short_description>\r\n"
"\t<long_description>" META_LONG1 "\r\n\r\n" META_LONG2 "</long_description>\r\n"
"\t<no_ios_reload/>\r\n"
Expand Down
40 changes: 22 additions & 18 deletions loader/source/usbstorage.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,27 +946,31 @@ static bool __usbstorage_IsInserted(void)
// If not, it might be a Wii U drive.
retval = USBStorageOGC_Read(&__usbfd, __lun, 0, 1, sector_buf);
if (retval == 0) {
if (sector_buf[510] == 0x55 &&
(sector_buf[511] == 0xAA || sector_buf[511] == 0xAB))
{
// Valid MBR and/or UStealth signature.
__mounted = true;
__vid = vid;
__pid = pid;
usb_last_used = gettime()-secs_to_ticks(100);
usleep(10000);
} else {
// Invalid signature.
// discard first read. I've seen a controller so buggy which returns the boot sector of LUN 1 when that of LUN 0 is asked for.
usb_last_used = gettime()-secs_to_ticks(100);
usleep(10000);
retval = USBStorageOGC_Read(&__usbfd, __lun, 0, 1, sector_buf);
if (retval == 0) {
if (sector_buf[510] == 0x55 &&
(sector_buf[511] == 0xAA || sector_buf[511] == 0xAB))
{
// Valid MBR and/or UStealth signature.
__mounted = true;
__vid = vid;
__pid = pid;
usb_last_used = gettime()-secs_to_ticks(100);
usleep(10000);
break; // found valid signature. Done!
}
// Else invalid signature.
// This may be a Wii U-formatted HDD.
__mounted = false;
__lun = 0;
}
} else {
// Read error.
__mounted = false;
__lun = 0;
// Else read error.
}
break;
// Else read error.
__mounted = false;
__lun = 0;
// continue scanning for next LUN instead of giving up
}

if (__mounted)
Expand Down
15 changes: 15 additions & 0 deletions metaxml.sx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<app version="1">
<name>Nintendont</name>
<coder>FIX94, crediar</coder>
<version>NIN_MAJOR_VERSION.NIN_MINOR_VERSION</version>
<release_date>DATETIME</release_date>
<short_description>Gamecube Loader</short_description>
<long_description>Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device.

Project website: https://github.com/FIX94/Nintendont

Committers: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan, nastys, carnage702, AnthonyRyuki, DankRank, Chickoodel, akemin-dayo, SuperrSonic, KoldMonster12, cheatfreak47, capnfunky77, cesarmades, crazycaveman, Wolfy76700, AndyCasaceli, ShadowOne333, Aurelio92, darkalemanbr, jmapjp, sailormoon, Dr-Crow, cyberstudio10, corey-underdown</long_description>
<no_ios_reload/>
<ahb_access/>
</app>
15 changes: 0 additions & 15 deletions nintendont/meta.xml

This file was deleted.