I have found the solution. You have to first set the IO config for that PWM port, and set the PIN corresponding to the docs (apalis_arm_som_imx6_datasheet.pdf):
You should check that the pin is configured as PWM and not as a regular GPIO using the GPIO library. You should configure the PWM library to use the pin you need as output and you can check that it has been properly configured using the gpio tool.