Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Commit

Permalink
Fix RPi2 build system
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkabir authored and LorenzMeier committed May 19, 2016
1 parent 02ba331 commit 529460d
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 26 deletions.
24 changes: 24 additions & 0 deletions Tools/scp_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

if [[ "$#" < 2 ]]; then
echo "usage: scp_upload.sh SRC1 [SRC2 ...] DEST"
exit
fi

echo "Uploading..."

# Get last argument
for last; do true; done

# Go through source files and push them one by one.
i=0
for arg
do
if [[ $((i+1)) == "$#" ]]; then
break
fi
# echo "Pushing $arg to $last"
#adb push $arg $last
scp $arg pi@px4autopilot:$last
((i+=1))
done
18 changes: 18 additions & 0 deletions cmake/common/px4_base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,24 @@ function(px4_add_adb_push)
)
endfunction()

function(px4_add_scp_push)
px4_parse_function_args(
NAME px4_add_upload
ONE_VALUE OS BOARD OUT DEST
MULTI_VALUE FILES DEPENDS
REQUIRED OS BOARD OUT FILES DEPENDS DEST
ARGN ${ARGN})

add_custom_target(${OUT}
COMMAND ${CMAKE_SOURCE_DIR}/Tools/scp_upload.sh ${FILES} ${DEST}
DEPENDS ${DEPENDS}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "uploading ${BUNDLE}"
VERBATIM
USES_TERMINAL
)
endfunction()


#=============================================================================
#
Expand Down
98 changes: 74 additions & 24 deletions cmake/configs/posix_rpi2_release.cmake
Original file line number Diff line number Diff line change
@@ -1,59 +1,109 @@
include(posix/px4_impl_posix)

if ("${RPI_TOOLCHAIN_DIR}" STREQUAL "")
set(RPI_TOOLCHAIN_DIR /opt/rpi_toolchain)
endif()
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake)

set(CMAKE_PROGRAM_PATH
"${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin"
${CMAKE_PROGRAM_PATH}
)

set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake)
# This definition allows to differentiate if this just the usual POSIX build
# or if it is for the RPi.
add_definitions(
-D__PX4_POSIX_RPI2
)

set(config_module_list
#
# Board support modules
#
drivers/device
platforms/common
platforms/posix/px4_layer
platforms/posix/work_queue
modules/sensors
platforms/posix/drivers/df_mpu9250_wrapper
platforms/posix/drivers/df_bmp280_wrapper
platforms/posix/drivers/df_hmc5883_wrapper
platforms/posix/drivers/df_trone_wrapper
platforms/posix/drivers/df_isl29501_wrapper

#
# System commands
#
systemcmds/param
systemcmds/mixer
systemcmds/ver
systemcmds/esc_calib
systemcmds/reboot
systemcmds/topic_listener
systemcmds/perf
modules/uORB
modules/param
modules/systemlib
modules/systemlib/mixer
modules/sensors
modules/mavlink

#
# Estimation modules (EKF/ SO3 / other filters)
#
#modules/attitude_estimator_ekf
modules/ekf_att_pos_estimator
modules/attitude_estimator_q
modules/position_estimator_inav
modules/navigator
modules/vtol_att_control
modules/mc_pos_control
modules/local_position_estimator
modules/ekf2

#
# Vehicle Control
#
modules/mc_att_control
modules/land_detector
modules/mc_pos_control
modules/fw_att_control
modules/fw_pos_control_l1
modules/dataman
modules/fw_pos_control_l1
modules/vtol_att_control

#
# Library modules
#
modules/sdlog2
modules/logger
modules/commander
modules/load_mon
modules/param
modules/systemlib
modules/systemlib/mixer
modules/uORB
modules/dataman
modules/land_detector
modules/navigator
modules/mavlink

#
# PX4 drivers
#

#
# Libraries
#
lib/controllib
lib/mathlib
lib/mathlib/math/filter
lib/conversion
lib/ecl
lib/external_lgpl
lib/geo
lib/ecl
lib/geo_lookup
lib/launchdetection
lib/external_lgpl
lib/conversion
lib/terrain_estimation
lib/runway_takeoff
lib/tailsitter_recovery
lib/DriverFramework/framework
)

#
# POSIX
#
platforms/common
platforms/posix/px4_layer
platforms/posix/work_queue

)

