A system on chip (SoC) comprising a one-time-programmable, (OTP) memory, a read only memory (ROM), a random access memory, (RAM), a processor unit and an OTP controller, said processor unit being connected to said OTP controller, to said ROM, and to said RAM said OTP controller being connected to said OTP memory and to said RAM, said ROM comprising instructions to be used by said processor unit after a power-up of said system on chip (SoC), and said OTP memory storing a set of instructions relating to an application program and an application length indicating a length of said application program, the system on chip (SoC) being arranged such that:
- said processor unit is configured to perform the following actions at power-up:
- copy said application length from said OTP memory to a length register in said OTP controller, the length register being a retention register which keeps its memory content even in case the processor unit enters a sleep mode;
- instruct said OTP controller to copy said set of instructions relating to said application program from said OTP memory to said RAM using said application length;
- execute said set of instructions relating to said application program from said RAM;
- set said system on chip (SoC) in sleep mode;
- said OTP controller is configured to perform the following actions in response to receiving an interrupt to wake-up the system on chip (SoC) from said sleep mode:
- copy said set of instructions relating to said application program from said OTP memory to said RAM while using said application length as stored in said length register;
- in response to said copying of said set of instructions, wake up said processor unit and transfer control back to said processor unit;
- said processor unit in response to being woken up by said OTP controller:
- execute said set of instructions relating to said application program from said RAM.