Topic : Workarounds for Linker Error 115

Forum : ST7/STM8

Original Post
Post Information Post
September 7, 2011 - 9:15pm
Guest

I am working on bringing up a new graphics library on a STM8AF51A9 target using the Raisonance 9_26_2009 Compiler / Linker.

I have since run into an issue where the library has large blocks of data (fonts etc...) that are larger than the 256 byte page. The resolution that the Linker manual states is:

"The error message indicates which segment has the problem. Either do not specify the segment with the INPAGE directive, or move some of the variables in the segment into another segment, which can also be located using the INPAGE
directive."

I have tried the following declarations when defining the fonts with no success: data, fdata, and fcode. Data and Fdata both return the same ERROR 115, but when I move it to fcode get compiler ERROR C156. I believe that this means that the value cannot be addressed directly (the failure occurs on this line "gcurvp->pfont = &SYSFONT;" where SYSFONT is stored in fcode).

So my immediate question: Is there a way to allow a variable to be larger than 256 bytes and be stored in data/fdata only using compiler/linker settings?

Replies
Post Information Post
+1
0
-1
September 8, 2011 - 10:01am
Raisonance Support Team

Hi Adam, There is no such 256-byte limitation in the compiler. All objects such as arrays must be INSECTION hence are inherently limited to a 64KB size. Ensure that your default RAM class is "data", not "zero page". Zero page is more efficient concerning code size, however it is limited to 256 bytes only! Please have a look at the AN55-Porting Cosmic applications to Raisonance.pdf  in the installed documentation, which should be very helpful for your project.

Also, your tools are outdated and not supported anymore. Please download the latest version from Product Downloads. If this does not fix your problem, can you post a little sample code that shows the problem, so we can reproduce it in our Labs? Best Regards,

+1
0
-1
September 8, 2011 - 5:10pm
Guest

Sorry to post so quickly. I went and changed the the zeropage to data before trying sending this and it did not save for whatever reason. I didn't think to double check on this setting.

Resolution: Changed global variables from zero page to data and pressed "OK" (I believe this is the part that got messed up last time :) ).

Thanks again.

+1
0
-1
September 9, 2011 - 7:03pm
Guest

Bruno,
I have made the switch to the latest and greatest compiler / linker. As I feared, it broke my build and the issue at hand is centralized on the startup asm files.

The previous compiler (2009) had a single startup file that chose the reset vectors conditionally if it was either ST7 or STM8 and the new compiler determines outside of the asm file which startup file to link in (_ST7 or _STM8). I was hoping that my start up files from the previous compiler would work but they do not. They build fine and the MAP file appears to be similar to what MAP files from other projects built with the 2009 compiler, however when I burn the images to the target it will not run.

As a brief background I have had to modify the startup.asm for the 2009 compiler to move the reset vectors from 8000h to B000h to compensate for a custom bootloader. I switch at compile time on which asm to use (bootloadable or non-bootloadable). See below for my bootload startup file.

After switching to the 2011 compiler, I first located the only startup assembly files that I could find in the Ride directory : "C:\Program Files (x86)\Raisonance\Ride\inc\Sources\ST7-STM8\startup" and copied startup_STM8.asm to my project directory. The troubling is that when I add this file to the project (without modification) it breaks my build in the same fashion that the old startup file did.

I am not set on keeping the startup files in the project, I would really prefer a way to just move the reset vector inside of main and get rid of the ASM files all together. In addition, I am not able to update the bootloader at this point in time due the significant number of units deployed.

Any advice here would be appreciated.

