Offline
Jr. Member
Karma: 0
Posts: 57
|
 |
« on: June 05, 2011, 08:08:50 pm » |
Look. I know this has been asked a MILLION times but I'm still confused as to the answer. Is it AT ALL possible to run Arduino-language code off an SD card? I assume you'd have to mess with the bootloader but how do you do that? Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 0
Posts: 360
Arduino rocks
|
 |
« Reply #1 on: June 05, 2011, 09:27:50 pm » |
No.
"Arduino language" code gets compiled to CPU instructions, which are loaded by the CPU from its internal flash. Adding an SD card via the bootloader doesn't help, since the code STILL needs to be loaded onto the ATmega at some point.
Of course, you could write your own interpreter for C/C++ and load a text file off an SD card, but it'd probably be a huge undertaking for very little gain.
If you're actually using more than 32 kilobytes of compiled code (that's something near 10000 lines, extrapolating from my existing code) in an Arduino, its past time for you to either a) optimize or b) use a bigger/better/faster controller.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 0
Posts: 507
|
 |
« Reply #2 on: June 06, 2011, 12:49:41 am » |
As Aeturnalus points out you cannot run arduino compiled code straight from a sd card. The code must be in flash memory.
There are some options but they are a long shot.
You can put "logic" on the sd card that drives some pre-arranged functionality, but it is well outside the lines of arduino to do so. It would be like defining your own virtual machine language interpreter and putting the bytecode on the sd card. It needent be quite that formal however, it could just be a handful of functions and some virtual registers to tie the functions together with the order of operations stored on the sd. Probably a performance hit, but could save space.
Also not in scope would be to store executable code on the sd card and load it into flash as needed. This would be ok for a rarely called function, but you will be testing the limits of your flash to rewrite it frequently, and you have to write a page at a time and play with fuses.
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #3 on: June 06, 2011, 02:53:36 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 334
Posts: 36453
Seattle, WA USA
|
 |
« Reply #4 on: June 06, 2011, 06:21:46 am » |
Look. I know this has been asked a MILLION times but I'm still confused as to the answer. How many times do you have to read NO, without ever reading YES, to stop being confused?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 0
Posts: 507
|
 |
« Reply #5 on: June 06, 2011, 06:35:27 am » |
I don't think he has seen a clear "No". The other thread has a couple long-winded Yes's in it. I'm not saying No, because you can run code off an SD card, just not directly. bitlash is a prime example, it runs arduino "looking" code from a sd card (though I have no clue what the motivation for writing it was).
|
|
|
|
« Last Edit: June 06, 2011, 06:41:33 am by dcb »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #6 on: June 06, 2011, 06:40:30 am » |
I certainly wouldn't say "no", but as usual, if you have to ask the question...
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 299
Posts: 26025
Solder is electric glue
|
 |
« Reply #7 on: June 06, 2011, 09:07:57 am » |
because you can run code off an SD card, just not directly. If it is not directly it is not running code off an SD card. You can't run code off an SD card. Maybe you want to ask the question, Can I store code on an SD card and use that to load it into the arduino to run. The answer to that is "not without considerable difficulty"
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #8 on: June 06, 2011, 11:47:15 am » |
Maybe you want to ask the question, Can I store code on an SD card and use that to load it into the arduino to run. The answer to that is "not without considerable difficulty" Well the uMMC bootloader does that with reasonable ease (mind you it does have another processor sorting a lot of the stuff out and a modified bootloader). If it is not directly it is not running code off an SD card. You can't run code off an SD card. I'd say bitlash is code and you can run bitlash using an arduino off of an SD card. Why's that not direct?
|
|
|
|
« Last Edit: June 06, 2011, 11:50:43 am by mowcius »
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 299
Posts: 26025
Solder is electric glue
|
 |
« Reply #9 on: June 06, 2011, 11:53:15 am » |
I'd say bitlash is code And I would say it is not.
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #10 on: June 06, 2011, 12:00:38 pm » |
And I would say it is not. I suppose that depends upon your definition of code. I presume you're talking specifically source code. Wikipedia says: In computer science, source code (commonly just source or code) is any collection of statements or declarations written in some human-readable computer programming language. Source code is the mechanism most often used by programmers to specify the actions to be performed by a computer. With that definition, I'd say bitlash is code. Or is your definition more like: A text listing of commands to be compiled or assembled into an executable computer program (Also specifically 'source code') I suppose bitlash isn't really assembled - they're more instructions or commands but then I'd say that html is also instructions/commands and not really assembled/compiled.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 0
Posts: 507
|
 |
« Reply #11 on: June 06, 2011, 12:43:04 pm » |
"Hey, where did that code you are running come from"
"It came off the SD card"
not much point in arguing semantics.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 0
Posts: 507
|
 |
« Reply #12 on: June 06, 2011, 12:55:09 pm » |
bitlash is code. It isn't binary machine language, but it absolutely is code and can make the CPU do stuff.
Code you run in flash that was loaded off SD card is also a reasonable interpretation.
But nobody has really explained WHY this is even necessary. I can think of a few hypotheticals but I'm not going there. I want to hear what problem the OP is really trying to solve.
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #13 on: June 06, 2011, 02:00:11 pm » |
I have thought of a few reasons for wanting to be able to do something similar (but not quite what has been posted).
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 299
Posts: 26025
Solder is electric glue
|
 |
« Reply #14 on: June 06, 2011, 02:07:39 pm » |
bitlash is code. No it is not. It is text that gets interpreted. You might as well call sensory data code as it is read by a program and the program changes its behavior depending on the sensory input.
|
|
|
|
|
Logged
|
|
|
|
|
|