Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Download Hex file to controller

Status
Not open for further replies.

Dhruv@aks

Newbie level 6
Joined
Sep 4, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
93
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
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,069
if you have a modem with a TCP/IP stack you could use FTP to download the file or write your own client/server TCP application
 

Venkadesh_M

Advanced Member level 4
Joined
Jun 26, 2013
Messages
1,375
Helped
258
Reputation
516
Reaction score
254
Trophy points
83
Location
Coimbatore, India
Activity points
6,738
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.
 

Dhruv@aks

Newbie level 6
Joined
Sep 4, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
93
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???
 

Venkadesh_M

Advanced Member level 4
Joined
Jun 26, 2013
Messages
1,375
Helped
258
Reputation
516
Reaction score
254
Trophy points
83
Location
Coimbatore, India
Activity points
6,738
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.
 

Dhruv@aks

Newbie level 6
Joined
Sep 4, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
93
that is what i do not get???
once i download the file from the server is it saved in the pic memory..??
where is this stored..???
 

Venkadesh_M

Advanced Member level 4
Joined
Jun 26, 2013
Messages
1,375
Helped
258
Reputation
516
Reaction score
254
Trophy points
83
Location
Coimbatore, India
Activity points
6,738
Answer for your questions are hidden inside your sample program.

What is the purpose of a boot loader ?

To get the executable code.

Where will be a executable code of controller will be stored ?

There the binary values are stored.

Why do you want to store it on a SD card ?
 

Dhruv@aks

Newbie level 6
Joined
Sep 4, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
93
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..????
 

Venkadesh_M

Advanced Member level 4
Joined
Jun 26, 2013
Messages
1,375
Helped
258
Reputation
516
Reaction score
254
Trophy points
83
Location
Coimbatore, India
Activity points
6,738
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.
 

Dhruv@aks

Newbie level 6
Joined
Sep 4, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
93
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..!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top