RepRapFirmware examines the start and end of the gcode file for comments describing the total filament consumption, layer height and other parameters, and parses the file to determine the number of layers, either by looking for comments, or failing that, by looking at layer height changes.
Your slicer should generate those in a format that RRF understands. Recent versions of RRF (v3.4) can parse comments created by PrusaSlicer, Cura, Simplify3D, Slic3r, KISSSlicer, Ideamaker, Pathio, MatterControl, Fusion 360, and most slicers that are based on these. Older versions of RRF may not support more recent versions of the slicers.
Even if there are no comments in the Gcode file, you should still get the time estimation based on the proportion of the file that has been processed.
Note that some slicers support variable layer height. This can make it hard to count layers, and somewhat undermines the concept of layer height and number.
In the absence of an object height comment, RRF will parse the file to determine what the maximum Z height is, and use this to determine the object height. However, moves in the end Gcode, to move the hot end away from the finished part, can confuse this. If you have such a move in your end Gcode, add a comment after that Gcode (usually found in the slicer 'end gcode' section) that starts with an E
. For example:
G1 Z220 ;E drop the print bed (E to exclude from layer count)
In the absence of a layer height comment, the firmware looks at the gcode itself to work out the layer height. If there is a Z move followed by extrusion (perhaps a purge line) that is at a different height to the rest of the job, this can confuse the firmware. It may cause an incorrect layer height to be assumed, and also an incorrect layer count.
It can also happen if supports are being used, and those supports are at a different layer height than the main part of the print.
The easiest way to resolve this is to add this in the 'after layer change G-code' in your slicer:
;LAYER [layer_num]
and this at the end of your 'custom end G-code':
;NUM_LAYERS [layer_num]
Then you should see the correct layer numbers. Support layers are counted as separate layers and ignored - at least in PrusaSlicer.