Skip to content

Commit

Permalink
PX4 System changes Supporting STM32H7
Browse files Browse the repository at this point in the history
stm32:ToneAlarmInterfacePWM TIM15-TIM17 have a BDTR Register

common:board_crashdump Add H7 support

stm32/board_mcu_version:Support H7

PX4 ADC:Use 32 interface and resoution abstraction

Added PX4 stm32h7 ADC driver

stm32h7:adc fix ADC ready check

fmu: handle BOARD_HAS_PWM==5

cmake: improve error handling for NuttX olddefconfig failures

WorkQueueManager:Quiet loadmon stack warning

camera_trigger:GPIO support < 6 GPIO

Adjust stack sizes (under hw stack check)

PX4 System changes Supporting STM32H7 PX4IO Driver

aerotenna_ocpoc:ADC add px4_arch_adc_dn_fullcount

init.cmake:Track Upstream change needing Make.def at config time

PX4 System changes Supporting STM32H7

NuttX CMakeLists.txt Track upstream changes

Common board_crashdump add header and px4 config

NuttX simplify callinb make libapps

Use UINT32_MAX for error return

drivers:uavcannode NuttX chip is now hardware

drivers:uavcanesc NuttX chip is now hardware

px4io:Avoid Race on AP to PX4 IO upgrade
  • Loading branch information
davids5 authored and LorenzMeier committed Nov 16, 2019
1 parent 58799dc commit e847698
Show file tree
Hide file tree
Showing 32 changed files with 1,559 additions and 98 deletions.
5 changes: 5 additions & 0 deletions boards/aerotenna/ocpoc/ocpoc_adc/ocpoc_adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,8 @@ int ocpoc_adc_main(int argc, char *argv[])
return PX4_OK;

}
// This is a replacement for the hardcoded 4096
uint32_t px4_arch_adc_dn_fullcount(void)
{
return 1 << 12; // 12 bit ADC
}
2 changes: 2 additions & 0 deletions platforms/common/include/px4_platform_common/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ typedef enum PX4_SOC_ARCH_ID_t {
PX4_SOC_ARCH_ID_KINETISK66 = 0x0003,
PX4_SOC_ARCH_ID_SAMV7 = 0x0004,

PX4_SOC_ARCH_ID_STM32H7 = 0x0006,

PX4_SOC_ARCH_ID_EAGLE = 0x1001,
PX4_SOC_ARCH_ID_QURT = 0x1002,
PX4_SOC_ARCH_ID_OCPOC = 0x1003,
Expand Down
2 changes: 1 addition & 1 deletion platforms/nuttx/NuttX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ add_custom_target(nuttx_builtin_list_target
# libapps.a
add_custom_command(OUTPUT ${APPS_DIR}/libapps.a ${APPS_DIR}/platform/.built
COMMAND find ${APPS_DIR} -name \*.o -delete
COMMAND make ${nuttx_build_options} --no-print-directory -C ../apps TOPDIR="${NUTTX_DIR}" libapps.a > nuttx_apps.log
COMMAND make ${nuttx_build_options} --no-print-directory TOPDIR="${NUTTX_DIR}" ../apps/libapps.a > nuttx_apps.log
DEPENDS
nuttx_builtin_list_target ${nuttx_builtin_list}
nuttx_context
Expand Down
15 changes: 15 additions & 0 deletions platforms/nuttx/cmake/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ execute_process(COMMAND ${cp_cmd} ${cp_opts} ${CP_SRC} ${CP_DST} WORKING_DIRECTO

set(NUTTX_DEFCONFIG ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig CACHE FILEPATH "path to defconfig" FORCE)

###############################################################################
# Create a temporary Toplevel Make.defs for the oldconfig step
###############################################################################
configure_file(${NUTTX_SRC_DIR}/Make.defs.in ${NUTTX_DIR}/Make.defs)

# If the board provides a Kconfig Use it or create an empty one
if(EXISTS ${NUTTX_CONFIG_DIR}/Kconfig)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NUTTX_CONFIG_DIR}/Kconfig ${NUTTX_DIR}/boards/dummy/Kconfig)
Expand Down Expand Up @@ -120,7 +125,17 @@ if (NOT config_expanded)
WORKING_DIRECTORY ${NUTTX_DIR}
OUTPUT_FILE nuttx_olddefconfig.log
ERROR_FILE nuttx_olddefconfig.log
RESULT_VARIABLE ret
)
if(NOT ret EQUAL "0")
# Show the log here as it will be deleted due to the incomplete configure step
file(READ ${NUTTX_DIR}/nuttx_olddefconfig.log DEFCONFIG_LOG)
message( STATUS "${DEFCONFIG_LOG}")
message( FATAL_ERROR "NuttX olddefconfig target failed. \
Possible cause: the board (${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}) has the wrong directory structure (i.e. missing files).")
endif()
# remove Toplevel Make.defs
file(REMOVE ${NUTTX_DIR}/Make.defs)
endif()

###############################################################################
Expand Down
3 changes: 3 additions & 0 deletions platforms/nuttx/cmake/px4_impl_os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ function(px4_os_determine_build_chip)
elseif(CONFIG_ARCH_CHIP_STM32F7)
set(CHIP_MANUFACTURER "stm")
set(CHIP "stm32f7")
elseif(CONFIG_ARCH_CHIP_STM32H7)
set(CHIP_MANUFACTURER "stm")
set(CHIP "stm32h7")
elseif(CONFIG_ARCH_CHIP_MK66FN2M0VMD18)
set(CHIP_MANUFACTURER "nxp")
set(CHIP "k66")
Expand Down
44 changes: 44 additions & 0 deletions platforms/nuttx/src/px4/common/board_crashdump.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
/****************************************************************************
*
* Copyright (C) 2017-2019 PX4 Development Team. All rights reserved.
*
* 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.
*
****************************************************************************/

/**
* @file board_crashdump.c
*
* Provides common board logic for crashdump callout
* and hardfault log support
*/

#ifdef CONFIG_BOARD_CRASHDUMP

#include <board_config.h>
Expand All @@ -18,6 +58,10 @@
# define HAS_BBSRAM CONFIG_STM32F7_BBSRAM
# define BBSRAM_FILE_COUNT CONFIG_STM32F7_BBSRAM_FILES
# define SAVE_CRASHDUMP CONFIG_STM32F7_SAVE_CRASHDUMP
#elif defined(CONFIG_STM32H7_BBSRAM) && defined(CONFIG_STM32H7_SAVE_CRASHDUMP)
# define HAS_BBSRAM CONFIG_STM32H7_BBSRAM
# define BBSRAM_FILE_COUNT CONFIG_STM32H7_BBSRAM_FILES
# define SAVE_CRASHDUMP CONFIG_STM32H7_SAVE_CRASHDUMP
#elif defined(CONFIG_STM32_BBSRAM) && defined(CONFIG_STM32_SAVE_CRASHDUMP)
# define HAS_BBSRAM CONFIG_STM32_BBSRAM
# define BBSRAM_FILE_COUNT CONFIG_STM32_BBSRAM_FILES
Expand Down
11 changes: 8 additions & 3 deletions platforms/nuttx/src/px4/stm/stm32_common/adc/adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
****************************************************************************/

#include <board_config.h>
#include <stdint.h>
#include <drivers/drv_adc.h>
#include <drivers/drv_hrt.h>
#include <px4_arch/adc.h>
Expand Down Expand Up @@ -190,7 +191,7 @@ void px4_arch_adc_uninit(uint32_t base_address)
// nothing to do
}

