Remove all loose paint by scraping. Now sand the surfaces with 120-150 grit sand paper. This will smooth out any rough edges and roughen up the wood a bit.
After sanding and assuming the wood is dry you now need to apply 2 coats of oil base primer. Thin the first coat a little bit to help it penetrate into the wood. Allow the primer to dry between each coat.
Now that the primer is dry you need to caulk any gaps in the wood or where two pieces meet. Use a good paintable caulking. Allow the caulking to dry then repaint. Use a semi-gloss 100% acrylic paint, 2 coats is better that 1 thick coat.