Here is another more complicated version.

Bock A with mass m is put on top of a surface. There is another block (B) with mass m2 on top of block A.
Friction coefficient between block A and surface is $\mu$, between block A and block B is $\mu_2$.

The normal force between block A and surface is $(m+m_2) g$, between block A and block B is $m_2 g$
The external force is F:

1. $F\le (m+m_2)g \mu$: both block would not move
Friction force between block A and surface is $-F$, between block A and block B is 0.
2. $(m+m_2)g\mu ($\frac{F-(m+m_2)g\mu}{m+m2}m_2< m_2 g\mu_2$Force on block B less than maximum static friction force) Friction force between block A and surface is$(m+m_2)g \mu$, acceleration of both blocks is$\frac{F-(m+m_2) g\mu}{m+m2}=\frac{F}{m+m_2}-g\mu$friction force between block A and block B is$\frac{m_2}{m+m_2} (F-(m+m_2) g\mu)=\frac{m_2}{m+m_2}F-m_2 g \mu $3.$F>(m+m_2) g (\mu+\mu_2)$: block A and block B move separately. Friction force between block A and surface is$(m+m_2)g \mu$, acceleration of blocks A is$\frac{F-(m+m_2) g\mu-m_2 g\mu_2}{m}$friction force between block A and block B is$m_2 g \mu_2$, acceleration of block B is$g \mu_2\$

Enjoy the simulation!
CLick the following image to display the simulation.
[eye]