I'm using SDCC 2.6.0 #4309 for programming Cypress EZUSB-FX2 (8051 based) chips. I have successfully ported all the source code (Cypress did it for the 8051 Keil Compiler) to use it with SDCC.
My application consists of 3 *.c files and 1 *.asm file. I compile these using SDCC and asx8051, then I use SDCC to link it all together to make an *.ihx file. The linking process also includes a library with support functions from Cypress.
Now when I look at the linker's *.map file, I can see that the linker orders the code fragments in the following order:
1. my object decks in the order I specified them
2. needed functions from the library
And the error is: as long as (2.) starts at an even address, everything is fine. If (1.) has an odd length, then (2.) will start at an odd address - and in this case the software is garbage and will not work! I can work around this problem if I throw in an additional byte like a nop into (1.)
What's wrong here?
Thanks for your help,
Allthough the assembler supports .even the linker does not.
Keil and SDCC use different calling conventions and you cannot use a library (by Cypress) compiled with Keil easily with SDCC.
The easiest way to put code at an even address with SDCC is using absolute segments (--codeseg).
Cypress supplies the source code for the library and OF COURSE I have ported the library, too, so that it can be compiled with SDCC. And as I said in my original post - as long as the code length of my application is an even number, so that the library (which is located after the end of the application code) will start at an even address, everything is fine and the whole thing works.
Is it maybe a jump / vector table that has to reside at an even address? If so, create it in assembly and give it an absolute address. E.g.:
.area JUMP (ABS, CODE)
The 2.7.0 linker will locate around it. The linker in 2.6.0 might overlay the area with unexpected results.
thanks for pointing me to the right direction - the USB device descriptor structure must start at an even address - although the application core and the USB core are both 8051 based and therefore 8-bit controller cores... The Cypress documentation is pretty lousy regarding these details.
The 2.6.0 linker does not overlay ".org"ed areas as long as you give each area an unique name, I think. Everything's working now, thank you.
Log in to post a comment.