Skip to main content
MLE S.1
Associate II
June 1, 2020
Solved

Compiler optimisation issue (remove used functions)[solved]

  • June 1, 2020
  • 13 replies
  • 13194 views

Hi all,

On our card with a STM32L4 we use a siliconLabs BGM13P32 for the BLE.

The L4 communicate with the BLE SOC in NCP mode (see here for more details).

To do that i have integrated the SiliconLabs libs (BGLIB) to our project on stm32cubeIDE.

The project build fine, with no errors/warnings (default options) and i can communicate with the BLE SoC ...only if i use -O0 option in optimization options.

0693W000001pmqpQAA.png

If i use for example -Og, the functions used in BGLIB (siliconLabs) is removed from the binary (checked on .map file). The project build without errors but the com with the BLE SoC fails !

For information our project is in C++. Join with this post the class of our Bluetooth Com. (bluetoothCom.h/cpp).

The whole project is build with -Og optimisation option, just bluetoothCom.cpp use -O0 option to have a correct communication.

Do you have an idea how to resolve this ?

This topic has been closed for replies.
Best answer by MLE S.1

I have found the issue ...

On stm32 side i use DMA to transfert the data from uart to a circular buffer. The problem is that the SiliconLabs rxcallBack is implemented to read directly on uart register ...

I just modified my code like this :

int32_t BluetoothCom::BGAPI_Rx(uint32_t len1, uint8_t* data1) {
	uint32_t length = len1;
	while (length) {
		if(uart2.bytesAvailable())//needed to be sure DMA have transfert data from uart...
		{
			*data1 = uart2.readc();
			length --;
			data1 ++;
		}
	}
	return len1;
}

added -fno-inline option to file compilation option and now all work fine !

Thanks all for your answer, i have learn a lot with compilation options !

13 replies

MLE S.1
MLE S.1Author
Associate II
June 2, 2020

If i add : -fno-inline in compilation options for bluetoothCom.cpp i see the function in map file and i can have a break point in c++ side when debugging. But it's not working yet ...

MLE S.1
MLE S.1AuthorAnswer
Associate II
June 3, 2020

I have found the issue ...

On stm32 side i use DMA to transfert the data from uart to a circular buffer. The problem is that the SiliconLabs rxcallBack is implemented to read directly on uart register ...

I just modified my code like this :

int32_t BluetoothCom::BGAPI_Rx(uint32_t len1, uint8_t* data1) {
	uint32_t length = len1;
	while (length) {
		if(uart2.bytesAvailable())//needed to be sure DMA have transfert data from uart...
		{
			*data1 = uart2.readc();
			length --;
			data1 ++;
		}
	}
	return len1;
}

added -fno-inline option to file compilation option and now all work fine !

Thanks all for your answer, i have learn a lot with compilation options !

waclawek.jan
Super User
June 3, 2020

Thanks for coming back with the solution.

Please select your post as Best so that the thread is marked as solved.

JW