$\operatorname{rank}(A^2)+\operatorname{rank}(B^2)\geq2\operatorname{rank}(AB)$ whenever $AB=BA$?

Well, turns out I made a mistake when trying to construct counterexamples... There is indeed a counterexample of order $4$: $$A=\begin{pmatrix}0&1&0&0\\0&0&0&0\\0&0&0&1\\0&0&0&0\end{pmatrix},\quad B=\begin{pmatrix}0&1&1&0\\0&0&0&1\\0&0&0&1\\0&0&0&0\end{pmatrix}.$$ Sorry for misleading. :(