View previous topic :: View next topic |
Author |
Message |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
Problem with tiny bootloader... |
Posted: Sun Jul 26, 2009 7:54 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Jul 27, 2009 8:15 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Mon Jul 27, 2009 11:09 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 28, 2009 1:35 pm |
|
|
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:
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 ? |
|
![](templates/subSilver/images/spacer.gif) |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Wed Jul 29, 2009 12:32 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|