Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeModules/FindFFmpeg.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(FindPackageHandleStandardArgs)

set( FFMPEG_LIB "${CMAKE_FIND_ROOT_PATH}/arm-linux-gnueabihf/lib" )
set( FFMPEG_INC "${CMAKE_FIND_ROOT_PATH}/arm-linux-gnueabihf/include" )
set( FFMPEG_LIB "${CMAKE_FIND_ROOT_PATH}/aarch64-linux-gnu/lib" )
set( FFMPEG_INC "${CMAKE_FIND_ROOT_PATH}/aarch64-linux-gnu/include" )


foreach (_component ${FFmpeg_FIND_COMPONENTS})
Expand All @@ -23,7 +23,7 @@ foreach (_component ${FFmpeg_FIND_COMPONENTS})
lib
HINTS
${FFmpeg_${_component}_INCLUDE_DIR}/../lib
${FFmpeg_${_component}_INCLUDE_DIR}/../lib/arm-linux-gnueabihf
${FFmpeg_${_component}_INCLUDE_DIR}/../lib/aarch64-linux-gnu
)
if ( FFmpeg_${_component}_LIBRARIES )
set( FFMPEG_${_component}_FOUND 1 )
Expand Down
4 changes: 2 additions & 2 deletions CMakeModules/FindGPS.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(FindPackageHandleStandardArgs)

set( LIBGPS_LIB "${CMAKE_FIND_ROOT_PATH}/arm-linux-gnueabihf/lib" )
set( LIBGPS_INC "${CMAKE_FIND_ROOT_PATH}/arm-linux-gnueabihf/include" )
set( LIBGPS_LIB "${CMAKE_FIND_ROOT_PATH}/aarch64-linux-gnu/lib" )
set( LIBGPS_INC "${CMAKE_FIND_ROOT_PATH}/aarch64-linux-gnu/include" )


find_library( GPS_LIBRARIES
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ This carrier board has the following features :
* Video composite output (can be directly connected to any FPV drone VTX)

## Building `controller_pc`
For cmake to run properly, the below dependecies should be installed first. Below commands are working for: ***Distro***: Ubuntu 22.04.2 LTS (Jammy Jellyfish), ***Kernel***: 5.15.0-69-lowlatency x86_64, ***bits***: 64, ***Desktop***: Xfce 4.16.0
For cmake to run properly, the below dependecies should be installed first. Below commands are working for: ***Distro***: Ubuntu 22.04.2 LTS (Jammy Jellyfish), ***Kernel***: 5.15.0-69-lowlatency x86_64, ***bits***: 64, ***Desktop***: Xfce 4.16.0
1. **Install dependencies**

* `sudo apt-get install nasm qtmultimedia5-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libiw-dev libfftw3-dev`
Expand Down Expand Up @@ -159,15 +159,14 @@ Currently only Raspberry Pi boards are supported, the 4'th variants are the reco

1. **Install dependencies**
* `sudo apt update`
* `sudo apt install git pkg-config cmake make g++ libc6-dev libraspberrypi-dev libiw-dev libdrm-dev libgbm-dev libcamera-dev libgles2-mesa-dev libgps-dev libasound2-dev libcrypt-dev zlib1g-dev libpng-dev libshine-dev libavformat-dev libavutil-dev libavcodec-dev libpigpio-dev lua5.3 libfftw3-dev`
* `sudo apt install git pkg-config cmake make g++ libc6-dev libraspberrypi-dev libiw-dev libdrm-dev libgbm-dev libcamera-dev libgles2-mesa-dev libgps-dev libasound2-dev libcrypt-dev zlib1g-dev libpng-dev libshine-dev libavformat-dev libavutil-dev libavcodec-dev libpigpio-dev lua5.4 liblua5.4-dev libfftw3-dev libpcap-dev`

2. **Build**
* `git clone https://github.com/dridri/bcflight`
* `cd bcflight/flight`
* `cmake -Dboard=rpi -Ddebug=1 -S . -B build`
* `cd build`
* `make -j$(nproc)`

* `cmake --build build -j`

This will produce two files : `flight_unstripped` which contains all debugging symbols, and `flight` which is a lightweight regular executable.
* `flight_unstripped` can be run via gdb, or Valgrind using [flight/valgrind.sh](./flight/valgrind.sh)
* `flight` is intended to be used on final product
12 changes: 6 additions & 6 deletions Toolchain-rpi.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
SET( CMAKE_SYSTEM_NAME Linux )
SET( CMAKE_SYSTEM_VERSION 1 )

SET( CROSS arm-linux-gnueabihf- )
SET( CMAKE_C_COMPILER arm-linux-gnueabihf-gcc )
SET( CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++ )
SET( CMAKE_ASM_COMPILER arm-linux-gnueabihf-as )
SET( CROSS aarch64-linux-gnu- )
SET( CMAKE_C_COMPILER aarch64-linux-gnu-gcc )
SET( CMAKE_CXX_COMPILER aarch64-linux-gnu-g++ )
SET( CMAKE_ASM_COMPILER aarch64-linux-gnu-as )

execute_process(
COMMAND bash -c "dirname $(dirname $(whereis arm-linux-gnueabihf-gcc | cut -d':' -f2 | tr -d ' '))"
COMMAND bash -c "dirname $(dirname $(which aarch64-linux-gnu-gcc | cut -d':' -f2 | tr -d ' '))"
OUTPUT_VARIABLE ROOT_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

SET( CMAKE_FIND_ROOT_PATH ${ROOT_PATH} )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOT_PATH}/arm-linux-gnueabihf/lib/arm-linux-gnueabihf")
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOT_PATH}/aarch64-linux-gnu/lib/aarch64-linux-gnu")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

