Single Hardware / Multiple Binaries #69029
Replies: 3 comments 5 replies
-
Why would you like to have multiple binaries instead a single binary and select the hardware based on the dts? Managing the multiple binaries would be a nightmare. |
Beta Was this translation helpful? Give feedback.
-
Well, the hardware is the same for all the binaries, I want to build. So the dts is the very same for all of them. With "normal" CMake, managing multiple binaries, is as simple, as adding Let's assume, I have some software, that interacts with a UART. This part of the software has just a dependency to that UART and is complex enough to being worth to have a lot of unit tests. I can factor out the UART, provide an interface to the software under test, write a mock for the hardware and can create every behavior I want to have for the UART. Probable even behavior which would be extremely hard to create in reality (like data arriving in unusual blocks, data outside of frames, backpressure from hardware handshakes etc.). Now, I'm certain, that the software, that is interacting with the UART is correct. What is missing now, is the UART driver itself. For that, I would like to have a binary for the target hardware, that I can use to interact with the driver itself. Does that makes sense to you? |
Beta Was this translation helpful? Give feedback.
-
As a workaround, I collect all firmware targets and then, use a function to conditionally add sources to a target:
Where To build either the firmware or the usb_cdc_test, a CMake cache variable has to be set and the Zephyrs one and only executable target will be build. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
we would love to create multiple binaries for the same hardware / hardware configuration. The purpose of this, is that we factor out all hardware decencies and test our code against hardware mocks. We try to have the hardware layer as thin as reasonable possible. To test the hardware layers, we use different binaries that run on the same hardware as the final firmware, but contains just one hardware layer (driver) and some interface, that allows to interact with the hardware layer.
I was surprised, that Zephyr is not exposed as a CMake library target, that could be used to link against, but that one has to add sources to a given library. But maybe, there is such a target, that I could use in different executable targets to link against? If not, is there a Zephyr way to have multiple binaries for the same board?
The only solution, I can currently think of, is to have a build parameter and have a lot of if/else in the cmake files to collect different source and then to have multiple builds.
best regards
Torsten
Beta Was this translation helpful? Give feedback.
All reactions