<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>reading from sd</title>
<description> hello guys...
I have another request....is there any library could hrl reading from sd slot?

thx
Amedeo</description><link>http://forum.wiibrew.org/read.php?11,13548,13548#msg-13548</link><lastBuildDate>Fri, 12 Jun 2026 03:50:00 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,23307#msg-23307</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,23307#msg-23307</link><description><![CDATA[ Was that always there? Thanks for the hint.<br /><br />You can still use "fat" if you want. I use that for example in my Gecko OS mod that loads Ocarina from sd and usb. Only if you use fatinitdefault, you can&#039;t use "fat" anymore, and i already told why i don&#039;t recommend using fatinitdefault.]]></description>
<dc:creator>WiiPower</dc:creator>
<category>Coding</category><pubDate>Thu, 02 Jul 2009 12:25:33 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,23299#msg-23299</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,23299#msg-23299</link><description><![CDATA[ fatMountSimple, fatMount and fatUnmount automatically handle device startup() and shutdown() functions, there shouldn&#039;t be any need for you to call them twice.<br /><br />Another interest of fatInitDefault is to set the first detected FAT device as default IO device so that you can simply access files without specifying "sd:" or "usb:". By the way, I don&#039;t think "fat:" is supported anymore with the current interfaces.]]></description>
<dc:creator>ekeeke</dc:creator>
<category>Coding</category><pubDate>Thu, 02 Jul 2009 09:59:46 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,23293#msg-23293</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,23293#msg-23293</link><description><![CDATA[ I use:<br />#include sdcard/wiisd_io.h<br /><br />And:<br />__io_wiisd.startup();<br />fatMountSimple("sd", &__io_wiisd);<br />to mount the sd card<br /><br />and:<br />fatUnmount("sd");<br />__io_wiisd.shutdown();<br />to unmount it again.<br /><br />If you do IOS Reloads or want to change the sd card inside the program you need the unmount. Also i prefer fatmountsimple because it only touches the sd card, while fatinitdefault inits ALL storage devices it finds, if you have an usb pen connected at the same time, it gets initialised too.<br /><br />I never got any code dumps because of this code, and also you can accesss all files with "sd:/filename" without problems, or change "sd" to "fat" for example if you use both sd and usb, just not at the same time, and want to use the same filenames for both.]]></description>
<dc:creator>WiiPower</dc:creator>
<category>Coding</category><pubDate>Thu, 02 Jul 2009 08:46:20 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,23108#msg-23108</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,23108#msg-23108</link><description><![CDATA[ figured it out -_-<br /><br />so aparently "fatMountSimple("sd", &__io_wiisd);" just doesn&#039;t work o.O<br /><br />anyhow, here is the working code:<br /><br /><pre class="bbcode">
#include <stdio.h>
#include <sdcard/wiisd_io.h>
#include <fat.h>
#include <gccore.h>
#include <string>
#include "FileIO.h"

namespace FileIO{
 
	void InitFat(){
		//__io_wiisd.startup();
		//fatMountSimple("sd", &__io_wiisd);
		fatInitDefault();
		//fatMountSimple("sd", &__io_wiisd);
	}
	
	void SDTest(){
		FILE* test;
		test = fopen("test.txt", "w");
		fprintf(test, "Hello World!\n");
		fclose(test);
	}
}

</pre>]]></description>
<dc:creator>CloneDeath</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 00:37:55 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,23101#msg-23101</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,23101#msg-23101</link><description><![CDATA[ Arg, I keep getting a code dump I need help @_@<br /><br />It compiles fine, and I included the lib.<br /><br />It works fine until I press A, then it just barfs all over my screen, with the whole DSI exception, Stack Dump, and Code Dump :P<br /><br />Here is the two functions that I use:<br /><br /><pre class="bbcode">
#include <stdio.h>
#include <sdcard/wiisd_io.h>
#include <fat.h>
#include <gccore.h>
#include <string>
#include "FileIO.h"

namespace FileIO{
 
