From 78e2a293d2a5c4e0e44794a3cf3a87699c607ee9 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 23 Mar 2017 17:19:26 -1000 Subject: [PATCH] Fix UAVCAN bootloader builds broken by os calls from stm32_flash Recent upsteam NuttX changes needed by PX4 added sem_[wait|post] in the stm32_flash driver. UAVCAN Bootloaders do not use the OS's scheduler etal. This commit nops the sem_[wait|post] with linker magic. Which precludes the linking the nuttx scheduler in the bootloader build. --- .../bootloaders/src/common/nuttx_stubs.c | 89 +++++++++++++++++++ src/firmware/nuttx/CMakeLists.txt | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/drivers/bootloaders/src/common/nuttx_stubs.c diff --git a/src/drivers/bootloaders/src/common/nuttx_stubs.c b/src/drivers/bootloaders/src/common/nuttx_stubs.c new file mode 100644 index 0000000000..8f5a36a2fc --- /dev/null +++ b/src/drivers/bootloaders/src/common/nuttx_stubs.c @@ -0,0 +1,89 @@ +/**************************************************************************** + * + * Copyright (c) 2017 PX4 Development Team. All rights reserved. + * Author: David Sidrane + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ +__EXPORT int __wrap_sem_wait(void *sem); +__EXPORT int __wrap_sem_post(void *sem); + +/**************************************************************************** + * Name: sem_wait and sem_post + * + * Description: + * These functions hijacks by the way of a compile time wrapper the systems + * sem_wait and sem_post functions. + * + ****************************************************************************/ + +int __wrap_sem_wait(void *sem) +{ + return 0; +} + +int __wrap_sem_post(void *sem) +{ + return 0; +} diff --git a/src/firmware/nuttx/CMakeLists.txt b/src/firmware/nuttx/CMakeLists.txt index 420d200fe9..c71ff12b90 100644 --- a/src/firmware/nuttx/CMakeLists.txt +++ b/src/firmware/nuttx/CMakeLists.txt @@ -29,7 +29,7 @@ set(startup_libs) if("${config_nuttx_config}" STREQUAL "bootloader") set(nuttx_ld_prefix "bootloader") set(nuttx_startup_files ${nuttx_export_dir}/startup/${nuttx_startup_files}) - set(nuttx_bootloader_wrapers "-Wl,-wrap,sched_process_timer") + set(nuttx_bootloader_wrapers "-Wl,-wrap,sched_process_timer -Wl,-wrap,sem_post -Wl,-wrap,sem_wait") add_custom_command(OUTPUT ${nuttx_startup_files}