Skip to content

Commit

Permalink
Add debugging via PowerPC UART
Browse files Browse the repository at this point in the history
Prints all printf over the serial port of the IBM PowerPC CPU found on Slim ps2 starting with `SCPH-75xxx`

- faster and smaller than UDPTTY
- no data loss when printing from the EE
- No dependency on networking
  • Loading branch information
israpps committed Jul 11, 2024
1 parent 249b6e2 commit 04c81e0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ XFROM ?= 0
UDPTTY ?= 0
MX4SIO ?= 0
SIO2MAN ?= 0
TTY2SIOR ?= 0
PPC_UART ?= 0
DEBUG ?= 0
# ----------------------------- #
.SILENT:

BIN_NAME = $(HAS_EXFAT)$(HAS_DS34)$(HAS_ETH)$(HAS_SMB)$(HAS_DVRP)$(HAS_XFROM)$(HAS_MX4SIO)$(HAS_EESIO)$(HAS_UDPTTY)$(HAS_TTY2SIOR)$(HAS_IOP_RESET)
BIN_NAME = $(HAS_EXFAT)$(HAS_DS34)$(HAS_ETH)$(HAS_SMB)$(HAS_DVRP)$(HAS_XFROM)$(HAS_MX4SIO)$(HAS_EESIO)$(HAS_UDPTTY)$(HAS_PPCTTY)$(HAS_IOP_RESET)
ifeq ($(DEBUG), 0)
EE_BIN = UNC-BOOT$(BIN_NAME).ELF
EE_BIN_PKD = BOOT$(BIN_NAME).ELF
Expand Down Expand Up @@ -91,11 +91,13 @@ ifeq ($(SIO_DEBUG),1)
HAS_EESIO = -SIO_DEBUG
endif

ifeq ($(TTY2SIOR),1)
EE_LIBS += -lsior
EE_CFLAGS += -DTTY2SIOR
HAS_TTY2SIOR = -TTY2SIOR
EE_OBJS += tty2sior_irx.o
ifeq ($(PPC_UART),1)
EE_CFLAGS += -DPOWERPC_UART
HAS_PPCTTY = -PPCTTY
EE_OBJS += ppctty.o
ifeq ($(UDPTTY),1)
$(error Both PPCTTY and UDPTTY enabled simultaneously)
endif
endif

ifeq ($(IOP_RESET),0)
Expand Down
4 changes: 2 additions & 2 deletions embed.make
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ $(EE_ASM_DIR)ps2kbd_irx.s: $(PS2SDK)/iop/irx/ps2kbd.irx | $(EE_ASM_DIR)
$(EE_ASM_DIR)sior_irx.s: $(PS2SDK)/iop/irx/sior.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ sior_irx

$(EE_ASM_DIR)tty2sior_irx.s:iop/__precompiled/tty2sior.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ tty2sior_irx
$(EE_ASM_DIR)ppctty_irx.s:iop/__precompiled/ppctty.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ ppctty_irx

iop/AllowDVDV.irx: iop/AllowDVDV
$(MAKE) -C $<
Expand Down
6 changes: 3 additions & 3 deletions include/launchelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
#include <sio.h>
#include <sior_rpc.h>

#ifdef SIO_DEBUG
#ifdef SIO_DEBUG //EE SIO will be printed separated. no need for diferentiation
#define DPRINTF(format, args...) \
sio_printf(format, ##args)
#elif defined(TTY2SIOR) || defined(COMMON_PRINTF) || defined(UDPTTY)
#elif defined(POWERPC_UART) || defined(COMMON_PRINTF) || defined(UDPTTY) //printf has to travel to IOP, add color escape to make up the diff
#define DPRINTF(format, args...) \
printf("\033[1;94;40m"format"\033[m", ##args)
#else
#define DPRINTF(format, args...) // strip away printf from consumer builds
#define DPRINTF(format, args...)// strip away printf from consumer builds
#endif

#define TRUE 1
Expand Down
Binary file added iop/__precompiled/ppctty.irx
Binary file not shown.
31 changes: 16 additions & 15 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ IMPORT_BIN2C(sio2man_irx);
IMPORT_BIN2C(padman_irx);
#endif

#ifdef TTY2SIOR
IMPORT_BIN2C(tty2sior_irx);
#ifdef POWERPC_UART
IMPORT_BIN2C(ppctty_irx);
#endif

IMPORT_BIN2C(usbd_irx);
Expand Down Expand Up @@ -433,7 +433,7 @@ static void Show_build_info(void)
" MX4SIO=0"
#endif
, COLOR_TEXT);
#if defined(UDPTTY) || defined(SIO_DEBUG) || defined(TTY2SIOR) || defined(NO_IOP_RESET)
#if defined(UDPTTY) || defined(SIO_DEBUG) || defined(POWERPC_UART) || defined(NO_IOP_RESET)


PrintPos(-1, hpos, "Debug Features:", COLOR_SELECT);
Expand All @@ -455,10 +455,10 @@ static void Show_build_info(void)
#else
" SIO_DEBUG=0"
#endif
#ifdef TTY2SIOR
" TTY2SIOR=1"
#ifdef POWERPC_UART
" PPC_UART=1"
#else
" TTY2SIOR=0"
" PPC_UART=0"
#endif
, COLOR_TEXT);
#endif
Expand Down Expand Up @@ -1137,18 +1137,12 @@ static void loadBasicModules(void)
DPRINTF(" [rom0:SIO2MAN]: id=%d\n", id);
#endif

#if defined(TTY2SIOR) || defined(SIO_DEBUG)
#if defined(SIO_DEBUG)
// I call this just after SIO2MAN have been loaded
sio_init(38400, 0, 0, 0, 0);
#endif
#ifdef TTY2SIOR
SIOR_Init(0x20);

id = SifExecModuleBuffer(tty2sior_irx, size_tty2sior_irx, 0, NULL, &ret);
DPRINTF(" [TTY2SIOR]: id=%d ret=%d\n", id, ret);
#endif

#if defined(TTY2SIOR) || defined(SIO_DEBUG)
#if defined(SIO_DEBUG)
DPRINTF("Hello from EE SIO!\n");
#endif

Expand Down Expand Up @@ -1425,7 +1419,7 @@ static void loadUsbModules(void)
#else
{
loadUsbDModule();
if (have_usbd && !have_usb_mass && (USB_mass_loaded = loadExternalModule("", &usb_mass_irx, size_usb_mass_irx))) {
if (have_usbd && !have_usb_mass && (USB_mass_loaded = loadExternalModule("USBMASS.IRX", &usb_mass_irx, size_usb_mass_irx))) {
delay(3);
have_usb_mass = 1;
}
Expand Down Expand Up @@ -2404,6 +2398,13 @@ static void Reset()
#ifdef XFROM
have_Flash_modules = 0;
#endif

#ifdef POWERPC_UART
int i, d;
i = SifExecModuleBuffer(&ppctty_irx, size_ppctty_irx, 0, NULL, &d);
DPRINTF(" [PPCTTY]: id=%d, ret=%d\n", i, d);
#endif

#ifdef UDPTTY
int i, d;
load_ps2ip();
Expand Down

0 comments on commit 04c81e0

Please sign in to comment.