B4R Question B4R compilation strategy for several MCUs

peacemaker

Expert
Licensed User
Longtime User
Hi, All

If it's planned to make, say
0) 10 .bas SW-modules to read from hardware sensors boards
1) 5 kinds of devices (sensors), where the sketches contain different sets of SW-modules
2) 2 device roles - receiver or transmitter-sensor
3) 2-3 MCU-types among ESP32 family - that can be chosen better for roles OR kinds (depending on ports qty)

... how better to organize the B4R sketch or sketches (using the conditional compilation and variables of the kinds and roles) set to have clear .bin FW files set ?

Compilation for each MCU means to choose the SDK\device\port...
 
Last edited:

hatzisn

Well-Known Member
Licensed User
Longtime User
Different B4R projects. Different sensors are supported by different libraries and yet B4X IDEs do not support conditional library loads. I had proposed something like this on the near past but @Erel is one all around supporter and it's logical that it has to put some order in his schedule.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I can't remember if B4R has conditional Builds, but if it does, just create as much conditional build you need, and use the tags in your code.
In compilation stage, choose the build you want, and the resulting "sketch" will ignore every non-related stuff, libraries included.
That can help you keep a simgle "project" for all your builds, but be carefull... to many build options and you may end up confusing it all!
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Different B4R projects
One project for one MCU, i guess...
Or B4R keeps the latest chosen MCU for all instances ?

I have found that the .bin for ESP32 is logically cannot be burnt into ESP32-C3 - flasher checks this and kicks me out, smart buddy...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
It's been a while since I used B4R... But if I recall it correctly, yes it does....
I guess you could make a wish for it to be a "Project Atribute"
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Or B4R keeps the latest chosen MCU for all instances ?

It does. But even with the same MCUs you will have to use different libraries for different sensors which do not load conditionally as said.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
you will have to use different libraries for different sensors

IMHO, it's not a problem, if .bin fits the partition.
Different modules (that include other libs) are included, but not used, if not called - due to conditional compilation.
Here the less .bin variants - the better order among versions.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
IMHO, it's not a problem, if .bin fits the partition.
Different modules (that include other libs) are included, but not used, if not called - due to conditional compilation.
Here the less .bin variants - the better order among versions.

That is correct, but it gets the the bin file to be burned bigger. I prefer to use Ocahm's Razor also in code (a literal approach in the code case would be: "just use only the necessary code/libraries to make your program work and never more").
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Sure, i also like WORA principle, but here no other tools razors to use it correctly cut non-needed ones nice way.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Sure, i also like WORA principle, but here no other tools razors to use it correctly cut non-needed ones nice way.

I was not aware of the WORA principle. At least the name because I knew about Java and Python's ability to run everywhere.
 
Upvote 0
Top