Homebrew flashcard-bootstrap: kernel replacement project

v1.0.0

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada
A fork of devkitPro's `BootStrap` module found in their Homebrew Menu, with support for more flashcarts than currently provided.

The goal is simple: get the flashcart to launch `BOOT.NDS` immediately after boot, without patching said file in any way, shape or form.

Currently supports the following:
  • DSTT (ttmenu.dat)
  • EZ Flash V (ez5sys.bin)
  • Original R4 (_ds_menu.dat)
  • R4iDSN (_dsmenu.dat)
  • Acekard 2, 2.1, 2i (akmenu4.nds)
  • Datel Games 'n' Music, Action Replay DSi (bootme.nds)
  • EDGEi (not to be confused with the original EDGE or iEDGE!) (dsedgei.dat)
  • N5 (in N5 folder)
  • r4ids.cn carts, R4 Ultra, R4iTT NEW, R4iTT 3DS, r4i-gold.me, r4i3d.com carts with a year number, r4igold.cc 3DS, r4i-drive.com, r4isdhc.com carts that are NOT between 2014-2021, r4isdhc.hk carts that are NOT 2021 (in r4ids.cn folder)
  • Amaze3DS, Wood r4igold.cc Upgrade (in MAZE folder)
  • Ace3DS+ (in ACEP folder)
  • R4iLS, r4isdhc.com.cn, r4isdhc.hk (in R4iLS folder)
  • Gateway Blue (in Gateway folder)
  • M3 DS Real, M3i Zero (non-GMP-Z003), iTouchDS, iTouch2, R4(i)RTS (r4rts.com), R4 SDHC RTS black (in M3R_iTDS_R4RTS folder)
  • DSOne SDHC, DSOnei (in DSOneSDHC_DSOnei folder)
  • R4i-SDHC and related timebomb clones (r4.dat)
  • M3i Zero (GMP-Z003) (in G003 folder)
  • SuperCard DSONE (non-SDHC) (scfw.sc)
  • iSmart Premium (ismat.dat)
  • EZ-Flash Vi (ez5isys.bin)
  • r4i.cn carts (_ds_menu.nds)
  • r4dspro.com carts (in r4dspro.com folder)
  • EZ-Flash Parallel (ezds.dat)
This is mostly meant for developer purposes, but it can be used, for example, to make a GBARunner2-only cartridge if you wish, for use in GBA Macro mods, by renaming GBARunner2 to BOOT.NDS, and so on.

This is meant to replace the cart's kernel with another homebrew application. This is NOT meant to be used to run kernels designed for other carts. This will not make it happen, unless it is confirmed to be a 1:1 clone of another cart. Unless you know what you are doing, if you try to use this to run other kernels prepare for misery/tears.

This cannot boot commercial ROMs. Use your original kernel or TWiLight Menu++ for that.

How to use:

I tend to use this project as a testing ground for future TWiLight Menu++ autoboot files.

Some previous use cases:
License is GPLv2 or later. Some DLDI files are GPLv3. Source: https://github.com/lifehackerhansol/flashcard-bootstrap

I keep some notes on each flashcart in devnotes.txt, if one wants to read.

Credits:
  • @AntonioND, @asiekierka
    • BlocksDS and libnds, and many help porting needed code to make it work
  • devkitPro:
    • Original nds-hb-menu source code
    • Code used to encrypt the R4 and Ace3DS+ boot files
  • Taiju Yamada (@Xenon++):
    • code used to patch the R4i-SDHC bootloader to bypass the protection
    • DLDI code used for EZ-Flash V, EZ-Flash Vi, iSmart Premium and r4i.cn
    • code used to patch the M3i Zero bootstrap to work with the encrypted bootloader
  • mimic from NDS Laboratory:
  • @BXZ_:
    • bruteforced encryption key for the Ace3DS+/R4 i.L.S./Gateway Blue bootloader files
  • Bliss:
    • Triple loader file used for DSONE SDHC/DSONEi
  • R4iDSN team:
  • @Gericom:
    • Code used for a new set of DLDI drivers
    • Offering lots and lots of advice on flashcarts, cartridges and DS hardware. I truly learned a lot from this person.
 
Last edited by lifehackerhansol,

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada
Changelog:
v1.0.0: initial release

v1.1.0:
  • Add N5 support
  • Add Amaze3DS and Wood R4igold.cc Upgrade support (thanks @elCerebrain for indirectly testing)
  • Use open-source EZ-Flash V DLDI (thanks @Xenon++)
  • Use open-source M3 DS Real DLDI (thanks @Xenon++)
v1.2.0:
  • Add M3i Zero (GMP-Z003 model) support
v1.2.1:
  • Switch to open-source Ace3DS+ DLDI
  • Switch to open-source DSONE SDHC DLDI
  • Switch to open-source DSTT DLDI
    • SD/SDHC detection is fixed. Now you can use 2GB SD cards without it failing! (why would you ever want to do this)