uint16_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
{
irqstate_t flags = px4_enter_critical_section();

Expand All @@ -211,12 +212,12 @@ uint16_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
/* don't wait for more than 50us, since that means something broke - should reset here if we see this */
if ((hrt_absolute_time() - now) > 50) {
px4_leave_critical_section(flags);
return 0xffff;
return UINT32_MAX;
}
}

/* read the result and clear EOC */
uint16_t result = rDR(base_address);
uint32_t result = rDR(base_address);

px4_leave_critical_section(flags);

Expand All @@ -228,3 +229,7 @@ uint32_t px4_arch_adc_temp_sensor_mask()
return 1 << 16;
}

uint32_t px4_arch_adc_dn_fullcount(void)
{
return 1 << 12; // 12 bit ADC
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,32 @@
# if defined(CONFIG_STM32_TIM14)
# error Must not set CONFIG_STM32_TIM14 when TONE_ALARM_TIMER is 14
# endif
#elif TONE_ALARM_TIMER == 15
# define TONE_ALARM_BASE STM32_TIM15_BASE
# define TONE_ALARM_CLOCK STM32_APB2_TIM15_CLKIN
# define TONE_ALARM_CLOCK_ENABLE RCC_APB2ENR_TIM15EN
# define TONE_ALARM_CLOCK_POWER_REG STM32_RCC_APB2ENR
# if defined(CONFIG_STM32_TIM15)
# error Must not set CONFIG_STM32_TIM15 when TONE_ALARM_TIMER is 15
# endif
#elif TONE_ALARM_TIMER == 16
# define TONE_ALARM_BASE STM32_TIM16_BASE
# define TONE_ALARM_CLOCK STM32_APB2_TIM16_CLKIN
# define TONE_ALARM_CLOCK_ENABLE RCC_APB2ENR_TIM16EN
# define TONE_ALARM_CLOCK_POWER_REG STM32_RCC_APB2ENR
# if defined(CONFIG_STM32_TIM16)
# error Must not set CONFIG_STM32_TIM16 when TONE_ALARM_TIMER is 16
# endif
#elif TONE_ALARM_TIMER == 17
# define TONE_ALARM_BASE STM32_TIM17_BASE
# define TONE_ALARM_CLOCK STM32_APB2_TIM17_CLKIN
# define TONE_ALARM_CLOCK_ENABLE RCC_APB2ENR_TIM17EN
# define TONE_ALARM_CLOCK_POWER_REG STM32_RCC_APB2ENR
# if defined(CONFIG_STM32_TIM17)
# error Must not set CONFIG_STM32_TIM16 when TONE_ALARM_TIMER is 17
# endif
#else
# error Must set TONE_ALARM_TIMER to one of the timers between 1 and 14 (inclusive) to use this driver.
# error Must set TONE_ALARM_TIMER to one of the timers between 1 and 17 (inclusive) to use this driver.
#endif // TONE_ALARM_TIMER

#if TONE_ALARM_CHANNEL == 1
Expand Down Expand Up @@ -199,6 +223,9 @@
# define rSR REG(STM32_ATIM_SR_OFFSET)
#else
# define rARR REG(STM32_GTIM_ARR_OFFSET)
#if TONE_ALARM_TIMER >= 15 && TONE_ALARM_TIMER <= 17 // Note: If using TIM15 - TIM17 it has a BDTR
# define rBDTR REG(STM32_ATIM_BDTR_OFFSET)
#endif
# define rCCER REG(STM32_GTIM_CCER_OFFSET)
# define rCCMR1 REG(STM32_GTIM_CCMR1_OFFSET)
# define rCCMR2 REG(STM32_GTIM_CCMR2_OFFSET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ enum MCU_REV {
MCU_REV_STM32F4_REV_Z = 0x1001,
MCU_REV_STM32F4_REV_Y = 0x1003,
MCU_REV_STM32F4_REV_1 = 0x1007,
MCU_REV_STM32F4_REV_3 = 0x2001
MCU_REV_STM32F4_REV_3 = 0x2001,
MCU_REV_STM32F7_REV_X = MCU_REV_STM32F4_REV_3,
MCU_REV_STM32F7_REV_V = 0x2003
};

