Need help compiling UBW bootloader

USB PICs and the UBW

Moderator: phalanx

Need help compiling UBW bootloader

Postby Randall » Wed Apr 02, 2008 12:32 pm

Hey all,

I'm looking to re-compile the bootloader source, so's I can twiddle some config bits, but it's not working so good. I'm getting the following error:

Code: Select all
Error - section '.code' can not fit the section. Section '.code' length=0x0000000e


I've monkeyed with the linker script a bit, but to no avail. How do I know exactly which bit of code isn't fitting into what section?

Thanks in advance,
Randall
Randall
 
Posts: 45
Joined: Fri Nov 02, 2007 6:42 am
Location: Boston, MA, USA

Postby EmbeddedMan » Wed Apr 02, 2008 1:11 pm

Randall,

Two quick things -

1) I'll check out re-compiling the bootloader later on today to see if I can get it to fail like you have. Are you using the stock bootloader code from the UBW website, or have you made modifications? The stock bootloader project from the UBW website only have a couple bytes of extra space, so anything you've changed may push it over the limit. (of 0x7FF bytes)

2) You can easily change config bits without recompiling if that's all you need to do. Just import the HEX file into MPLAB, edit the config bits, then export the HEX file and include the new config bits, then use that new HEX file to program the part.

*Brian
User avatar
EmbeddedMan
Support Volunteer
 
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Postby Randall » Wed Apr 02, 2008 1:24 pm

1). I haven't made any modifications yet. I'm only trying to get it to compile exactly as it is on the UBW website. I did, however, remove BORV from the config bits, because the compiler was complaining 28 is not a valid value for that. (strange)

I found I can get it to compile if I change the following line (found in the linker script):

Code: Select all
CODEPAGE   NAME=page       START=0x2E           END=0x7FF


to END=0x820. However, the resulting hex file does nothing. Possibly because I'm writing past the interrupt vectors at that point? Don't know why the code doesn't just fit snuggly like it should. I'm at MPLAB v8.00 and C18 v3.12 Student Edition, if that's at all significant.

2). I didn't know I could do that! That is, in fact, all I wish to do. Sounds a lot easier, thanks!
Randall
 
Posts: 45
Joined: Fri Nov 02, 2007 6:42 am
Location: Boston, MA, USA

Postby EmbeddedMan » Wed Apr 02, 2008 8:13 pm

Ugg! Sometimes I love Microchip, sometimes not.

You are correct, the current bootloader code does NOT build under MPLAB 8.02 and C18 3.12. It used to build just fine with the student version of the compiler - this new version must have changed the way it compiles code and makes things slightly larger.

I will be posting an updated version of the original bootloader if I can squeeze out 0x0F bytes. I've also fixed the BORV problem (again, a change Microchip made between compiler versions) and some project paths so that it will build anywhere you put it on your hard drive.

*Brian
User avatar
EmbeddedMan
Support Volunteer
 
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Postby EmbeddedMan » Wed Apr 02, 2008 8:40 pm

OK, all fixed now. Very slightly tweaked version of the bootloader is now posted to the UBW website. http://greta.dhs.org/UBW/FW/2455/B or http://greta.dhs.org/UBW/FW/2455/B/B.zip

The changes are as follows:
1) Changed just a few variables to ACCESS bank to reduce memory footprint to fit into 0x7FF boot block.
2) Changed BORV value from 28 to 3
3) Changed compiler options from DEBUG to RELEASE, and cleaned up the paths for the C compiler in project options.

This now compiles and fits properly with MPLAB 8.02 and C18 3.12

*Brian
User avatar
EmbeddedMan
Support Volunteer
 
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Postby Randall » Thu Apr 03, 2008 10:28 am

Brian,

