Necessary conditions for a soliton on a torus $M=R^m/Lambda$ to be a soliton crystal, that is, a spatially periodic array of topological solitons in stable equilibrium, are derived. The stress tensor of the soliton must be $L^2$ orthogonal to $ee$, the space of parallel symmetric bilinear forms on $TM$, and, further, a certain symmetric bilinear form on $ee$, called the hessian, must be positive. It is shown that, for baby Skyrme models, the first condition actually implies the second. It is also shown that, for any choice of period lattice $Lambda$, there is a baby Skyrme model which supports a soliton crystal of periodicity $Lambda$. For the three-dimensional Skyrme model, it is shown that any soliton solution on a cubic lattice which satisfies a virial constraint and is equivariant with respect to (a subgroup of) the lattice symmetries automatically satisfies both tests. This verifies in particular that the celebrated Skyrme crystal of Castillejo {it et al.}, and Kugler and Shtrikman, passes both tests.