set(config_df_driver_list
mpu9250
bmp280
hmc5883
trone
isl29501
)
86 changes: 86 additions & 0 deletions cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# defines:
#
# NM
# OBJCOPY
# LD
# CXX_COMPILER
# C_COMPILER
# CMAKE_SYSTEM_NAME
# CMAKE_SYSTEM_VERSION
# GENROMFS
# LINKER_FLAGS
# CMAKE_EXE_LINKER_FLAGS
# CMAKE_FIND_ROOT_PATH
# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE

include(CMakeForceCompiler)

if ("$ENV{RPI_TOOLCHAIN_DIR}" STREQUAL "")
message(FATAL_ERROR "RPI_TOOLCHAIN_DIR not set")
else()
set(RPI_TOOLCHAIN_DIR $ENV{RPI_TOOLCHAIN_DIR})
endif()

# this one is important
set(CMAKE_SYSTEM_NAME Generic)

#this one not so much
set(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
find_program(C_COMPILER arm-linux-gnueabihf-gcc
PATHS ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
NO_DEFAULT_PATH
)

if(NOT C_COMPILER)
message(FATAL_ERROR "could not find arm-linux-gnueabihf-gcc compiler")
endif()
cmake_force_c_compiler(${C_COMPILER} GNU)

find_program(CXX_COMPILER arm-linux-gnueabihf-g++
PATHS ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
NO_DEFAULT_PATH
)

if(NOT CXX_COMPILER)
message(FATAL_ERROR "could not find arm-linux-gnueabihf-g++ compiler")
endif()
cmake_force_cxx_compiler(${CXX_COMPILER} GNU)

# compiler tools
foreach(tool objcopy nm ld)
string(TOUPPER ${tool} TOOL)
find_program(${TOOL} arm-linux-gnueabihf-${tool}
PATHS ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
NO_DEFAULT_PATH
)
if(NOT ${TOOL})
message(FATAL_ERROR "could not find arm-linux-gnueabihf-${tool}")
endif()
endforeach()

# os tools
foreach(tool echo patch grep rm mkdir nm genromfs cp touch make unzip)
string(TOUPPER ${tool} TOOL)
find_program(${TOOL} ${tool})
if(NOT ${TOOL})
message(FATAL_ERROR "could not find ${TOOL}")
endif()
endforeach()

set(LINKER_FLAGS "-Wl,-gc-sections")
set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS})
set(CMAKE_C_FLAGS ${C_FLAGS})
set(CMAKE_CXX_LINKER_FLAGS ${C_FLAGS})

# where is the target environment
set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH))

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Empty file removed posix-configs/rpi2/init/rcS_navio
Empty file.
17 changes: 17 additions & 0 deletions posix-configs/rpi2/mainapp.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uorb start
param set SYS_AUTOSTART 4001
sleep 1
param set MAV_TYPE 2
df_mpu9250_wrapper start
df_hmc5883_wrapper start
sensors start
commander start
ekf2 start
land_detector start multicopter
mc_pos_control start
mc_att_control start
mavlink start -u 14556 -r 1000000
sleep 1
mavlink stream -u 14556 -s HIGHRES_IMU -r 50
mavlink stream -u 14556 -s ATTITUDE -r 50
mavlink boot_complete
24 changes: 24 additions & 0 deletions src/firmware/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
${CMAKE_SOURCE_DIR}/posix-configs/eagle/flight/mainapp.config
DEPENDS mainapp
DEST /home/linaro)

elseif ("${BOARD}" STREQUAL "rpi2")

add_executable(mainapp
${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp
apps.h
)

target_link_libraries(mainapp
-Wl,--start-group
${module_libraries}
df_driver_framework
${df_driver_libs}
pthread m rt
-Wl,--end-group
)

px4_add_scp_push(OUT upload
OS ${OS}
BOARD ${BOARD}
FILES ${CMAKE_CURRENT_BINARY_DIR}/mainapp
${CMAKE_SOURCE_DIR}/posix-configs/rpi2/mainapp.config
DEPENDS mainapp
DEST /home/pi)

else()
add_executable(mainapp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ int DfBmp280Wrapper::_publish(struct baro_sensor_data &data)
const double R = 287.05; /* ideal gas constant in J/kg/K */

/* current pressure at MSL in kPa */
double p1 = MSL_PRESSURE / 1000.0;
double p1 = MSL_PRESSURE / 1000.0f;

/* measured pressure in kPa */
double p = data.pressure_pa / 1000.0;
double p = data.pressure_pa / 1000.0f;

/*
* Solve:
Expand Down

0 comments on commit 529460d

Please sign in to comment.