Dealing with an ESP-IDF project that needs to support many PCB revisions?
Posted: Tue Sep 13, 2022 5:34 pm
I have an project which has several different PCB revisions, each with different peripheral ICs that the ESP32 communicates with. Each revision has a variety of changes like for example using a different sensor IC, and so I need different functions to communicate with the specific sensor. The application code otherwise remains identical. Until now there were just two PCB revisions, and so I used pre-processor directives to conditionally compile with relevant blocks code.
We are now approaching a third hardware version, and so I want to create a sort of hardware abstraction layer that includes only code relating to that specific PCB revision. That way the code can remain clear, and it will be simple in the future to add changes for new hardware revisions. What I am envisioning is that when I build the project, I could specify the PCB revision I am building for, and the relevant component would be included. When changes are made to the application code, automated CI processes could build for each of the revisions.
For example there could be a component for each PCB revision. Then there would be a header file with interface definitions, for example "uint32_t read_sensor_api()". Each board component would then have the actual implementation for their specific sensor.
What is the best practice with the ESP-IDF build system to accomplish this? Would I need to write CMake instructions? Any help on the direction to go with this would be greatly appreciated.
We are now approaching a third hardware version, and so I want to create a sort of hardware abstraction layer that includes only code relating to that specific PCB revision. That way the code can remain clear, and it will be simple in the future to add changes for new hardware revisions. What I am envisioning is that when I build the project, I could specify the PCB revision I am building for, and the relevant component would be included. When changes are made to the application code, automated CI processes could build for each of the revisions.
For example there could be a component for each PCB revision. Then there would be a header file with interface definitions, for example "uint32_t read_sensor_api()". Each board component would then have the actual implementation for their specific sensor.
What is the best practice with the ESP-IDF build system to accomplish this? Would I need to write CMake instructions? Any help on the direction to go with this would be greatly appreciated.