Code Banking with SDCC

I need to use code banking in 8051 microcontroller to match all code. SDCC says it supports it, but I'm having problems at the link stage.

I have a test project with 3 files: main.c, func1.c and bank.asm. The main function should call func1 () and then sit in the while loop. But func1 () is in a different code bank.

// main.c
int func1(void) banked;

void main()
{
    int i = func1();

    while(i)
    {
    }
}

// func1.c
#pragma codeseg BANK1

int func1(void) {
    return 99; }

//bank.asm
    .area HOME    (CODE)
    .area GSINIT0 (CODE)
    .area GSINIT1 (CODE)
    .area GSINIT2 (CODE)
    .area GSINIT3 (CODE)
    .area GSINIT4 (CODE)
    .area GSINIT5 (CODE)
    .area GSINIT  (CODE)
    .area GSFINAL (CODE)
    .area CSEG    (CODE)
    .area HOME    (CODE)

__sdcc_banked_call::
    ret             ;make the call

__sdcc_banked_ret::
    ret         ;return to caller

      

I have a build batch file to compile everything and link it all together.

sdcc -c func1.c
sdcc -c main.c
asx8051 -ol bank.asm
sdcc "-Wl -b BANK1=0x018000" main.rel func1.rel bank.rel

      

I am getting this linker error:

?ASlink-Error-Insufficient ROM/EPROM/FLASH memory.

      

How can I get a link?

+2


source to share


2 answers


In the SDCC manual:

Segments can be placed anywhere in the 4MB address space using the usual - * - loc options. Note that if any segments are above 64K, then the -r flag must be passed to the linker to generate the correct segment displacements and the Intel HEX format must be used. The -r flag can be passed to the linker using option -Wl-r on the SDCC command line. However, the linker cannot handle code segments> 64k at this time.



So add -Wl-r to the linker line.

+1


source


I'm not familiar with SDCC, but from other banking memory architectures we had to provide calls with a routed banking function.

You need to enter the correct code to set up bank registers or whatever sets the memory bank to ever:

__sdcc_banked_call::
    ret                 ;make the call

__sdcc_banked_ret::
    ret                 ;return to caller

      

procedures?



Although this is probably not a linker issue.
Do you need to define a seg code for: BANK1?

It looks like it is setting up the code segments:

//bank.asm
    .area HOME    (CODE)
    .area GSINIT0 (CODE)
    .area GSINIT1 (CODE)
    .area GSINIT2 (CODE)
    .area GSINIT3 (CODE)
    .area GSINIT4 (CODE)
    .area GSINIT5 (CODE)
    .area GSINIT  (CODE)
    .area GSFINAL (CODE)
    .area CSEG    (CODE)
    .area HOME    (CODE)

      

but BANK1 is undefined. Is there a linker file and does it assign all memory / flash space to these code segments?

0


source







All Articles