	void InitFat(){
		//__io_wiisd.startup();
		//fatMountSimple("sd", &__io_wiisd);
		fatInitDefault();
		fatMountSimple("sd", &__io_wiisd);
	}
	
//This is the function it crashes on...
	void SDTest(){
		FILE* test;
		test = fopen("sd:/test.txt", "rw");
		fprintf(test, "Hello World!\n");
		fclose(test);
	}
}</pre><br />I call InitFat once then run the SDTest and it crashes there.<br /><br />I get all the complicated stuff for the game done, but I can&#039;t figure out simple saving and loading #_#<br /><br />P.S. I know the code is bad, but I just want this to work so I could start making the actual saving and loading system.]]></description>
<dc:creator>CloneDeath</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 00:10:05 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,14702#msg-14702</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,14702#msg-14702</link><description><![CDATA[ Well sure enough, it is not opening my file so when I try to read the file I get a Code Dump.<br /><br />But as to why it can&#039;t open the file, I don&#039;t know. The code looks right....<br />I put the file on the root of the SD card. File has the right name.<br />I even put a copy of the file in the same directory as my application just in case it wasn&#039;t looking in the root dir.<br />Still no luck.<br /><br />*******************************<br /><b><u>PROBLEM SOLVED!!!!!</u></b><br /><br />1) If I use "sd:/filename" it does NOT work but if I use just plain "filename" it does work<br />2) SDHC does not work but a plain SD card does - this now explains why on some of the Homebrew I get a Core Dump<br /><br />I updated my DEVKITPRO to the latest and recompiled and now SDHC <b><u>WORKS!!!!!</u></b>]]></description>
<dc:creator>csanii</dc:creator>
<category>Coding</category><pubDate>Fri, 17 Apr 2009 23:30:13 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,14625#msg-14625</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,14625#msg-14625</link><description><![CDATA[ I can&#039;t see a problem. Looks like you have the correct libs.<br /><br />Maybe your buffer[20] is not big enough. You could always put a NULL check on the file to ensure it&#039;s actually opening the file.<br /><br /><pre class="bbcode">
FILE* fp = 0;
fp=fopen("sd:/gamefile.dat","rb");
if(!fp) exit(0);</pre><br />Also don&#039;t forget in the printf("%s\n",buffer); your buffer is treated as text and needs to be NULL terminated. So if you&#039;re reading 20 bytes from the file then your buffer should be buffer[21] = {0} otherwise the printf will overrun the buffer.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Fri, 17 Apr 2009 06:20:07 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,14608#msg-14608</guid>
<title>Code Dump???</title><link>http://forum.wiibrew.org/read.php?11,13548,14608#msg-14608</link><description><![CDATA[ I am not sure what is wrong with this code....<br />It compiles with no issues but when I run it I just get a Code Dump.<br />There are arrows around the include names but the forum doesn&#039;t show them.<br /><br />#include stdio.h<br />#include fat.h<br />....<br />char buffer[20] = {0};<br />FILE* fp;<br /><br />fatInitDefault();<br />fp=fopen("sd:/gamefile.dat","rb");<br />fread(buffer, 20, 1, fp);<br />printf("%s\n",buffer);<br />fclose(fp);<br /><br />Anyone see the problem?<br /><br />My makefile has the following:<br />LIBS := -lfat -lwiiuse -lbte -logc -lm<br />Does the order matter? Am i missing a library?<br />There are no compile or linking error messages.]]></description>
<dc:creator>csanii</dc:creator>
<category>Coding</category><pubDate>Fri, 17 Apr 2009 03:17:10 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13918#msg-13918</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13918#msg-13918</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Tantric</strong><br />Here&#039;s a better example:<br />This was what I was looking for...perfect example!!!<br /><br /><br /><pre class="bbcode">

fatInitDefault(); // should only be called once

// will read in the whole file

char * buffer; // file buffer
int size = 0; // file size
FILE* file = fopen("sd:/hello.txt","rb");

if(file &gt; 0)
{
	struct stat fileinfo;
	fstat(file-&gt;_file, &fileinfo);
	size = fileinfo.st_size;	
	buffer = (char *)malloc(size);
	fread(buffer, 1, size, file);
	fclose(file);
}

// call this when you&#039;re done with the file data
free(buffer);

</pre></div></blockquote>]]></description>
<dc:creator>trottolo</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Apr 2009 13:04:34 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13705#msg-13705</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13705#msg-13705</link><description><![CDATA[ Here&#039;s a better example:<br /><br /><pre class="bbcode">

