Porting to new hardware

hi,
I am trying to port ardupilot to STM32F407 (STMf4DISCOVERY board).
I am following the link http://ardupilot.org/dev/docs/porting.html

I am trying to build with
./waf copter
I am getting the following error

In file included from …/…/modules/ChibiOS/os/hal/include/hal.h:130:0,
from …/…/libraries/AP_HAL/board/chibios.h:4,
from …/…/libraries/AP_HAL/AP_HAL_Boards.h:177,
from …/…/libraries/AP_HAL/AP_HAL.h:6,
from …/…/libraries/AP_HAL_ChibiOS/UARTDriver.cpp:17:
…/…/libraries/AP_HAL_ChibiOS/UARTDriver.cpp: In member function ‘void ChibiOS::UARTDriver::write_pending_bytes()’:
…/…/libraries/AP_HAL_ChibiOS/UARTDriver.cpp:820:41: error: ‘SerialDriver’ was not declared in this scope
uint32_t space = qSpaceI(&((SerialDriver*)sdef.serial)->oqueue);
^
…/…/modules/ChibiOS/os/hal/include/hal_queues.h:142:23: note: in definition of macro ‘qSpaceI’
#define qSpaceI(qp) ((qp)->q_counter)
^~
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/home/deepti/Desktop/Deepti/ardupilot/build/F4DISC’
Build failed
-> task in ‘objs/AP_HAL_ChibiOS’ failed (exit status 1):
{task 140515573993296: cxx UARTDriver.cpp -> UARTDriver.cpp.0.o}
(run with -v to display more information)

Can someone tell where am i doing it wrong? I am a newbie to CPP. But I know about hardware.