NuttX: fixes for NuttX build

In the upstream tree ringbuffer.h includes the method implementations
in the header file which causes multiple definitions in the link for
other targets. Changed so ringbuffer.cpp is build separately for other
platforms and is included by ringbuffer.h on NuttX.

uORB changes do not link without uORBTest_UnitTest.cpp enabled for
the NuttX build.

px4_getopt was not exported and wasn't visible in NuttX build.

The makefiles were restored to be as close as possible to upstream
so the NuttX build builtin's work again. The code will have to be
refactored after the merge.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-15 12:56:18 -07:00
parent a3a0d0612c
commit 9f391b1867
12 changed files with 340 additions and 37 deletions
+2 -3
View File
@@ -41,8 +41,7 @@ SRCS = \
cdev.cpp \
i2c_nuttx.cpp \
pio.cpp \
spi.cpp \
ringbuffer.cpp
spi.cpp
else
SRCS = \
device_posix.cpp \
@@ -51,5 +50,5 @@ SRCS = \
vdev_posix.cpp \
i2c_posix.cpp \
sim.cpp \
ringbuffer.cpp
ringbuffer.cpp
endif
+1 -1
View File
@@ -237,7 +237,7 @@ RingBuffer::force(double val)
// FIXME - clang crashes on this get() call
#ifdef __PX4_QURT
#define __PX4_SBCAP my_sync_bool_compare_and_swap
static bool my_sync_bool_compare_and_swap(volatile unsigned *a, unsigned b, unsigned c)
static inline bool my_sync_bool_compare_and_swap(volatile unsigned *a, unsigned b, unsigned c)
{
if (*a == b) {
*a = c;
+6
View File
@@ -172,3 +172,9 @@ private:
RingBuffer operator=(const RingBuffer&);
};
#ifdef __PX4_NUTTX
// Not sure why NuttX requires these to be defined in the header file
// but on other targets it causes a problem with multiple definitions
// at link time
#include "ringbuffer.cpp"
#endif
@@ -51,6 +51,8 @@ PublisherExample::PublisherExample() :
{
}
px4::AppState PublisherExample::appState;
int PublisherExample::main()
{
px4::Rate loop_rate(10);
@@ -361,7 +361,7 @@ main_state_transition(struct vehicle_status_s *status, main_state_t new_main_sta
return ret;
}
#ifdef PX4_NUTTX
#ifdef __PX4_NUTTX
static transition_result_t disable_publication(const int mavlink_fd)
{
transition_result_t ret;
+1
View File
@@ -41,6 +41,7 @@ MODULE_STACKSIZE = 2048
ifeq ($(PX4_TARGET_OS),nuttx)
SRCS = uORBDevices_nuttx.cpp \
uORBTest_UnitTest.cpp \
uORBManager_nuttx.cpp
else
+1
View File
@@ -35,6 +35,7 @@
#include "uORBCommon.hpp"
#include <px4_config.h>
#include <px4_time.h>
#include <stdio.h>
uORBTest::UnitTest &uORBTest::UnitTest::instance()
{
+1 -2
View File
@@ -121,7 +121,7 @@ static int reorder(int argc, char **argv, const char *options)
// Argv is changed to put all options and option args at the beginning,
// followed by non-options.
//
int px4_getopt(int argc, char *argv[], const char *options, int *myoptind, const char **myoptarg)
__EXPORT int px4_getopt(int argc, char *argv[], const char *options, int *myoptind, const char **myoptarg)
{
char *p;
char c;
@@ -149,4 +149,3 @@ int px4_getopt(int argc, char *argv[], const char *options, int *myoptind, const
}
return -1;
}
@@ -72,21 +72,6 @@ px4_systemreset(bool to_bootloader)
while(true);
}
static void kill_task(FAR struct tcb_s *tcb, FAR void *arg);
void px4_killall()
{
// printf("Sending SIGUSR1 to all processes now\n");
/* iterate through all tasks and send kill signal */
sched_foreach(kill_task, NULL);
}
static void kill_task(FAR struct tcb_s *tcb, FAR void *arg)
{
kill(tcb->pid, SIGUSR1);
}
int px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, main_t entry, char * const argv[])
{
int pid;