I connect a 5v 5w solar panel a usb port and a 3.7v 2.5Ah lipo with pcb. If I connect a phone to usb port it doesn't charge, but if I remove the battery from the circuit, it does. I suppose it's because battery pcb downgrade the voltage to 4.2v or there is not enough energy to serve both.
It is not so much a matter of energy availability (although that matters) as of voltage. The USB input phone charger requires voltage in about the 4.8 - 5.1V range to operate. The LiPo cell will load the PV panel to <= 4.2V OR be destroyed. If the battery has not caught fire or exploded yet it will prevent the phone charger working.
If you have a 5V 5W panel it will produce 1A in full sun. A 2500 mAh LiPo will usually have a safe maximum charging current of 2.5A so the PV panel will not provide excess current (probably). A single cell LiPo battery has an ABSOLUTE MAXIMUM voltage of 4.2V. As long as the battery is not fully charged the PV panel will probably niot damage it. Once the battery reaches 4.2V when charging it will need a progressively lower current to stop Vbat rising above 4.2V. If you connect a 5V and 1A capable source at this stage the battery will soon be damaged or destroyed.
Is there is a simple way to prioritize the USB or make them share?
Determine the lowest voltage at which the phone will still charge correctly.
Say it is 4.8V.
Choose some slightly higher minimum Vpv vpoltage - say 4.85V.
Use a comparator or opamp to control a switch (probably a MOSFET) between PV panel and LiPo such that the MOSFET is progressively turned off if the PV panel is loaded to beyond 4.85V.
Diagrammatic only. When Vpv is > 4.85V (and when scaled by R1 & R2 is greater than Vref) the FET Q1 is on and the LiPo (hopefully with a proper charger circuit) is supplied. If Vpv is loaded below 4.85 volts for amy reason (low sun, phone charger load, LiPo load) the FET is switched off. By adding finite gain to the comparator circuit the transitiin can be made linear rather than just on/off. If in linear mode Q1 will dissipate energy due to current and voltage difference. At maximum LiPo load, _FET = (Vpv - V_Lipo) ~= 2V worst case.
I_FET = 1A (PV max)
FET dissipation = V x I = 2 x 1 = 2 Watts.
Modest heatsinking needed.
simulate this circuit – Schematic created using CircuitLab