;=============================================================================
; (c) Copyright Raisonance S.A.S. 1989 - 2008, All rights reserved.
;=============================================================================
;
; This is the 'C' language "STARTUP" routine for RCSTM8.
;      File name:  startup_bootload.asm
;
;        Purpose:  To provide the initial startup code for STM8 or ST7 from
;                  power-up to the initial execution of the main() routine.
;
;          Scope:  This file contains all the code and information required
;                  to accomplish "Purpose". It is applicable to all memory
;                  models and RCSTM8 options.
;                  This file, assembled using the appropriate memory model,
;                  is automatically linked in by the linker when it encounters
;                  a "main" symbol in the object modules to be linked.
;
;                  The routine will be executed each time the controller
;                  experiences a "reset" condition.
;
;                  If you wish to use this startup routine with your assembly
;                  code too, you should add a "main" label in your asm code.
;
; Considerations:  The values selected are intended for a standard STM8 or ST7
;                  controller. In most cases these will work well for other
;                  processors under most conditions. The ranges for
;                  initialization, or the initialization values can be changed
;                  or modified as needed.
;
;        Caveats:  It is possible to modify this file and affect the execution
;                  the target processor in many ways. Often settings and
;                  selections have effects on each other. Some may not be
;                  compatible. This startup routine is provided "as is". If
;                  you change it to meet some design objective, you are
;                  responsible of the outcome of your selections, and
;                  their effect upon the target system.
;
;                  This file MUST be assembled in case-sensitive mode
;                  (assembler directive CASESENSITIVE or CS) to avoid any
;                  unresolved references by the linker.
;
;-----------------------------------------------------------------------------
;  NOTE:  YOU SHOULD ALTER THIS FILE ONLY AFTER YOU HAVE BUILT AND TESTED YOUR
;  CODE, AND YOU'RE CONVINCED THAT YOU CAN MAKE IT RUN OR WORK BETTER BY DOING
;  SO.  IF YOU ONLY NEED SOME SPECIFIC INITIALIZATIONS, IT IS RECOMMENDED THAT
;  YOU  DO  THEM  IN  THE FIRST FEW LINES OF YOUR MAIN() ROUTINE.  MODIFY THIS
;  FILE ONLY AS A LAST RESORT.
;=============================================================================
; $Id: startup_bootload.asm 188 2010-12-04 07:55:39Z adam $
;=============================================================================

    CSTART              SEGMENT CODE INSECTION0

;-----------------------------------------------------------------------------
; External symbols
;-----------------------------------------------------------------------------

    ; The "?C?InitData" routine is responsible for initializing the global
    ; variables. If your application does not use global initialized variables,
    ; it will not be used.
    ; The routine is available from the standard library used with your model,
    ; for instance RCSTM8.LIB
    EXTRN   CODE(?C?InitData)
    
    ; The "?C?ZeroData" routine is responsible for initializing some global
    ; variables to 0.
    EXTRN   CODE(?C?ZeroData)

    ; The "main" routine is the main entry point for the user application
    EXTRN   CODE(main)

    RSEG                CSTART

;-----------------------------------------------------------------------------
; Public symbols
; The symbol CST7_START is the reset entry point for the RLST7 linker.
; Several variants of this entry point may be required by your projects,
; depending of your project requirements.
; It is recommended that all these startup variants are defined as public
; symbols here.
;-----------------------------------------------------------------------------

    PUBLIC  CST7_START                 ; Minimal startup
    PUBLIC  CST7_START_V               ; Startup with global variables initialization
    PUBLIC  CST7_START_Z               ; Startup with a segment initialized to 0
    PUBLIC  CST7_START_V_Z             ; Startup with globals + initialization to 0


;=============================================================================
; Reset entry point. This is the first piece of code to get called upon
; RESET conditions
;=============================================================================

CST7_START:
CST7_START_V:
CST7_START_Z:
CST7_START_V_Z:


; Comment out the following line if your project does not use any
; 0-initialized C global variables initialization.
; ?C?ZeroData must be called BEFORE ?C?InitData
;-----------------------------------------------------------------------------
; WARNING: On ST7 projects, the ?C?ZeroData function will blank the stack
;          if there are zero-initialized variables in both page0 and data
;          memory spaces.
;-----------------------------------------------------------------------------
    CALL    ?C?ZeroData                ; Initialize null global variables

; Comment out the following line if your project does not use any C global
; variables initialization. If you are unsure, just leave it as it is.
    CALL    ?C?InitData                ; Initialize global variables.

    JP      main                       ; Call the user entry point (main)
                                       ; main must NEVER return!