/* Define any issues with the Silicon as lines separated by \n
Expand All @@ -60,6 +62,7 @@ enum MCU_REV {
# define REVID_MASK 0xFFFF0000
# define DEVID_MASK 0xFFF

# define STM32H74xx_75xx 0x450
# define STM32F74xxx_75xxx 0x449
# define STM32F76xxx_77xxx 0x451
# define STM32F40x_41x 0x413
Expand All @@ -81,6 +84,10 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata)

switch (chip_version) {

case STM32H74xx_75xx:
*revstr = "STM32H74xxx";
break;

case STM32F74xxx_75xxx:
*revstr = "STM32F74xxx";
break;
Expand Down Expand Up @@ -139,7 +146,12 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata)
break;

case MCU_REV_STM32F4_REV_3:
*rev = '3';
*rev = chip_version == STM32H74xx_75xx ? 'X' : '3' ;
chip_errata = NULL;
break;

case MCU_REV_STM32F7_REV_V:
*rev = 'V';
chip_errata = NULL;
break;

Expand Down
46 changes: 46 additions & 0 deletions platforms/nuttx/src/px4/stm/stm32h7/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
############################################################################
#
# Copyright (c) 2019 PX4 Development Team. All rights reserved.
#
# 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.
#
############################################################################


add_subdirectory(adc)
add_subdirectory(../stm32_common/board_critmon board_critmon)
add_subdirectory(../stm32_common/board_hw_info board_hw_info)
add_subdirectory(../stm32_common/board_reset board_reset)
add_subdirectory(../stm32_common/dshot dshot)
add_subdirectory(../stm32_common/hrt hrt)
add_subdirectory(../stm32_common/io_pins io_pins)
add_subdirectory(../stm32_common/tone_alarm tone_alarm)
add_subdirectory(../stm32_common/version version)

add_subdirectory(px4io_serial)

36 changes: 36 additions & 0 deletions platforms/nuttx/src/px4/stm/stm32h7/adc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
############################################################################
#
# Copyright (c) 2015-2019 PX4 Development Team. All rights reserved.
#
# 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.
#
############################################################################

px4_add_library(arch_adc
adc.cpp
)
Loading

0 comments on commit e847698

Please sign in to comment.