Recently we have updated a multi-phase transport (AMPT) model with modern parton distribution functions of nuclei (nPDFs). Here we study open charm production in the updated AMPT model and compare to the experimental data from $pp$ and $AA$ collisions over a wide range of collision energies. Besides the update of nPDFs, we have removed the transverse momentum cutoff on initial heavy quark productions and also included the resultant heavy flavor cross section into the total minijet cross section in the initial condition as described by the HIJING model. We show that the AMPT model with these updates provides a much better description of the yields and transverse momentum spectra of various open charm hadrons in comparison with the experimental data. This lays the foundation for further heavy flavor studies within the transport model approach.