SET( FREETYPE_INCLUDE_DIRS "${CMAKE_FIND_ROOT_PATH}/include/freetype2" )
Expand Down
6 changes: 3 additions & 3 deletions controller_pc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set( LUA_32 "-m32" )
endif()
# add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_32} )
add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_HOST_CC_OPTIONS} )
# add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_HOST_CC_OPTIONS} )
add_custom_target( libopenh264_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_openh264.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} )

qt5_wrap_ui( controller_pc_UI
Expand Down Expand Up @@ -91,10 +91,10 @@ add_executable( controller_pc
)

add_dependencies( controller_pc libopenh264_static )
add_dependencies( controller_pc libluajit_static )
# add_dependencies( controller_pc libluajit_static )
add_dependencies( controller_pc controller )
add_dependencies( controller_pc libdebug )

target_link_libraries( controller_pc -L./ controller libdebug -lluajit_static -ldecoder_static -lopenh264_static ${SHINE_LIBRARIES} ${MP4V2_LIBRARIES} ${QSCINTILLA_LIBRARY} Qt5::Widgets Qt5::OpenGL Qt5::PrintSupport Qt5::Multimedia ${OPENGL_LIBRARIES} -lpthread ${OTHER_LIBS} )
# target_link_libraries( controller_pc -L./ controller libdebug -lluajit_static -ldecoder_static -lopenh264_static ${SHINE_LIBRARIES} ${MP4V2_LIBRARIES} ${QSCINTILLA_LIBRARY} Qt5::Widgets Qt5::OpenGL Qt5::PrintSupport Qt5::Multimedia ${OPENGL_LIBRARIES} -lpthread ${OTHER_LIBS} )

install( TARGETS controller_pc RUNTIME DESTINATION bin )
6 changes: 3 additions & 3 deletions controller_rc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/../external/LuaJIT-2.0.4/src )
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libcontroller libcontroller )
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libdebug libdebug )

