cancel
Showing results for 
Search instead for 
Did you mean: 

.bsct and .ubsct segments

filippo2399
Associate
Posted on June 12, 2010 at 10:25

Hello everyone,

I'm a student from Italy and I'm working on a project in which the testing platform is an STM8S-Discovery board.

I developed my project with no problem but now, after few modifications to improve the performance of the code running on the board I keep obtaining the same error (reported below):

&sharperror clnk Debug\aes.lkf:1 segment .bsct size overflow (10)

&sharperror clnk Debug\aes.lkf:1 segment .ubsct size overflow (10)

 The command: ''clnk -l''C:\Program Files\COSMIC\CXSTM8_16K\Lib''  -o Debug\aes.sm8 -mDebug\aes.map Debug\aes.lkf '' has failed, the returned value is: 1

exit code=1.

I found little information about .bsct and .ubsct segments, they should be related to static and static uninitialized data. The problem is that I didn't change the size of those data in the modified version of the code.

The code that compiles and runs fine contains 6 look-up tables of 256 bytes (1.5 kB total). The code that is supposed to compile, which doesn't, contains exactly 6 look-up tables of 256 bytes (1.5 kB total again). One of those tables is not the same as before, but I hardly think the contents can make any difference since it is of the same size.

Note: I tried both the debug and release mode and I see no changes.

Is there anyone that can help with this problem?

Thank you in advance.

#linking #c #programming #compiling #cosmic #stm8s-discovery
4 REPLIES 4
danielfischer9
Associate II
Posted on June 14, 2010 at 08:48

Hello Sirus,

The problem you have is caused (I think) about the data size (size of your global variables) in your program.  I got the same error message the moment the amount of data my program used, exceeded 256 bytes.  The STM8 processor has 256 bytes at the begining of its memory map, and the Cosmic compiler / linker (I guess you must be using Cosmic, and not Rasonance), by default, uses this space for data; the moment the needed amount exceeds 256 bytes, the linker gives an error message and quits.  I did not manage to find a way to tell Cosmic to move the data somewhere else (the procesor does have 2k of data space, so it is possible); I found that the Raisonance compiler gives the same error message, however if I use the word ''data'', e.g. ''data char buffer[1000]'', the application compiles and links OK.

The problem is, the Rasonance toolset (1) returns an error message when used from STVD, and for the life of me, I do not understand what the error message window is trying to tell me and what I must do, and (2) the demo for the board comes with a project for Cosmic, but not Rasonance; when I created a workspace, a project, and I included the same files that compiled under Cosmic, I started getting all kinds of errors.

Clearly, ST gives this board for $10, but the software tools are terrible. I am a professor in a Canadian university, am trying very hard to learn this board and the tools, to be able to use them in my courses, but I do this only because the board is cheap, and not because STM has made my life easy and because of that I love their product...  It's too bad.

I hope this helps.

Daniel

 

luca239955_stm1_st
Senior II
Posted on June 14, 2010 at 09:08

Hi,

.bsct is the segment that contains initialized data in page0

.ubsct is the segment that contains non-initialized data in page0

.data is the segment that contains initialized data out of page0

.bss is the segment that contains non-initialized data out of page0

examples of how to put a global variable in a given segment:

@tiny char aa;          // will go to .ubsct

@tiny char aa = 10;  // will go to .bsct

@near char aa;          // will go to .bss

@near char aa = 10;  // will go to .data

when you don't specify @tiny or @near the memory model you are using will decide for you (see the manual for details)

The page0 is architecture-limited to 256 bytes, but this number can be lower in reality: the linker will check the actual size of any segment versus the -m parameter specified for that segment in the linker file (that is often created automatically by stvd7)

The rest of the memory (referred to as ''out of Page0'' above) is actually limited to the amount of RAM implemented on the specific device you are using: it is important to specify a -m parameter that is coherent with the device for .data+.bss

In conclusion, the error message you see means that there is more data than available space to store it. If you can't figure out why by just reading the source file you can follow these steps:

- manually edit the .lkf file and set ''big'' values for the the -m parameter

- your application will now compile and link (but of course will not execute: because you are using more RAM than actually available

- check in the map file how the segments are filled (which variable goes in which segment)

- correct the source, restore the right values for -m and build your application

Hope this helps.

Regards,

Luca (Cosmic)

danielfischer9
Associate II
Posted on June 14, 2010 at 09:27

Hello Luca,

Thank you for your reply.

I am using the STM8S-Discovery board (STM8S105C I believe).

Can you please tell us what settings we must use to be able to successfully compile an application having more than 256 bytes of data, with your compiler / linker.  If I understand you correctly, we must use:

@near char aa;

or

@near char aa = 1;

Correct?

Daniel

luca239955_stm1_st
Senior II
Posted on June 14, 2010 at 12:55

use a ''long'' memory model (+modsl or +modsl0) that will put all the data @near by default.

Regards,

Luca