MegaPirateNG / ardupilot-mpng

MegaPirateNG
GNU General Public License v3.0
117 stars 105 forks source link

HK AIOP v2 - MPNG compiles but boards do not boot #147

Open maciek252 opened 10 years ago

maciek252 commented 10 years ago

I have two controllers AIOP v2.0 from HobbyKing (with MultiWii &MegaPirate Flight Controller /hexatronik texts on the back). For both of them, MultiWii works perfectly, and I can also load MegaPirate soft using the FlashTool, everything flies fine - checked for ArduPlane and ArduCopter.

I can also compile MPNG, it uploads correctly but boards do not start. The red LED blinks a couple of times and... nothing more happens. Connection with apmplanner2 fails. I set CRIUS_V1 version of the board, tried for several MPNG versions (2.76, 3.0.1 R4), and arduino 1.0.3 with libraries copied and pde.jar replaced, running linux and windows.

There is a remark in the mpng site that recalibrating compass and accelerometers helps. But how can I do this if it is impossible to connect from apmplanner2?

Espenf commented 10 years ago

Guess this is a Amp planner question. Try posting here: http://ardupilot.com/forum/viewforum.php?f=82 Have you tried MP?

maciek252 commented 10 years ago

I'm afraid it's not a problem with ApmPlanner, as boards seem not to run at all. The red diode should be flashing, and the green one blinking depending on the valid GPS fix. Flight modes cannot be switched etc. And the same boards run perfectly after loading pre-compiled hex versions with FlashTool. Yes, I have also tried MP, to no avail. I also did EEPROM->clean, but it did not help.

Espenf commented 10 years ago

Ok, cant help you maciek252 . I stopped compiling at R3, on R4 I only used the flash tool because it worked for my needs. Some of team here hopefully help you solve this. You selected correct controller before compiling?

maciek252 commented 10 years ago

There are more users having a similar problem:

http://www.multirotorforums.com/showthread.php?14626-Crius-AIOP-V2-with-MegaPirate-3-0-1-R2 http://www.megapirateng.com/2013/09/megapirateng-3-0-1-r2-public-release/ (see the comments - user nitbeat) https://github.com/MegaPirateNG/ardupilot-mpng/issues/94 (solution - use flashtool, exactly as in my case)

smurfy commented 10 years ago

I'm not exactly sure what the problem is. FlashTool uses a different compiler version than arduino i think.

Why do you want to compile it yourself?

SirAlex commented 10 years ago

@maciek252 Use terminal to see what is wrong with your board during boot. You can use Mission planner terminal window or use any other program, I'm recommend PUTTY.

maciek252 commented 10 years ago

FlashTool downloads precompiled hex versions, I don't know how were they compiled. I want to compile it myself, because I would like to learn how this works and to add some modifications. For example, data logging and thermaling capabilities. And it annoys me that it fails and nobody knows why :) Maybe I will try to use data logging as a form of simple debugging.

I've also ordered HKpilot and MicroWii controllers, but I still want MPNG to work with AIOP! @SirAlex, I'll report what is appears on the terminal.

maciek252 commented 10 years ago

Nothing appears at the terminal, dead. And the version loaded with FlashTool writes:

Init ArduPlane 2.76 (03cbaa4)

Free RAM: 4096 Board Type: 2 load_all took 18588us

Press ENTER 3 times to start interactive setup

In both cases, the only power supply I use is by USB, is that OK? It works for the precompiled version.

SirAlex commented 10 years ago

Try to touch ISP port pins during boot.

maciek252 commented 10 years ago

Touching ISP port does not cause any change, maybe I'm doing it wrong :) (I have no pins soldered)

What code could turn on a LED and stops the execution? I could see what happens and if the program starts at all.

SirAlex commented 10 years ago

I think, in your case only bootloader works. The phrase "Init ArduPlane 2.76" printed out before any initialization, so it it not appear than firmware not started at all. First of all, check you are using Arduino IDE 1.0.3, next check controller type in IDE (must be Arduino Mega). Also you can enable in preferences verbose mode for upload process and check it actually upload firmware into board.

maciek252 commented 10 years ago

This phrase appears only for (working) version loaded in FlashTool. I ask where is the main entry point and can I add a simple loop flashing a LED there, to see if the program loads and runs at all. There are some test programs in the sketchbook. Thanks for your help!

SirAlex commented 10 years ago

Then main entry point located here: AP_HAL_MPNG_Main.h, first of all it called Init method located here: HAL_MPNG_Class.cpp

maciek252 commented 10 years ago

OK, and what code can I put there? I tried to compile the "Hello" example, but it complains:

Hello:26: error: ‘AP_HAL_MPNG’ was not declared in this scope Hello:38: error: expected constructor, destructor, or type conversion before ‘;’ token

The toolchain seems to be the proper one, provided by arduino 1.0.3 (with appropriate pde.jar copied)

arduino-1.0.3/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=103 -mcall-prologues -DCONFIG_HAL_BOARD=HAL_BOARD_MPNG -DEXCLUDECORE -I/home/maciek/Downloads/kk-multicopter-multiwii/MegaPirateNG/2.76/arduino-ide-1.0.3/arduino-1.0.3/libraries/AP_Common (...)

SirAlex commented 10 years ago

In order to compile regular arduino sketches, you must set HAL BOARD to NONE in Arduino IDE. Also you must point scketch folder in preferences to standard arduino sketchbook folder. And do not forget to restart Arduino IDE after this.

maciek252 commented 10 years ago

I did some experiments.

-I flashed the bootloader m2560, result OK -uploaded the original arduino example "Blink", it works, pins 13 and 30 correspond to the leds A and C, resp. -the same code placed in the main function of the APM code does not execute

So something is wrong with the modified toolchain. Maybe the main function is not reached? What is the role of the pde.jar file? Wrong version of JDK?

chriskmn commented 10 years ago

I had same issues and this helped for me:

http://www.rcgroups.com/forums/showthread.php?t=1794688&page=36