cancel
Showing results for 
Search instead for 
Did you mean: 

What's VL53L4CX bare driver memory requirement ?

SLin.11
Associate II

Hi All,

I want to port VL53L4CX bare driver to my M0+ MCU (36KB SRAM) however it cannot fit into RAM (.bss)

What's RAM requirement of VL53L4CX bare driver ?

(I used VL53L1CX ULD and VL53L4CD ULD driver that's ok)

 

or how to trim down the memory requirement ?

 

BR,

Sam

3 REPLIES 3
John E KVAM
ST Employee

When you jump from the ULD drivers of the VL53L1X and VL53L4CD up to the big drivers of the VL53L1CB or the VL53L4CX, you really do step up the complexity. 

Those big drivers use histograms. And the histogram data is uploaded to where it is your host that extracts the range from the raw data.

JohnEKVAM_0-1711030781408.png

Your VL53L4CX runs the same code as the VL53L1 Full - with very slight modifications.

It looks to me like RAM isn't going to be the issue, but the ROM is the trick. 

That larger code was written by a bunch of Linux programmers, and they don't think about code size - ever.

There isn't an easy way to make it smaller - without reducing functionality. Although one could remove those useless abstraction layers. But that doesn't save a significant amount.

But search GitHub, I'm betting someone is proud of what they have done. 

I'd investigate the cost of selecting the next larger processor size. (But then I'm a software guy, and hardware solutions are easy - for me.)

 


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'

Hi John,

 

I found the root cause of the RAM issue is

VL53LX_Dev_t

A single instance takes around 9k which it too big for MCU SRAM.

It there any way to trim it down or fine tune to fit limited SRAM ?

 

 

John E KVAM
ST Employee

That's a trick invented by Unix. Because the Dev is on the stack and we know stack sizes are basically infinite, one can shove every possible thing into the Dev. (It's why I demanded the Dev in the VL53L4CD Ultra Lite Driver be an integer.)

That Dev structure looks pretty harmless until you start digging. You get to:

typedef struct {
	VL53LX_LLDriverData_t   LLData;
	/*!< Low Level Driver data structure */

	VL53LX_LLDriverResults_t llresults;
	/*!< Low Level Driver data structure */

	VL53LX_DeviceParameters_t CurrentParameters;
	/*!< Current Device Parameter */

} VL53LX_DevData_t;
 

and those structures are pretty large. 

I measured 10872 bytes. 

Worse is that our footprint size calculations do not include structures put on the stack. (That is a mistake.)

The easy solution (software wise) is to switch to the VL53l1CX. The UltraLite Driver runs on that part. 

But the lens on the L1CX makes it more expensive, and if you had more money, you could use a chip with more ram of course. 

I don't a have a good solution. 

The folks who wrote that code were thinking Cellphones and PCs - not tiny MCUs.

- john

 

 


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'