Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world.
And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download two short videos (registration required) highlighting:

System Workbench for STM32


Very strange .bss RAM overflow

Hello all!

I’m currently building a project with SW4STM32 using a STM32F070F6 but the identical behaviour was also observed on a STM32F030xx.

In my code where I read, over the I2C bus, I’ve defined locally variables... (Is there some way to paste/format code here?)

Capture

That compiles and works flawless.

If I define the variable gradScale globally in the file then the linker complaines about the .bss RAM region being overflowed by

“region `RAM’ overflowed by 24608 bytes”.

Capture

24608 bytes!?!?!?!?! What the (insert prefered angry word) is going on?
Can somebody point me to what I’m doing wrong here. I’m an experienced programmer on lower level programming but not as much in C.

Thanks in advance!

France

Hi,

You do not give really enough information to get sensible help; what does the HighDensSequentialRead does with the AdrGradScale value and, BTW, what is this value? What is the usefulness of the IR_Sensor_Read function (from a C point of view): it does not return anything and computes a value (gradScale) that is not used (meaning the compiler may not even compute it).

In the modified code, how did you define globally gradScale?

Bernard (Ac6)

PS: to put code in a post, just bracket it by {CODE()} and {CODE}



Hello!

Thanks for the reply, I’ll try to answer as good as possible.

The function HighDensSequentialRead reads on the I2C bus and writes in the char array eecpy. I’m sending the pointer to that function.

#define AdrGradScale 0x08
void HighDensSequentialRead(unsigned short address, unsigned char* data, unsigned short numbytes)
{
	unsigned char reg_data [] = {  ((unsigned char)((address&0xFF00)>>8)) , ((unsigned char)(address&0xFF)) };

	HAL_I2C_Master_Sequential_Transmit_IT(&hi2c1,EEPROM_ADR,reg_data,2,I2C_FIRST_FRAME); //write(ControlByte)
	while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY);
	HAL_I2C_Master_Sequential_Receive_IT(&hi2c1,EEPROM_ADR,data,numbytes,I2C_FIRST_AND_LAST_FRAME );
	while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY);

	return;
}

void IR_Sensor_Read(void)
{
	unsigned short gradScale;
    unsigned char eecpy[ 8 ] = "";

	HighDensSequentialRead((unsigned short)AdrGradScale,eecpy,sizeof(char)*2);
	gradScale = ((0x00 (double left arrow)  8) | eecpy[0]); 
    return;
}


This seems to be related to something regarding the array, since I can define a float both local and global without any problem.

Shift left (double arrow) will not format in the code parser..?

B.R/

France

Hi,

Which variable do you convert to global and how (and also why, but thta has nothing to do with your .bss overflow...)

Bernard (Ac6)

PS: Regarding the double lower-than sign, the simpler (although not ideal) is to put a space inbetween both lower-than signs.

BTW, gradScale = eecpy[0]; would be largely enough and, by definition, sizeof(char) == 1...

The overflow error occurs when

unsigned short gradScale;

is defined globally, or rather at the top of the file. It’s not per definition defined with the keyword GLOBAL.

I’ve been programming C before and of course I know it’s my blame but I just can’t find out what it is.

France

Hi,

I really don’t understand what can cause this problem. Could you compile your program once with gradScale defined localy and once with it defined globally (with absolutely no other change) and post, in attachments, the two output.map files that are generated in the Debug directory?

Bernard (Ac6)

Sorry, should have replied instead of writing a new post... Don’t know if you get a notification on that.

Hello!

So much has happened the last days, I had to go back a long way in the repository. A good thing with your inputs gave was that I think that I know the solution to the problem.

When the linker fails and put out overflow by Jesus Christ many bytes I have many other defined global variables in the file, but they are unused (I’m porting generic code given by the supplier). To me with my limited C knowledge I never thought that the compiler would allocate the memory for them also as soon as I moved one used global variable there. If I comment out all other globals it works.
To be clear here, the other unused globals are still there when I declare gradScale local but then it works and the compiler doesn’t allocate memory for them.
Still strange though...

I’ll attach both .c files (heavily commented) and the linker map files both for working and non-working scenarios.