Precompiled HAL/LL files possible?

Post here all questions related to STM32 core if you can't find a relevant section!
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Precompiled HAL/LL files possible?

Post by MGeo »

I've been playing around with this somewhat out of date core based on libopencm3 project here https://github.com/Serasidis/arduino_opencm3

It relies on precompiled archive files for the libopencm3 library files (found here https://github.com/Serasidis/arduino_op ... pencm3/lib). The build times are shockingly quick.

Might something like this be possible to precompile the HAL and LL functions? Constant rebuild of these static files seems somewhat inefficient.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Precompiled HAL/LL files possible?

Post by mrburnette »

https://www.learncpp.com/cpp-tutorial/i ... libraries/
LinkingObjects-min.png
LinkingObjects-min.png (13.85 KiB) Viewed 3718 times

Most
developers prefer source code to pre-compiled libraries; to fulfill the definition of "open source" and to browse through and analyze the library logic and maybe even "tweak" a library or port to another cpu architecture.

If you object (unintended pun) to source libraries, you can conceivably pre-compile yourself. With Arduino, usually the /.../temp files are compiled only once into object files and after that (while the IDE is open) only changes in the Arduino edited source are recompiled. In this manner, slow PC hardware only "suffers" once the compile.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Precompiled HAL/LL files possible?

Post by ag123 »

i did it slightly differently, i used a makefile
viewtopic.php?f=41&t=183
viewtopic.php?f=47&t=37

but really using a makefile isn't the most portable means
these days it seemed the 'best practice' approach seem to be
arduino cli - for the build
https://blog.arduino.cc/2020/03/13/ardu ... roduction/
and integrated with IDE
https://marketplace.visualstudio.com/it ... de-arduino
https://www.arduino.cc/en/Tutorial/gett ... ith-ide-v2

the key concept is you should use incremental build and not use /tmp/ directories. this is so that each time you rebuild the old pre-compiled object files is simply re-linked. And only those files that you edit are rebuilt

i'm not against pre-compiled HAL/LL files, in fact i think both the 'old' arduino ide , arduino-cli and the recent build stacks and tool chains supports that.
it is kind of compile the object files into a .a library. then all the linking uses that .a file.
it'd take researching a little to figure out how to do that, shouldn't be too difficult.
and you can still keep your sources there. it is 2 steps, first build the lib (.a file) then build the sketch sources linked against the .a file.

the *catch* i think is if you have 1001 if-defs for each different mcu and boards combinations, then you would end up with 1001 .a / lib files for each of those permutations, assuming that the if-defs results in different codes being assembled into the object files. that is simply fixed if you only use 1 mcu and 1 board, most of the time it is. And u'd only need to figure out how to build that .a lib and link against it.

to understand the state-of-the-art of all that if-defs, try reviewing the adafruit ili9341 lcd library codes and feel the complexity.
there are n number of if-defs you can use standard gpio (i.e. digitalWrite), digitalWrite fast, software spi, hardware spi, then if defs for each different mcu combinations, then maybe if defs for each different core, and more if defs for n number of permutations of possible configurations in the most fluid possible way. the code assembled into the object file can range from everything to nothing, simply changing the if-defs
https://github.com/adafruit/Adafruit_ILI9341
and didn't everyone only want an lcd library? if only all the mcus every created this far has 1 GB of sram and 1GB of flash.
all that if-defs can be 'dynamic', the program decides at run time what code to run
write 1 firmware, it can run on all the mcus and cpus ever created
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Precompiled HAL/LL files possible?

Post by ag123 »

there is one language that tries to achieve that, it is called javascript, it runs in 'every' web browser across different machine architectures.
it works until u get a browser than doesn't run javascript and that not all javascript are 'equally' supported.

on the mcu front there is an attempt as well, micropython, circuitpython, embedded lua and all that 'intepreted' languages etc.
it reaches a hard stop if there is not enough (s)ram. But it is as dynamic as is possible, configure and run at run time, no compiler needed.
-------
in short there is no escape from if-defs, to get rid of if defs, you need to fix the mcu, board and feature set, and you can use .a lib file.
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Precompiled HAL/LL files possible?

Post by MGeo »

Thanks for the replies. I sounds like a smarter IDE with incremental build features could provide an improvement on a project by project basis (ie each quick and dirty test project will still drive a new folder / full rebuild).
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Precompiled HAL/LL files possible?

Post by fpiSTM »

The main issue is Arduino + Windows.
On Linux the same build took the first time few seconds while on windows it took 4/5 minutes....
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: Precompiled HAL/LL files possible?

Post by BennehBoy »

Is it single threaded on Windows? I never really checked.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Precompiled HAL/LL files possible?

Post by fpiSTM »

I don't know. Anyway some of the drawback on Windows are the network access and the antivirus...
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: Precompiled HAL/LL files possible?

Post by BennehBoy »

fpiSTM wrote: Thu Mar 25, 2021 10:22 am I don't know. Anyway some of the drawback on Windows are the network access and the antivirus...
Not sure ref the network access, presumably an enumeration timeout for network resources?

AV, an exclusion for the arduino15 folder can be added in the windows default AV... Also for the Arduino folder in documents. I guess it's a harder proposition to add one for the temp build folder, wouldn't want to exclude all of temp - so a fixed build location is probably preferable.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Precompiled HAL/LL files possible?

Post by fpiSTM »

BennehBoy wrote: Thu Mar 25, 2021 10:31 am Not sure ref the network access, presumably an enumeration timeout for network resources?
Right
BennehBoy wrote: Thu Mar 25, 2021 10:31 am AV, an exclusion for the arduino15 folder can be added in the windows default AV... Also for the Arduino folder in documents. I guess it's a harder proposition to add one for the temp build folder, wouldn't want to exclude all of temp - so a fixed build location is probably preferable.
Not so easy depending of AV.
Post Reply

Return to “General discussion”