R4 like Switch FPGA Code

brawhalla1

Member
OP
Newcomer
Joined
Oct 24, 2021
Messages
18
Trophies
0
Location
Some place
XP
146
Country
Brazil
Note: this is work in progress, needs to be finished. Use for your risk


Even though other people already launching our r4 solutions i will share my progress developing a chip to emulate using FPGA Actel ProASIC 3 ASP250 VQG100 1115 ZA632076 (like r4 gold) for emulate bus signal from ROM (not xci image, just full rom dump) for switch cartridge (see https://switchbrew.org/wiki/Gamecard)

this is very simple on related a actual jailbreak solution

this just consists in emulate real cartridge chip like a real MMC using programmable fpga hardware.

If this work dumps will work like a genuine card.


FPGA Verilog Firmware:

module rom_controller (
input wire clk,
input wire rst,
input wire [31:0] signal,
output reg [31:0] data
);
output wire [15:0] spi_mosi;
input wire [15:0] spi_miso;
output wire spi_sck;
output wire spi_cs;
output wire [7:0] led;
sd_card sd_card (
.clk(clk),
.rst(rst),
.cs(spi_cs),
.mosi(spi_mosi),
.miso(spi_miso),
.sck(spi_sck)
);
top top (
.clk(clk),
.rst(rst),
.signal(signal)
// .data(data)
);
endmodule
module sd_card (
input wire clk,
input wire rst,
output wire cs,
input wire [15:0] mosi,
output wire [15:0] miso,
input wire sck
);
reg [7:0] data;
reg [7:0] byte_count;
parameter IDLE = 0;
parameter READ_CMD = 1;
parameter READ_DATA = 2;
parameter READ_STOP = 3;
reg [2:0] state;
always @(posedge clk or posedge rst) begin
if (rst) begin
state <= IDLE;
byte_count <= 0;
end else begin
case (state)
IDLE: begin
if (cs) begin
state <= READ_CMD;
end
end
READ_CMD: begin
data <= mosi;
if (sck) begin
state <= READ_DATA;
end
end
READ_DATA: begin
data <= miso;
byte_count <= byte_count + 1;
if (byte_count == 8) begin
state <= READ_STOP;
end
end
READ_STOP: begin
if (sck) begin
state <= IDLE;
end
end
endcase
end
end
assign miso = data;
endmodule
module top (
input wire clk,
input wire rst,
input wire [31:0] signal,
input wire cs,
output reg [31:0] data
);
// ...
reg [31:0] file_bytes [0:MAX_FILE_COUNT-1];
reg [31:0] random_number;
reg [31:0] file_index_random;
reg [31:0] i;
reg [31:0] file_index;
wire [15:0] miso;

parameter MAX_FILE_COUNT = 100;
lfsr_random #(32) random_generator (
.clk(clk),
.rst(rst)
);
always @(posedge clk) begin
if (rst) begin
data <= 0;
end else begin
if (cs) begin
data <= file_bytes[file_index_random];
end
end
end
always @(posedge clk) begin
if (rst) begin
for (i = 0; i < MAX_FILE_COUNT; i = i + 1) begin
file_bytes <= 0;
end
end else begin
if (cs) begin
file_bytes[file_index] <= miso;
file_index <= file_index + 1;
end
end
end
always @(posedge clk) begin
if (rst) begin
random_number <= 0;
end else begin
if (cs) begin
random_number <= random_generator.lfsr;
end
end
end
always @(posedge clk) begin
if (rst) begin
file_index_random <= 0;
end else begin
if (cs) begin
file_index_random <= random_number % MAX_FILE_COUNT;
end
end
end
always @(posedge clk) begin
if (rst) begin
data <= 0;
end else begin
if (cs) begin
data <= file_bytes[file_index_random];
end
end
end
endmodule
module lfsr_random #(
parameter DATA_WIDTH = 16
)(
input wire clk,
input wire rst,
output reg [DATA_WIDTH-1:0] random_number
);
reg [DATA_WIDTH-1:0] lfsr;
always @(posedge clk or posedge rst) begin
if (rst) begin
lfsr <= 16'h1234;
end else begin
lfsr <= {lfsr[DATA_WIDTH-2:0], lfsr[DATA_WIDTH-1]} ^ (lfsr << 1);
end
random_number <= lfsr;
end
endmodule