;;; JPF     main                       ; Necessary if "main" is above address FFFFh


;=============================================================================
; Interrupt vector table (in fact just the reset vector is present here)
;=============================================================================

$IF(__STM8__==1)                       ; __STM8__ symbol activated automatically

    CSEG AT 45056                      ; Interrupt vectors start at 8000h on STM8

    DB      082h, 000h                 ; The interrupt address in in 24-bits mode,
    DW      CST7_START                 ; and preceded by the 82h opcode.

$ELSE

    CSEG AT 0FFFEh                     ; Reset address vector is at FFFEh on ST7

    DW      CST7_START

$ENDIF

END
+1
0
-1
September 12, 2011 - 11:44am
Raisonance Support Team

Hi Adam,

For me your startup.asm is fine.

If you stick to the usual way RCSTM8 handles the startup, this is the baseline:
1) The linker will require a startup entry point if (and only if) there is a main() function in your application.
2) The RCSTM8 library provides pre-built, automatic startup files, that are automatically linked in your application if you do not provide your own startup.
3) If you provide the entry points CST7_START, CST7_START_V, CST7_START_Z, CST7_START_V_Z (as external references) in your application, then the linker will recognize it as being a startup file. Consequently it will not add any specific startup functionality from the C library.

You can keep your file as is, you could not get much better.

