A method of downloading a main code to a flash memory is provided. The
method includes: comparing the size of the buffer with the size of the
flash memory and determining a number of stages or segments in which the
main code is to be downloaded to the flash memory based on the comparison
results; obtaining a plurality of sub-main codes by dividing the main
code by the determined number; generating a plurality of flash loader
codes corresponding to the sub-main codes; and downloading the sub-main
codes to the flash memory using the flash loader codes. Accordingly, it
is possible to use the entire storage capacity of the flash memory even
when the flash memory size is not smaller than the buffer size.