I've recently done this as well. Paint was flaking and in generally horrible condition. Here's what we did:

Used an angle grinder with a harsh sanding pad.

The angle grinder wouldn't do the corners - use one of those corner sanders with the harshest paper you can get for that.

When we had removed all paint, we washed the hell out of the wall and gave it a coat of primer/sealer (we used a 2 in 1 or something along those lines).

Paint to your heart's content. We used a low sheen - as mentioned earlier, using a low sheen paint means imperfections don't stand out as much. Besides, I prefer the look of the low sheen.

Sure, it was a prick of a job, but it looks fantastic now.

Cheers,
Lotte