CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with tiny bootloader...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

Problem with tiny bootloader...
PostPosted: Sun Jul 26, 2009 7:54 am     Reply with quote

Hi,

I am trying to understand how hex data is sent by the Tinybootloader program.

I made a simple program using the 18F4620 mcu.

I then connected two COM ports to each other using a null modem, so that the bootloader program sent the (.HEX) data to another terminal program (terminal v 1.9), this way I was able to capture data sent out by the tinybld.exe program.

Examining the transmitted data I found that the bootloader program (tinybld.exe) always sent this code first (All data is in hEX)

40 A0 EF 7F F0

after this the program data from address 0x0004 was sent, program data for 0x0000 to 0x0002 was not sent until towards the end of the transmission.

I cannot understand what kind of algorithm is being used...

Please help....

thanks
arunb
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jul 27, 2009 8:15 pm     Reply with quote

From tinybld18F258.asm:
Code:
;----------------------  Bootloader  ----------------------
;PC_flash:      C1h             U       H       L       x  ...  <64 bytes>   ...  crc
;PC_eeprom:     C1h             40h   EEADR   EEDATA    0       crc
;PC_cfg         C1h         U OR 80h    H       L       1       byte    crc
;PIC_response:     type `K`

'type' = IdTypePIC, see icdpictypes.inc
CRC: addition of all bytes should be zero (including crc but not the C1h).
In case of CRC errors an 'N' character response is sent.

For more details look into the mentioned assembly file. It is only 196 lines, including comments.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Mon Jul 27, 2009 11:09 pm     Reply with quote

Thank you for the reply..

I finally started understanding parts of the code. I was able to modify the USART portion for RS485 communication.

But I still have some fundamental queries.

For instance I found that the bootloader program (tinybld.exe) always transmitted the first two program words from the bootloader code instead of the code from the taregt application.

The words were A0EF 7FF0. After sending these two codes all other words from the target application was sent.

Kindly explain the significance of the first two words...

thanks
arunb
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 28, 2009 1:35 pm     Reply with quote

1. Create a blank, new project in MPLAB. In the Configure menu,
set the device to 18F4620 in the Select Device menu.

2. Go to the View menu, and select Program Memory.

3. Click on the Opcode for Line 1 and type in: EFA0

4. Click on the Opcode for Line 2 and type in: F07F

What do you see in the Disassembly column ?


Download the source for Tiny Bootloader:
http://www.etc.ugal.ro/cchiculita/software/tinybld198.zip
It contains .asm and .inc files that are needed to understand the bootloader.

5. Look at the 18F2620.asm file. There is no 18F4620 file, so use
the one for the 18F2620. It has the same ROM size as the 18F4620.
Look at the #define statement for "first_address".

6. Look at the icdpictypes.inc file. Find the section for this:
Code:
IFDEF __18F2620 

Note the max_flash_size value.

7. Now you can calculate the "first_address" in the 18F2620.asm file.
What is it ?

How does the "first_address" compare to the address that you saw
in the Disassembly column in the Program Memory window ?
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Wed Jul 29, 2009 12:32 am     Reply with quote

Thank you.. I got the idea.

first_address=0xFF38 (0x10000-0xC8)

Those are the addresses to which the mcu must jump to...

thank you for making it clear enough....

arunb
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group