Importing and re-exporting the hex file as you suggested worked, so that'll suit my purposes just fine. But I wanted to let you know that the links you've provided still point to the old version of the bootloader. I was all psyched to see it compile and it still does the same ole thing :(

Thanks again for your help on this, and for all of your help in general. You are a pillar of the embedded community.

Cheers,
Randall
Randall
 
Posts: 45
Joined: Fri Nov 02, 2007 6:42 am
Location: Boston, MA, USA

Postby EmbeddedMan » Thu Apr 03, 2008 9:12 pm

Sorry about that. It should all be correct now - make sure you get the latest version (i.e. clear your browser cache).

*Brian
User avatar
EmbeddedMan
Support Volunteer
 
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Mods on bootloader

Postby DeviceMan » Sun Dec 28, 2008 6:58 pm

I was looking through the updated code to see what you modified to shrink the code, but did not see any files with new revision histories. Maybe I missed which files were modified since I did not look through every one. Could you kindly point out the changes if not too much trouble?

Also, a newbie question, how do you specify for the user code to start at 0800h? I don't wish to overwrite the bootloader since I do not have a PIC programmer. I wish to put off purchases until I can demonstrate I can do something half useful with this widget. Wife is watching my spending.
DeviceMan
 
Posts: 2
Joined: Sun Dec 28, 2008 6:47 pm
Location: Phoenix

Postby EmbeddedMan » Sun Dec 28, 2008 8:29 pm

DeviceMan,

I understand about the wife. Completely understand.

The changes are very subtle. The one that really made the difference is on line 51 of boot.c, where I put the #pragma udata access fast_vars. That forces the allocation of all variables after that point to be in the 'fast_vars' section (from 0x00 to 0xFF) which means they can be accessed without bank switches. For any oft-used variables, this makes a HUGE difference in size.

<aside> Why the heck can't C18 do this by itself? Is it really that hard to fill the fast_vars section first, then spill over into normal RAM? This really grinds my gears.</aside>

As for your second question, the way to do it is with a modified linker file. These three lines from rm18F2455.lkr show how to do it:

Code: Select all
CODEPAGE   NAME=boot       START=0x0            END=0x7FF          PROTECTED
CODEPAGE   NAME=vectors    START=0x800          END=0x829          PROTECTED
CODEPAGE   NAME=page       START=0x82A          END=0x5FFF


Notice that from 0x000 to 0x7FF (the boot sector) is protected,and that the vectors start at 0x800, with normal CODEPAGE space from 0x82A to 0x5FFF.

I hope this explains things well enough-

*Brian
User avatar
EmbeddedMan
Support Volunteer
 
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

UBW FW compiling

Postby DeviceMan » Mon Dec 29, 2008 9:04 pm

Thanks! If you use MS-DOS Batch files for building, do you mind forwarding for the B and D versions? - hope I'm not bothering you too much with so many questions.
DeviceMan
 
Posts: 2
Joined: Sun Dec 28, 2008 6:47 pm
Location: Phoenix

Postby EmbeddedMan » Mon Dec 29, 2008 10:15 pm

I do not use anything but MPLAB for building. You can download the complete projects for all of the firmware versions from the UBW website, and they will all build in MPLAB. I've never tried things from the command line, so I don't know if they'll work for that or not.

*Brian
User avatar
EmbeddedMan
Support Volunteer
 
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Re: Need help compiling UBW bootloader

Postby andrewz » Sat Nov 20, 2010 3:55 am

Randall wrote:Hey all,
I'm looking to re-compile the bootloader source, so's I can twiddle some config bits, but it's not working so good. I'm getting the following error:
Code: Select all
Error - section '.code' can not fit the section. Section '.code' length=0x0000000e

Randall


Can you give please whole script?
лазерная коррекция зренияastigmatism
Last edited by andrewz on Sat Jun 11, 2011 1:17 am, edited 2 times in total.
andrewz
 
Posts: 1
Joined: Sat Nov 20, 2010 3:53 am

Re: Need help compiling UBW bootloader

Postby brian111 » Wed Jan 19, 2011 2:54 am

Hey, I was also faced with this issue but after reading about it over here; I fixed it with the help. Thanks a lot. Certainly you are pillar of help. I am looking forward to more of such help in the coming future also. By the way thanks for the link as well.
brian111
 
Posts: 5
Joined: Thu Jan 13, 2011 12:34 am


Return to USB Development

Who is online

Users browsing this forum: Google [Bot] and 1 guest