I'm not sure that Marx directly addresses the question you're asking, i.e., how consciousness is precisely accounted for or by what process it might arise. However, he does stress that consciousness is not something pre-given (as in the cogito) but something that arises out of particular circumstances. Thus, to pick on The German Ideology:
The production of ideas, of conceptions, of consciousness, is at first directly interwoven with the material activity and the material intercourse of men—the language of real life. Conceiving, thinking, the mental intercourse of men at this stage still appear as the direct efflux of their material behaviour. ... Consciousness can never be anything else than conscious being, and the being of men is their actual life-process.
Marx and Engels, The German Ideology, p. 36
And then a short while on:
The "mind" is from the outset afflicted with the curse of being "burdened" with matter, which here makes its appearance in the form of agitated layers of air, sounds, in short, of language. Language is as old as consciousness, language is practical, real consciousness that exists for other men as well, and only therefore does it also exist for me; language, like consciousness, only arises from the need, the necessity, of intercourse with other men. ... Consciousness is, therefore, from the very beginning a social product, and remains so as long as men exist at all. Consciousness is at first, of course, merely consciousness concerning the immediate sensuous environment and consciousness of the limited connection with other persons and things outside the individual who is growing self-conscious. ... This sheep-like or tribal consciousness receives its further development and extension through increased productivity, the increase of needs, and, what is fundamental to both of these, the increase of population. With these there develops the division of labour, which was originally nothing but the division of labour in the sexual act, then the division of labour which develops spontaneously or "naturally" by virtue of natural predisposition (e.g., physical strength), needs, accidents, etc., etc. Division of labour only becomes truly such from the moment when a division of material and mental labour appears. From this moment onwards consciousness can really flatter itself that it is something other than consciousness of existing practice, that it really represents something without representing something real; from now on consciousness is in a position to emancipate itself from the world and to proceed to the formation of "pure" theory, theology, philosophy, morality, etc. But even if this theory, theology, philosophy, morality, etc., come into contradiction with the existing relations, this can only occur because existing social relations have come into contradiction with existing productive forces.
Marx and Engels, The German Ideology, p. 43-45
Consciousness, for Marx then, is not primary; it only exists as a product of certain material activities. It is something that has arisen from out of a historical need---not something prior or immediately separable from to the material conditions which produce this need.
Descartes, in his Meditations, which you allude to, seeks after an Archimedian point, "just one little thing that is certain and unshakeable." (Descartes, Meditations, p.17) And where does he arrive? Descartes assumes everything, his senses, his memory, etc., are false, but winds up with this:
Certainly I did exist, if I convinced myself of something.—But there is some deceiver or other, supremely powerful and cunning, who is deliberately deceiving me all the time.— Beyond doubt then, I also exist, if he is deceiving me; and he can deceive me all he likes, but he will never bring it about that I should be nothing as long as I think I am something. So that, having weighed all these considerations sufficiently and more than sufficiently, I can finally decide that this proposition, ‘I am, I exist’, whenever it is uttered by me, or conceived in the mind, is necessarily true.
In other words, there is no way to convince myself that "I" do not exist---even if everything around me were to prove to be false, I would still be able to hold onto this self-conscious "I."
Against such a view, Marx argues that this "I" does not, in the first instance, exist. It is rather a product of certain social and material relations. To seek, therefore, to ground philosophy on this "I" is to miss the very foundations of this "I" itself, which are its relationship to producing the means of sustenance for the creature that can come to be this "I." For Marx, Descartes simply assumes to quickly that there is this "I"; of course, this "I" exists, but it does not exist ex nihilo, but rather out of a particular history, the history of the person.
But if consciousness is dependent on the material conditions of its production, then surely the more pressing consideration is not "how do we explain consciousness?" but rather "what is the nature of the processes by which a thing such as consciousness can be produced?"
As a final comment: for a materialist the key point would be that there is no ontological split between mind and matter, that is, what mind is (however this gets cashed out) is never going to need to rely on a non-material explanation. Mind may be some kind of supervenient property and so may be distinguishable from more familiar types of material things, but it is not a different class of being. Consciousness is merely something that arises out of matter, not some mysterious other-worldly thing.