Answer:
All the energy in an ecosystem enters through the sun. The sunlight is absorbed by the green plants known as the producers of the ecosystem.
This energy is transferred to the primary consumers when they eat producers (green plants)
The energy from the primary consumers are transferred to secondary consumers and then to tertiary consumers.
So, we can say that the primary source of energy is Sun.