C3 and SD
Rsadeika
Posts: 3,837
I was just testing out my C3 board, just to see if it still works, and I tried too get the SD mounted, how is that being done now days. It seems like the sd_mount() is not working for me. Is that in the documentation some where?
Ray
Ray
Comments
I recommend formatting your SD card or doing an error check.
Error-Check: Insert SD card into PC. Right click on it (windows) and choose properties. Click Tools tab, and run Error-Checking.
My SD card would not work until I did error-check.
Out of curiosity, which of the Parallax boards support XMM-SINGLE External RAM and XMM-Split ... modes, I just tried using those on the C3, and was not successful. It seemed like before everything use too work so smoothly, now it is...
Is SimpleIDE becoming a tool just for the Activity and PropBOE boards? To use all the other boards you have too go through all kinds of contortions... I better shut up before I am asked to leave.
Ray
Ray
You're my best customer.
As I said before, Simple Libraries are not compiled for xmm-single and xmm-split. You can compile them yourself by opening the libraries you care about and selecting xmm-single then compile, and xmm-split then compile.
Parallax wanted Simple View for the education program. Maybe we can convince Andy to precompile all versions of libraries for distribution (with a Makefile).
https://sites.google.com/site/propellergcc/documentation/libraries#TOC-Console-and-File-system-driver-initialization
Andy doesn't cover the C3 board in his tutorials.
The C3 should support all of the XMM modes assuming that the program you're trying to run fits. The main problem with fitting is with XMM-SINGLE where the entire program and data must fit in < 64k (the size of the two SRAM chips on the C3).
I tried building filetest.c under SimpleIDE, and it failed for me with an unresolved symbol "getcnt". Is this the error you're getting? I changed "getcnt()" to "CNT", and it works OK. Select "C3F" for the board type in SimpleIDE.
Dave
Ray
You are missing a few key pieces of code in your program. At the beginning of your program add the following lines: At the end of your mount routine add this: That should fix your program.
Since the C3 is an orphan, in terms of C support, I think I will have to create a C3.c file, and start putting in the necessary drivers as they become available. I will probably have to do the same thing(DNA.c) with the DNA-RTC board, another orphan, also. Having the drivers file added in for compile time will also allow me to use an XMM mode without any problems, I hope. "Back to the Future"...
Ray
Ray
In that case the mount is handled automatically thanks to David Betz. I was never able to convince Andy to use that method though.
Ray, can you run any program from XMMC ?
As long as you select either C3 or C3F for the board type you shouldn't have to perform the mount yourself.
@Dave, I can run filetest.c in CMM mode, but in XMMC mode the SD does not get mounted.
That is what I thought, but when I tried it that way the SD was not mounted.
Ray
This one does not use Simple Libraries.
I am going to see if I can figure this out for myself, I am most certain that it is some minute detail that I overlooked that is causing the problem. After all it used to work before without any problems, sorry about the big fuss.
While I am doing that I will have to give some more thought as to the best way to get "C" drivers for the other things on the C3 board, like A/D conversion, maybe some functional servos, and what else? Oh, have them work in XMM mode. I am still looking for way to access cogs in XMM mode, something a lay person can understand and work with.
Ray
Simpletools has a lot of time saving functions, maybe at some point they will be added to propeller.h, and then you would be able to use the XMM mode without any problems. As an example, I have been using fwrite() to write to the SD, in Simple View, now I do not know if that is strictly simpletools function or is it available without simpletools. It is almost like you are going to have two sets of tools, and two learning strategies, once you move to Project View status then you will have to learn how too use a new set of tools. I guess in a nutshell simpletools is not a subset propeller.h.
Now I am not so sure about SimpleIDE, maybe SimpleIDE should just be Simple View, and have a separate IDE for the regular "C" programming.
Ray
However, just setting the board type is not enough. You also have to have the file driver in your file list. You can either define your own driver list, which would include the serial driver and the file driver, or you can add the file driver by calling add_driver. I wasn't aware of the add_driver routine before, but that's how sd_mount does it.
I replaced the call to sd_mount in "SD with Tests" with the following code, and it works!
If you have a board with a simple 4-pin SD interface you could define CALL_SD_MOUNT along with SO, CLK, DI and CS, and you don't need to tell SimpleIDE your board type. However, if your board does not have a simple 4-pin SD interface you must select your board type in SimpleIDE, and don't define CALL_SD_MOUNT. Or you could write your own mount routine, which is what filetest.c does.
I realize this is very confusing. I think the confusion could be reduced if the sd_mount routine accommodated the serial and parallel SD interface types in addition to the simple interface type.
EDIT: So I'm suggesting that sd_mount have 8 parameters, where the first parameter is the interface type, and the remaining 7 parameters are used to convey the pin numbers and CS selection value. If the first parameter doesn't match either the simple, serial or parallel values sd_mount could just call add_driver without calling dfs_mount, and it would rely on the loader to initialize the file system.
Ray
After thinking about it for a while this could be fixed by allowing sd_mount to have a variable number of parameters. If four parameters are specified it would configure for a simple interface like it currently does. If 6 parameters are specified it will configure for a serial SD interface, and if 7 parameters are specified it would configure for parallel. If no parameters are specified it would use the configuration set by the loader. Doing it this way will allow sd_mount to be backwards compatible with the current use for a simple serial interface.
I'm not sure about this, but it may be necessary to add a null driver entry to the list like below for using simpletools.h .
I'll update the code listing.