This paper describes an innovative method to estimate the wall losses during the compression and combustion strokes of a gasoline engine using the cylinder pressure measurement. The estimation during the compression and combustion strokes allows to better represent the system during the combustion. A sliding mode observer is derived from a validated 0-D physical engine model and its convergence and stability are proved. The observer is validated using two different engine models: a one zone engine model and a two zones engine model with flame wall interaction. A good agreement between the estimation results and the model reference is observed, showing the interest of using closed loop strategies to estimate the wall losses in a SI engine.