|
|
View previous topic :: View next topic |
Author |
Message |
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
Just one change to the bootloader example.... |
Posted: Thu Aug 25, 2011 10:26 pm |
|
|
...and it seems to go astray.
I have spent a substantial amount of time on this (over 40 hours since last Saturday) and I need to get things moving forward. Any help is truly appreciated. I've literally picked apart the example bootloader code, I have read numerous forum postings, and I have RTFM when I didn't understand a command. I have printed and read PCM Programmer's outstanding post on how to adjust the memory allocations:
http://www.ccsinfo.com/forum/viewtopic.php?t=45044&highlight=ive+created+technique+solve+problem
What is going to drive me to drink is the memory allocation. At one point, I had coaxed it to get me past the infamous:
"Out of ROM. A segment or the program is too large real_load_program SEG 0004A-001FF,0169 left, need 001CC"
To keep a long story short, I found that I was doing a stomp job on the loader.
So, I took a step back and started with a clean copy of the bootloader example. I trimmed out all of the PCH options and I added a few output_high and output_low commands to handle the transceivers. I have to use UART2, which has not been an issue.
I still got the error message.
I made a worksheet that follows PCM programmer's outline for the memory allocation. Attempted to move all of the locations, widen locations, etc.
Still get the same error.
...At this point, make mine a scotch, please!
So, I went to the original bootloader code with NO changes what so ever. I only change the header file. Got the same error message.
If any one wants to give it the old college try or has recommendations, I would truly appreciate it. The only thing that needs to be changed in the bootloader code is the header file, from <16F877.h> to <16F1947.h> and voila, instance error message!
Using a PIC16F1947 (you don't have to have one...I just need someone to successfully compiler it)
Using version 4.123 with MPLAB 8.73.
Thanks for your help and understanding,
RckRllRfg |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Aug 26, 2011 1:09 am |
|
|
The answer is simple. The 16F1947, which is called Enhanced MID Range CPU implements additional registers and increases some registers to 16 Bit. As a result, the code size increases. The bootloader as is won't fit in the 0..1FF segment any more, it has to be increased by at least 2 rows to 0..27F.
Unfortunately, bootloader protection is only available for 0..1FF or 0..FFF, so it would be preferably to shrink the bootloader.
However, if you don't rely on bootloader protection, adjusting the limits is rather easy.
Code: | #define LOADER_END 0x27F
#define LOADER_SIZE 0x23B |
Bootloader main() size also slightly increases
|
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
|
Posted: Fri Aug 26, 2011 7:32 am |
|
|
Hi FvM
Thank you for your reply.
Unfortunately, I do not have a choice when it comes to shrinking the bootloader. In fact, I have to add to it in order control my transceivers. Fortunately, my main application uses about 40% of the memory, so I have plenty of room for the bootloader.
I have been adjusting the LOADER_END,LOADER_SIZE, and the main(); however, other than pushing the main() backwards to #0RG 0x11, 0x3F, I have not be successful in adjusting the widths or lengths of the memory space.
Is there a protected region? Is there a command that I can declare that turns off the protection? I'm also thinking about the use of the #Seperate and possibly splitting up the real_load_program.
Thanks for your insights,
RckRllRfg |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Aug 26, 2011 10:05 am |
|
|
I tried my example with V4.112, which is my working CCS C version, and just noticed, that the size of the main() stub has increased a few bytes with recent versions. With V4.124, I corrected the settings to
Code: | #define LOADER_END 0x27F
#define LOADER_SIZE 0x237
...
#org 0x20,0x47 |
I must admit, that didn't check for other possible 16F1947 issues, just made it compile without errors. |
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
Let me make sure that I understand this correctly... |
Posted: Fri Aug 26, 2011 11:55 am |
|
|
Just to confirm: You use CCS version V4.112 with the PIC16F1947.h file substituted into the example bootloader code and got it work? It this correct?
The CCS website is vague on details when it comes to releases. Do you know approximately when V4.112 was released?
Thanks -
RckrRllRfg |
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
Tried the values.... |
Posted: Fri Aug 26, 2011 2:15 pm |
|
|
I did try the values as FvM provided:
Code: |
#define LOADER_END (0x27F) //extend out the end addr
#define LOADER_SIZE (0x237) //but keep the size slightly smaller
#org 0x20, 0x47
|
But got the following results....
Code: |
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Users\engr\Desktop\Modified exbootloader\ex_bootloader.ESYM".
Clean Warning: File "C:\Users\engr\Desktop\Modified exbootloader\ex_bootloader.o" doesn't exist.
Clean: Deleted file "C:\Users\engr\Desktop\Modified exbootloader\ex_bootloader.ERR".
Clean: Done.
Executing: "C:\Program Files\PICC\Ccsc.exe" +FM "ex_bootloader.c" +DF +LN +T +A +M +Z +Y=9 +EA #__16F1947=TRUE
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 00000-0003F (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 00040-00049 (0000 used) Priv
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 0004A-001FF (0000 used) Priv
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 00200-00213 (0000 used) Priv
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 00214-007FF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 00800-00FFF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 01000-017FF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 01800-01FFF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 02000-027FF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 02800-02FFF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 03000-037FF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Segment at 03800-03FFF (0000 used)
--- Info 300 "ex_bootloader.c" Line 50(1,5): More info: Attempted to create: 00020-00047 for #org
*** Error 126 "ex_bootloader.c" Line 50(1,5): Invalid ORG range
1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Fri Aug 26 13:06:15 2011
|
I find it interesting that the segments being listed match the bootloader's memory allocations for the original 877. Is there any residual stuff that might be contributing? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 26, 2011 2:43 pm |
|
|
It compiles for me. I installed vs. 4.112. I made a project in the
Examples directory using the CCS Ex_bootloader.c program as the
source file for the project. I made the suggested changes as shown in
bold in the two files below. Result:
Quote: |
0 Errors, 0 Warnings.
Loaded C:\Program Files\PICC\Examples\ex_bootloader.cof.
BUILD SUCCEEDED: Fri Aug 26 13:42:44 2011 |
Changes in Ex_bootloader.c
Quote: |
#if defined(__PCM__)
//#include <16F877.h>
#include <16F1947.h>
|
and
Quote: |
#if defined(__PCH__)
#org 0x40,0x7F
#else
#org 0x20, 0x47 // Add this line
//#org 0x20,0x3F // Comment this line
#endif
|
Changes in bootloader.h
Quote: |
#if defined(__PCM__)
#define LOADER_END 0x27F // was 0x1FF
#define LOADER_SIZE 0x237 // was 0x1BF |
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Aug 26, 2011 2:56 pm |
|
|
V4.112 was released about one year ago. It seems to support 16F1947, but I don't know if there are any issues. However, as I said, I used recent V4.124 with the final settings. They work with the original ex_bootloader.c example, the said changes apply to bootloader.h and ex_bootloader.c. There's also a LOADER_SIZE definition in loader.c that should be probably adjusted, but it doesn't cause segment errors.
You get "Invalid org range" with #org 0x20,0x47 if you didn't modify LOADER_END and LOADER_SIZE in bootloader.h, as suggested. |
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
While you were writing, I had a break through |
Posted: Fri Aug 26, 2011 3:38 pm |
|
|
FvM and PCM Programmer -
Thank you for the responses. After I had posted, I was staring at the error message. It was driving me crazy that the values were not changing. (ie, 40-49 was ALWAYS the space for the load_program function.)
Sure enough, I remembered that when I first went about doing this several days ago, I had copied and changed the name of the bootloader.h and loader.c to avoid any ambiguity with the original files. This remedied the issue at the time. In the mix of it all, I had forgotten all about it.
As mentioned earlier, I decided to start fresh with the example code and changed only that what I needed. My original code is fine; however, I added a TON of comments in it when I was first reading through it to understand its mechanics. I also added many print statements. I was seeing memory stomping and thus decided to step back with a clean example. That is when I started stumbling over the memory issue again.
I was able to get it to compile. One minor tweak was needed for the main. I am jazzed about that! Thank you for guiding me along.
Apparently, the compiler is looking at the example directory in the C:\Program File\PICC installation directory for the bootloader.h. That's a bit scary! (and confirms FvM's suspicion that bootloader.h was never being modified)
BUT, I'm not completely out of the woods just yet....
The issue that I was seeing with my original code seems to have resurfaced. My memory allocation for the loader ends at 3FF. Therefore, the application should start at 400h and go on from there; however, I am seeing code from the bootloader being placed in the 400h addresses.
Any thoughts on that?
Again, many thanks for getting me through thus far.
RckRllRfg |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 26, 2011 3:47 pm |
|
|
Quote: | I am seeing code from the bootloader being placed in the 400h addresses. |
What tool are you using to see this ? Explain how you see it.
If I compile Ex_bootloader.c (with the changes given in my post, per
FvM's suggestions), and I look at the .LST file and the .SYM file, I don't
see any code in the 0x400 area. If I use View / Program Memory in
MPLAB and scroll down to the 0x400 area, which will surely show anything
if it's there, I don't see anything. All I see is 3FFF. Blanks.
This is with vs. 4.112. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Aug 26, 2011 3:55 pm |
|
|
Yes, directory usage of CCS C is confusing, particularly if you have multiple versions installed in parallel. At least when I modify CCS C provided files, I prefer to have a copy in the application directory, preferably with a different name. |
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
Here's what I'm getting |
Posted: Fri Aug 26, 2011 4:03 pm |
|
|
PCM Programmer -
I am using the following memory allocations:
#org 0x20, 0x7A
#define LOADER_END (0x3FF)
#define LOADER_SIZE (0x37F)
I also widened some of the other functions. necessary? Not really; however, did it to ensure that everything fit. I can tighten this up later.
Just before the void real_load_program in the loader.c (approx line 46)
Code: |
//#ORG LOADER_ADDR+10, LOADER_END auto=0 default
#ORG LOADER_ADDR+20, LOADER_END auto=0 default
|
Just before the void load_program loader.c (approx. line 184)
Code: |
//#ORG LOADER_ADDR, LOADER_ADDR+9
#ORG LOADER_ADDR, LOADER_ADDR+19
|
Note: the ORG statement for the application remains the same:
Code: |
#org LOADER_END+1,LOADER_END+20
|
|
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
.lst file result |
Posted: Fri Aug 26, 2011 4:05 pm |
|
|
This is the code that I am seeing in the .lst file:
Code: |
.................... #include <ROS16F1947.h>
.................... //////// Standard Header file for the PIC16F1947 device ////////////////
.................... #device PIC16F1947
.................... #list
....................
.................... #fuses HS,NOWDT,NOPROTECT,NOLVP
.................... #use delay(clock=16000000)
*
0414: MOVLW 20
0415: MOVWF 05
0416: MOVLW 77
0417: MOVWF 04
0418: MOVF 00,W
0419: BTFSC 03.2
041A: GOTO 429
041B: MOVLW 05
041C: MOVWF 78
041D: CLRF 77
041E: DECFSZ 77,F
041F: GOTO 41E
0420: DECFSZ 78,F
0421: GOTO 41D
0422: MOVLW 2E
0423: MOVWF 77
0424: DECFSZ 77,F
0425: GOTO 424
0426: GOTO 427
0427: DECFSZ 00,F
0428: GOTO 41B
0429: RETURN
|
As mentioned earlier, I shouldn't be in the 400h memory space.
RckRllRfg |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 26, 2011 4:07 pm |
|
|
I don't get this. You're constantly changing things. We're always one
step behind you. We fix what you currently say. But by then you've
changed it and the new code doesn't work...
What is this ? A custom file ?
Quote: | #include <ROS16F1947.h>
|
I just got a fax with an order. I've got to go build boards. |
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
Renamed to avoid ambiguity |
Posted: Fri Aug 26, 2011 4:16 pm |
|
|
Hi PCM programmer -
I agree that I am bouncing about here. I'm trying things on my end while getting responses to you. For that, I apologize.
The bootloader name was changed to ensure that my compiler was not going off and looking for it in the Program Files directory. It contains the addresses I mentioned above.
Here's my bootloader file. I stripped it of the PCH stuff:
Code: |
#define LOADER_END (0x3FF) //extend out the end addr
#define LOADER_SIZE (0x37F)
#ifndef _bootloader
#build(reset=LOADER_END+1, interrupt=LOADER_END+5)
#org 0, LOADER_END {}
#endif
|
|
|
|
|
|
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
|