Executing CODE from SD card

I want to change the bootloader or make a sketch which reads the compiled code from SD card and executes the code as I need to write some huge sketches which will not fit the FLASH memory.
I dont have a deep knowledge of bootloader or inners of an SD card and code execution mechanism of Arduino.

That is not possible with arduino. You can execute the binary code which fits in the flash and ram.

Why is the sketch so large anyways?
Does it have lots of data (stuff that is not code) such as pictures or sound?
If so you could have your program read the data from the sd card when it is needed.
Also you could try optimizing your sketch.
I have seen many examples of arduino code that could be made smaller without sacrificing functionality.
If you want to could you post your code so that I can see what it is that you are trying to do.
Anyways you don't have much ram and the AVR uses the harvard architecture which means flash and ram are separate and as such you cannot execute code from ram.
You could make a bootloader that would load code from the SD card and store it into flash memory but that does not solve the size issue.

Thanks for clarification and support, actually my project needs to handle 4X4 matrix keypad, atleast 10 digital I/O lines, an I2C 20X4 LCD display, and serial communication with PC. Currently I am using 89c4051 micro-controller and programming in assembly, the program is over 1200 lines of code, but compiles less than 4K.
While experimenting with arduino I noticed that simple LED sketches could take more than 2K of flash, so I was looking for a way to increase program memory.
Is there any other arduino compatible derivative which has larger flash and similar I/O as MEGA328 ?

While experimenting with arduino I noticed that simple LED sketches could take more than 2K of flash, so I was looking for a way to increase program memory.

That still leaves nearly 30K of flash/program memory.

Is there any other arduino compatible derivative which has larger flash and similar I/O as MEGA328 ?

The Mega and the Due.

I am not sure what led sketch you are running but you can blink an led in less than 100 bytes. The 2k (I am assuming you mean kilobytes not kilobits) sketches that you saw may have been programmed inefficiently. What you want to do on the atmega382 will fit just fine.

you should pick a part with more Flash.... if possible... :slight_smile:

1284P is also similar, nice part in that it also available as a DIP for easy replacement when you smoke it.
128K flash, 16K SRAM, 32 IO, dual hardware serial ports.
I offer a duemilnove style kit/board (FTDI interface vs 16U2 interface)
http://www.crossroadsfencing.com/BobuinoRev17/

1284P is also similar, nice part in that it also available as a DIP for easy replacement when you smoke it.
128K flash, 16K SRAM, 32 IO, dual hardware serial ports.
I offer a duemilnove style kit/board (FTDI interface vs 16U2 interface)

How about programming this device, is it arduino compatible?

Yes, totally. There are links to "core files" and updated pins_arduino.h on my webpage, about 1/2 way down.
Those have been updated in the last few days,

I program them using IDE 1.0.5 regularly.

There is also this set of boards that will give you more room and speed.
https://www.pjrc.com/teensy/