The contact forces with two blocks are $N_1 = m_1 g + m_2 g$ for the bottom block (to the floor) and $N_2 = m_2 g$ for the top block (to the 1st block).
The available traction is $F^\star_1 = \mu_1 (m_1+m_2)\,g$ and $F^\star_2 = \mu_2 m_2\, g$ or
$$ \begin{pmatrix}F_1^\star\\F_2^\star\end{pmatrix} = \begin{bmatrix}1&-1\\0&1\end{bmatrix} ^{-1} \begin{pmatrix}\mu_1 m_1\,g\\\mu_2 m_2\,g\end{pmatrix} = \begin{pmatrix}\mu_1 (m_1+m_2)\,g\\\mu_2 m_2\,g\end{pmatrix} $$
The balance of horizontal forces is
$$ \boxed{ \begin{pmatrix}P_1\\P_2\end{pmatrix} - \begin{bmatrix}1&-1\\0&1\end{bmatrix} \begin{pmatrix}F_1\\F_2\end{pmatrix} = \begin{pmatrix}m_1 \ddot{x}_1\\m_2 \ddot{x}_2\end{pmatrix}} $$
where $P_1$, $P_2$ are any applied forces on the blocks (in your case $P_1=1N,\; P_2=0N$) and $F_1$, $F_2$ are the friction forces. Here comes the fun part:
Assume blocks are sticking and solve for the required friction $F_1$, $F_2$ when $\ddot{x}_1=\ddot{x}_2=0$
$$ \begin{pmatrix}F_1\\F_2\end{pmatrix}_{stick} = \begin{bmatrix}1&-1\\0&1\end{bmatrix} ^{-1} \begin{pmatrix}P_1\\P_2\end{pmatrix} = \begin{pmatrix}P_1+P_2\\P_2\end{pmatrix} $$
Find the cases where required friction exceeds traction
$$ \begin{pmatrix}F_1\\F_2\end{pmatrix}_{stick} > \begin{pmatrix}F_1^\star\\F_2^\star\end{pmatrix} = \begin{pmatrix}\mu_1 (m_1+m_2)\,g\\\mu_2 m_2\,g\end{pmatrix} $$
For those cases set $F_i = F_i^\star$ otherwise set $\ddot{x}_i = \ddot{x}_{i-1}$ and solve the balance of horizontal forces.
Example 1, All slipping:
$$ \begin{pmatrix}P_1\\P_2\end{pmatrix} - \begin{bmatrix}1&-1\\0&1\end{bmatrix} \begin{pmatrix}\mu_1 (m_1+m_2)\,g\\\mu_2 m_2\,g\end{pmatrix} = \begin{pmatrix}m_1 \ddot{x}_1\\m_2 \ddot{x}_2\end{pmatrix} $$
to be solved for $\ddot{x}_1$ and $\ddot{x}_2$
Example 2, All sticking:
$$\begin{pmatrix}P_1\\P_2\end{pmatrix} - \begin{bmatrix}1&-1\\0&1\end{bmatrix} \begin{pmatrix}F_1\\F_2\end{pmatrix} = \begin{pmatrix}0\\0\end{pmatrix}$$
to be solved for $F_1$ and $F_2$
Example 3, Bottom slipping, top sticking:
$$ \begin{pmatrix}P_1\\P_2\end{pmatrix} - \begin{bmatrix}1&-1\\0&1\end{bmatrix} \begin{pmatrix}\mu_1 (m_1+m_2)\,g\\ F_2\end{pmatrix} = \begin{pmatrix}m_1 \ddot{x}_1\\m_2 \ddot{x}_1\end{pmatrix} $$
to be solved for $F_2$ and $\ddot{x}_1$.
The matrix $A=\begin{bmatrix}1&-1\\0&1\end{bmatrix}$ is the connectivity matrix, and it can be expanded if you have more blocks. See my full solution here of similar problem in more detail: https://physics.stackexchange.com/a/79182/392
@Manishearth
to notify me) $\endgroup$ – Manishearth May 16 '13 at 9:34