fatInitDefault(); // should only be called once

// will read in the whole file

char * buffer; // file buffer
int size = 0; // file size
FILE* file = fopen("sd:/hello.txt","rb");

if(file &gt; 0)
{
	struct stat fileinfo;
	fstat(file-&gt;_file, &fileinfo);
	size = fileinfo.st_size;	
	buffer = (char *)malloc(size);
	fread(buffer, 1, size, file);
	fclose(file);
}

// call this when you&#039;re done with the file data
free(buffer);

</pre>]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Wed, 08 Apr 2009 20:59:47 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13704#msg-13704</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13704#msg-13704</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>scanff</strong><br />If you&#039;re just wanting to read a file then...<br /><br /><pre class="bbcode">

fatInitDefault();

FILE* f;
char buf[50] = {0};

f = fopen("/hello.txt","r"); // will be root of the SD
fread(buf,50,1,f);
fclose(f);

</pre></div></blockquote><br />Actually, that might not be the root of the SD. Depends on if SD was mounted and set as the default devoptab device. It&#039;d be best to do this instead:<br /><br />f = fopen("sd:/hello.txt","r"); // will be root of the SD]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Wed, 08 Apr 2009 20:51:24 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13703#msg-13703</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13703#msg-13703</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>cdmac</strong><br />libfat, which is installed as part of devkitpro.<br /><br /><pre class="bbcode">
#include fat.h // Should have angle brackets but this forum doesn&#039;t display them
...
fatInitDefault();
fatMountSimple("sd", &__io_wiisd);
</pre></div></blockquote><br />fatMountSimple("sd", &__io_wiisd); is not required - this is done by fatInitDefault()]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Wed, 08 Apr 2009 20:50:27 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13652#msg-13652</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13652#msg-13652</link><description><![CDATA[ If you&#039;re just wanting to read a file then...<br /><br /><pre class="bbcode">

fatInitDefault();

FILE* f;
char buf[50] = {0};

f = fopen("/hello.txt","r"); // will be root of the SD
fread(buf,50,1,f);
fclose(f);

</pre>]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 08 Apr 2009 08:36:13 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13651#msg-13651</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13651#msg-13651</link><description><![CDATA[ thx for reply...could you add the code of your test software?]]></description>
<dc:creator>trottolo</dc:creator>
<category>Coding</category><pubDate>Wed, 08 Apr 2009 08:23:29 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13565#msg-13565</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13565#msg-13565</link><description><![CDATA[ libfat, which is installed as part of devkitpro.<br /><br /><pre class="bbcode">
#include fat.h // Should have angle brackets but this forum doesn&#039;t display them
...
fatInitDefault();
fatMountSimple("sd", &__io_wiisd);</pre><br />From then on you can access files on the SD card by just using the regular C file operations. Just add sd:/ (or whatever you mounted the drive with) to the beginning of your path name.<br /><br />Oh yeah, you have to link with -lfat too, and I found the order important. I have mine declared at the beginning of my library list, after -ldb.<br /><br />Thanks,<br />cdmac]]></description>
<dc:creator>cdmac</dc:creator>
<category>Coding</category><pubDate>Tue, 07 Apr 2009 20:01:23 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13564#msg-13564</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13564#msg-13564</link><description><![CDATA[ hrl= help ...but I don&#039;t know why I wrote that....]]></description>
<dc:creator>trottolo</dc:creator>
<category>Coding</category><pubDate>Tue, 07 Apr 2009 19:44:36 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13551#msg-13551</guid>
<title>Re: reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13551#msg-13551</link><description><![CDATA[ hrl?<br /><br />:D]]></description>
<dc:creator>daniel_c_w</dc:creator>
<category>Coding</category><pubDate>Tue, 07 Apr 2009 16:08:24 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,13548,13548#msg-13548</guid>
<title>reading from sd</title><link>http://forum.wiibrew.org/read.php?11,13548,13548#msg-13548</link><description><![CDATA[ hello guys...<br />I have another request....is there any library could hrl reading from sd slot?<br /><br />thx<br />Amedeo]]></description>
<dc:creator>trottolo</dc:creator>
<category>Coding</category><pubDate>Tue, 07 Apr 2009 15:59:18 +0200</pubDate></item>
</channel>
</rss>