add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip "-m32" )
# add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip "-m32" )
add_custom_target( ui_headers COMMAND
${UIC} ${CMAKE_SOURCE_DIR}/ui/main.ui > ${CMAKE_BINARY_DIR}/ui_main.h
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/window.ui > ${CMAKE_BINARY_DIR}/ui_window.h
Expand Down Expand Up @@ -91,10 +91,10 @@ add_executable( controller_rc
)

add_dependencies( controller_rc controller )
add_dependencies( controller_rc libluajit_static )
# add_dependencies( controller_rc libluajit_static )
add_dependencies( controller_rc ui_headers )


target_link_libraries( controller_rc -L./ controller libdebug libluajit_static.a -lrt -ldl ${RAWWIFI_LIBS} -lz pthread ${BOARD_LIBS} )
# target_link_libraries( controller_rc -L./ controller libdebug libluajit_static.a -lrt -ldl ${RAWWIFI_LIBS} -lz pthread ${BOARD_LIBS} )

install( TARGETS controller_rc RUNTIME DESTINATION bin )
4 changes: 2 additions & 2 deletions controller_rc/boards/rpi/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ execute_process( COMMAND uname -p OUTPUT_VARIABLE BUILD_ARCH )
set( TARGET_CPU_BITS 32 )

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_DEFAULT_SOURCE -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard -Wl,--unresolved-symbols=ignore-in-shared-libs -I/opt/vc/include/ -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -mfloat-abi=hard -Wl,--unresolved-symbols=ignore-in-shared-libs -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs -I/opt/vc/include/ -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_LINKER_FLAGS "${CMAKE_LD_FLAGS}")
include_directories( /opt/vc/include )
set( BOARD_LIBS -lpigpio -lrt -lpthread -ldl -lz -liw )
Expand Down
25 changes: 0 additions & 25 deletions external/build_luajit.sh

This file was deleted.

2 changes: 1 addition & 1 deletion flight/BlackBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void BlackBox::Enqueue( const char* data[], const char* values[], int n )

mQueueMutex.lock();
for ( int i = 0; i < n; i++ ) {
sprintf( str, "%llu,%s,%s", time, data[i], values[i] );
sprintf( str, "%" PRIu64 ",%s,%s", time, data[i], values[i] );
mQueue.emplace_back( string(str) );
}
mQueueMutex.unlock();
Expand Down
12 changes: 8 additions & 4 deletions flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ option(debug "debug")
option(socket "socket")
option(rawwifi "rawwifi")

add_compile_options(-Wall -Werror)
add_compile_options(-Wno-error=return-type)
add_compile_options(-Wno-error=deprecated-declarations)

