When was the custom of Hakafos initiated?
The custom of Hakafos was initiated by the prophets. It is not considered even a Rabbinical injunction, but rather a mere custom. [The intent of the above is not that the prophets instituted Hakafos, but that the custom of rejoicing with the Sefer Torah was derived from David Hamelech, who was a prophet, and removed the ark from its place and danced and sang in front of it. However the actual custom of dancing in circles on Simchas Torah is a custom initiated by the Jewish people in later generations, unbeknownst to us the exact time period. Alternatively, this custom was initiated by Moshe Rabbeinu, and he himself danced on Simchas Torah with the Sefer Torah.]
 Siddur Im Dach p. 269; See also Likkutei Torah 2nd “Ushiavtem Mayim” “It is a mere custom”
 Letter printed in Likkutei Sichos 29/505; See there that perhaps a) The word “prophets” is a printing error; b) Even if not a printing eror, it is not to be taken literally, and does not mnean to say that dancing in a circle around the Bima on Shemini Atzeres is a custom of the prophets, but rather in general that the concept of celebrating with the Torah is derived from the prophets.
 Hisvadyus 1984 2/1082; See the Pizmon of Sisu Visimchu that is recited after Kerias Hatorah in which we state that Mosher rejoiced on Simchas Torah, and it should be accepted literally, as a) Mosher Rabbeinu established the reading of the Torah during the weeks; b) It is difficult to assume that some person in a later generation established it, as why would Klal Yisrael suddenly follow his custom. Rather one must say it was already followed by Moshe Rabbeinu as a custom. [Hisvadyos ibid]