Build:

iverilog -o out rom_controller.v

FPGA Actel ProASIC 3 ASP250 VQG100 1115 ZA632076 datasheet: https://ww1.microchip.com/downloads...s/FPGA/ProductDocuments/UserGuides/pa3_ug.pdf
Winbond 25q155nsjc 1124 (SDCard IC) https://pdf1.alldatasheet.com/datasheet-pdf/view/555584/WINBOND/W25X40CLSNIG.html

3D Printable cardtridge case (after make pcb) https://www.printables.com/model/31474-nintendo-switch-cartridge

Pinout:

PinModuleFunction
GNDAll modulesGround
CD#All modulesCard Detect
CLKAll modulesClock
RCLKAll modulesReturn Clock
CS#All modulesChip Select
DAT[7:0]All modulesData Bus
VCC 3.1VAll modulesPower Supply (3.1V)
VCC 1.8VAll modulesPower Supply (1.8V)
RST#All modulesReset


Module Pintout:
PinModule
spi_mosisd_card
spi_misosd_card
spi_scksd_card
spi_cssd_card
clktop, sd_card
rsttop, sd_card



Brazil carai
bandeira_do_brasil_flag_brazil_preview
 

brawhalla1

Member
OP
Newcomer
Joined
Oct 24, 2021
Messages
18
Trophies
0
Location
Some place
XP
146
Country
Brazil
This doesn't do shit. It looks like something ChatGPT would spit out.

This is work in progress, but work. and not chatgpt. I think chatgpt cant do this. Some data secs need to be optimzed. The random data when vcc is came is for random game select, in the future this can be ordered by game name saving state in the sdcard
 
  • Wow
  • Like
Reactions: peteruk and impeeza

linuxares

The inadequate, autocratic beast!
Global Moderator
Joined
Aug 5, 2007
Messages
13,380
Trophies
2
XP
18,302
Country
Sweden
This is work in progress, but work. and not chatgpt. I think chatgpt cant do this. Some data secs need to be optimzed. The random data when vcc is came is for random game select, in the future this can be ordered by game name saving state in the sdcard
Curiously, do you have a video of it working? :)
 

TheStonedModder

Well-Known Member
Member
Joined
Dec 25, 2022
Messages
878
Trophies
0
Age
27
XP
1,723
Country
United States
Note: this is work in progress, needs to be finished. Use for your risk


