I have an ESP32 project in mind and I want to design the PCB in such a way, that depending on the parts soldered, it can bei either powered by a LiPo or a LiFePo4 battery and of course also over USB. Besides powering the MCU with 3.3V, a boost circuit supplys other sensors with 5V.
Case: LiPo, no USB
If using a LiPo, the voltage needs to regulated by an LDO to 3.3V and another connection goes to a boost converter to output 5V.
LiPo, USB Connected
If USB is connected, the LiPo should be taken off the supply for the load. The 5V USB should go to the 3.3V LDO and also to the boost circuit. In the boost circuit I hope it just passes the diode and inductor and the boost circuit doesnt do anything else since it already has 5V.
Case: LiFePo4, no usb
For this battery, the current should go straight to the MCU, not going through a regulator. This is recommended in many articles and should work fine, as long as it is not charged over 3.6V. It should also go to the boost circuit to 5V.
LiFePo4, USB connected
If the USB is connected, the battery should be taken off the circuit since no 5V should never enter the battery. The 5V USB should go to the 3.3V LDO and regulated down. Similar to the LiPo circuit, the USB should also go to the boost circuit hoping it wont do much with it but pass it through the diode.
Goal:
The goal is that I have as few components and traces as possible while the circuit works as described.
First Ideas
Load sharing systems have been used quite often lately, but I havent seen them working with two battery types.
The idea is that once USB is connected, the gate of a p channel mosfet turns off the connection between the battery and the load.
I opt for two load sharing circuits while soldering only the one for the specific battery, not knowing if that would really work. There are also some solder bridges in the circuit to take that part completly off everything depending of the battery chosen.
I would really appreciate if someone could look at my circuit and tell me if that makes any sense / could work, or if I should do something different.

