I tested the altitude hold mode (firmware 2017.06) with my crazyflie 1.0 but it didn't work 100%. I am able to choose a setpoint using the throttle but the drone sometimes falls or ascends losing the target altitude. I am using the foam to protect the sensor but this problem is still happening. What else can I do to achieve a good altitude control using crazyflie 1.0?

First thing to check: do you have a Crazyflie 1.0 10DOF, if not there is no pressure sensor and altitude hold will use only the accelerometer which means that it is going to drift after a while.

If you have the pressure sensor, altitude hold is dependent of the ambiant pressure change. You can test if the ambiant pressure is changing a log in your environment by loggin the pressure reading using the Crazyflie client, for example big pressure change can normally be seen by opening and closing the room door/windows. If the ambiant pressure fluctuate a log there is not much that can be done to get a more stable hold.

If the pressure is more stable than what you are observing, there might be hope to improve things with better firmware implementation. This is something that requires looking into and tweaking the Crazyflie source code.

Thanks for the reply, arnaud.
My crazyflie 1.0 is 10 DOF and the room where I tested was closed. Could you give me a tip, which files(codes) do I have to change in order to improve the altitude hold mode? I use the crazyflie VM too and I can change the codes.