include( config.cmake )
if ( ${BUILD_links} MATCHES 0 OR ${BUILD_links} MATCHES OFF )
file(GLOB children RELATIVE ${CMAKE_SOURCE_DIR}/links ${CMAKE_SOURCE_DIR}/links/*)
Expand Down Expand Up @@ -271,10 +275,10 @@ if ( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux" )
else()
set( LUA_HOST_CC_OPTIONS "" )
endif()
add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_HOST_CC_OPTIONS} "${CMAKE_C_FLAGS} -Wno-misleading-indentation" )
add_dependencies( flight_unstripped libluajit_static )
# add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_HOST_CC_OPTIONS} "${CMAKE_C_FLAGS} -Wno-misleading-indentation" )
# add_dependencies( flight_unstripped libluajit_static )
include_directories( ${CMAKE_SOURCE_DIR}/../external/LuaJIT-2.0.4/src )
set( LIBS ${LIBS} luajit_static )
# set( LIBS ${LIBS} luajit_static )
elseif( "${CMAKE_SYSTEM_NAME}" MATCHES "Generic" )
# add_definitions( -DLUA_32BITS )
# set( LUA_CFLAGS "${CMAKE_C_FLAGS} -DLUA_32BITS" )
Expand All @@ -289,7 +293,7 @@ endif()
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libluacore ${CMAKE_CURRENT_BINARY_DIR}/libluacore )
include_directories( ${CMAKE_SOURCE_DIR}/../libluacore/src )
add_definitions( -DLUA_CLASS= -DLUA_EXPORT= )
add_dependencies( luacore libluajit_static )
# add_dependencies( luacore libluajit_static )

add_dependencies( flight_unstripped libdebug )
# add_dependencies( flight_unstripped flight_register )
Expand Down
8 changes: 4 additions & 4 deletions flight/Config.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* BCFlight
* Copyright (C) 2016 Adrien Aubry (drich)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
Expand Down Expand Up @@ -90,7 +90,7 @@ string Config::ReadFile()
file.read( buf, length );
buf[length] = 0;
ret = buf;
delete buf;
delete [] buf;
file.close();
}

Expand Down
22 changes: 12 additions & 10 deletions flight/boards/rpi/board.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
execute_process( COMMAND uname -p OUTPUT_VARIABLE BUILD_ARCH )

if ( ${BUILD_ARCH} MATCHES "x86*" )
# message( "Cross compilation detected, setting compiler prefix to arm-linux-gnueabihf-" )
# set( CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc" )
# set( CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++" )
# set( CMAKE_AR "arm-linux-gnueabihf-ar" )
# message( "Cross compilation detected, setting compiler prefix to aarch64-linux-gnu-" )
# set( CMAKE_C_COMPILER "aarch64-linux-gnu-gcc" )
# set( CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++" )
# set( CMAKE_AR "aarch64-linux-gnu-ar" )
endif()

set( TARGET_LINUX 1 )
Expand All @@ -25,8 +25,8 @@ add_definitions( -DHAVE_PTHREAD_SETNAME_NP )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DEFAULT_SOURCE -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs -I/opt/vc/include/ -I/opt/vc/include/interface/vmcs_host -I/opt/vc/include/interface/vmcs_host/khronos -I/opt/vc/include/interface/vmcs_host/khronos -I/opt/vc/include/interface/khronos/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -mfloat-abi=hard -Wl,--unresolved-symbols=ignore-in-shared-libs -I/opt/vc/include/ -I/opt/vc/include/interface/vmcs_host -I/opt/vc/include/interface/vmcs_host/khronos -I/opt/vc/include/interface/vmcs_host/khronos -I/opt/vc/include/interface/khronos/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -mfloat-abi=hard -Wl,--unresolved-symbols=ignore-in-shared-libs -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs -I/opt/vc/include/ -I/opt/vc/include/interface/vmcs_host -I/opt/vc/include/interface/vmcs_host/khronos -I/opt/vc/include/interface/vmcs_host/khronos -I/opt/vc/include/interface/khronos/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs -L/opt/vc/lib/ -Wl,-rpath=/opt/vc/lib")
set(CMAKE_LINKER_FLAGS "${CMAKE_LD_FLAGS}")
set( BOARD_LIBS ${BOARD_LIBS} -lpigpio -lbcm_host -lvcos -lvchiq_arm -lrt -lpthread -ldl -lz -ldrm ) # -lpigpio
# set( BOARD_LIBS ${BOARD_LIBS} -lavformat -lavcodec -lavutil )
Expand All @@ -40,10 +40,12 @@ get_filename_component( CROSS_ROOT ${CMAKE_C_COMPILER} DIRECTORY )
include_directories( ${CROSS_ROOT}/../include )
include_directories( ${CROSS_ROOT}/../include/libdrm )
include_directories( ${CROSS_ROOT}/../include/libcamera )
include_directories( ${CROSS_ROOT}/../arm-linux-gnueabihf/include )
include_directories( ${CROSS_ROOT}/../arm-linux-gnueabihf/include/libdrm )
include_directories( ${CROSS_ROOT}/../arm-linux-gnueabihf/include/libcamera )
include_directories( ${CROSS_ROOT}/../aarch64-linux-gnu/include )
include_directories( ${CROSS_ROOT}/../aarch64-linux-gnu/include/libdrm )
include_directories( ${CROSS_ROOT}/../aarch64-linux-gnu/include/libcamera )
include_directories( /opt/vc/include )
find_package(Lua REQUIRED)
include_directories( ${LUA_INCLUDE_DIR} )

#if ( "${rawwifi}" MATCHES 1 )
set( BOARD_LIBS ${BOARD_LIBS} -liw -lcamera -lcamera-base -lgps )
Expand All @@ -62,7 +64,7 @@ endif()

function( board_strip )
add_custom_target( flight ALL
COMMAND arm-linux-gnueabihf-strip -s -o flight flight_unstripped
COMMAND aarch64-linux-gnu-strip -s -o flight flight_unstripped
DEPENDS flight_unstripped
COMMENT "Stripping executable"
VERBATIM
Expand Down
Loading