However, as you suggest, you could place the reset vector right inside your code. You just need to rename your main() function (let's rename it to appmain). Given my explanations 1-3 above, the linker will not put any startup in your application anymore.

To better describe how you can use that, here is the code for a C file that will setup the absolute minimal STM8 application. There is just a reset vector, that points to appmain(), which loops forever. As this application does NOT contain any main() function, the linker will not add any startup code.

void appmain(void)
{
    while(1);
}

// Define the ISR type, which is a 24-bit pointer to an void function
typedef char (far* ISR)(void);

// "Manual" reset vector in C. Mapped at address 0x8000
at 0x8000 code unsigned char reset_head = 0x82;
at 0x8001 code ISR reset_vect = appmain;

The application has a code size of 6 bytes: 4 for the reset vector, 2 for the loop instruction.

You can use similar tricks to get away from the assembler code in your application, but a little bit of assembly code does not sound like a problem to me.

Note that the startup source code has been split between ST7 and STM8 versions in the last RKit-STM8 releases, as most customers use only one of these families, and we wanted to offer simpler startup code. That's it for the story.

Best Regards,

+1
0
-1
September 13, 2011 - 7:43am
Guest

Bruno,
I have been trying to get this compiler to work for me with little to no luck regarding the start up files. Below I have a break down of each code startup configuration and any note I have on them.

  1. No startup file defined & main() used: The precompiled started up files seem to work just fine. Please note that it appears it Startup with globals + initialization to 0 is configured by default. (_V_Z) [/*]
  2. startup_STM8.asm as provided by Ride 7: Based on the comments of this file I would expect to see the same _V_Z configuration of the startup file.[/*]
  3. startup.asm as provided by Ride 7 - 2009: This startup file has worked great with the 2009 version of the STM8 compiler/linker, but is apparently having difficulties with the latest compiler / linker. It's worth noting that the booloadable version I posted previously also worked well for the 2009 compiler / linker. When I pause this while debugging, it stops in two address ranges 0x5xxx and 0x9000+. This being said, I do not believe that it is even getting into CODE.[/*]

I have spent quite some time trying to figure this out and have hit a pretty large brick wall. My working assumption is that the the globals / variables are not getting initialized or getting it's getting hung trying to clear the RAM. If you need more information please let me know and as always, thanks for all of your support.

Previous startup.asm as provided by Ride 7 in 2009

;=============================================================================
; (c) Copyright Raisonance S.A.S. 1989 - 2008, All rights reserved.
;=============================================================================
;
; This is the 'C' language "STARTUP" routine for RCSTM8.
;      File name:  STARTUP.ASM
;
;        Purpose:  To provide the initial startup code for STM8 or ST7 from
;                  power-up to the initial execution of the main() routine.
;
;          Scope:  This file contains all the code and information required
;                  to accomplish "Purpose". It is applicable to all memory
;                  models and RCSTM8 options.
;                  This file, assembled using the appropriate memory model,
;                  is automatically linked in by the linker when it encounters
;                  a "main" symbol in the object modules to be linked.
;
;                  The routine will be executed each time the controller
;                  experiences a "reset" condition.
;
;                  If you wish to use this startup routine with your assembly
;                  code too, you should add a "main" label in your asm code.
;
; Considerations:  The values selected are intended for a standard STM8 or ST7
;                  controller. In most cases these will work well for other
;                  processors under most conditions. The ranges for
;                  initialization, or the initialization values can be changed
;                  or modified as needed.
;
;        Caveats:  It is possible to modify this file and affect the execution
;                  the target processor in many ways. Often settings and
;                  selections have effects on each other. Some may not be
;                  compatible. This startup routine is provided "as is". If
;                  you change it to meet some design objective, you are
;                  responsible of the outcome of your selections, and
;                  their effect upon the target system.
;
;                  This file MUST be assembled in case-sensitive mode
;                  (assembler directive CASESENSITIVE or CS) to avoid any
;                  unresolved references by the linker.
;
;-----------------------------------------------------------------------------
;  NOTE:  YOU SHOULD ALTER THIS FILE ONLY AFTER YOU HAVE BUILT AND TESTED YOUR
;  CODE, AND YOU'RE CONVINCED THAT YOU CAN MAKE IT RUN OR WORK BETTER BY DOING
;  SO.  IF YOU ONLY NEED SOME SPECIFIC INITIALIZATIONS, IT IS RECOMMENDED THAT
;  YOU  DO  THEM  IN  THE FIRST FEW LINES OF YOUR MAIN() ROUTINE.  MODIFY THIS
;  FILE ONLY AS A LAST RESORT.
;=============================================================================
; $Id: startup.asm 188 2010-12-04 07:55:39Z adam $
;=============================================================================

    CSTART              SEGMENT CODE INSECTION0

;-----------------------------------------------------------------------------
; External symbols
;-----------------------------------------------------------------------------

    ; The "?C?InitData" routine is responsible for initializing the global
    ; variables. If your application does not use global initialized variables,
    ; it will not be used.
    ; The routine is available from the standard library used with your model,
    ; for instance RCSTM8.LIB
    EXTRN   CODE(?C?InitData)
    
    ; The "?C?ZeroData" routine is responsible for initializing some global
    ; variables to 0.
    EXTRN   CODE(?C?ZeroData)

    ; The "main" routine is the main entry point for the user application
    EXTRN   CODE(main)

    RSEG                CSTART

;-----------------------------------------------------------------------------
; Public symbols
; The symbol CST7_START is the reset entry point for the RLST7 linker.
; Several variants of this entry point may be required by your projects,
; depending of your project requirements.
; It is recommended that all these startup variants are defined as public
; symbols here.
;-----------------------------------------------------------------------------

    PUBLIC  CST7_START                 ; Minimal startup
    PUBLIC  CST7_START_V               ; Startup with global variables initialization
    PUBLIC  CST7_START_Z               ; Startup with a segment initialized to 0
    PUBLIC  CST7_START_V_Z             ; Startup with globals + initialization to 0


;=============================================================================
; Reset entry point. This is the first piece of code to get called upon
; RESET conditions
;=============================================================================

CST7_START:
CST7_START_V:
CST7_START_Z:
CST7_START_V_Z:


; Comment out the following line if your project does not use any
; 0-initialized C global variables initialization.
; ?C?ZeroData must be called BEFORE ?C?InitData
;-----------------------------------------------------------------------------
; WARNING: On ST7 projects, the ?C?ZeroData function will blank the stack
;          if there are zero-initialized variables in both page0 and data
;          memory spaces.
;-----------------------------------------------------------------------------
    CALL    ?C?ZeroData                ; Initialize null global variables

; Comment out the following line if your project does not use any C global
; variables initialization. If you are unsure, just leave it as it is.
    CALL    ?C?InitData                ; Initialize global variables.

    JP      main                       ; Call the user entry point (main)
                                       ; main must NEVER return!
;;; JPF     main                       ; Necessary if "main" is above address FFFFh


;=============================================================================
; Interrupt vector table (in fact just the reset vector is present here)
;=============================================================================

$IF(__STM8__==1)                       ; __STM8__ symbol activated automatically

    CSEG AT 8000h                      ; Interrupt vectors start at 8000h on STM8

    DB      082h, 000h                 ; The interrupt address in in 24-bits mode,
    DW      CST7_START                 ; and preceded by the 82h opcode.

$ELSE

    CSEG AT 0FFFEh                     ; Reset address vector is at FFFEh on ST7

    DW      CST7_START

$ENDIF 

END

No ASM / Precompiled startup (WORKING)

   * * * * * * * *   C O D E       M E M O R Y   * * * * * * * *
   CODE     008000H      000004H    AT              ?CO?STARTUP_V_Z00
   CODE     008004H      000004H    INSECTION0      ?PR?ANALOG_TO_DIGITAL
   CODE     008008H      000004H    AT              ?IT?VECTOR#0
   CODE     00800CH      000004H    AT              ?IT?VECTOR#1
   CODE     008010H      000004H    AT              ?IT?VECTOR#2
   CODE     008014H      000004H    AT              ?IT?VECTOR#3
   CODE     008018H      000004H    AT              ?IT?VECTOR#4
   CODE     00801CH      000004H    AT              ?IT?VECTOR#5
   CODE     008020H      000004H    AT              ?IT?VECTOR#6
   CODE     008024H      000004H    AT              ?IT?VECTOR#7
   CODE     008028H      000004H    AT              ?IT?VECTOR#8
   CODE     00802CH      000004H    AT              ?IT?VECTOR#9
   CODE     008030H      000004H    AT              ?IT?VECTOR#10
   CODE     008034H      000004H    AT              ?IT?VECTOR#11
   CODE     008038H      000004H    AT              ?IT?VECTOR#12
   CODE     00803CH      000004H    AT              ?IT?VECTOR#13
   CODE     008040H      000004H    AT              ?IT?VECTOR#14
   CODE     008044H      000004H    AT              ?IT?VECTOR#15
   CODE     008048H      000004H    AT              ?IT?VECTOR#16
   CODE     00804CH      000004H    AT              ?IT?VECTOR#17
   CODE     008050H      000004H    AT              ?IT?VECTOR#18
   CODE     008054H      000004H    AT              ?IT?VECTOR#19
   CODE     008058H      000004H    AT              ?IT?VECTOR#20
   CODE     00805CH      000004H    AT              ?IT?VECTOR#21
   CODE     008060H      000004H    AT              ?IT?VECTOR#22
   CODE     008064H      000004H    AT              ?IT?VECTOR#23
   CODE     008068H      000004H    AT              ?IT?VECTOR#24
   CODE     00806CH      000E0AH    INSECTION0      ?PR?OLED
   CODE     008E76H      000E07H    INSECTION0      ?PR?DISPLAY

startup_STM8 from /Ride/inc/Sources/ST7-STM8/startup (NOT WORKING)

* * * * * * * *   C O D E       M E M O R Y   * * * * * * * *
   CODE     008000H      000004H    AT              ?CO?STARTUP_STM800
   CODE     008004H      000004H    INSECTION0      ?PR?ANALOG_TO_DIGITAL
   CODE     008008H      000004H    AT              ?IT?VECTOR#0
   CODE     00800CH      000004H    AT              ?IT?VECTOR#1
   CODE     008010H      000004H    AT              ?IT?VECTOR#2
   CODE     008014H      000004H    AT              ?IT?VECTOR#3
   CODE     008018H      000004H    AT              ?IT?VECTOR#4
   CODE     00801CH      000004H    AT              ?IT?VECTOR#5
   CODE     008020H      000004H    AT              ?IT?VECTOR#6
   CODE     008024H      000004H    AT              ?IT?VECTOR#7
   CODE     008028H      000004H    AT              ?IT?VECTOR#8
   CODE     00802CH      000004H    AT              ?IT?VECTOR#9
   CODE     008030H      000004H    AT              ?IT?VECTOR#10
   CODE     008034H      000004H    AT              ?IT?VECTOR#11
   CODE     008038H      000004H    AT              ?IT?VECTOR#12
   CODE     00803CH      000004H    AT              ?IT?VECTOR#13
   CODE     008040H      000004H    AT              ?IT?VECTOR#14
   CODE     008044H      000004H    AT              ?IT?VECTOR#15
   CODE     008048H      000004H    AT              ?IT?VECTOR#16
   CODE     00804CH      000004H    AT              ?IT?VECTOR#17
   CODE     008050H      000004H    AT              ?IT?VECTOR#18
   CODE     008054H      000004H    AT              ?IT?VECTOR#19
   CODE     008058H      000004H    AT              ?IT?VECTOR#20
   CODE     00805CH      000004H    AT              ?IT?VECTOR#21
   CODE     008060H      000004H    AT              ?IT?VECTOR#22
   CODE     008064H      000004H    AT              ?IT?VECTOR#23
   CODE     008068H      000004H    AT              ?IT?VECTOR#24
   CODE     00806CH      000E0AH    INSECTION0      ?PR?OLED
   CODE     008E76H      000E07H    INSECTION0      ?PR?DISPLAY

startup.asm as defined in Ride 7 in 2009 (NOT WORKING)

* * * * * * * *   C O D E       M E M O R Y   * * * * * * * *
   CODE     008000H      000004H    AT              ?CO?STARTUP00
   CODE     008004H      000004H    INSECTION0      ?PR?ANALOG_TO_DIGITAL
   CODE     008008H      000004H    AT              ?IT?VECTOR#0
   CODE     00800CH      000004H    AT              ?IT?VECTOR#1
   CODE     008010H      000004H    AT              ?IT?VECTOR#2
   CODE     008014H      000004H    AT              ?IT?VECTOR#3
   CODE     008018H      000004H    AT              ?IT?VECTOR#4
   CODE     00801CH      000004H    AT              ?IT?VECTOR#5
   CODE     008020H      000004H    AT              ?IT?VECTOR#6
   CODE     008024H      000004H    AT              ?IT?VECTOR#7
   CODE     008028H      000004H    AT              ?IT?VECTOR#8
   CODE     00802CH      000004H    AT              ?IT?VECTOR#9
   CODE     008030H      000004H    AT              ?IT?VECTOR#10
   CODE     008034H      000004H    AT              ?IT?VECTOR#11
   CODE     008038H      000004H    AT              ?IT?VECTOR#12
   CODE     00803CH      000004H    AT              ?IT?VECTOR#13
   CODE     008040H      000004H    AT              ?IT?VECTOR#14
   CODE     008044H      000004H    AT              ?IT?VECTOR#15
   CODE     008048H      000004H    AT              ?IT?VECTOR#16
   CODE     00804CH      000004H    AT              ?IT?VECTOR#17
   CODE     008050H      000004H    AT              ?IT?VECTOR#18
   CODE     008054H      000004H    AT              ?IT?VECTOR#19
   CODE     008058H      000004H    AT              ?IT?VECTOR#20
   CODE     00805CH      000004H    AT              ?IT?VECTOR#21
   CODE     008060H      000004H    AT              ?IT?VECTOR#22
   CODE     008064H      000004H    AT              ?IT?VECTOR#23
   CODE     008068H      000004H    AT              ?IT?VECTOR#24
   CODE     00806CH      000E0AH    INSECTION0      ?PR?OLED
   CODE     008E76H      000E07H    INSECTION0      ?PR?DISPLAY