v1.2.2
  • Switched back to SDHC-specific DSTT/DSONE SDHC DLDI. It was causing more harm than good. TODO: figure out why
v1.2.3
  • Added support for the Datel Games 'n' Music and the Action Replay DSi: `bootme.nds`
  • Newly written DLDIs, based on a newly written original R4 DLDI (though original R4 is currently not used in this project yet)
    • Rewritten DLDIs are as follows:
      • Ace3DS+
      • M3 DS Real
      • DSTT
      • DSONE
      • DSONE SDHC
  • Switched to open source GMP-Z003 driver (also based on r4tfv3)
  • Fix DSONE SDHC not having non-SDHC support temporarily. Added with the new rewrite.
v1.2.4
  • Fix DSONE SDHC's SDHC check (again. I'm sorry.)
  • Fix timebomb carts freezing on SD driver initialization
  • Update original R4 / N5 driver to r4tfv3
v1.3.0
  • Added support for the EDGEi (dsedgei.dat)
    • Not to be confused with the original EDGE or the iEDGE!
  • DLDI space is increased to 32KB. This introduces compatibility of launching flashcard-bootstrap from very old homebrew apps.
    • This requires forking libnds: it now lives at https://github.com/lifehackerhansol/libnds32
    • Moonshell 2, for instance, regardless of available DLDI space, will write the entire 32KB data into the binary, corrupting flashcard-bootstrap (and pretty much all other homebrew since 2017) in RAM and causing the system to freeze.
    • flashcard-bootstrap will refuse to launch `boot.nds` if the actual DLDI driver is over 16KB, as modern homebrew is now using 16KB drivers and anything over that will not fit.
 
Last edited by lifehackerhansol,

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada
Any plans on making this work for the DSTWO? If so, hopefully it fixes this issue
https://github.com/DS-Homebrew/TWiLightMenu/issues/1738
As far as I understand it the DSTWO uses some of its CPU in order to boot. One would have to dissect what the original loader is doing to find out.

Unfortunately at the most I (barely) understand what ARM code does, but not MIPS. So I don't know.

Maybe one can make a DSTWO plugin. But that seems out of scope of this project for now.
 
  • Like
Reactions: The Catboy

The Catboy

GBAtemp Official Catboy™: Boywife
Member
Joined
Sep 13, 2009
Messages
27,950
Trophies
4
Location
Making a non-binary fuss
XP
39,345
Country
Antarctica
As far as I understand it the DSTWO uses some of its CPU in order to boot. One would have to dissect what the original loader is doing to find out.

Unfortunately at the most I (barely) understand what ARM code does, but not MIPS. So I don't know.

Maybe one can make a DSTWO plugin. But that seems out of scope of this project for now.
Fair enough. I will continue my interesting setup of using BagPlug as a bootloader. I am booting TWiLight Menu++ though EOS from BagPlug. This fixes the issue causing nds-bootstrap. I could just replace my bootloader with EOS and autoboot that way but that would cut out EOS as viable kernel
 

tholasko

New Member
Newbie
Joined
Nov 23, 2022
Messages
1
Trophies
0
Age
22
XP
36
Country
United States
This is amazing! This was just what I needed to get my (admittedly probably janky) MoonShell 2.10 setup running on my R4i SDHC. Now I can boot directly into moonshl2.nds, and then use inilink/iniclear/mshl2wrap to load commercial ROMs.
 

Flame

Me > You
Global Moderator
Joined
Jul 15, 2008
Messages
7,297
Trophies
3
XP
18,822

flashcard-bootstrap v1.2.0

What's new?

  • Add M3i Zero (GMP-Z003 model) support
It took us 12 years to create a proper replacement bootloader for the GMP-Z003... But better late than never.

what a start to the year. thank you for this.

edit: how did you manage to get this to work?
 
Last edited by Flame,

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada
what a start to the year. thank you for this.

edit: how did you manage to get this to work?

The GMP-Z003 boots from a certain _M3_MENU.DAT file. This file is encrypted to hell, but it does allow you to observe its behaviour when no other files exist.

The latest version of this file taken from Sakura did nothing, but I went back to the initial version of the Sakura kernel that had the GMP-Z003 support, and it gave me a feedback that I was missing a g003menu.* file, depending on the language you select. So if M3 was trying to obfuscate the kernel... good job.

After that it was a simple matter of figuring out how the header encryption worked for g003menu.eng. M3 team used the same "protection" as the previous M3 DS Real carts (custom header format with encryption only in the header). This is fairly well documented by Xenon++, and it was how I implemented autobooting for TWiLight Menu++ for the M3 DS Real until I came up with a better solution for that cart, which is the M3R_iTDS_R4RTS post I made a month or few ago.

So we have:
_M3_MENU.DAT: encrypted bootloader
MuliLang.bin: a language settings file, pre-provided so that _M3_MENU.DAT will always choose g003menu.eng. it could be other languages, but if we aren't using the original kernel, do we care which one it is? Lol
g003menu.eng: flashcard-bootstrap with M3 header encryption applied

Actually Xenon++ had a different implementation of G003 bootstrapping in his own mshl2tools project, but he made a few incorrect assumptions on the G003's boot process. Or maybe it worked for him, but it didn't work for me on the _M3_MENU.DAT files I had. Nonetheless, he is the one who wrote the header encryption tool (and nearly half of the other things used in this flashcard-bootstrap project), and I wish to show appreciation for all the work he put into the DS scene 10 years ago. He was too early for his time (or maybe I am too late for my time?)
Post automatically merged:

This is amazing! This was just what I needed to get my (admittedly probably janky) MoonShell 2.10 setup running on my R4i SDHC. Now I can boot directly into moonshl2.nds, and then use inilink/iniclear/mshl2wrap to load commercial ROMs.
On that... I wonder if it's possible to add nds-bootstrap support to inilink... Seems like a really stupid project
 
Last edited by lifehackerhansol,
v1.2.1

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada

flashcard-bootstrap v1.2.1

Improvements

  • Switch to open-source Ace3DS+ DLDI
  • Switch to open-source DSONE SDHC DLDI
  • Switch to open-source DSTT DLDI
    • SD/SDHC detection is fixed. Now you can use 2GB SD cards without it failing! (why would you ever want to do this)
The open-source DSONE SDHC source code was very incomplete and slow, but all of that is fixed here now.
 
v1.2.4

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada

flashcard-bootstrap v1.2.3/v1.2.4

What's new?

  • Added support for the Datel Games 'n' Music and the Action Replay DSi: bootme.nds

Improvements

  • Newly written DLDIs, based on a newly written original R4 DLDI, dubbed r4tfv3 (though original R4 is currently not used in this project yet)
  • Rewritten DLDIs based on r4tfv3 are as follows:
    • Ace3DS+
    • M3 DS Real
    • DSTT
    • DSONE
    • DSONE SDHC
  • Switched to open source GMP-Z003 driver (also based on r4tfv3)

Bug fixes

  • Fix DSONE SDHC not having non-SDHC support temporarily. Added with the new rewrite.

Thanks to @Gericom for a new set of code for cartridge operations!
 
Last edited by lifehackerhansol,
v1.3.0

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada

flashcard-bootstrap v1.3.0

Please read the original post for usage instructions!

What's new?

  • Added support for the EDGEi (dsedgei.dat)
    • Not to be confused with the original EDGE or the iEDGE!

Improvements

  • DLDI space is increased to 32KB. This introduces compatibility of launching flashcard-bootstrap from very old homebrew apps.
    • This requires forking libnds: it now lives at https://github.com/lifehackerhansol/libnds32
    • Moonshell 2, for instance, regardless of available DLDI space, will write the entire 32KB data into the binary, corrupting flashcard-bootstrap (and pretty much all other homebrew since 2017) in RAM and causing the system to freeze.
    • flashcard-bootstrap will refuse to launch `boot.nds` if the actual DLDI driver is over 16KB, as modern homebrew is now using 16KB drivers and anything over that will not fit.

pssst: This cart supports a newer kernel, BL2CK! You can find the kernel here: https://flashcard-archive.ds-homebrew.com/EDGEi/
 
v1.4.0

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada

flashcard-bootstrap v1.4.0

Please read the original post for usage instructions!

What's new?

  • Added support for the EZ-Flash Vi (ez5isys.bin)
  • Added support for the r4i.cn flashcart (_ds_menu.nds)
    • Side note: both of the carts are identical to the iSmart Premium, which has an open-source DLDI driver.

Improvements

  • Bootloader module is updated to nds-hb-menu version 0.9.0.
  • Binary size has been reduced.
    • R4i-SDHC and related timebomb carts have seen over 200KB decrease in size!
    • All other carts have seen roughly 20KB decrease in size.
 
v2.0.0

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada

flashcard-bootstrap v2.0.0

Please read the original post for usage instructions!

What's new?

  • Project has completely moved to BlocksDS.
    • All devkitPro dependencies have been either refactored or forked.

Improvements

  • By switching to BlocksDS, file size has further decreased.
    • An average of about 70KB decrease is seen.

Many thanks to @asiekierka and @AntonioND for BlocksDS and help in the transition!
 
v2.2.0

lifehackerhansol

i write working(?) code
OP
Member
Joined
Oct 2, 2021
Messages
468
Trophies
0
XP
1,443
Country
Canada
kinda forgot this thread existed lol

flashcard-bootstrap v2.1.0/v2.2.0

Please read the original post for usage instructions!

What's new?

  • Added support for the r4dspro.com carts (in r4dspro.com folder)
    • This cart's firmware has a bug that required it to be separated from other Acekard 2 derivatives.
  • Added support for the EZ-Flash Parallel (ezds.dat)

Improvements

  • Updated BlocksDS to v0.14.0
  • Added a fix for timebomb carts not booting.
    • Turns out some variants of this cart does in fact need bloating, so the inflator has returned...
  • Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Lol rappers still promoting crypto