hi i am making a sd card bootloader for pic32.I have used the sample program and it works fine.Now what i want to do is to download a hex file from server using a sim900 gprs.
What i want to know is how do i direct this downloaded file to the be written to the sd card memory??Can a hex file be downloaded directly???Please if u cant guide me in the write direction
You have two ways doing this,
1. Storing the direct binary values as a file, and loading directly on SD card. (you can use hex2bin executables)
2, Storing hex file in server and after reading you have to decode it to binary values. (you have to write code for decoding hex file)
I think the first way is easy, but will take little more data usage in net pack.
But i dont want to convert it do binary. my bootloader searches for "image .hex".
i can download the file using AT commands,But am not able to store it sd card using the pic32 controller???
Storing the hex file directly on the SD card is useless, because it cant be executed directly, It has to be processed and has to decoded as binary values for a controller to execute.
What problem you are having in writing to SD card, you can use SPI and write sector by sector.
my bootloader loades the hex file from the sd card.
i store it at location 6x000 of the microcontroller(this is the main program).but when i download the new file using the main program i do not have a location..??
this is using the at commands for the sim900
so how will i be able to store it in sd card..????
Question from sample code:
In which format you stored hex file in your SD card (is it intel hex an ASCII file)? Using FAT file system ?
Now you can split the application
1, downloading the file and storing on SD card.
2, Reading the SD card and booting with the boot loader.
You already completed the second part.
So you need libraries for,
downloading a file from server for GPRS module
Storing a file on FAT file system using SD card (might be library for filesystem is already used in your sample code for SD card reading )
You can download the microchip MLA application library for a fast start.
The hex file i am storing is an ascii file.
Yes i am using MDD file system for reading from sd card.And yes i can do the reading part.
But writing..???i dont have a clue....
And i checked the microchip MLA and couldnt find something that helps me..!!
- - - Updated - - -
i think i found how to create the file in the sd card
Code:
while (!FSInit());
// Create a file
pointer = FSfopen ("image.hex", "w");
if (pointer == NULL)
while(1);
// Write 21 1-byte objects from sendBuffer into the file
if (FSfwrite (sendBuffer, 1, 21, pointer) != 21)
while(1);
// FSftell returns the file's current position
if (FSftell (pointer) != 21)
while(1);
i still have to figure out how to copy contents of the downloaded hex file to this file created here.
- - - Updated - - -
ok the sendbuffer is the content that is being copied..!!