Pages: 1 [2]   Go Down
Author Topic: Small SD card code?  (Read 2664 times)
0 Members and 1 Guest are viewing this topic.
Stockton, CA
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

as interesting as the idea is. wouldn't it be easier to take the time to write out a 'full' (i'm using this term loosely) bootloader similar to a PC's embeded chip that allows it to boot the ram/hdd?

it seems like a bootloader could be written that could not only boot the sd but also there should be enough room left over to throw in an interpreter for c files...

i just figure that if someone can write a functional 3 line (30 mb) program that can check the answers to calculus equations. then it should be able to be done. and before anyone says that doing this would leave no room on the chip...i want to say "YOUR RIGHT!!! IT WOULDN'T" but considering you would then be able to use a sd card..which i beleive do come in gb....you wouldn't need the eprom anymore...

in a way doing this would also cause the arduino to be classified as a true micro computer...and not just a chipset or...yah...forgot the others...

anyways...my point is...if i got a basic outline of such a bootloader...would anyone be willing to aide in perfecting it?
Logged

Finland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

All three Sdboot examples worked well in Arduino Uno (328P) with an Ethernet shield. A 2 gigabyte Sd -card   of a not a well known manufacturer. Arduino 1.0. Windows XP. The only thing was to change the pin nr in the library as instructed earlier.
No hardware errors reported either.
sizeTest program file (flash)  size was 1634 bytes .
File TEST.BIN was read in 210 seconds with readTest.

This code is something I had hoped to be written, and it happened sooner than I expected. Excellent work.

Thanks to fat16lib!
« Last Edit: February 02, 2012, 06:23:20 am by optimistx » Logged

0
Offline Offline
Edison Member
*
Karma: 63
Posts: 1604
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A new version of SdBoot is attached to this reply.  You must be logged in to download the the attachment.

I fixed a couple of bugs.  The most serious bug required a major change to avoid a 32-bit multiply and the increase in flash size.

I added a number of configuration options and improved error handling.  I managed to limit the size increase to six bytes by optimizing several areas.

The options such as chip select pin can be set by editing SdBootConfig.h.

* SdBoot20120202.zip (8.43 KB - downloaded 29 times.)
Logged

Finland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The new version worked with the configuration file.  sizeTest 1644 bytes. readTest time in fast mode 85 seconds.

In future we might transfer  new versions of application programs  via internet or phone to an SD card file of Arduino,  anywhere in the world, and Arduino would update (= replace) its own application program in the program memory using the boot program.
« Last Edit: February 03, 2012, 03:36:35 am by optimistx » Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1899
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

All
This sounds very interesting but I fail to feel confident about what this is about. So I have some questions.

I think this is about a sketch that allows to load and run a sketch written on a sd card. The total size of the Arduino bootloader and the sketch from fat16lib and the sketch on the sd card can not be bigger than the total amount of flash memory on your Arduino.

Assuming the above is correct. What I don't understand is:
Is the sketch from fat16lib some code I include in my sketch or is it a sketch on its own.
When the sketch from fat16lib has uploaded the SD card content and I remove the sd card and reset arduino what is running on the arduino? the sdcard code or the sketch from fat16lib?
The code on the sdcard is this a hex file? If not how do I create it?

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The total size of the Arduino bootloader and the sketch from fat16lib and the sketch on the sd card can not be bigger than the total amount of flash memory on your Arduino.
Correct, except that the program written by fat16lib (or something similar) should be added to the bootloader so the Arduino can boot from an SD card. So there would only be two programs, the BL and the application sketch.

Quote
Is the sketch from fat16lib some code I include in my sketch or is it a sketch on its own.
The program written by fatlib16 is a file reader, if added to a bootloader the lot will reside in the upper portion of the flash memory. In general a bootloader will get a file from somewhere (UART or SD or outer space, it doesn't matter) and burn the contents of that file into lower flash memory.

Having done so it will jump to the newly burned program.

Now I think we started talking about the bootloader testing for a file on the SD at power up, if it finds the file it does the above. If not it simply jumps into the resident program.

What optimistx is talking about it taking it a step further. On a given trigger the bootloader could download a file from say the internet, burn it into the SD card then restart the chip. This would cause the above mechanism to be invoked and voila you can update your gadget from 10000k away with no need to mail an SD card or have the user burn one themselves.

Quote
Is the sketch from fat16lib some code I include in my sketch or is it a sketch on its own.
He has provided some utility functions that can be used in your programs, plus a few test sketches.

Quote
When the sketch from fat16lib has uploaded the SD card content and I remove the sd card and reset arduino what is running on the arduino? the sdcard code or the sketch from fat16lib?
As I understand it the code is just a file reader not a bootloader. So it doesn't write to the flash at all, so if you load one of the test sketches that's what will always run regardless of how many times you read a file from the SD.

Quote
The code on the sdcard is this a hex file?
At present I think it simply reads any file, it could be the first chapter of "War and Peace". When/if this is incorporated into a bootloader the file format can be HEX or binary or anything, however HEX would be the most likely.

I've not been following this for a few days and just caught up, apologies if I have the wrong end of the stick.


______
Rob
« Last Edit: February 03, 2012, 06:45:41 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1899
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Rob
Thanks for the explanation.
It is lots clearer now. I'm still not 100% understanding but I guess that is because we are in the early stages.
Best regards
Jan
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Pages: 1 [2]   Go Up
Jump to: