To charge 2 LiIon series from 5V you need a boost circuit.
To charge 2S LiIon from 24V you need a buck.
To create 5V from 2S LiIon you need to buck.
The easiest path for a 2S seems to be using the 24Vin to charge the 2S, then buck from the 2S to make…