Massive machine type communications (mMTC) is one of the three major scenarios of the fifth generation (5G) communication system, and raises new challenges for the development of new radio access technology. Unlike human type communications (HTC), mMTC is typically characterised by a massive number of devices, small-sized packets, low or no mobility, low energy consumption and sporadic transmission, which requires novel solutions. In this paper, we propose the 2-step random access with early data transmission (2-step-EDT) framework. To solve the optimization problem proposed in the framework, we introduce an algorithm, namely, Backward Sparsity Adaptive Matching Pursuit with Checking and Projecting (BSAMP-CP), which jointly conducts the sparsity level estimation, active device detection, channel estimation and data recovery in two phases. Specifically, in the first phase, BSAMP-CP conducts the sparsity level estimation in a backward manner exploiting the data length diversity information. In the second phase, BSAMP-CP jointly conducts activity detection, channel estimation and data recovery, taking the joint sparsity information of pilot and data symbols, the error checking information and the modulation constellation information into account. Furthermore, we provide a theoretical analysis on the convergence of the proposed BSAMP-CP in the noiseless case and the rationale for the improvement yielded by exploiting data length diversity. Simulation results demonstrate the superiority of the proposed solution in comparison to other existing methods.