Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


You are viewing a reply to Very strange .bss RAM overflow  

Very strange .bss RAM overflow



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.


 

Newest Forum Posts

  1. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  2. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  3. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  4. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  5. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  6. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  8. Build a project in "release" mode by tang, 2025-02-20 10:36
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35
  10. Fail to debug in Win 11 C/C++ by mortenlund, 2024-12-26 20:27

Last-Modified Blogs