View previous topic :: View next topic |
Author |
Message |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
CCS bootloader |
Posted: Tue Feb 24, 2015 3:26 am |
|
|
Hi Everybody,
I know there is many posts about it but none seem to answer few important questions.
https://pic-c.com/forum/viewtopic.php?t=45044 THIS ONE TOO...
- We are talking about - ex_bootloader.c and related files
- I use two pics 18F4520 and 18F4620
Questions:
1. Is there anybody who could explain like to a child how to calculate those 2 entries for each MCU
Code: |
#define LOADER_END 0xXXXX
#define LOADER_SIZE 0xXXXX
|
DATASHEET was looked at.
2. Then what value is to be placed in:
Code: |
#if defined(__PCH__)
#org 0x40,0xXXXX
|
3. Do I need to modify the HEX I load into the system from the bootloader level or is this HEX unchanged? Do I need to add any #ORG entries to protect the bootloader block or not?
I seem to run in the circles and it is just a waste of time so some nice clear answer would be appreciated as it seem to be common issue with this file.
Thank you for any help. _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Tue Feb 24, 2015 8:27 am |
|
|
You don't calculate these entries.
You compile _your_ bootloader. Look at how large it is, and put in the end figure, the top byte under next page boundary above the size of you code. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Wed Feb 25, 2015 1:09 am |
|
|
Do I need to modify the program which is to be run by the bootloader, I mean tell it where is the reset vector, where bootloader is placed, etc? Or do I just compile it as normally like if there would be no bootloader in the system?
Then I think nobody here really had a look at the datasheet at all, I place it then for easy understanding. I guess that is why the posts about this MCU are not resolved.
So could you please help here. I am a bit confused here how to operate on pages which are not listed, etc.
Rom makes not much too here:
ROM Allocation:
Code: | 0080 @delay_ms1
001E @delay_us1
00DE @PUTCHARI_BIU_1
00AA @GETCH_BIU_1
04CE real_load_program
046C @14@FLASHWR
048C @14@WRITE_PROGRAM_MEMORY
040A atoi_b16
0400 load_program
0800 application
0040 MAIN
0008 isr
0040 @cinit
|
Thank you _________________ Help "d" others and then you shell receive some help from "d" others.
Last edited by Linuxbuilders on Wed Feb 25, 2015 1:45 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Feb 25, 2015 1:28 am |
|
|
Look at ex_bootload.c
The program needs to be relocated to avoid the bootloader. This shows how to perform this relocation. Note how it includes bootloader.h, but without defining the keyword "_bootloader". This tells it to perform the relocation only. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Wed Feb 25, 2015 1:54 am |
|
|
So if I understand it correctly based on my compilation my
and
Code: |
#define LOADER_END 0x7FF
#define LOADER_SIZE 0x400
|
Would that be correct based on below?
Code: | 0400 load_program - 1 = 3FF
0800 application - 1 = 7FF
7FF-3FF = 400 |
_________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Feb 25, 2015 2:44 am |
|
|
I doubt it.
Just use the bootloader.h. If you need a different LOADER_END address, just #define this before loading bootloader.h. It does everything else. It generates loader size for you, from loader_end. It calculates the #ORG etc.. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Wed Feb 25, 2015 3:00 am |
|
|
As instructed, left it alone. After compilation it looks like this:
ROM Allocation:
0514 @delay_ms1
001E @delay_us1
0572 @PUTCHARI_BIU_1
053E @GETCH_BIU_1
01CE real_load_program
016C @24@FLASHWR
018C @24@WRITE_PROGRAM_MEMORY
010A atoi_b16
0100 load_program
0500 application
0040 MAIN
0008 isr
0040 @cinit
Then I have used EX_BOOTLOAD.C to check if it will work, no go, does not boot up. Ideas? _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Wed Feb 25, 2015 3:17 am |
|
|
Got it working,
no change required, just compile and load, then modify the main program as per instructions.
However it is chaotic, it enters bootloader every second reset - I will have to look at my input.
Thnx _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Feb 25, 2015 5:18 am |
|
|
I'd be looking at the pullup resistor on the input. |
|
|
|