I have some custom code, which needs initialisation. I used the Copter::setup() function (ArduCopter.cpp) to call my initialisation functions, assuming that this function will be called after every power cycle, since it is doing the basic system initialisation. But after some digging around, I found the following: If I restart my Pixhawk (with all the peripherals connected) by simply removing the power cord and plugging it in again, the setup() function does not get called! I verified this by sending a message to GCS through this function. The message reaches only some times (e.g. when I command a reboot through GCS), but not when I disconnect the power and reconnect.
Is my understanding wrong? Should I be using some other function to initialise my custom code?