A light rope $AB$ passes over a rough circular cylinder, which is fixed with its axis horizontal. Bodies of weights $M$ and $m$ are attached at $A$ and $B$ respectively so that the ends of the rope hang in a vertical plane perpendicular to the axis of the cylinder. If $A$ is about to descend, find the greatest weight that can be added to $B$ before $B$ starts to descend.
Here what I tried but some parts not sure. (Here $T$=tension, $s$ =arc length,$\varphi$= the angle that the tangent to the curve ,R=reaction from the cylinder)

First I consider when $A$ is about to descend, and derive two equation
$$\frac{dT}{ds}=\mu R \space\space \text{and} \space\space R\frac{ds}{d\varphi}=T$$ by solving I got $\ln(T)=\mu \varphi+c$ where c is arbitary constant. Since at $\varphi=\pi/2$ , $T=M$ so
$$ \ln\big{(}\frac{T}{M} \big{)}=\mu\varphi-\frac{\mu \pi }{2}$$
At $\varphi=-\pi/2$ ,$T=m$ therefore
$$\ln \big( \frac{m}{M}\big{)}=-\mu \pi $$
Similarly for the second case I got $\ln \big( \frac{m+w}{M}\big{)}=\mu \pi $ so
finally $w=\frac{M^2-m^2}{m}$
Can anyone verify my answer? Is there anything wrong here?