Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org> Run tools/nxsthyle against all files and eliminate as many complaints as is reasonable. Run tools/rmcr to eliminate all dangling garbage at the end of lines. Run tools/detab to eliminate all TAB characters from the files. Author: Bill Gatliff <bgat@billgatliff.com> configs/omnibusf4: Initial support for the OmnibusF4 family of flight management units. "OmnibusF4" is not a product name per se, but rather a design spec that many product vendors adhere to. The spec defines the major components, and how those components are wired into the microcontroller. Airbot is one such vendor, and they publish a schematic here: http://bit.ly/obf4pro Other software that supports the OmnibusF4 family include Betaflight, iNAV, and many others. PX4 recently added support as well, using their own, non-upstreamed, bespoke port of NuttX. No code from those resources is included in this port.
This commit is contained in:
parent
aefacb05ca
commit
c17c05f8a4
@ -1360,6 +1360,13 @@ config ARCH_BOARD_STM32F334_DISCO
|
||||
---help---
|
||||
STMicro STM32F334-Discovery board based on the STMicro STM32F334C8T6 MCU.
|
||||
|
||||
config ARCH_BOARD_OMNIBUSF4
|
||||
bool "OMNIBUSF4 flight controller"
|
||||
depends on ARCH_CHIP_STM32F405RG
|
||||
select ARCH_HAVE_LEDS
|
||||
---help---
|
||||
Flight controllers compatible with the OMINBUSF4 Betaflight target
|
||||
|
||||
config ARCH_BOARD_STM32F4_DISCOVERY
|
||||
bool "STMicro STM32F4-Discovery board"
|
||||
depends on ARCH_CHIP_STM32F407VG
|
||||
@ -1866,6 +1873,7 @@ config ARCH_BOARD
|
||||
default "olimex-stm32-p407" if ARCH_BOARD_OLIMEX_STM32P407
|
||||
default "olimex-strp711" if ARCH_BOARD_OLIMEX_STRP711
|
||||
default "olimexino-stm32" if ARCH_BOARD_OLIMEXINO_STM32
|
||||
default "omnibusf4" if ARCH_BOARD_OMNIBUSF4
|
||||
default "open1788" if ARCH_BOARD_OPEN1788
|
||||
default "or1k" if ARCH_BOARD_OR1K
|
||||
default "p112" if ARCH_BOARD_P112
|
||||
@ -2255,6 +2263,9 @@ endif
|
||||
if ARCH_BOARD_OLIMEXINO_STM32
|
||||
source "configs/olimexino-stm32/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_OMNIBUSF4
|
||||
source "configs/omnibusf4/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_OPEN1788
|
||||
source "configs/open1788/Kconfig"
|
||||
endif
|
||||
|
@ -529,6 +529,9 @@ configs/olimex-strp711
|
||||
further information. STATUS: Configurations for the basic OS test and NSH
|
||||
are complete and verified.
|
||||
|
||||
configs/omnibusf4
|
||||
Flight controllers compatible with the OMINBUSF4 Betaflight target
|
||||
|
||||
configs/or1k
|
||||
Generic OpenRISC board.
|
||||
|
||||
|
30
configs/omnibusf4/Kconfig
Normal file
30
configs/omnibusf4/Kconfig
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_BOARD_OMNIBUSF4
|
||||
|
||||
config STM32_ROMFS
|
||||
bool "Automount baked-in ROMFS image"
|
||||
default n
|
||||
depends on FS_ROMFS
|
||||
---help---
|
||||
Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT
|
||||
|
||||
config STM32_ROMFS_DEV_MINOR
|
||||
int "Minor for the block device backing the data"
|
||||
depends on STM32_ROMFS
|
||||
default 64
|
||||
|
||||
config STM32_ROMFS_MOUNTPOINT
|
||||
string "Mountpoint of the custom romfs image"
|
||||
depends on STM32_ROMFS
|
||||
default "/rom"
|
||||
|
||||
config STM32_ROMFS_IMAGEFILE
|
||||
string "ROMFS image file to include into build"
|
||||
depends on STM32_ROMFS
|
||||
default "../../../rom.img"
|
||||
|
||||
endif
|
268
configs/omnibusf4/include/board.h
Normal file
268
configs/omnibusf4/include/board.h
Normal file
@ -0,0 +1,268 @@
|
||||
/************************************************************************************
|
||||
* configs/omnibusf4/include/board.h
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All Rights reserved.
|
||||
* Copyright (C) 2012, 2014-2016, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __CONFIG_OMNIBUSF4_INCLUDE_BOARD_H
|
||||
#define __CONFIG_OMNIBUSF4_INCLUDE_BOARD_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Clocking *************************************************************************/
|
||||
|
||||
/* The OMNIBUSF4 board uses a single 8MHz crystal.
|
||||
*
|
||||
* This is the canonical configuration:
|
||||
* System Clock source : PLL (HSE)
|
||||
* SYSCLK(Hz) : 168000000 Determined by PLL configuration
|
||||
* HCLK(Hz) : 168000000 (STM32_RCC_CFGR_HPRE)
|
||||
* AHB Prescaler : 1 (STM32_RCC_CFGR_HPRE)
|
||||
* APB1 Prescaler : 4 (STM32_RCC_CFGR_PPRE1)
|
||||
* APB2 Prescaler : 2 (STM32_RCC_CFGR_PPRE2)
|
||||
* HSE Frequency(Hz) : 8000000 (STM32_BOARD_XTAL)
|
||||
* PLLM : 8 (STM32_PLLCFG_PLLM)
|
||||
* PLLN : 336 (STM32_PLLCFG_PLLN)
|
||||
* PLLP : 2 (STM32_PLLCFG_PLLP)
|
||||
* PLLQ : 7 (STM32_PLLCFG_PLLQ)
|
||||
* Main regulator output voltage : Scale1 mode Needed for high speed SYSCLK
|
||||
* Flash Latency(WS) : 5
|
||||
* Prefetch Buffer : OFF
|
||||
* Instruction cache : ON
|
||||
* Data cache : ON
|
||||
* Require 48MHz for USB OTG FS, : Enabled
|
||||
* SDIO and RNG clock
|
||||
*/
|
||||
|
||||
/* HSI - 16 MHz RC factory-trimmed
|
||||
* LSI - 32 KHz RC
|
||||
* HSE - On-board crystal frequency is 8MHz
|
||||
* LSE - 32.768 kHz
|
||||
*/
|
||||
|
||||
#define STM32_BOARD_XTAL 8000000ul
|
||||
|
||||
#define STM32_HSI_FREQUENCY 16000000ul
|
||||
#define STM32_LSI_FREQUENCY 32000
|
||||
#define STM32_HSE_FREQUENCY STM32_BOARD_XTAL
|
||||
#define STM32_LSE_FREQUENCY 32768
|
||||
|
||||
/* Main PLL Configuration.
|
||||
*
|
||||
* PLL source is HSE
|
||||
* PLL_VCO = (STM32_HSE_FREQUENCY / PLLM) * PLLN
|
||||
* = (8,000,000 / 8) * 336
|
||||
* = 336,000,000
|
||||
* SYSCLK = PLL_VCO / PLLP
|
||||
* = 336,000,000 / 2 = 168,000,000
|
||||
* USB OTG FS, SDIO and RNG Clock
|
||||
* = PLL_VCO / PLLQ
|
||||
* = 48,000,000
|
||||
*/
|
||||
|
||||
#define STM32_PLLCFG_PLLM RCC_PLLCFG_PLLM(8)
|
||||
#define STM32_PLLCFG_PLLN RCC_PLLCFG_PLLN(336)
|
||||
#define STM32_PLLCFG_PLLP RCC_PLLCFG_PLLP_2
|
||||
#define STM32_PLLCFG_PLLQ RCC_PLLCFG_PLLQ(7)
|
||||
|
||||
#define STM32_SYSCLK_FREQUENCY 168000000ul
|
||||
|
||||
/* AHB clock (HCLK) is SYSCLK (168MHz) */
|
||||
|
||||
#define STM32_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */
|
||||
#define STM32_HCLK_FREQUENCY STM32_SYSCLK_FREQUENCY
|
||||
#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */
|
||||
|
||||
/* APB1 clock (PCLK1) is HCLK/4 (42MHz) */
|
||||
|
||||
#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLKd4 /* PCLK1 = HCLK / 4 */
|
||||
#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY/4)
|
||||
|
||||
/* Timers driven from APB1 will be twice PCLK1 */
|
||||
|
||||
#define STM32_APB1_TIM2_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM3_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM4_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM5_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM6_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM7_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM12_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM13_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
#define STM32_APB1_TIM14_CLKIN (2*STM32_PCLK1_FREQUENCY)
|
||||
|
||||
/* APB2 clock (PCLK2) is HCLK/2 (84MHz) */
|
||||
|
||||
#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLKd2 /* PCLK2 = HCLK / 2 */
|
||||
#define STM32_PCLK2_FREQUENCY (STM32_HCLK_FREQUENCY/2)
|
||||
|
||||
/* Timers driven from APB2 will be twice PCLK2 */
|
||||
|
||||
#define STM32_APB2_TIM1_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM8_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM9_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM10_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM11_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
|
||||
/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx
|
||||
* otherwise frequency is 2xAPBx.
|
||||
* Note: TIM1,8 are on APB2, others on APB1
|
||||
*/
|
||||
|
||||
#define BOARD_TIM1_FREQUENCY STM32_HCLK_FREQUENCY
|
||||
#define BOARD_TIM2_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
#define BOARD_TIM3_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
#define BOARD_TIM4_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
#define BOARD_TIM5_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
#define BOARD_TIM6_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
#define BOARD_TIM7_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
#define BOARD_TIM8_FREQUENCY STM32_HCLK_FREQUENCY
|
||||
|
||||
/* Pin configurations **************************************************************/
|
||||
|
||||
#define BOARD_NLEDS 2 /* One literal LED, one beeper */
|
||||
#define GPIO_LED1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz |\
|
||||
GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN5)
|
||||
#define GPIO_BEEPER1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz |\
|
||||
GPIO_OUTPUT_CLEAR | GPIO_PORTB|GPIO_PIN4)
|
||||
|
||||
/* USART1: */
|
||||
|
||||
#if 0
|
||||
#define INVERTER_PIN_USART1 PC0 /* DYS F4 Pro, Omnibus F4 AIO 1st Gen only */
|
||||
#endif
|
||||
#define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */
|
||||
#define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */
|
||||
|
||||
/* USART2:
|
||||
*
|
||||
* TODO: Do OMNIBUSF4 targets use USART2?
|
||||
*/
|
||||
|
||||
/* USART3: */
|
||||
|
||||
#define GPIO_USART3_TX GPIO_USART3_TX_1 /* PB10 */
|
||||
#define GPIO_USART3_RX GPIO_USART3_RX_1 /* PB11 */
|
||||
|
||||
/* USART4: */
|
||||
|
||||
/* USART6: */
|
||||
|
||||
#if 0
|
||||
#define INVERTER_PIN_UART6 PC8 /* Omnibus F4 V3 and later, EXUAVF4PRO */
|
||||
#endif
|
||||
#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */
|
||||
#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */
|
||||
|
||||
/* PWM - motor outputs, etc. are on these pins: */
|
||||
|
||||
#define GPIO_TIM3_CH3OUT GPIO_TIM3_CH3OUT_1 /* S1_OUT PB0 */
|
||||
#define GPIO_TIM3_CH4OUT GPIO_TIM3_CH4OUT_1 /* S2_OUT PB1 */
|
||||
#define GPIO_TIM2_CH4OUT GPIO_TIM2_CH4OUT_1 /* S3_OUT PA3 */
|
||||
#define GPIO_TIM2_CH3OUT GPIO_TIM3_CH3OUT_1 /* S4_OUT PA2 */
|
||||
|
||||
/* SPI1 :
|
||||
*
|
||||
* MPU6000 6-axis motion sensor (accelerometer + gyroscope), or
|
||||
* MPU6500 6-Axis MEMS MotionTracking Device with DMP
|
||||
*
|
||||
* MPU6000 interrupts
|
||||
* #define USE_GYRO_EXTI
|
||||
* #define GYRO_1_EXTI_PIN PC4
|
||||
* #define USE_MPU_DATA_READY_SIGNAL
|
||||
*
|
||||
* #define GYRO_1_ALIGN CW270_DEG
|
||||
* #define ACC_1_ALIGN CW270_DEG
|
||||
*/
|
||||
|
||||
#define GPIO_SPI1_MISO GPIO_SPI1_MISO_1 /* PA6 */
|
||||
#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_1 /* PA7 */
|
||||
#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1 /* PA5 */
|
||||
#if 0
|
||||
#define GPIO_SPI1_NSS GPIO_SPI1_NSS_2 /* PA4 */
|
||||
#endif
|
||||
#define DMACHAN_SPI1_RX DMAMAP_SPI1_RX_1 /* 2:0:3 */
|
||||
#define DMACHAN_SPI1_TX DMAMAP_SPI1_TX_1 /* 2:3:3 */
|
||||
|
||||
/* SPI2 :
|
||||
*
|
||||
* Used for MMC/SD on OMNIBUSF4SD.
|
||||
*/
|
||||
|
||||
#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1 /* PB14 */
|
||||
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1 /* PB15 */
|
||||
#define GPIO_SPI2_NSS (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN12)
|
||||
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_2 /* PB13 */
|
||||
#define DMACHAN_SPI2_RX DMAMAP_SPI2_RX /* 1:3:0 */
|
||||
#define DMACHAN_SPI2_TX DMAMAP_SPI2_TX /* 1:4:0 */
|
||||
|
||||
#define GPIO_MMCSD_NSS GPIO_SPI2_NSS
|
||||
#define GPIO_MMCSD_NCD (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | \
|
||||
GPIO_PORTB | GPIO_PIN7) /* PB7 SD_DET */
|
||||
|
||||
/* SPI3 :
|
||||
*
|
||||
* OMNIBUSF4SD targets use PA15 for NSS; others use PB4 (? BF code says "PB3").
|
||||
* define GPIO_SPI3_NSS GPIO_SPI3_NSS_2 PB4
|
||||
*
|
||||
* Barometer and/or MAX7456, depending on the target.
|
||||
* (OMNIBUSF4BASE targets appear to have a cyrf6936 device.)
|
||||
*/
|
||||
|
||||
#define GPIO_SPI3_MISO GPIO_SPI3_MISO_2 /* PC11 */
|
||||
#define GPIO_SPI3_MOSI GPIO_SPI3_MOSI_2 /* PC12 */
|
||||
#define GPIO_SPI3_NSS GPIO_SPI3_NSS_1 /* PA15 */ /* TODO: doesn't work like a chip select */
|
||||
#define GPIO_SPI3_SCK GPIO_SPI3_SCK_2 /* PC10 */
|
||||
|
||||
#if 0
|
||||
/* I2C : */
|
||||
|
||||
#define GPIO_I2C1_SCL GPIO_I2C1_SCL_1
|
||||
#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2
|
||||
#endif
|
||||
|
||||
#endif /* __CONFIG_OMNIBUSF4_INCLUDE_BOARD_H */
|
2
configs/omnibusf4/kernel/.gitignore
vendored
Normal file
2
configs/omnibusf4/kernel/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/nuttx_user.elf
|
||||
|
124
configs/omnibusf4/kernel/Makefile
Normal file
124
configs/omnibusf4/kernel/Makefile
Normal file
@ -0,0 +1,124 @@
|
||||
############################################################################
|
||||
# configs/omnibusf4/kernel/Makefile
|
||||
#
|
||||
# Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
# Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
# Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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 NuttX 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
# This is the directory for the board-specific header files
|
||||
|
||||
BOARD_INCLUDE = $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)include
|
||||
|
||||
# The entry point name (if none is provided in the .config file)
|
||||
|
||||
CONFIG_USER_ENTRYPOINT ?= user_start
|
||||
ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))
|
||||
|
||||
# Get the paths to the libraries and the links script path in format that
|
||||
# is appropriate for the host OS
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
|
||||
USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}"
|
||||
USER_LDSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}"
|
||||
USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
|
||||
USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
|
||||
USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
|
||||
else
|
||||
# Linux/Cygwin-native toolchain
|
||||
USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
|
||||
USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld
|
||||
USER_LDSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld
|
||||
USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
|
||||
USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
|
||||
USER_BINFILE += "$(TOPDIR)$(DELIM)nuttx_user.bin"
|
||||
endif
|
||||
|
||||
USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT)
|
||||
USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
|
||||
USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
|
||||
|
||||
# Source files
|
||||
|
||||
CSRCS = stm32_userspace.c
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
OBJS = $(COBJS)
|
||||
|
||||
# Targets:
|
||||
|
||||
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
|
||||
.PHONY: nuttx_user.elf depend clean distclean
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
# Create the nuttx_user.elf file containing all of the user-mode code
|
||||
|
||||
nuttx_user.elf: $(OBJS)
|
||||
$(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
|
||||
|
||||
$(TOPDIR)$(DELIM)nuttx_user.elf: nuttx_user.elf
|
||||
@echo "LD: nuttx_user.elf"
|
||||
$(Q) cp -a nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user.elf
|
||||
ifeq ($(CONFIG_INTELHEX_BINARY),y)
|
||||
@echo "CP: nuttx_user.hex"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(USER_HEXFILE)
|
||||
endif
|
||||
ifeq ($(CONFIG_MOTOROLA_SREC),y)
|
||||
@echo "CP: nuttx_user.srec"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(USER_SRECFILE)
|
||||
endif
|
||||
ifeq ($(CONFIG_RAW_BINARY),y)
|
||||
@echo "CP: nuttx_user.bin"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(USER_BINFILE)
|
||||
endif
|
||||
|
||||
$(TOPDIR)$(DELIM)User.map: nuttx_user.elf
|
||||
@echo "MK: User.map"
|
||||
$(Q) $(NM) nuttx_user.elf >$(TOPDIR)$(DELIM)User.map
|
||||
$(Q) $(CROSSDEV)size nuttx_user.elf
|
||||
|
||||
.depend:
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, nuttx_user.elf)
|
||||
$(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
|
||||
$(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
136
configs/omnibusf4/kernel/stm32_userspace.c
Normal file
136
configs/omnibusf4/kernel/stm32_userspace.c
Normal file
@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/kernel/stm32_userspace.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/userspace.h>
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_NUTTX_USERSPACE
|
||||
# error "CONFIG_NUTTX_USERSPACE not defined"
|
||||
#endif
|
||||
|
||||
#if CONFIG_NUTTX_USERSPACE != 0x08020000
|
||||
# error "CONFIG_NUTTX_USERSPACE must be 0x08020000 to match memory.ld"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* These 'addresses' of these values are setup by the linker script. They
|
||||
* are ot actual uint32_t storage locations! They are only used meaningfully
|
||||
* in the following way:
|
||||
*
|
||||
* - The linker script defines, for example, the symbol_sdata.
|
||||
* - The declaration extern uint32_t _sdata; makes C happy. C will believe
|
||||
* that the value _sdata is the address of a uint32_t variable _data (it is
|
||||
* not!).
|
||||
* - We can recover the linker value then by simply taking the address of
|
||||
* of _data. like: uint32_t *pdata = &_sdata;
|
||||
*/
|
||||
|
||||
extern uint32_t _stext; /* Start of .text */
|
||||
extern uint32_t _etext; /* End_1 of .text + .rodata */
|
||||
extern const uint32_t _eronly; /* End+1 of read only section (.text + .rodata) */
|
||||
extern uint32_t _sdata; /* Start of .data */
|
||||
extern uint32_t _edata; /* End+1 of .data */
|
||||
extern uint32_t _sbss; /* Start of .bss */
|
||||
extern uint32_t _ebss; /* End+1 of .bss */
|
||||
|
||||
/* This is the user space entry point */
|
||||
|
||||
int CONFIG_USER_ENTRYPOINT(int argc, char *argv[]);
|
||||
|
||||
const struct userspace_s userspace __attribute__ ((section (".userspace"))) =
|
||||
{
|
||||
/* General memory map */
|
||||
|
||||
.us_entrypoint = (main_t)CONFIG_USER_ENTRYPOINT,
|
||||
.us_textstart = (uintptr_t)&_stext,
|
||||
.us_textend = (uintptr_t)&_etext,
|
||||
.us_datasource = (uintptr_t)&_eronly,
|
||||
.us_datastart = (uintptr_t)&_sdata,
|
||||
.us_dataend = (uintptr_t)&_edata,
|
||||
.us_bssstart = (uintptr_t)&_sbss,
|
||||
.us_bssend = (uintptr_t)&_ebss,
|
||||
|
||||
/* Memory manager heap structure */
|
||||
|
||||
.us_heap = &g_mmheap,
|
||||
|
||||
/* Task/thread startup routines */
|
||||
|
||||
.task_startup = task_startup,
|
||||
#ifndef CONFIG_DISABLE_PTHREAD
|
||||
.pthread_startup = pthread_startup,
|
||||
#endif
|
||||
|
||||
/* Signal handler trampoline */
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
.signal_handler = up_signal_handler,
|
||||
#endif
|
||||
|
||||
/* User-space work queue support (declared in include/nuttx/wqueue.h) */
|
||||
|
||||
#ifdef CONFIG_LIB_USRWORK
|
||||
.work_usrstart = work_usrstart,
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */
|
1911
configs/omnibusf4/nsh/defconfig
Normal file
1911
configs/omnibusf4/nsh/defconfig
Normal file
File diff suppressed because it is too large
Load Diff
138
configs/omnibusf4/scripts/Make.defs
Normal file
138
configs/omnibusf4/scripts/Make.defs
Normal file
@ -0,0 +1,138 @@
|
||||
############################################################################
|
||||
# configs/omnibusf4/scripts/Make.defs
|
||||
#
|
||||
# Copyright (C) 2011-2012, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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 NuttX 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
|
||||
|
||||
LDSCRIPT = ld.script
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
DIRLINK = $(TOPDIR)/tools/copydir.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
|
||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||
else
|
||||
# Linux/Cygwin-native toolchain
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||
endif
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
STRIP = $(CROSSDEV)strip --strip-unneeded
|
||||
AR = $(ARCROSSDEV)ar rcs
|
||||
NM = $(ARCROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
|
||||
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ARCHCFLAGS = -fno-builtin
|
||||
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHDEFINES =
|
||||
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||
|
||||
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
ifeq ($(WINTOOL),y)
|
||||
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
|
||||
else
|
||||
LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
|
||||
endif
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
ifeq ($(WINTOOL),y)
|
||||
LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}"
|
||||
else
|
||||
LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld
|
||||
endif
|
||||
|
||||
|
||||
ASMEXT = .S
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
EXEEXT =
|
||||
|
||||
ifneq ($(CROSSDEV),arm-nuttx-elf-)
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
|
||||
HOSTLDFLAGS =
|
||||
|
139
configs/omnibusf4/scripts/gnu-elf.ld
Normal file
139
configs/omnibusf4/scripts/gnu-elf.ld
Normal file
@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/scripts/gnu-elf.ld
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x00000000 :
|
||||
{
|
||||
_stext = . ;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.warning)
|
||||
*(.stub)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.jcr)
|
||||
|
||||
/* C++ support: The .init and .fini sections contain specific logic
|
||||
* to manage static constructors and destructors.
|
||||
*/
|
||||
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.init) /* Old ABI */
|
||||
*(.fini) /* Old ABI */
|
||||
_etext = . ;
|
||||
}
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab*)
|
||||
}
|
||||
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx*)
|
||||
}
|
||||
|
||||
.rodata :
|
||||
{
|
||||
_srodata = . ;
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.rodata.*)
|
||||
*(.gnu.linkonce.r*)
|
||||
_erodata = . ;
|
||||
}
|
||||
|
||||
.data :
|
||||
{
|
||||
_sdata = . ;
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
_edata = . ;
|
||||
}
|
||||
|
||||
/* C++ support. For each global and static local C++ object,
|
||||
* GCC creates a small subroutine to construct the object. Pointers
|
||||
* to these routines (not the routines themselves) are stored as
|
||||
* simple, linear arrays in the .ctors section of the object file.
|
||||
* Similarly, pointers to global/static destructor routines are
|
||||
* stored in .dtors.
|
||||
*/
|
||||
|
||||
.ctors :
|
||||
{
|
||||
_sctors = . ;
|
||||
*(.ctors) /* Old ABI: Unallocated */
|
||||
*(.init_array) /* New ABI: Allocated */
|
||||
_edtors = . ;
|
||||
}
|
||||
|
||||
.dtors :
|
||||
{
|
||||
_sdtors = . ;
|
||||
*(.dtors) /* Old ABI: Unallocated */
|
||||
*(.fini_array) /* New ABI: Allocated */
|
||||
_edtors = . ;
|
||||
}
|
||||
|
||||
.bss :
|
||||
{
|
||||
_sbss = . ;
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.gnu.linkonce.b*)
|
||||
*(COMMON)
|
||||
_ebss = . ;
|
||||
}
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
109
configs/omnibusf4/scripts/kernel-space.ld
Normal file
109
configs/omnibusf4/scripts/kernel-space.ld
Normal file
@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/scripts/kernel-space.ld
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* NOTE: This depends on the memory.ld script having been included prior to
|
||||
* this script.
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_stext)
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.vectors)
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > kflash
|
||||
|
||||
.init_section : {
|
||||
_sinit = ABSOLUTE(.);
|
||||
*(.init_array .init_array.*)
|
||||
_einit = ABSOLUTE(.);
|
||||
} > kflash
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} > kflash
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx*)
|
||||
} > kflash
|
||||
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
.data : {
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
_edata = ABSOLUTE(.);
|
||||
} > ksram AT > kflash
|
||||
|
||||
.bss : {
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > ksram
|
||||
|
||||
/* Stabs debugging sections */
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
123
configs/omnibusf4/scripts/ld.script
Normal file
123
configs/omnibusf4/scripts/ld.script
Normal file
@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/scripts/ld.script
|
||||
*
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* The STM32F407VG has 1024Kb of FLASH beginning at address 0x0800:0000 and
|
||||
* 192Kb of SRAM. SRAM is split up into three blocks:
|
||||
*
|
||||
* 1) 112Kb of SRAM beginning at address 0x2000:0000
|
||||
* 2) 16Kb of SRAM beginning at address 0x2001:c000
|
||||
* 3) 64Kb of CCM SRAM beginning at address 0x1000:0000
|
||||
*
|
||||
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
|
||||
* where the code expects to begin execution by jumping to the entry point in
|
||||
* the 0x0800:0000 address
|
||||
* range.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K
|
||||
}
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_stext)
|
||||
EXTERN(_vectors)
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.vectors)
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > flash
|
||||
|
||||
.init_section : {
|
||||
_sinit = ABSOLUTE(.);
|
||||
*(.init_array .init_array.*)
|
||||
_einit = ABSOLUTE(.);
|
||||
} > flash
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} > flash
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx*)
|
||||
} > flash
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
.data : {
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
_edata = ABSOLUTE(.);
|
||||
} > sram AT > flash
|
||||
|
||||
.bss : {
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > sram
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
100
configs/omnibusf4/scripts/memory.ld
Normal file
100
configs/omnibusf4/scripts/memory.ld
Normal file
@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/scripts/memory.ld
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* The STM32F407VG has 1024Kb of FLASH beginning at address 0x0800:0000 and
|
||||
* 192Kb of SRAM. SRAM is split up into three blocks:
|
||||
*
|
||||
* 1) 112KB of SRAM beginning at address 0x2000:0000
|
||||
* 2) 16KB of SRAM beginning at address 0x2001:c000
|
||||
* 3) 64KB of CCM SRAM beginning at address 0x1000:0000
|
||||
*
|
||||
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
|
||||
* where the code expects to begin execution by jumping to the entry point in
|
||||
* the 0x0800:0000 address range.
|
||||
*
|
||||
* For MPU support, the kernel-mode NuttX section is assumed to be 128Kb of
|
||||
* FLASH and 4Kb of SRAM. That is an excessive amount for the kernel which
|
||||
* should fit into 64KB and, of course, can be optimized as needed (See
|
||||
* also configs/omnibusf4/scripts/kernel-space.ld). Allowing the
|
||||
* additional does permit addition debug instrumentation to be added to the
|
||||
* kernel space without overflowing the partition.
|
||||
*
|
||||
* Alignment of the user space FLASH partition is also a critical factor:
|
||||
* The user space FLASH partition will be spanned with a single region of
|
||||
* size 2**n bytes. The alignment of the user-space region must be the same.
|
||||
* As a consequence, as the user-space increases in size, the alignmment
|
||||
* requirement also increases.
|
||||
*
|
||||
* This alignment requirement means that the largest user space FLASH region
|
||||
* you can have will be 512KB at it would have to be positioned at
|
||||
* 0x08800000. If you change this address, don't forget to change the
|
||||
* CONFIG_NUTTX_USERSPACE configuration setting to match and to modify
|
||||
* the check in kernel/userspace.c.
|
||||
*
|
||||
* For the same reasons, the maximum size of the SRAM mapping is limited to
|
||||
* 4KB. Both of these alignment limitations could be reduced by using
|
||||
* multiple regions to map the FLASH/SDRAM range or perhaps with some
|
||||
* clever use of subregions.
|
||||
*
|
||||
* A detailed memory map for the 112KB SRAM region is as follows:
|
||||
*
|
||||
* 0x20000 0000: Kernel .data region. Typical size: 0.1KB
|
||||
* ------- ---- Kernel .bss region. Typical size: 1.8KB
|
||||
* 0x20000 0800: Kernel IDLE thread stack (approximate). Size is
|
||||
* determined by CONFIG_IDLETHREAD_STACKSIZE and
|
||||
* adjustments for alignment. Typical is 1KB.
|
||||
* ------- ---- Padded to 4KB
|
||||
* 0x20000 1000: User .data region. Size is variable.
|
||||
* ------- ---- User .bss region Size is variable.
|
||||
* 0x20000 2000: Beginning of kernel heap. Size determined by
|
||||
* CONFIG_MM_KERNEL_HEAPSIZE.
|
||||
* ------- ---- Beginning of user heap. Can vary with other settings.
|
||||
* 0x20001 c000: End+1 of CPU RAM
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* 1024Kb FLASH */
|
||||
|
||||
kflash (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
||||
uflash (rx) : ORIGIN = 0x08020000, LENGTH = 128K
|
||||
xflash (rx) : ORIGIN = 0x08040000, LENGTH = 768K
|
||||
|
||||
/* 112Kb of contiguous SRAM */
|
||||
|
||||
ksram (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
|
||||
usram (rwx) : ORIGIN = 0x20001000, LENGTH = 4K
|
||||
xsram (rwx) : ORIGIN = 0x20002000, LENGTH = 104K
|
||||
}
|
111
configs/omnibusf4/scripts/user-space.ld
Normal file
111
configs/omnibusf4/scripts/user-space.ld
Normal file
@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/scripts/user-space.ld
|
||||
*
|
||||
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* NOTE: This depends on the memory.ld script having been included prior to
|
||||
* this script.
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
SECTIONS
|
||||
{
|
||||
.userspace : {
|
||||
*(.userspace)
|
||||
} > uflash
|
||||
|
||||
.text : {
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > uflash
|
||||
|
||||
.init_section : {
|
||||
_sinit = ABSOLUTE(.);
|
||||
*(.init_array .init_array.*)
|
||||
_einit = ABSOLUTE(.);
|
||||
} > uflash
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} > uflash
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx*)
|
||||
} > uflash
|
||||
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
.data : {
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
_edata = ABSOLUTE(.);
|
||||
} > usram AT > uflash
|
||||
|
||||
.bss : {
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > usram
|
||||
|
||||
/* Stabs debugging sections */
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
2
configs/omnibusf4/src/.gitignore
vendored
Normal file
2
configs/omnibusf4/src/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.depend
|
||||
/Make.dep
|
100
configs/omnibusf4/src/Makefile
Normal file
100
configs/omnibusf4/src/Makefile
Normal file
@ -0,0 +1,100 @@
|
||||
############################################################################
|
||||
# configs/omnibusf4/src/Makefile
|
||||
#
|
||||
# Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
# Copyright (C) 2011-2013, 2015-2016, 2018 Gregory Nutt. All rights
|
||||
# reserved.
|
||||
# Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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 NuttX 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ASRCS =
|
||||
CSRCS = stm32_boot.c stm32_bringup.c stm32_spi.c stm32_userleds.c
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_MPU60X0),y)
|
||||
CSRCS += stm32_mpu6000.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_CRITMONITOR),y)
|
||||
CSRCS += stm32_critmon.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32_OTGFS),y)
|
||||
CSRCS += stm32_usb.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NETDEVICES),y)
|
||||
CSRCS += stm32_netinit.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PWM),y)
|
||||
CSRCS += stm32_pwm.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += stm32_appinit.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_CUSTOM_PMINIT),y)
|
||||
CSRCS += stm32_pm.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_IDLE_CUSTOM),y)
|
||||
CSRCS += stm32_idle.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TESTING_OSTEST),y)
|
||||
CSRCS += stm32_ostest.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TIMER),y)
|
||||
CSRCS += stm32_timer.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32_ROMFS),y)
|
||||
CSRCS += stm32_romfs_initialize.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
|
||||
CSRCS += stm32_uid.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBMSC),y)
|
||||
CSRCS += stm32_usbmsc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MMCSD),y)
|
||||
CSRCS += stm32_mmcsd.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
208
configs/omnibusf4/src/omnibusf4.h
Normal file
208
configs/omnibusf4/src/omnibusf4.h
Normal file
@ -0,0 +1,208 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/omnibusf4.h
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2011-2012, 2015-2016, 2018 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CONFIGS_OMNIBUSF4_SRC_OMNIBUSF4_H
|
||||
#define __CONFIGS_OMNIBUSF4_SRC_OMNIBUSF4_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
#include <arch/stm32/chip.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* procfs File System */
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
# ifdef CONFIG_NSH_PROC_MOUNTPOINT
|
||||
# define STM32_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
|
||||
# else
|
||||
# define STM32_PROCFS_MOUNTPOINT "/proc"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* OMNIBUSF4 GPIOs *********************************************************/
|
||||
|
||||
#define SPIPORT_MPU6000 1
|
||||
#define SPIMINOR_MPU6000 0
|
||||
#define GPIO_CS_MPU6000 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN4)
|
||||
#define GPIO_EXTI_MPU6000 (GPIO_INPUT | GPIO_FLOAT | GPIO_SPEED_50MHz | \
|
||||
GPIO_OPENDRAIN | GPIO_PORTC | GPIO_PIN4)
|
||||
#define DEVNODE_MPU6000 "/dev/imu0"
|
||||
|
||||
/* USB OTG FS ***************************************************************/
|
||||
|
||||
/* PC5 OTG_FS_VBUS VBUS sensing */
|
||||
|
||||
#define GPIO_OTGFS_VBUS (GPIO_INPUT | GPIO_FLOAT | GPIO_SPEED_100MHz |\
|
||||
GPIO_OPENDRAIN | GPIO_PORTC | GPIO_PIN5)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_bringup
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture-specific initialization
|
||||
*
|
||||
* CONFIG_BOARD_INITIALIZE=y :
|
||||
* Called from board_initialize().
|
||||
*
|
||||
* CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
|
||||
* Called from the NSH library
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spidev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the omnibusf4
|
||||
* board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function stm32_spidev_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mmcsdinitialize
|
||||
*
|
||||
* Description:
|
||||
* Sets up MMC/SD interface.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_mmcsd_initialize(int port, int minor);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_usbinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called from stm32_usbinitialize very early in initialization to setup
|
||||
* USB-related GPIO pins for the OMNIBUSF4 board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
void weak_function stm32_usbinitialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_usbhost_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called at application startup time to initialize the USB host
|
||||
* functionality. This function will start a thread that will monitor for
|
||||
* device connection/disconnection events.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST)
|
||||
int stm32_usbhost_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize PWM and register the PWM device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
int weak_function stm32_pwm_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_can_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize CAN and register the CAN device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CAN
|
||||
int stm32_can_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_timer_driver_setup
|
||||
*
|
||||
* Description:
|
||||
* Configure the timer driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the timer device. This should be of the
|
||||
* form /dev/timer0
|
||||
* timer - The timer's number.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
int stm32_timer_driver_setup(FAR const char *devpath, int timer);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_OMNIBUSF4_SRC_OMNIBUSF4_H */
|
98
configs/omnibusf4/src/stm32_appinit.c
Normal file
98
configs/omnibusf4/src/stm32_appinit.c
Normal file
@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
* config/omnibusf4/src/stm32_appinit.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2012, 2014, 2016, 20018 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OK
|
||||
# define OK 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_app_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform application specific initialization. This function is never
|
||||
* called directly from application code, but only indirectly via the
|
||||
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
|
||||
*
|
||||
* Input Parameters:
|
||||
* arg - The boardctl() argument is passed to the board_app_initialize()
|
||||
* implementation without modification. The argument has no
|
||||
* meaning to NuttX; the meaning of the argument is a contract
|
||||
* between the board-specific initialization logic and the
|
||||
* matching application logic. The value cold be such things as a
|
||||
* mode enumeration value, a set of DIP switch switch settings, a
|
||||
* pointer to configuration data read from a file or serial FLASH,
|
||||
* or whatever you would like to do with it. Every implementation
|
||||
* should accept zero/NULL as a default configuration.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_app_initialize(uintptr_t arg)
|
||||
{
|
||||
#ifdef CONFIG_BOARD_INITIALIZE
|
||||
|
||||
/* Board initialization already performed by board_initialize() */
|
||||
|
||||
return OK;
|
||||
#else
|
||||
|
||||
/* Perform board-specific initialization */
|
||||
|
||||
return stm32_bringup();
|
||||
#endif
|
||||
}
|
147
configs/omnibusf4/src/stm32_boot.c
Normal file
147
configs/omnibusf4/src/stm32_boot.c
Normal file
@ -0,0 +1,147 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_boot.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2011-2012, 2015, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "itm.h"
|
||||
|
||||
#include "stm32.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* All STM32 architectures must provide the following entry point. This
|
||||
* entry point is called early in the initialization -- after all memory
|
||||
* has been configured and mapped but before any devices have been
|
||||
* initialized.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void stm32_boardinitialize(void)
|
||||
{
|
||||
#ifdef CONFIG_SCHED_CRITMONITOR
|
||||
/* Make sure the high speed cycle counter is running. It will be started
|
||||
* automatically only if a debugger is connected.
|
||||
*/
|
||||
|
||||
putreg32(0xc5acce55, ITM_LAR);
|
||||
modifyreg32(DWT_CTRL, 0, DWT_CTRL_CYCCNTENA_MASK);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
|
||||
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak
|
||||
* function stm32_spidev_initialize() has been brought into the link.
|
||||
*/
|
||||
|
||||
if (stm32_spidev_initialize)
|
||||
{
|
||||
stm32_spidev_initialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
/* Initialize USB if the 1) OTG FS controller is in the configuration and 2)
|
||||
* disabled, and 3) the weak function stm32_usbinitialize() has been brought
|
||||
* into the build. Presumably either CONFIG_USBDEV or CONFIG_USBHOST is also
|
||||
* selected.
|
||||
*/
|
||||
|
||||
if (stm32_usbinitialize)
|
||||
{
|
||||
stm32_usbinitialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETMONITOR
|
||||
/* Configure board resources to support networking. */
|
||||
|
||||
if (stm32_netinitialize)
|
||||
{
|
||||
stm32_netinitialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
/* Configure on-board LEDs if LED support has been selected. */
|
||||
|
||||
board_autoled_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CCM_HEAP
|
||||
/* Initialize CCM allocator */
|
||||
|
||||
ccm_initialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_initialize
|
||||
*
|
||||
* Description:
|
||||
* If CONFIG_BOARD_INITIALIZE is selected, then an additional
|
||||
* initialization call will be performed in the boot-up sequence to a
|
||||
* function called board_initialize(). board_initialize() will be
|
||||
* called immediately after up_initialize() is called and just before the
|
||||
* initial application is started. This additional initialization phase
|
||||
* may be used, for example, to initialize board-specific device drivers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BOARD_INITIALIZE
|
||||
void board_initialize(void)
|
||||
{
|
||||
/* Perform board-specific initialization */
|
||||
|
||||
(void)stm32_bringup();
|
||||
}
|
||||
#endif
|
297
configs/omnibusf4/src/stm32_bringup.c
Normal file
297
configs/omnibusf4/src/stm32_bringup.c
Normal file
@ -0,0 +1,297 @@
|
||||
/****************************************************************************
|
||||
* config/omnibusf4/src/stm32_bringup.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2012, 2014-2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef CONFIG_USBMONITOR
|
||||
# include <nuttx/usb/usbmonitor.h>
|
||||
#endif
|
||||
|
||||
#include "stm32.h"
|
||||
#include "stm32_romfs.h"
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
# include "stm32_usbhost.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USERLED
|
||||
# include <nuttx/leds/userled.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RNDIS
|
||||
# include <nuttx/usb/rndis.h>
|
||||
#endif
|
||||
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/* Conditional logic in omnibusf4.h will determine if certain features
|
||||
* are supported. Tests for these features need to be made after including
|
||||
* omnibusf4.h.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
# include <nuttx/timers/rtc.h>
|
||||
# include "stm32_rtc.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_i2c_register
|
||||
*
|
||||
* Description:
|
||||
* Register one I2C drivers for the I2C tool.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
|
||||
static void stm32_i2c_register(int bus)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
i2c = stm32_i2cbus_initialize(bus);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = i2c_register(i2c, bus);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
|
||||
bus, ret);
|
||||
stm32_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_i2ctool
|
||||
*
|
||||
* Description:
|
||||
* Register I2C drivers for the I2C tool.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
|
||||
static void stm32_i2ctool(void)
|
||||
{
|
||||
stm32_i2c_register(1);
|
||||
#if 0
|
||||
stm32_i2c_register(1);
|
||||
stm32_i2c_register(2);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
# define stm32_i2ctool()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_bringup
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture-specific initialization
|
||||
*
|
||||
* CONFIG_BOARD_INITIALIZE=y :
|
||||
* Called from board_initialize().
|
||||
*
|
||||
* CONFIG_BOARD_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y :
|
||||
* Called from the NSH library
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_bringup(void)
|
||||
{
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
FAR struct rtc_lowerhalf_s *lower;
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
|
||||
stm32_i2ctool();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USBHOST
|
||||
/* Initialize USB host operation. stm32_usbhost_initialize() starts a
|
||||
* thread will monitor for USB connection and disconnection events.
|
||||
*/
|
||||
|
||||
ret = stm32_usbhost_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to initialize USB host: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USBMONITOR
|
||||
/* Start the USB Monitor */
|
||||
|
||||
ret = usbmonitor_start();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to start USB monitor: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MMCSD_SPI
|
||||
/* Our MMC/SD port is on SPI2. */
|
||||
|
||||
ret = stm32_mmcsd_initialize(2, CONFIG_NSH_MMCSDMINOR);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize SD slot %d: %d\n",
|
||||
CONFIG_NSH_MMCSDMINOR, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
ret = stm32_pwm_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_pwm_setup() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CAN
|
||||
/* Initialize CAN and register the CAN driver. */
|
||||
|
||||
ret = stm32_can_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_MPU60X0
|
||||
/* Initialize the MPU6000 device. */
|
||||
|
||||
int stm32_mpu6000_initialize(void);
|
||||
ret = stm32_mpu6000_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_mpu6000_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USERLED
|
||||
/* Register the LED driver */
|
||||
|
||||
ret = userled_lower_initialize("/dev/userleds");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
/* Instantiate the STM32 lower-half RTC driver */
|
||||
|
||||
lower = stm32_rtc_lowerhalf();
|
||||
if (!lower)
|
||||
{
|
||||
serr("ERROR: Failed to instantiate the RTC lower-half driver\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the lower half driver and register the combined RTC driver
|
||||
* as /dev/rtc0
|
||||
*/
|
||||
|
||||
ret = rtc_initialize(0, lower);
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: Failed to mount procfs at %s: %d\n",
|
||||
STM32_PROCFS_MOUNTPOINT, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_ROMFS
|
||||
/* Initialize and mount ROMFS. */
|
||||
|
||||
ret = stm32_romfs_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: Failed to mount romfs at %s: %d\n",
|
||||
STM32_ROMFS_MOUNTPOINT, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RNDIS) && defined(CONFIG_NSH_MACADDR)
|
||||
/* Set up a MAC address for the RNDIS device. */
|
||||
|
||||
uint8_t mac[6];
|
||||
mac[0] = 0xa0; /* TODO */
|
||||
mac[1] = (CONFIG_NSH_MACADDR >> (8 * 4)) & 0xff;
|
||||
mac[2] = (CONFIG_NSH_MACADDR >> (8 * 3)) & 0xff;
|
||||
mac[3] = (CONFIG_NSH_MACADDR >> (8 * 2)) & 0xff;
|
||||
mac[4] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
|
||||
mac[5] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
|
||||
usbdev_rndis_initialize(mac);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
80
configs/omnibusf4/src/stm32_critmon.c
Normal file
80
configs/omnibusf4/src/stm32_critmon.c
Normal file
@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
* config/omnibusf4/src/stm32_netinit.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include "dwt.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#ifdef CONFIG_SCHED_CRITMONITOR
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_critmon_gettime
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t up_critmon_gettime(void)
|
||||
{
|
||||
return getreg32(DWT_CYCCNT);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_critmon_gettime
|
||||
****************************************************************************/
|
||||
|
||||
void up_critmon_convert(uint32_t elapsed, FAR struct timespec *ts)
|
||||
{
|
||||
b32_t b32elapsed;
|
||||
|
||||
b32elapsed = itob32(elapsed) / STM32_SYSCLK_FREQUENCY;
|
||||
ts->tv_sec = b32toi(b32elapsed);
|
||||
ts->tv_nsec = NSEC_PER_SEC * b32frac(b32elapsed) / b32ONE;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_CRITMONITOR */
|
277
configs/omnibusf4/src/stm32_idle.c
Normal file
277
configs/omnibusf4/src/stm32_idle.c
Normal file
@ -0,0 +1,277 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_idle.c
|
||||
*
|
||||
* Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||
*
|
||||
* 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 NuttX 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 <arch/board/board.h>
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
#include "stm32_pm.h"
|
||||
#include "stm32_rcc.h"
|
||||
#include "stm32_exti.h"
|
||||
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Does the board support an IDLE LED to indicate that the board is in the
|
||||
* IDLE state?
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_LEDS) && defined(LED_IDLE)
|
||||
# define BEGIN_IDLE() board_autoled_on(LED_IDLE)
|
||||
# define END_IDLE() board_autoled_off(LED_IDLE)
|
||||
#else
|
||||
# define BEGIN_IDLE()
|
||||
# define END_IDLE()
|
||||
#endif
|
||||
|
||||
/* Values for the RTC Alarm to wake up from the PM_STANDBY mode */
|
||||
|
||||
#ifndef CONFIG_PM_ALARM_SEC
|
||||
# define CONFIG_PM_ALARM_SEC 3
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_PM_ALARM_NSEC
|
||||
# define CONFIG_PM_ALARM_NSEC 0
|
||||
#endif
|
||||
|
||||
#define PM_IDLE_DOMAIN 0 /* Revisit */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if 0 /* Not used */
|
||||
static void up_alarmcb(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_idlepm
|
||||
*
|
||||
* Description:
|
||||
* Perform IDLE state power management.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void stm32_idlepm(void)
|
||||
{
|
||||
static enum pm_state_e oldstate = PM_NORMAL;
|
||||
enum pm_state_e newstate;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
/* Decide, which power saving level can be obtained */
|
||||
|
||||
newstate = pm_checkstate(PM_IDLE_DOMAIN);
|
||||
|
||||
/* Check for state changes */
|
||||
|
||||
if (newstate != oldstate)
|
||||
{
|
||||
sinfo("newstate= %d oldstate=%d\n", newstate, oldstate);
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Force the global state change */
|
||||
|
||||
ret = pm_changestate(PM_IDLE_DOMAIN, newstate);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* The new state change failed, revert to the preceding state */
|
||||
|
||||
(void)pm_changestate(PM_IDLE_DOMAIN, oldstate);
|
||||
|
||||
/* No state change... */
|
||||
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Then perform board-specific, state-dependent logic here */
|
||||
|
||||
switch (newstate)
|
||||
{
|
||||
case PM_NORMAL:
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_IDLE:
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_STANDBY:
|
||||
{
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
/* Disable RTC Alarm interrupt */
|
||||
|
||||
#warning "missing logic"
|
||||
|
||||
/* Configure the RTC alarm to Auto Wake the system */
|
||||
|
||||
#warning "missing logic"
|
||||
|
||||
/* The tv_nsec value must not exceed 1,000,000,000. That
|
||||
* would be an invalid time.
|
||||
*/
|
||||
|
||||
#warning "missing logic"
|
||||
|
||||
/* Set the alarm */
|
||||
|
||||
#warning "missing logic"
|
||||
#endif
|
||||
/* Call the STM32 stop mode */
|
||||
|
||||
stm32_pmstop(true);
|
||||
|
||||
/* We have been re-awakened by some even: A button press?
|
||||
* An alarm? Cancel any pending alarm and resume the normal
|
||||
* operation.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
#warning "missing logic"
|
||||
#endif
|
||||
/* Resume normal operation */
|
||||
|
||||
pm_changestate(PM_IDLE_DOMAIN, PM_NORMAL);
|
||||
newstate = PM_NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_SLEEP:
|
||||
{
|
||||
/* We should not return from standby mode. The only way out
|
||||
* of standby is via the reset path.
|
||||
*/
|
||||
|
||||
(void)stm32_pmstandby();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Save the new state */
|
||||
|
||||
oldstate = newstate;
|
||||
|
||||
errout:
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define stm32_idlepm()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_alarmcb
|
||||
*
|
||||
* Description:
|
||||
* RTC alarm service routine
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if 0 /* Not used */
|
||||
static void up_alarmcb(void)
|
||||
{
|
||||
/* This alarm occurs because there wasn't any EXTI interrupt during the
|
||||
* PM_STANDBY period. So just go to sleep.
|
||||
*/
|
||||
|
||||
pm_changestate(PM_IDLE_DOMAIN, PM_SLEEP);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_idle
|
||||
*
|
||||
* Description:
|
||||
* up_idle() is the logic that will be executed when their is no other
|
||||
* ready-to-run task. This is processor idle time and will continue until
|
||||
* some interrupt occurs to cause a context switch from the idle task.
|
||||
*
|
||||
* Processing in this state may be processor-specific. e.g., this is where
|
||||
* power management operations might be performed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_idle(void)
|
||||
{
|
||||
#if defined(CONFIG_SUPPRESS_INTERRUPTS) || defined(CONFIG_SUPPRESS_TIMER_INTS)
|
||||
/* If the system is idle and there are no timer interrupts, then process
|
||||
* "fake" timer interrupts. Hopefully, something will wake up.
|
||||
*/
|
||||
|
||||
sched_process_timer();
|
||||
#else
|
||||
|
||||
/* Perform IDLE mode power management */
|
||||
|
||||
BEGIN_IDLE();
|
||||
stm32_idlepm();
|
||||
END_IDLE();
|
||||
#endif
|
||||
}
|
120
configs/omnibusf4/src/stm32_mmcsd.c
Normal file
120
configs/omnibusf4/src/stm32_mmcsd.c
Normal file
@ -0,0 +1,120 @@
|
||||
/*****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_mmcsd.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2017 Greg Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* 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 NuttX 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 <debug.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "chip.h"
|
||||
#include "stm32.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
# error "SD driver requires CONFIG_DISABLE_MOUNTPOINT to be disabled"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: stm32_spi1register
|
||||
*
|
||||
* Description:
|
||||
* Registers media change callback
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_spi2register(struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
void *arg)
|
||||
{
|
||||
/* TODO: media change callback */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: stm32_mmcsd_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SPI-based SD card and card detect thread.
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_mmcsd_initialize(int port, int minor)
|
||||
{
|
||||
struct spi_dev_s *spi;
|
||||
int rv;
|
||||
|
||||
stm32_configgpio(GPIO_MMCSD_NCD); /* SD_DET */
|
||||
stm32_configgpio(GPIO_MMCSD_NSS); /* CS */
|
||||
|
||||
mcinfo("INFO: Initializing mmcsd port %d minor %d SD_DET %x\n",
|
||||
port, minor, stm32_gpioread(GPIO_MMCSD_NCD));
|
||||
|
||||
spi = stm32_spibus_initialize(port);
|
||||
if (spi == NULL)
|
||||
{
|
||||
mcerr("ERROR: Failed to initialize SPI port %d\n", port);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rv = mmcsd_spislotinitialize(minor, minor, spi);
|
||||
if (rv < 0)
|
||||
{
|
||||
mcerr("ERROR: Failed to bind SPI port %d to SD slot %d\n",
|
||||
port, minor);
|
||||
return rv;
|
||||
}
|
||||
|
||||
spiinfo("INFO: mmcsd card has been initialized successfully\n");
|
||||
return OK;
|
||||
}
|
122
configs/omnibusf4/src/stm32_mpu6000.c
Normal file
122
configs/omnibusf4/src/stm32_mpu6000.c
Normal file
@ -0,0 +1,122 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_mpu6000.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#include <nuttx/sensors/mpu60x0.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_spi.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpu6000_initialize
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Initialize and register's Omnibus F4's MPU6000 IMU. The wiring
|
||||
* isn't configurable, but we use macros anyway because some of the
|
||||
* values are referred to in more than one place. And also, because
|
||||
* that's generally what NuttX does.
|
||||
*
|
||||
* In particular, the slave-select pin is defined by us, but
|
||||
* controlled elsewhere as part of the SPI machinery. This is an odd
|
||||
* thing in our case because nothing else is using the SPI port, but
|
||||
* that's not the general presentation so I'm staying consistent
|
||||
* with the pattern.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_mpu6000_initialize(void)
|
||||
{
|
||||
int port = SPIPORT_MPU6000;
|
||||
int minor = SPIMINOR_MPU6000;
|
||||
int exti = GPIO_EXTI_MPU6000;
|
||||
int cs = GPIO_CS_MPU6000;
|
||||
|
||||
stm32_configgpio(GPIO_CS_MPU6000);
|
||||
stm32_configgpio(GPIO_EXTI_MPU6000);
|
||||
|
||||
/* Note: the "minor" concept doesn't really apply since we're
|
||||
* uniquely-identified by a CS pin, we're the only device on the SPI
|
||||
* bus, and because users will refer to us through our device-node
|
||||
* pathname; I'm leaving this here for now anyway, in case we decide
|
||||
* sometime soon to do things differently.
|
||||
*
|
||||
* Likewise, we'll probably add things like EXTI, etc. to
|
||||
* mpu_config_s as the driver learns to support them.
|
||||
*/
|
||||
|
||||
struct mpu_config_s config =
|
||||
{
|
||||
.spi_devid = minor,
|
||||
};
|
||||
UNUSED(cs);
|
||||
UNUSED(exti);
|
||||
|
||||
/* Get the spi bus instance. */
|
||||
|
||||
struct spi_dev_s *spi = stm32_spibus_initialize(port);
|
||||
if (spi == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
config.spi = spi;
|
||||
|
||||
/* TODO: configure EXTI pin */
|
||||
|
||||
/* Register the chip with the device driver. */
|
||||
|
||||
int ret = mpu60x0_register(DEVNODE_MPU6000, &config);
|
||||
return ret;
|
||||
}
|
54
configs/omnibusf4/src/stm32_netinit.c
Normal file
54
configs/omnibusf4/src/stm32_netinit.c
Normal file
@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
* config/stm32f4discovery/src/stm32_netinit.c
|
||||
*
|
||||
* Copyright (C) 2017 Masayuki Ishikawa. All rights reserved.
|
||||
* Author: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_netinitialize
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET) && !defined(CONFIG_NETDEV_LATEINIT)
|
||||
void up_netinitialize(void)
|
||||
{
|
||||
}
|
||||
#endif
|
113
configs/omnibusf4/src/stm32_ostest.c
Normal file
113
configs/omnibusf4/src/stm32_ostest.c
Normal file
@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_ostest.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#undef HAVE_FPU
|
||||
#if defined(CONFIG_ARCH_FPU) && \
|
||||
!defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \
|
||||
defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \
|
||||
defined(CONFIG_SCHED_WAITPID) && \
|
||||
!defined(CONFIG_DISABLE_SIGNALS)
|
||||
# define HAVE_FPU 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FPU
|
||||
|
||||
#if CONFIG_TESTING_OSTEST_FPUSIZE != (4 * SW_FPU_REGS)
|
||||
# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t g_saveregs[XCPTCONTEXT_REGS];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will
|
||||
* return the current FPU registers.
|
||||
*/
|
||||
|
||||
void arch_getfpu(FAR uint32_t *fpusave)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
/* Take a snapshot of the thread context right now */
|
||||
|
||||
flags = enter_critical_section();
|
||||
up_saveusercontext(g_saveregs);
|
||||
|
||||
/* Return only the floating register values */
|
||||
|
||||
memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS));
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function
|
||||
* will compare them and return true if they are identical.
|
||||
*/
|
||||
|
||||
bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2)
|
||||
{
|
||||
return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_FPU */
|
107
configs/omnibusf4/src/stm32_pm.c
Normal file
107
configs/omnibusf4/src/stm32_pm.c
Normal file
@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_pm.c
|
||||
*
|
||||
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
#include "stm32_pm.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_pminitialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by MCU-specific logic at power-on reset in
|
||||
* order to provide one-time initialization the power management subystem.
|
||||
* This function must be called *very* early in the initializeation sequence
|
||||
* *before* any other device drivers are initialized (since they may
|
||||
* attempt to register with the power management subsystem).
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_pminitialize(void)
|
||||
{
|
||||
/* Then initialize the NuttX power management subsystem proper */
|
||||
|
||||
pm_initialize();
|
||||
|
||||
#if defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS)
|
||||
/* Initialize the buttons to wake up the system from low power modes */
|
||||
|
||||
stm32_pm_buttons();
|
||||
#endif
|
||||
|
||||
/* Initialize the LED PM */
|
||||
|
||||
stm32_led_pminitialize();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PM */
|
127
configs/omnibusf4/src/stm32_pwm.c
Normal file
127
configs/omnibusf4/src/stm32_pwm.c
Normal file
@ -0,0 +1,127 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_pwm.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <nuttx/drivers/pwm.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "stm32_pwm.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Initialize PWM and register Omnibus F4's TIM2 and TIM3 PWM devices:
|
||||
*
|
||||
* TIM3 CH3 PB0 S1_OUT
|
||||
* TIM3 CH4 PB1 S2_OUT
|
||||
* TIM2 CH4 PA3 S3_OUT
|
||||
* TIM2 CH3 PA2 S4_OUT
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_pwm_setup(void)
|
||||
{
|
||||
int npwm = 0; /* hardware device enumerator */
|
||||
const char *ppwm = NULL; /* pointer to PWM device name */
|
||||
struct pwm_lowerhalf_s *pwm = NULL; /* lower-half driver handle */
|
||||
|
||||
/* Initialize TIM2 and TIM3.
|
||||
*
|
||||
* Ihe underlying STM32 driver "knows" there are up to four channels
|
||||
* available for each timer device, so we don't have to do anything
|
||||
* special here to export the two channels each that we're
|
||||
* interested in. The user will want to avoid the channels that
|
||||
* aren't connected to anything, however, or risk death by boredom
|
||||
* from resulting non-response.
|
||||
*/
|
||||
|
||||
for (npwm = 2; npwm <= 3; npwm++)
|
||||
{
|
||||
pwm = stm32_pwminitialize(npwm);
|
||||
|
||||
/* If we can't get the lower-half handle, skip and keep going. */
|
||||
|
||||
if (!pwm)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Translate the peripheral number to a device name. */
|
||||
|
||||
switch (npwm)
|
||||
{
|
||||
case 2:
|
||||
ppwm = "/dev/pwm2";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ppwm = "/dev/pwm3";
|
||||
break;
|
||||
|
||||
/* Skip missing names. */
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
pwm_register(ppwm, pwm);
|
||||
}
|
||||
return 0;
|
||||
}
|
76
configs/omnibusf4/src/stm32_romfs.h
Normal file
76
configs/omnibusf4/src/stm32_romfs.h
Normal file
@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_romfs.h
|
||||
*
|
||||
* Copyright (C) 2017 Tomasz Wozniak. All rights reserved.
|
||||
* Author: Tomasz Wozniak <t.wozniak@samsung.com>
|
||||
*
|
||||
* 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 NuttX 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CONFIGS_STM32F4DISCOVERY_SRC_STM32_ROMFS_H
|
||||
#define __CONFIGS_STM32F4DISCOVERY_SRC_STM32_ROMFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_STM32_ROMFS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ROMFS_SECTOR_SIZE 64
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_romfs_initialize
|
||||
*
|
||||
* Description:
|
||||
* Registers built-in ROMFS image as block device and mounts it.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success, a negated errno value on error.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* Memory addresses [&romfs_data_begin .. &romfs_data_begin) should contain
|
||||
* ROMFS volume data, as included in the assembly snippet above (l. 84).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_romfs_initialize(void);
|
||||
|
||||
#endif /* CONFIG_STM32_ROMFS */
|
||||
|
||||
#endif /* __CONFIGS_STM32F4DISCOVERY_SRC_STM32_ROMFS_H */
|
156
configs/omnibusf4/src/stm32_romfs_initialize.c
Normal file
156
configs/omnibusf4/src/stm32_romfs_initialize.c
Normal file
@ -0,0 +1,156 @@
|
||||
/*****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_romfs_initialize.c
|
||||
* This file provides contents of an optional ROMFS volume, mounted at boot.
|
||||
*
|
||||
* Copyright (C) 2017 Tomasz Wozniak. All rights reserved.
|
||||
* Author: Tomasz Wozniak <t.wozniak@samsung.com>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/drivers/ramdisk.h>
|
||||
#include "stm32_romfs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STM32_ROMFS
|
||||
# error "CONFIG_STM32_ROMFS must be defined"
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_STM32_ROMFS_IMAGEFILE
|
||||
# error "CONFIG_STM32_ROMFS_IMAGEFILE must be defined"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_STM32_ROMFS_DEV_MINOR
|
||||
# error "CONFIG_STM32_ROMFS_DEV_MINOR must be defined"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_STM32_ROMFS_MOUNTPOINT
|
||||
# error "CONFIG_STM32_ROMFS_MOUNTPOINT must be defined"
|
||||
#endif
|
||||
|
||||
#define NSECTORS(size) (((size) + ROMFS_SECTOR_SIZE - 1)/ROMFS_SECTOR_SIZE)
|
||||
|
||||
#define STR2(m) #m
|
||||
#define STR(m) STR2(m)
|
||||
|
||||
#define MKMOUNT_DEVNAME(m) "/dev/ram" STR(m)
|
||||
#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_STM32_ROMFS_DEV_MINOR)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
__asm__ (
|
||||
".section .rodata\n"
|
||||
".balign 16\n"
|
||||
".globl romfs_data_begin\n"
|
||||
"romfs_data_begin:\n"
|
||||
".incbin " STR(CONFIG_STM32_ROMFS_IMAGEFILE) "\n"\
|
||||
\
|
||||
".balign " STR(ROMFS_SECTOR_SIZE) "\n"
|
||||
".globl romfs_data_end\n"
|
||||
"romfs_data_end:\n"
|
||||
".globl romfs_data_size\n"
|
||||
"romfs_data_size:\n"
|
||||
".word romfs_data_end - romfs_data_begin\n");
|
||||
|
||||
extern const char romfs_data_begin;
|
||||
extern const char romfs_data_end;
|
||||
extern const int romfs_data_size;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_romfs_initialize
|
||||
*
|
||||
* Description:
|
||||
* Registers the aboveincluded binary file as block device.
|
||||
* Then mounts the block device as ROMFS filesystems.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success, a negated errno value on error.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* Memory addresses [&romfs_data_begin .. &romfs_data_begin) should contain
|
||||
* ROMFS volume data, as included in the assembly snippet above (l. 84).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_romfs_initialize(void)
|
||||
{
|
||||
uintptr_t romfs_data_len
|
||||
int ret;
|
||||
|
||||
/* Create a ROM disk for the /etc filesystem */
|
||||
|
||||
romfs_data_len = (uintptr_t)&romfs_data_end - (uintptr_t)&romfs_data_begin;
|
||||
|
||||
ret = romdisk_register(CONFIG_STM32_ROMFS_DEV_MINOR, &romfs_data_begin,
|
||||
NSECTORS(romfs_data_len), ROMFS_SECTOR_SIZE);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: romdisk_register failed: %d\n", -ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Mount the file system */
|
||||
|
||||
finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||
CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
|
||||
|
||||
ret = mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
|
||||
"romfs", MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
|
||||
MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_STM32_ROMFS */
|
161
configs/omnibusf4/src/stm32_spi.c
Normal file
161
configs/omnibusf4/src/stm32_spi.c
Normal file
@ -0,0 +1,161 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_spi.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "chip.h"
|
||||
#include "stm32.h"
|
||||
|
||||
#include "omnibusf4.h"
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spidev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the omnibusf4 board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function stm32_spidev_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
stm32_configgpio(GPIO_CS_MPU6000);
|
||||
stm32_configgpio(GPIO_EXTI_MPU6000);
|
||||
#endif
|
||||
#if defined(CONFIG_MMCSD_SPI)
|
||||
(void)stm32_configgpio(GPIO_MMCSD_NCD); /* SD_DET */
|
||||
(void)stm32_configgpio(GPIO_MMCSD_NSS); /* CS */
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status
|
||||
*
|
||||
* Description:
|
||||
* The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status
|
||||
* must be provided by board-specific logic. They are implementations of
|
||||
* the select and status methods of the SPI interface defined by struct
|
||||
* spi_ops_s (see include/nuttx/spi/spi.h). All other methods (including
|
||||
* stm32_spibus_initialize()) are provided by common STM32 logic. To use
|
||||
* this common SPI logic on your board:
|
||||
*
|
||||
* 1. Provide logic in stm32_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide stm32_spi1/2/3select() and stm32_spi1/2/3status() functions
|
||||
* in your board-specific logic. These functions will perform chip
|
||||
* selection and
|
||||
* status operations using GPIOs in the way your board is configured.
|
||||
* 3. Add a calls to stm32_spibus_initialize() in your low level
|
||||
* application initialization logic
|
||||
* 4. The handle returned by stm32_spibus_initialize() may then be used to
|
||||
* bind the SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n",
|
||||
(int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
/* Note: CS is active-low. */
|
||||
|
||||
stm32_gpiowrite(GPIO_CS_MPU6000, !selected);
|
||||
}
|
||||
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n",
|
||||
(int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
/* Note: NSS is active-low. */
|
||||
|
||||
stm32_gpiowrite(GPIO_MMCSD_NSS, selected ? 0 : 1);
|
||||
}
|
||||
uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
/* Note: SD_DET is pulled high when there's no SD card present. */
|
||||
|
||||
return stm32_gpioread(GPIO_MMCSD_NCD) ? 0 : 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool selected)
|
||||
{
|
||||
/* Note: I don't know what is on SPI3 yet. */
|
||||
|
||||
spiinfo("devid: %d %s\n",
|
||||
(int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 || CONFIG_STM32_SPI3 */
|
78
configs/omnibusf4/src/stm32_timer.c
Normal file
78
configs/omnibusf4/src/stm32_timer.c
Normal file
@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
* config/omnibusf4/src/stm32_timer.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* With modifications from Calvin Maguranis
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
#include <nuttx/timers/timer.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include "stm32_tim.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_timer_driver_setup
|
||||
*
|
||||
* Description:
|
||||
* Configure the timer driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the timer device. This should be of the
|
||||
* form /dev/timer0
|
||||
* timer - The timer's number.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_timer_driver_setup(FAR const char *devpath, int timer)
|
||||
{
|
||||
return stm32_timer_initialize(devpath, timer);
|
||||
}
|
||||
|
||||
#endif
|
70
configs/omnibusf4/src/stm32_uid.c
Normal file
70
configs/omnibusf4/src/stm32_uid.c
Normal file
@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_uid.c
|
||||
*
|
||||
* Copyright (C) 2015 Marawan Ragab. All rights reserved.
|
||||
* Author: Marawan Ragab <marawan31@gmail.com>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include "stm32_uid.h"
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OK
|
||||
# define OK 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_UNIQUEID)
|
||||
int board_uniqueid(uint8_t *uniqueid)
|
||||
{
|
||||
if (uniqueid == 0)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
stm32_get_uniqueid(uniqueid);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
350
configs/omnibusf4/src/stm32_usb.c
Normal file
350
configs/omnibusf4/src/stm32_usb.c
Normal file
@ -0,0 +1,350 @@
|
||||
/************************************************************************************
|
||||
* configs/omnibusf4/src/stm32_usb.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2012-2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "stm32.h"
|
||||
#include "stm32_otgfs.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(CONFIG_USBDEV) || defined(CONFIG_USBHOST)
|
||||
# define HAVE_USB 1
|
||||
#else
|
||||
# warning "CONFIG_STM32_OTGFS is enabled but neither CONFIG_USBDEV nor CONFIG_USBHOST"
|
||||
# undef HAVE_USB
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_OMNIBUSF4_USBHOST_PRIO
|
||||
# define CONFIG_OMNIBUSF4_USBHOST_PRIO 100
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_OMNIBUSF4_USBHOST_STACKSIZE
|
||||
# define CONFIG_OMNIBUSF4_USBHOST_STACKSIZE 1024
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
static struct usbhost_connection_s *g_usbconn;
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: usbhost_waiter
|
||||
*
|
||||
* Description:
|
||||
* Wait for USB devices to be connected.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
static int usbhost_waiter(int argc, char *argv[])
|
||||
{
|
||||
struct usbhost_hubport_s *hport;
|
||||
|
||||
uinfo("Running\n");
|
||||
for (; ; )
|
||||
{
|
||||
/* Wait for the device to change state */
|
||||
|
||||
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||
uinfo("%s\n", hport->connected ? "connected" : "disconnected");
|
||||
|
||||
/* Did we just become connected? */
|
||||
|
||||
if (hport->connected)
|
||||
{
|
||||
/* Yes.. enumerate the newly connected device */
|
||||
|
||||
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep the compiler from complaining */
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_usbinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called from stm32_usbinitialize very early in inialization to setup USB-related
|
||||
* GPIO pins for the Omnibusf4 board.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void stm32_usbinitialize(void)
|
||||
{
|
||||
/* The OTG FS has an internal soft pull-up. No GPIO configuration is required */
|
||||
|
||||
/* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
stm32_configgpio(GPIO_OTGFS_VBUS);
|
||||
#endif
|
||||
}
|
||||
|
||||
/***********************************************************************************
|
||||
* Name: stm32_usbhost_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called at application startup time to initialize the USB host functionality.
|
||||
* This function will start a thread that will monitor for device
|
||||
* connection/disconnection events.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
int stm32_usbhost_initialize(void)
|
||||
{
|
||||
int pid;
|
||||
#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \
|
||||
defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) || \
|
||||
defined(CONFIG_USBHOST_XBOXCONTROLLER)
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
/* First, register all of the class drivers needed to support the drivers
|
||||
* that we care about:
|
||||
*/
|
||||
|
||||
uinfo("Register class drivers\n");
|
||||
|
||||
#ifdef CONFIG_USBHOST_HUB
|
||||
/* Initialize USB hub class support */
|
||||
|
||||
ret = usbhost_hub_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
uerr("ERROR: usbhost_hub_initialize failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_MSC
|
||||
/* Register the USB mass storage class class */
|
||||
|
||||
ret = usbhost_msc_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to register the mass storage class: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_CDCACM
|
||||
/* Register the CDC/ACM serial class */
|
||||
|
||||
ret = usbhost_cdcacm_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to register the CDC/ACM serial class: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_HIDKBD
|
||||
/* Initialize the HID keyboard class */
|
||||
|
||||
ret = usbhost_kbdinit();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to register the HID keyboard class\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_HIDMOUSE
|
||||
/* Initialize the HID mouse class */
|
||||
|
||||
ret = usbhost_mouse_init();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to register the HID mouse class\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_XBOXCONTROLLER
|
||||
/* Initialize the HID mouse class */
|
||||
|
||||
ret = usbhost_xboxcontroller_init();
|
||||
if (ret != OK)
|
||||
{
|
||||
uerr("ERROR: Failed to register the XBox Controller class\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Then get an instance of the USB host interface */
|
||||
|
||||
uinfo("Initialize USB host\n");
|
||||
g_usbconn = stm32_otgfshost_initialize(0);
|
||||
if (g_usbconn)
|
||||
{
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = kthread_create("usbhost", CONFIG_OMNIBUSF4_USBHOST_PRIO,
|
||||
CONFIG_OMNIBUSF4_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***********************************************************************************
|
||||
* Name: stm32_usbhost_vbusdrive
|
||||
*
|
||||
* Description:
|
||||
* Enable/disable driving of VBUS 5V output. This function must be provided be
|
||||
* each platform that implements the STM32 OTG FS host interface
|
||||
*
|
||||
* "On-chip 5 V VBUS generation is not supported. For this reason, a charge pump
|
||||
* or, if 5 V are available on the application board, a basic power switch, must
|
||||
* be added externally to drive the 5 V VBUS line. The external charge pump can
|
||||
* be driven by any GPIO output. When the application decides to power on VBUS
|
||||
* using the chosen GPIO, it must also set the port power bit in the host port
|
||||
* control and status register (PPWR bit in OTG_FS_HPRT).
|
||||
*
|
||||
* "The application uses this field to control power to this port, and the core
|
||||
* clears this bit on an overcurrent condition."
|
||||
*
|
||||
* Input Parameters:
|
||||
* iface - For future growth to handle multiple USB host interface. Should be zero.
|
||||
* enable - true: enable VBUS power; false: disable VBUS power
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
void stm32_usbhost_vbusdrive(int iface, bool enable)
|
||||
{
|
||||
DEBUGASSERT(iface == 0);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
/* Enable the Power Switch by driving the enable pin low */
|
||||
|
||||
stm32_gpiowrite(GPIO_OTGFS_PWRON, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Disable the Power Switch by driving the enable pin high */
|
||||
|
||||
stm32_gpiowrite(GPIO_OTGFS_PWRON, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_setup_overcurrent
|
||||
*
|
||||
* Description:
|
||||
* Setup to receive an interrupt-level callback if an overcurrent condition is
|
||||
* detected.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handler - New overcurrent interrupt handler
|
||||
* arg - The argument provided for the interrupt handler
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise, a negated errno value is returned
|
||||
* to indicate the nature of the failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
int stm32_setup_overcurrent(xcpt_t handler, void *arg)
|
||||
{
|
||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_usbsuspend
|
||||
*
|
||||
* Description:
|
||||
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is
|
||||
* used. This function is called whenever the USB enters or leaves suspend mode.
|
||||
* This is an opportunity for the board logic to shutdown clocks, power, etc.
|
||||
* while the USB is suspended.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV
|
||||
void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
|
||||
{
|
||||
uinfo("resume: %d\n", resume);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_STM32_OTGFS */
|
87
configs/omnibusf4/src/stm32_usbmsc.c
Normal file
87
configs/omnibusf4/src/stm32_usbmsc.c
Normal file
@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_usbmsc.c
|
||||
*
|
||||
* Copyright (C) 2012, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Configure and register the STM32 SPI-based MMC/SD block driver.
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "stm32.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_SYSTEM_USBMSC_DEVMINOR1
|
||||
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_usbmsc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization of the USB MSC device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_usbmsc_initialize(int port)
|
||||
{
|
||||
/* If system/usbmsc is built as an NSH command, then SD slot should
|
||||
* already have been initialized in board_app_initialize() (see
|
||||
* stm32_appinit.c). In this case, there is nothing further to be done
|
||||
* here.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NSH_BUILTIN_APPS
|
||||
return stm32_sdinitialize(CONFIG_SYSTEM_USBMSC_DEVMINOR1);
|
||||
#else
|
||||
return OK;
|
||||
#endif
|
||||
}
|
237
configs/omnibusf4/src/stm32_userleds.c
Normal file
237
configs/omnibusf4/src/stm32_userleds.c
Normal file
@ -0,0 +1,237 @@
|
||||
/****************************************************************************
|
||||
* configs/omnibusf4/src/stm32_userleds.c
|
||||
*
|
||||
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
|
||||
* Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Bill Gatliff <bgat@billgatliff.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
#include "stm32.h"
|
||||
#include "omnibusf4.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* This array maps an LED number to GPIO pin configuration */
|
||||
|
||||
static uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||
{
|
||||
GPIO_LED1,
|
||||
GPIO_BEEPER1
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Protototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* LED Power Management */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb, int domain,
|
||||
enum pm_state_e pmstate);
|
||||
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
|
||||
enum pm_state_e pmstate);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static struct pm_callback_s g_ledscb =
|
||||
{
|
||||
.notify = led_pm_notify,
|
||||
.prepare = led_pm_prepare,
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_notify
|
||||
*
|
||||
* Description:
|
||||
* Notify the driver of new power state. This callback is called after
|
||||
* all drivers have had the opportunity to prepare for the new power state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb, int domain,
|
||||
enum pm_state_e pmstate)
|
||||
{
|
||||
switch (pmstate)
|
||||
{
|
||||
case(PM_NORMAL):
|
||||
{
|
||||
/* Restore normal LEDs operation */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_IDLE):
|
||||
{
|
||||
/* Entering IDLE mode - Turn leds off */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_STANDBY):
|
||||
{
|
||||
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_SLEEP):
|
||||
{
|
||||
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
/* Should not get here */
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_prepare
|
||||
*
|
||||
* Description:
|
||||
* Request the driver to prepare for a new power state. This is a warning
|
||||
* that the system is about to enter into a new power state. The driver
|
||||
* should begin whatever operations that may be required to enter power
|
||||
* state. The driver may abort the state change mode by returning a
|
||||
* non-zero value from the callback function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
|
||||
enum pm_state_e pmstate)
|
||||
{
|
||||
/* No preparation to change power modes is required by the LEDs driver.
|
||||
* We always accept the state change by returning OK.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_initialize
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_initialize(void)
|
||||
{
|
||||
for (unsigned wled = 0; wled < BOARD_NLEDS; wled++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[wled]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < BOARD_NLEDS)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_all
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_all(uint8_t ledset)
|
||||
{
|
||||
for (unsigned wled = 0; wled < BOARD_NLEDS; wled++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[wled],
|
||||
(ledset & (1 << wled)) == 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_led_pminitialize
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
void stm32_led_pminitialize(void)
|
||||
{
|
||||
/* Register to receive power management callbacks */
|
||||
|
||||
int ret = pm_register(&g_ledscb);
|
||||
if (ret != OK)
|
||||
{
|
||||
board_autoled_on(LED_ASSERTION);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
Loading…
Reference in New Issue
Block a user