MN 36 parallels for section where Buddha as a 9 year old boy has first jhana
I could find the part about the 4 jhanas instead of only the first jhana, but I could not find the part about the earthworms.
From Ekottarāgama 31.8 of the Taisho Tripitaka:

「爾時，我作 是念：『今日可食一果。』爾時我便食一果。當 我食一果之日，身形萎弱不能自起居，如 年百二十，骨節離散不能扶持。比丘當知，
爾時一果者，如似今日小棗耳。爾時，我復作 是念：『非我成道之本，故當更有餘道。』爾時， 我復作是念：『我自憶昔日，在父王樹下無
婬、無欲，除去惡不善法，遊於初禪；無覺、 無觀，遊於二禪；念清淨無有眾想，遊於 三禪；無復苦樂，意念清淨，遊於四禪。此或
能是道，我今當求此道。』

Using Google Translate, I got:

&quot;At this time, I just said: &quot;I can eat one fruit today.&quot; At this time,
I eat one fruit. When I eat one fruit, I am weak and unable to live by
myself. For example, when I am a hundred and twenty, my joints cannot
be separated. Support. Bhikkhus should know that when there is a
fruit, it is like today's jujube ears. When you are here, I repeat it
by saying: &quot;It is not the foundation of my enlightenment, so I should
have more surplus.&quot; &quot;I recall from the past, under my father’s tree,
there was no lust, no desire, no evil and unwholesome dhammas,
swimming in the first meditation; no awareness, no insight, swimming
in the second meditation; pure mind without many thoughts, swimming in
the third meditation; Resume suffering and happiness, pure mind, swim
in the four meditations. This may be the Tao, I should ask for it
now.&quot;

The Chinese used in the agama is probably a bit different from modern Chinese, so the machine translation may be inaccurate.
Ekottarāgama is the Sanskrit equivalent of the Pali collection of Aṅguttara Nikāya.