Even though other people already launching our r4 solutions i will share my progress developing a chip to emulate using FPGA Actel ProASIC 3 ASP250 VQG100 1115 ZA632076 (like r4 gold) for emulate bus signal from ROM (not xci image, just full rom dump) for switch cartridge (see https://switchbrew.org/wiki/Gamecard)

this is very simple on related a actual jailbreak solution

this just consists in emulate real cartridge chip like a real MMC using programmable fpga hardware.

If this work dumps will work like a genuine card.


FPGA Verilog Firmware:



Build:



FPGA Actel ProASIC 3 ASP250 VQG100 1115 ZA632076 datasheet: https://ww1.microchip.com/downloads...s/FPGA/ProductDocuments/UserGuides/pa3_ug.pdf
Winbond 25q155nsjc 1124 (SDCard IC) https://pdf1.alldatasheet.com/datasheet-pdf/view/555584/WINBOND/W25X40CLSNIG.html

3D Printable cardtridge case (after make pcb) https://www.printables.com/model/31474-nintendo-switch-cartridge

Pinout:

PinModuleFunction
GNDAll modulesGround
CD#All modulesCard Detect
CLKAll modulesClock
RCLKAll modulesReturn Clock
CS#All modulesChip Select
DAT[7:0]All modulesData Bus
VCC 3.1VAll modulesPower Supply (3.1V)
VCC 1.8VAll modulesPower Supply (1.8V)
RST#All modulesReset


Module Pintout:
PinModule
spi_mosisd_card
spi_misosd_card
spi_scksd_card
spi_cssd_card
clktop, sd_card
rsttop, sd_card



Brazil carai
bandeira_do_brasil_flag_brazil_preview
Well if anyone wants to test this and can’t print out their own case. I’m welcome to donate my printers time and filament

Paying a company to print an STL is usually hella expensive unless at scale
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Veho @ Veho:
    It's not a Nintendo / iQue official product, it's a 3rd party custom.
    +1
  • Veho @ Veho:
    Nothing special about it other than it's more comfortable than the Lite
    for people with beefy hands.
    +1
  • Jayro @ Jayro:
    I have yaoi anime hands, very lorge but slender.
  • Jayro @ Jayro:
    I'm Slenderman.
  • Veho @ Veho:
    I have hands.
  • BakerMan @ BakerMan:
    imagine not having hands, cringe
    +1
  • AncientBoi @ AncientBoi:
    ESPECIALLY for things I do to myself :sad:.. :tpi::rofl2: Or others :shy::blush::evil:
    +1
  • The Real Jdbye @ The Real Jdbye:
    @SylverReZ if you could find a v5 DS ML you would have the best of both worlds since the v5 units had the same backlight brightness levels as the DS Lite unlockable with flashme
  • The Real Jdbye @ The Real Jdbye:
    but that's a long shot
  • The Real Jdbye @ The Real Jdbye:
    i think only the red mario kart edition phat was v5
  • BigOnYa @ BigOnYa:
    A woman with no arms and no legs was sitting on a beach. A man comes along and the woman says, "I've never been hugged before." So the man feels bad and hugs her. She says "Well i've also never been kissed before." So he gives her a kiss on the cheek. She says "Well I've also never been fucked before." So the man picks her up, and throws her in the ocean and says "Now you're fucked."
    +2
  • BakerMan @ BakerMan:
    lmao
  • BakerMan @ BakerMan:
    anyways, we need to re-normalize physical media

    if i didn't want my games to be permanent, then i'd rent them
    +1
  • BigOnYa @ BigOnYa:
    Agreed, that why I try to buy all my games on disc, Xbox anyways. Switch games (which I pirate tbh) don't matter much, I stay offline 24/7 anyways.
  • AncientBoi @ AncientBoi:
    I don't pirate them, I Use Them :mellow:. Like I do @BigOnYa 's couch :tpi::evil::rofl2:
    +1
  • cearp @ cearp:
    @BakerMan - you can still "own" digital media, arguably easier and better than physical since you can make copies and backups, as much as you like.

    The issue is DRM
  • cearp @ cearp:
    You can buy drm free games / music / ebooks, and if you keep backups of your data (like documents and family photos etc), then you shouldn't lose the game. but with a disk, your toddler could put it in the toaster and there goes your $60

    :rofl2:
  • cearp @ cearp:
    still, I agree physical media is nice to have. just pointing out the issue is drm
  • rqkaiju2 @ rqkaiju2:
    i like physical media because it actually feels like you own it. thats why i plan on burning music to cds
  • cearp @ cearp:
    It's nice to not have to have a lot of physical things though, saves space
    +1
  • AncientBoi @ AncientBoi:
    Nor clothes 🤮 . Saves on time, soap, water and money having to wash them. :D
  • SylverReZ @ SylverReZ:
    @rqkaiju2, Physical media is a great source for archiving your data, none of that cloud storage shiz.
    +1
  • AncientBoi @ AncientBoi:
    [squeezes @SylverReZ onto a physical media, then archives you in my old stuff box] :tpi::rofl2::tpi:
    +1
    AncientBoi @ AncientBoi: [squeezes @SylverReZ onto a physical media, then archives you in my old stuff box]... +1