[WIP] Add custom DVD commands for homebrew app functionality#6
Closed
Copilot wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
Overview
Add new custom DVD commands (under the existing
0xF4command prefix indvd.c) that allow a homebrew app running on the GameCube to:0xF4 0x00, but should be verified/enhanced).memmap_data.ld.Current Architecture
Flash Memory Layout (from
memmap_data.ld)ORIGIN(FLASH), length 128KB (PICO_FLASH_SIZE_BYTES = 131072in CMakeLists.txt)ORIGIN(FLASH) + LENGTH(FLASH) + ALIGN(66k, 4k) - 66k, length 66KB — containsgbi.hdrandiso.hdr2048k - LENGTH(FLASH) - LENGTH(HEADER)— contains the DOL/ISO payloadExisting Custom Commands (
dvd.c→dvd_request_custom())0xF4 0x00— Device info: returns 32-byte buffer with magic0x0D15E45E, major version, minor version0xF4 0x01— Reboot into USB bootloader (reset_usb_boot)How DVD Commands Work
The GameCube sends 12-byte command packets via the DVD interface. The first byte is the command ID. For custom command
0xF4, bytereq[1]is the sub-command. The remaining bytesreq[2..11]are available for parameters. The Pico responds usingdvd_drv_send()to send data back, ordvd_drv_set_error()to signal errors.Passthrough Mode
When PicoLoader enters passthrough mode (via
dvd_drv_enable_passthrough()indvd_drv.c), it disables the PIO state machines for recv/send, enables the passthrough SM, and forwards all signals between the GameCube and the physical DVD drive. The PIO IRQs and GPIO IRQs are disabled. To exit passthrough mode, the Pico's PIO state machines need to be re-initialized.Required Changes
1. Exit Passthrough Mode Command (
0xF4 0x02)Add a new function
dvd_drv_disable_passthrough()indvd_drv.c/dvd_drv.hthat reverses whatdvd_drv_enable_passthrough()does:PIO_PASSTHROUGH_SM)pin_gc_dstrbback to PIO function (from GPCK)pin_dvd_dir,pin_gc_cover,pin_dvd_resetoverrides back to their ODE-mode statesHowever, the homebrew app cannot send a custom DVD command while in passthrough mode because the PicoLoader is not intercepting commands — the physical drive is. So the mechanism needs to work differently:
Approach: Sniff for a magic command sequence while in passthrough mode.
While in passthrough mode, the PicoLoader should passively monitor the DVD bus (since data lines are visible even in passthrough mode) for a specific magic "wake-up" command sequence. When it detects this sequence, it exits passthrough mode and re-enters ODE mode.
Implementation approach:
dvd_drv.c, when entering passthrough mode, set up a GPIO IRQ or use a DMA-based sniffer on thepin_hstrbline to capture incoming bytes on the data bus0xF4 0x02followed by a magic value like0x50 0x49 0x43 0x4F= "PICO")dvd_drv_disable_passthrough()to exit passthrough modestatic bool passthrough_active) so other parts of the code know the current modeIn
dvd.c, add the0xF4 0x02sub-command handler:2. Firmware Version Query Enhancement (
0xF4 0x00)The existing device info command already returns version info. Enhance it to also include:
flash_capacityfromdvd.c)Update the
device_inforesponse buffer to include this information in the existing 32-byte response: