I ran it unpatched, because your code does not have a file system access. AFAIK r4 should work fine too, so the problem is somewhere else...
A thing I have noticed is that in your batch file you're patching the nds rom with dsbuild. You need to use the nds file for your card, because nds.gba are only used on some slot2 devices to run nds roms in gba mode.
In fact, trying to run the nds.gba rom, the touch screen does not work at all and the nds freezes. Try to use the .nds file and let me know if it works or not.