Problem running the example sketches on a Pixhawk

Hi all,

I’m having the exact issue that was described by two other users in this post. Is anyone able to shed a bit more light on this? As was the case with the other users, the full build of the Copter firmware works fine, however I’ve tried uploading several different example sketches to no avail. I’m building the code using Make on a Linux machine.

After uploading an example sketch, the B/E LED on the I/O board flashes at 4Hz, indicating no FMU input, while the main LED Pixhawk never gets past the point of displaying solid white during the boot process. Is this just because the I/O board is unused when running a basic sketch such as UART_test.cpp or Hello.cpp, or could there be an issue arising during the board’s boot sequence?


Hi Brian,

Some of the examples got messed up by a recent change where board initialisation was done differently.
There are 2 options.
1 remove the SD card. Then connect to a serial console via USB. (I use GTKTerm fwiw). Then type ‘ls’ at the terminal and you should see a File system displayed. That is just to check you are connected OK. Then type

sh /etc/init.d/rc.APM

That runs a script that starts the peripheral drivers.

If that doesnt work then look at This patch, which didn’t get merged. ( I will try to re-open these PR’s at some stage soon)

It is a different example but try making similar changes to your example source. Note that as well as the example source file, you need to modify the file to ad the AP_BoardConfig library else you will get linker errors.

If it works then I suggest you submit a PR :slight_smile:

Hi skyscraper,

Thanks for the response - I had been scratching my head for a few days so this was much appreciated :smiley:

I tried both of the proposed solutions, however only the first (manually running the rc.APM script via NuttX shell) seemed to work. The other option (patching the code and running w/ the microSD inserted) still yielded the same problem, i.e. it seemed the Pixhawk failed to finish initializing.

Is there another way to get custom sketches running with the microSD inserted? Also – noob question – what exactly is the microSD used for, aside for storing the dataflash logs?

In the meantime, manually running the rc.APM script should allow me to start testing some basic “Hello World” sketches , at least :slight_smile:


Hi Brian,

Can you say which example you are working with? The examples arent working great on PX4
Ideally there needs to be a way on PX4 to pause (eg. wait for a key press , then call the AP_BoardConfig::init function) in examples since any diagnostics are gone by the time the console is running, or so I found, since USB insertion starts everything running. Catch22 . If the initialisation diagnostics could be read it might give a clue by comparing the console output against what drivers are loaded without the SD card.

There is an example here of how to wait for user input. You could try adding that to your example just before AP_BoardConfig::init(( and then try with and without SD card and see what drivers are being loaded) ( N.B that example hasnt been updated with fixes so sketch wont run without mods FWIW)

Unfortunately I am working flat out on other stuff ATM

SD card is used for logging the sensor output in flight.

Anyway welcome to Ardupilot development :slight_smile: If you get it working do submit a PR !