mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 16:33:35 +08:00
Merged NuttX
This commit is contained in:
@@ -163,6 +163,57 @@ dtoa():
|
||||
"This product includes software developed by the University of
|
||||
California, Berkeley and its contributors."
|
||||
|
||||
libc/string/lib_vikmemcpy.c
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If you enable CONFIG_MEMCPY_VIK, then you will build with the optimized
|
||||
version of memcpy from Daniel Vik. Licensing information for that version
|
||||
of memcpy() follows:
|
||||
|
||||
Copyright (C) 1999-2010 Daniel Vik
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you
|
||||
use this software in a product, an acknowledgment in the
|
||||
use this software in a product, an acknowledgment in the
|
||||
product documentation would be appreciated but is not
|
||||
required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
libc/math
|
||||
^^^^^^^^^
|
||||
|
||||
If you enable CONFIG_LIB, you will build the math library at libc/math.
|
||||
This library was taken from the math library developed for the Rhombus
|
||||
OS by Nick Johnson (https://github.com/nickbjohnson4224/rhombus). This
|
||||
port was contributed by Darcy Gong. The Rhombus math library has this
|
||||
compatible MIT license:
|
||||
|
||||
Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
|
||||
Documents/rss.gif
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
+197
-1
@@ -3453,7 +3453,7 @@
|
||||
* net/uip/uip_icmpping.c: Fix problem that prevented ping from
|
||||
going outside of local network. Submitted by Darcy Gong
|
||||
|
||||
6.23 2012-09-29 Gregory Nutt <gnutt@nuttx.org>
|
||||
6.23 2012-11-05 Gregory Nutt <gnutt@nuttx.org>
|
||||
|
||||
* arch/arm/src/stm32/stm32_rng.c, chip/stm32_rng.h, and other files:
|
||||
Implementation of /dev/random using the STM32 Random Number
|
||||
@@ -3470,4 +3470,200 @@
|
||||
* configs/shenzhou/*/Make.defs: Now uses the new buildroot 4.6.3
|
||||
EABI toolchain.
|
||||
* lib/stdio/lib_libdtoa.c: Another dtoa() fix from Mike Smith.
|
||||
* configs/shenzhou/src/up_adc.c: Add ADC support for the Shenzhou
|
||||
board (Darcy Gong).
|
||||
* configs/shenzhou/thttpd: Add a THTTPD configuration for the
|
||||
Shenzhou board (Darcy Gong).
|
||||
* include/termios.h and lib/termios/libcf*speed.c: The non-standard,
|
||||
"hidden" c_speed cannot be type const or else static instantiations
|
||||
of termios will be required to initialize it (Mike Smith).
|
||||
* drivers/input/max11802.c/h, and include/nuttx/input max11802.h: Adds
|
||||
support for the Maxim MAX11802 touchscreen controller (contributed by
|
||||
Petteri Aimonen).
|
||||
* graphics/nxtk/nxtk_events.c: Missing implementation of the blocked
|
||||
method. This is a critical bugfix for graphics support (contributed
|
||||
by Petteri Aimonen).
|
||||
* drivers/usbdev/pl2303.c, drivers/usbdev/usbmsc.h, and
|
||||
include/nuttx/usb/cdcacm.h: USB_CONFIG_ATTR_SELFPOWER vs.
|
||||
USB_CONFIG_ATT_SELFPOWER (contributed by Petteri Aimonen).
|
||||
* arch/arm/src/armv7-m/up_memcpy.S: An optimized memcpy() function for
|
||||
the ARMv7-M family contributed by Mike Smith.
|
||||
* lib/strings/lib_vikmemcpy.c: As an option, the larger but faster
|
||||
implemementation of memcpy from Daniel Vik is now available (this is
|
||||
from http://www.danielvik.com/2010/02/fast-memcpy-in-c.html).
|
||||
* lib/strings/lib_memset.c: CONFIG_MEMSET_OPTSPEED will select a
|
||||
version of memset() optimized for speed. By default, memset() is
|
||||
optimized for size.
|
||||
* lib/strings/lib_memset.c: CONFIG_MEMSET_64BIT will perform 64-bit
|
||||
aligned memset() operations.
|
||||
* arch/arm/src/stm32/stm32_adc.c: Need to put the ADC back into the
|
||||
initial reset in the open/setup logic. Opening the ADC driver works
|
||||
the first time, but not the second because the device is left in a
|
||||
powered down state on the last close.
|
||||
* configs/olimex-lpc1766stck/scripts: Replace all of the identical
|
||||
ld.script files with the common one in this directory.
|
||||
* configs/stm3220g-eval/scripts: Replace all of the identical
|
||||
ld.script files with the common one in this directory.
|
||||
* configs/hymini-stm32v/scripts: Replace all of the identical
|
||||
ld.script files with the common one in this directory.
|
||||
* configs/lpcxpresso-lpc1768/scripts: Replace all of the identical
|
||||
ld.script files with the common one in this directory.
|
||||
* binfmt/elf.c, binfmt/libelf, include/elf.h, include/nuttx/elf.h: Add
|
||||
basic framework for loadable ELF module support. The initial check-
|
||||
in is non-functional and is simply the framework for ELF support.
|
||||
* include/nuttx/binfmt.h, nxflat.h, elf.h, and symtab.h: Moved to
|
||||
include/nuttx/binfmt/.
|
||||
* arch/sim/src/up_elf.c and arch/x86/src/common/up_elf.c: Add
|
||||
for ELF modules.
|
||||
* arch/arm/include/elf.h: Added ARM ELF header file.
|
||||
* include/elf32.h: Renamed elf.h to elf32.h.
|
||||
* configs/stm32f4discovery/ostest: Converted to use the new
|
||||
Kconfig-based configuration system.
|
||||
* configs/stm32f4discovery/elf and configs/stm32f4discovery/scripts/gnu-elf.ld
|
||||
Add a configuration for testing the ARM ELF loader.
|
||||
* binfmt/libelf: Can't use fstat(). NuttX does not yet support it. Damn!
|
||||
* binfmt/libelf: The basic ELF module execution appears fully functional.
|
||||
* configs/shenzhou/src/up_relays.c: Add support for relays from the
|
||||
Shenzhou board. Contributed by Darcy Gong.
|
||||
* lib/fixedmath: Moved the old lib/math to lib/fixedmath to make room for
|
||||
the math library from the Rhombus OS
|
||||
* lib/math: Now contains the math library from the Rhombus OS by Nick Johnson
|
||||
(submitted by Darcy Gong).
|
||||
* include/float.h: Add a first cut at the float.h header file. This
|
||||
really should be an architecture/toolchain-specific header file. It
|
||||
is only used if CONFIG_ARCH_FLOAT_H is defined.
|
||||
* lib/math: Files now conform to coding standards. Separated float,
|
||||
double, and long double versions of code into separate files so that
|
||||
they don't draw in so much un-necessary code when doing a dumb link.
|
||||
* binfmt/libelf: The ELF loader is working correctly with C++ static
|
||||
constructors and destructors and all.
|
||||
* Documentation/NuttXBinfmt.html: Add documentation of the binary loader.
|
||||
* configs/sim/ostest: Converted to use the mconfig configuration tool.
|
||||
* configs/sim/cxxtest: New test that will be used to verify the uClibc++
|
||||
port (eventually).
|
||||
* include/nuttx/fs/fs.h, lib/stdio/lib_libfread.c, lib_ferror.c,
|
||||
lib_feof.c, and lib_clearerr.c: Add support for ferror(), feof(),
|
||||
and clearerror(). ferror() support is bogus at the moment (it
|
||||
is equivalent to !feof()); the others should be good.
|
||||
* configs/stm32f4discovery/include/board.h: Correct timer 2-7
|
||||
base frequency (provided by Freddie Chopin).
|
||||
* include/nuttx/sched.h, sched/atexit.c, and sched/task_deletehook.c:
|
||||
If both atexit() and on_exit() are enabled, then implement atexit()
|
||||
as just a special caseof on_exit(). This assumes that the ABI can
|
||||
handle receipt of more call parameters than the receiving function
|
||||
expects. That is usually the case if parameters are passed in
|
||||
registers.
|
||||
* libxx/libxx_cxa_atexit(): Implements __cxa_atexit()
|
||||
* configs/stm32f4discovery/cxxtest: New test that will be used to
|
||||
verify the uClibc++ port (eventually). The sim platform turned not
|
||||
to be a good platform for testing uClibc++. The sim example will not
|
||||
run because the simulator will attempt to execute the static
|
||||
constructors before main() starts. BUT... NuttX is not initialized
|
||||
and this results in a crash. On the STM324Discovery, I will have
|
||||
better control over when the static constructors run.
|
||||
* RGMP 4.0 updated from Qiany Yu.
|
||||
* configs/*/Make.defs and configs/*/ld.script: Massive clean-up
|
||||
and standardization of linker scripts from Freddie Chopin.
|
||||
* net/netdev_ioctl.c: Add interface state flags and ioctl calls
|
||||
to bring network interfaces up and down (from Darcy Gong).
|
||||
* config/stm32f4discovery: Enable C++ exceptions. Now the entire
|
||||
apps/examples/cxxtest works -- meaning the the uClibc++ is
|
||||
complete and verified for the STM32 platform.
|
||||
|
||||
6.24 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
|
||||
|
||||
* arch/arm/src/stm32: Support for STM32F100 high density chips
|
||||
added by Freddie Chopin.
|
||||
* configs/stm32f100_generic: Support for generic STM32F100RC board
|
||||
contributed by Freddie Chopin.
|
||||
* arch/arm/src/stm32_otgfsdev.c: Partial fix from Petteri Aimonen.
|
||||
* drivers/lcd/ug-2864ambag01.c and include/nuttx/lcd/ug_2864ambag01.h:
|
||||
LCD driver for the Univision OLED of the same name (untested on
|
||||
initial check-in).
|
||||
* configs/stm32f4discovery/nxlines: Configure to use mconf/Kconfig
|
||||
tool.
|
||||
* configs/stm32f4discovery/src/up_ug2864ambag01.c: Board-specific
|
||||
initialization for UG-2864AMBAG01 OLED connecte to STM32F4Disovery.
|
||||
* libxx/libxx_stdthrow.cxx: Exception stubs from Petteri Aimonen.
|
||||
* configs/stm32f4discovery/src/up_ug2864ambag01.c: Driver has been
|
||||
verified on the STM32F4Discovery platform. Some tuning of the
|
||||
configuration could improve the presentation. Lower resolution displays
|
||||
are also more subject to the "fat, flat line bug" that I need to fix
|
||||
someday. See http://www.nuttx.org/doku.php?id=wiki:graphics:nxgraphics
|
||||
for a description of the fat, flat line bug.
|
||||
* libc: Renamed nuttx/lib to nuttx/libc to make space for a true lib/
|
||||
directory that will be forthcoming. Also rename libraries: liblib.a -> libc.a,
|
||||
libulib.a -> libuc.a, libklib.a -> libkc.a, liblibxx.a ->libcxx.a.
|
||||
(I will probably, eventually rename libxx to libcxx for consistency)
|
||||
* Makefile, lib/: A new, empty directory that will hold generated libraries.
|
||||
This simplifies the library patch calculations and lets me get rid of some
|
||||
bash logic. The change is functional, but only partially complete;
|
||||
additional logic is needed in the arch/*/src/Makefile's as well. Right
|
||||
now that logic generate multiple library paths, all pointing to the lib/
|
||||
directory.
|
||||
* arch/*/src/Makefile: Now uses only the libraries in lib/
|
||||
Replace bash fragments that test for board/Makefile.
|
||||
* Makefile.win: The beginnings of a Windows-native build. This is just
|
||||
the begining and not yet ready for prime time use.
|
||||
* configs/stm32f4discovery/winbuild: This is a version of the standard
|
||||
NuttX OS test, but configured to build natively on Windows. Its only
|
||||
real purpose is to very the native Windows build logic.
|
||||
* tools/mkdeps.bat and tools/mkdeps.c: mkdeps.bat is a failed attempt
|
||||
to leverage mkdeps.sh to CMD.exe. It fails because the are certain
|
||||
critical CFLAG values that cannot be passed on the CMD.exe command line
|
||||
(line '='). mkdeps.c is a work in progress that will, hopefully,
|
||||
replace both mkdeps.sh and mkdeps.bat.
|
||||
* tools/Config.mk: Centralize the definition of the scrpt that will be
|
||||
used to generated header file include paths for the compiler. This
|
||||
needs to be centralized in order to support the Windows native build.
|
||||
* tools/incdir.bat: A replaced for tools/incdir.sh for use with the
|
||||
the Windows native build.
|
||||
* Makefile.unix: The existing top-level Makefile has been renamed
|
||||
Makefile.unix.
|
||||
* Makefile: This is a new top-level Makefile that just includes
|
||||
either Makefile.unix or Makefile.win
|
||||
* configs/stm3240g-eval/src: Qencoder fixes from Ryan Sundberg.
|
||||
* arch/arm/src/stm32/stm32_qencoder.c: TIM3 bug fix from Ryan Sundberg.
|
||||
* tools/mkromfsimg.sh: Correct typo in an error message (Ryan Sundberg)
|
||||
* arch/*/src/Makefile: Remove tftboot install and creation of System.map
|
||||
for Windows native build. The fist is necessary, the second just needs
|
||||
re-implemented.
|
||||
* configs/mirtoo: Update Mirtoo pin definitions for Release 2. Provided
|
||||
by Konstantin Dimitrov.
|
||||
* Fixed an uninitialized variable in the file system that can cause
|
||||
assertions if DEBUG on (contributed by Lorenz Meier).
|
||||
* Config.mk: Defined DELIM to be either / or \, depending upon
|
||||
CONFIG_WINDOWS_NATIVE. This will allow me to eliminate a lot of
|
||||
conditional logic elsewhere.
|
||||
* nuttx/graphics: One a mouse button is pressed, continue to report all
|
||||
mouse button events to the first window that received the the initial
|
||||
button down event, even if the mouse attempts to dray outside the
|
||||
window. From Petteri Aimonen.
|
||||
* nuttx/graphics/nxmu/nx_block.c: One more fixe to the NX block message
|
||||
logic from Petteri Aimonen.
|
||||
* include/nuttx/wqueue.h: Some basic definitions to support a user-
|
||||
space work queue (someday in the future).
|
||||
* graphics/nxmu: Add semaphores so buffers messages that send buffers
|
||||
will block until the buffer data has been acted upon.
|
||||
* graphics/nxmw: Extended the blocked messages to cover mouse movement
|
||||
and redraw events. These will also cause problems if sent to a window
|
||||
while it is closing.
|
||||
* arch/several: Change UARTs are enabled for i.MX, LM3S, ez80, and M16C to
|
||||
match how they are enabled for other architectures.
|
||||
* configs/ez80f910200kitg: Convert to use mconf configuration.
|
||||
* sched/pause.c: Implements the POSIX pause() function.
|
||||
* ez80: Lots of changes to ez80 configurations and build logic as I
|
||||
struggle to get a clean Windows build (still not working).
|
||||
* tools/prebuild.py: A Python script for Darcy Gong that can automate
|
||||
many build/configuration operations.
|
||||
* configs/cloudctrl: Darcy Gong's CloudController board. This is a
|
||||
small network relay development board. Based on the Shenzhou IV development
|
||||
board design. It is based on the STM32F107VC MCU.
|
||||
* Lots of build files: ARMv7-M and MIPS32 Make.defs now include a common
|
||||
Toolchain.defs file that can be used to manage toolchains in a more
|
||||
configurable way. Contributed by Mike Smith
|
||||
* configs/stm32f4discovery/winbuild and configs/cloudctrl: Adapted to use
|
||||
Mike's Toolchain.defs.
|
||||
* tools/configure.sh: Adapted to handle paths and setenv.bat files correctly
|
||||
for native Windows builds.
|
||||
|
||||
|
||||
+106
-6
@@ -20,10 +20,75 @@ menu "Build Setup"
|
||||
config EXPERIMENTAL
|
||||
bool "Prompt for development and/or incomplete code/drivers"
|
||||
|
||||
choice
|
||||
prompt "Build Host Platform"
|
||||
default HOST_LINUX
|
||||
|
||||
config HOST_LINUX
|
||||
bool "Linux"
|
||||
|
||||
config HOST_OSX
|
||||
bool "OSX"
|
||||
|
||||
config HOST_WINDOWS
|
||||
bool "Windows"
|
||||
|
||||
config HOST_OTHER
|
||||
bool "Other"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Windows Build Environment"
|
||||
default WINDOWS_CYGWIN
|
||||
depends on HOST_WINDOWS
|
||||
|
||||
config WINDOWS_NATIVE
|
||||
bool "Windows Native"
|
||||
---help---
|
||||
Build natively in a CMD.exe environment with Windows style paths (like C:\cgywin\home)
|
||||
|
||||
config WINDOWS_CYGWIN
|
||||
bool "Cygwin"
|
||||
- --help---
|
||||
Build natively in a Cygwin environment with POSIX style paths (like /cygdrive/c/cgywin/home)
|
||||
|
||||
config WINDOWS_MSYS
|
||||
bool "MSYS"
|
||||
---help---
|
||||
Build natively in a Cygwin environment with POSIX style paths (like /cygdrive/c/cgywin/home)
|
||||
|
||||
config WINDOWS_OTHER
|
||||
bool "Windows POSIX-like environment"
|
||||
---help---
|
||||
Build natively in another POSIX-like environment. Additional support may be necessary
|
||||
|
||||
endchoice
|
||||
|
||||
config WINDOWS_MKLINK
|
||||
bool "Use mklink"
|
||||
default n
|
||||
depends on WINDOWS_NATIVE
|
||||
---help---
|
||||
Use the mklink command to set up symbolic links when NuttX is
|
||||
configured. Otherwise, configuration directories will be copied to
|
||||
establish the configuration.
|
||||
|
||||
If directories are copied, then some confusion can result ("Which
|
||||
version of the file did I modify?"). In that case, it is recommended
|
||||
that you re-build using 'make clean_context all'. That will cause the
|
||||
configured directories to be recopied on each build.
|
||||
|
||||
NOTE: This option also (1) that you have administrator privileges, (2)
|
||||
that you are using Windows 2000 or better, and (3) that you are using
|
||||
the NTFS file system. Select 'n' is that is not the case.
|
||||
|
||||
menu "Build Configuration"
|
||||
|
||||
config APPS_DIR
|
||||
string "Application directory"
|
||||
default "../apps"
|
||||
default "../apps" if !WINDOWS_NATIVE
|
||||
default "..\apps" if WINDOWS_NATIVE
|
||||
---help---
|
||||
Identifies the directory that builds the
|
||||
application to link with NuttX. Default: ../apps This symbol must be assigned
|
||||
@@ -192,6 +257,17 @@ config ARCH_MATH_H
|
||||
that don't select ARCH_MATH_H, the redirecting math.h header file
|
||||
will stay out-of-the-way in include/nuttx/.
|
||||
|
||||
config ARCH_FLOAT_H
|
||||
bool "float.h"
|
||||
default n
|
||||
---help---
|
||||
The float.h header file defines the properties of your floating
|
||||
point implementation. It would always be best to use your
|
||||
toolchain's float.h header file but if none is avaiable, a default
|
||||
float.h header file will provided if this option is selected. However
|
||||
there is no assurance that the settings in this float.h are actually
|
||||
correct for your platform!
|
||||
|
||||
config ARCH_STDARG_H
|
||||
bool "stdarg.h"
|
||||
default n
|
||||
@@ -244,17 +320,24 @@ config DEBUG_ENABLE
|
||||
|
||||
comment "Subsystem Debug Options"
|
||||
|
||||
config DEBUG_MM
|
||||
bool "Enable Memory Manager Debug Output"
|
||||
default n
|
||||
---help---
|
||||
Enable memory management debug output (disabled by default)
|
||||
|
||||
config DEBUG_SCHED
|
||||
bool "Enable Scheduler Debug Output"
|
||||
default n
|
||||
---help---
|
||||
Enable OS debug output (disabled by default)
|
||||
|
||||
config DEBUG_MM
|
||||
bool "Enable Memory Manager Debug Output"
|
||||
config DEBUG_PAGING
|
||||
bool "Enable Demand Paging Debug Output"
|
||||
default n
|
||||
depends on PAGING
|
||||
---help---
|
||||
Enable memory management debug output (disabled by default)
|
||||
Enable demand paging debug output (disabled by default)
|
||||
|
||||
config DEBUG_NET
|
||||
bool "Enable Network Debug Output"
|
||||
@@ -311,6 +394,13 @@ config DEBUG_INPUT
|
||||
Enable low level debug output from the input device drivers such as
|
||||
mice and touchscreens (disabled by default)
|
||||
|
||||
config DEBUG_ANALOG
|
||||
bool "Enable Analog Device Debug Output"
|
||||
default n
|
||||
---help---
|
||||
Enable low level debug output from the analog device drivers such as
|
||||
A/D and D/A converters (disabled by default)
|
||||
|
||||
config DEBUG_I2C
|
||||
bool "Enable I2C Debug Output"
|
||||
default n
|
||||
@@ -325,12 +415,18 @@ config DEBUG_SPI
|
||||
---help---
|
||||
Enable I2C driver debug output (disabled by default)
|
||||
|
||||
config DEBUG_DMA
|
||||
bool "Enable DMA Debug Output"
|
||||
default n
|
||||
---help---
|
||||
Enable DMA-releated debug output (disabled by default)
|
||||
|
||||
config DEBUG_WATCHDOG
|
||||
bool "Enable Watchdog Timer Debug Output"
|
||||
default n
|
||||
depends on WATCHDOG
|
||||
---help---
|
||||
Enable watchdog timer debug output (disabled by default)
|
||||
Enable watchdog timer debug output (disabled by default)
|
||||
|
||||
endif
|
||||
|
||||
@@ -375,8 +471,12 @@ menu "Memory Management"
|
||||
source mm/Kconfig
|
||||
endmenu
|
||||
|
||||
menu "Binary Formats"
|
||||
source binfmt/Kconfig
|
||||
endmenu
|
||||
|
||||
menu "Library Routines"
|
||||
source lib/Kconfig
|
||||
source libc/Kconfig
|
||||
source libxx/Kconfig
|
||||
endmenu
|
||||
|
||||
|
||||
+12
-614
@@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||
# 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
|
||||
@@ -33,619 +33,17 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
TOPDIR := ${shell pwd | sed -e 's/ /\\ /g'}
|
||||
-include ${TOPDIR}/.config
|
||||
-include ${TOPDIR}/tools/Config.mk
|
||||
-include ${TOPDIR}/Make.defs
|
||||
# This is a top-level "kludge" Makefile that just includes the correct
|
||||
# Makefile. If you already know the Makefile that you want, you can skip
|
||||
# this nonsense using:
|
||||
#
|
||||
# make -f Makefile.unix, OR
|
||||
# make -f Makefile.win
|
||||
#
|
||||
|
||||
# Control build verbosity
|
||||
|
||||
ifeq ($(V),1)
|
||||
export Q :=
|
||||
-include .config
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
include Makefile.win
|
||||
else
|
||||
export Q := @
|
||||
include Makefile.unix
|
||||
endif
|
||||
|
||||
# Default tools
|
||||
|
||||
ifeq ($(DIRLINK),)
|
||||
DIRLINK = $(TOPDIR)/tools/link.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
endif
|
||||
|
||||
# This define is passed as EXTRADEFINES for kernel-mode builds. It is also passed
|
||||
# during PASS1 (but not PASS2) context and depend targets.
|
||||
|
||||
KDEFINE = ${shell $(TOPDIR)/tools/define.sh $(CC) __KERNEL__}
|
||||
|
||||
# Process architecture and board-specific directories
|
||||
|
||||
ARCH_DIR = arch/$(CONFIG_ARCH)
|
||||
ARCH_SRC = $(ARCH_DIR)/src
|
||||
ARCH_INC = $(ARCH_DIR)/include
|
||||
BOARD_DIR = configs/$(CONFIG_ARCH_BOARD)
|
||||
|
||||
# Add-on directories. These may or may not be in place in the
|
||||
# NuttX source tree (they must be specifically installed)
|
||||
#
|
||||
# CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file.
|
||||
# The default value of CONFIG_APPS_DIR is ../apps. Ultimately, the application
|
||||
# will be built if APPDIR is defined. APPDIR will be defined if a directory containing
|
||||
# a Makefile is found at the path provided by CONFIG_APPS_DIR
|
||||
|
||||
ifeq ($(CONFIG_APPS_DIR),)
|
||||
CONFIG_APPS_DIR = ../apps
|
||||
endif
|
||||
APPDIR := ${shell if [ -r $(CONFIG_APPS_DIR)/Makefile ]; then echo "$(CONFIG_APPS_DIR)"; fi}
|
||||
|
||||
# All add-on directories.
|
||||
#
|
||||
# NUTTX_ADDONS is the list of directories built into the NuttX kernel.
|
||||
# USER_ADDONS is the list of directories that will be built into the user application
|
||||
|
||||
NUTTX_ADDONS := $(NX_DIR)
|
||||
USER_ADDONS :=
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USER_ADDONS += $(APPDIR)
|
||||
else
|
||||
NUTTX_ADDONS += $(APPDIR)
|
||||
endif
|
||||
|
||||
# Lists of build directories.
|
||||
#
|
||||
# FSDIRS depend on file descriptor support; NONFSDIRS do not (except for parts
|
||||
# of FSDIRS). We will exclude FSDIRS from the build if file descriptor
|
||||
# support is disabled
|
||||
# CONTEXTDIRS include directories that have special, one-time pre-build
|
||||
# requirements. Normally this includes things like auto-generation of
|
||||
# configuration specific files or creation of configurable symbolic links
|
||||
# USERDIRS - When NuttX is build is a monolithic kernel, this provides the
|
||||
# list of directories that must be built
|
||||
# OTHERDIRS - These are directories that are not built but probably should
|
||||
# be cleaned to prevent garbarge from collecting in them when changing
|
||||
# configurations.
|
||||
|
||||
NONFSDIRS = sched $(ARCH_SRC) $(NUTTX_ADDONS)
|
||||
FSDIRS = fs drivers binfmt
|
||||
CONTEXTDIRS = $(APPDIR)
|
||||
USERDIRS =
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
|
||||
NONFSDIRS += syscall
|
||||
CONTEXTDIRS += syscall
|
||||
USERDIRS += syscall lib mm $(USER_ADDONS)
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
USERDIRS += libxx
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
NONFSDIRS += lib mm
|
||||
OTHERDIRS += syscall $(USER_ADDONS)
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
NONFSDIRS += libxx
|
||||
else
|
||||
OTHERDIRS += libxx
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
NONFSDIRS += graphics
|
||||
CONTEXTDIRS += graphics
|
||||
else
|
||||
OTHERDIRS += graphics
|
||||
endif
|
||||
|
||||
# CLEANDIRS are the directories that will clean in. These are
|
||||
# all directories that we know about.
|
||||
# KERNDEPDIRS are the directories in which we will build target dependencies.
|
||||
# If NuttX and applications are built separately (CONFIG_NUTTX_KERNEL),
|
||||
# then this holds only the directories containing kernel files.
|
||||
# USERDEPDIRS. If NuttX and applications are built separately (CONFIG_NUTTX_KERNEL),
|
||||
# then this holds only the directories containing user files.
|
||||
|
||||
CLEANDIRS = $(NONFSDIRS) $(FSDIRS) $(USERDIRS) $(OTHERDIRS)
|
||||
KERNDEPDIRS = $(NONFSDIRS)
|
||||
USERDEPDIRS = $(USERDIRS)
|
||||
|
||||
# Add file system directories to KERNDEPDIRS (they are already in CLEANDIRS)
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
KERNDEPDIRS += fs
|
||||
endif
|
||||
KERNDEPDIRS += drivers
|
||||
endif
|
||||
else
|
||||
KERNDEPDIRS += $(FSDIRS)
|
||||
endif
|
||||
|
||||
# Add networking directories to KERNDEPDIRS and CLEANDIRS
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
KERNDEPDIRS += net
|
||||
endif
|
||||
CLEANDIRS += net
|
||||
|
||||
#
|
||||
# Extra objects used in the final link.
|
||||
#
|
||||
# Pass 1 1ncremental (relative) link objects should be put into the
|
||||
# processor-specific source directory (where other link objects will
|
||||
# be created). If the pass1 obect is an archive, it could go anywhere.
|
||||
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
EXTRA_OBJS += $(CONFIG_PASS1_OBJECT)
|
||||
endif
|
||||
|
||||
# NUTTXLIBS is the list of NuttX libraries that is passed to the
|
||||
# processor-specific Makefile to build the final NuttX target.
|
||||
# Libraries in FSDIRS are excluded if file descriptor support
|
||||
# is disabled.
|
||||
# USERLIBS is the list of libraries used to build the final user-space
|
||||
# application
|
||||
|
||||
NUTTXLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT)
|
||||
USERLIBS =
|
||||
|
||||
# Add libraries for syscall support. The C library will be needed by
|
||||
# both the kernel- and user-space builds. For now, the memory manager (mm)
|
||||
# is placed in user space (only).
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
NUTTXLIBS += syscall/libstubs$(LIBEXT) lib/libklib$(LIBEXT)
|
||||
USERLIBS += syscall/libproxies$(LIBEXT) lib/libulib$(LIBEXT) mm/libmm$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += mm/libmm$(LIBEXT) lib/liblib$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for C++ support. CXX, CXXFLAGS, and COMPILEXX must
|
||||
# be defined in Make.defs for this to work!
|
||||
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USERLIBS += libxx/liblibxx$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += libxx/liblibxx$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add library for application support.
|
||||
|
||||
ifneq ($(APPDIR),)
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USERLIBS += $(APPDIR)/libapps$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += $(APPDIR)/libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add libraries for network support
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
NUTTXLIBS += net/libnet$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for file system support
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
NUTTXLIBS += fs/libfs$(LIBEXT)
|
||||
endif
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
NUTTXLIBS += drivers/libdrivers$(LIBEXT)
|
||||
endif
|
||||
else
|
||||
NUTTXLIBS += fs/libfs$(LIBEXT) drivers/libdrivers$(LIBEXT) binfmt/libbinfmt$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for the NX graphics sub-system
|
||||
|
||||
ifneq ($(NX_DIR),)
|
||||
NUTTXLIBS += $(NX_DIR)/libnx$(LIBEXT)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
NUTTXLIBS += graphics/libgraphics$(LIBEXT)
|
||||
endif
|
||||
|
||||
# This is the name of the final target (relative to the top level directorty)
|
||||
|
||||
BIN = nuttx$(EXEEXT)
|
||||
|
||||
all: $(BIN)
|
||||
.PHONY: context clean_context check_context export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
|
||||
|
||||
# Target used to copy include/nuttx/math.h. If CONFIG_ARCH_MATH_H is
|
||||
# defined, then there is an architecture specific math.h header file
|
||||
# that will be included indirectly from include/math.h. But first, we
|
||||
# have to copy math.h from include/nuttx/. to include/.
|
||||
|
||||
ifeq ($(CONFIG_ARCH_MATH_H),y)
|
||||
include/math.h: include/nuttx/math.h
|
||||
@cp -f include/nuttx/math.h include/math.h
|
||||
else
|
||||
include/math.h:
|
||||
endif
|
||||
|
||||
# Target used to copy include/nuttx/stdarg.h. If CONFIG_ARCH_STDARG_H is
|
||||
# defined, then there is an architecture specific stdarg.h header file
|
||||
# that will be included indirectly from include/stdarg.h. But first, we
|
||||
# have to copy stdarg.h from include/nuttx/. to include/.
|
||||
|
||||
ifeq ($(CONFIG_ARCH_STDARG_H),y)
|
||||
include/stdarg.h: include/nuttx/stdarg.h
|
||||
@cp -f include/nuttx/stdarg.h include/stdarg.h
|
||||
else
|
||||
include/stdarg.h:
|
||||
endif
|
||||
|
||||
# Targets used to build include/nuttx/version.h. Creation of version.h is
|
||||
# part of the overall NuttX configuration sequence. Notice that the
|
||||
# tools/mkversion tool is built and used to create include/nuttx/version.h
|
||||
|
||||
tools/mkversion:
|
||||
@$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion
|
||||
|
||||
$(TOPDIR)/.version:
|
||||
@if [ ! -f .version ]; then \
|
||||
echo "No .version file found, creating one"; \
|
||||
tools/version.sh -v 0.0 -b 0 .version; \
|
||||
chmod 755 .version; \
|
||||
fi
|
||||
|
||||
include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion
|
||||
@tools/mkversion $(TOPDIR) > include/nuttx/version.h
|
||||
|
||||
# Targets used to build include/nuttx/config.h. Creation of config.h is
|
||||
# part of the overall NuttX configuration sequence. Notice that the
|
||||
# tools/mkconfig tool is built and used to create include/nuttx/config.h
|
||||
|
||||
tools/mkconfig:
|
||||
@$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig
|
||||
|
||||
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig
|
||||
@tools/mkconfig $(TOPDIR) > include/nuttx/config.h
|
||||
|
||||
# dirlinks, and helpers
|
||||
#
|
||||
# Directories links. Most of establishing the NuttX configuration involves
|
||||
# setting up symbolic links with 'generic' directory names to specific,
|
||||
# configured directories.
|
||||
#
|
||||
# Link the apps/include directory to include/apps
|
||||
|
||||
include/apps: Make.defs
|
||||
ifneq ($(APPDIR),)
|
||||
@if [ -d $(TOPDIR)/$(APPDIR)/include ]; then \
|
||||
$(DIRLINK) $(TOPDIR)/$(APPDIR)/include include/apps; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Link the arch/<arch-name>/include directory to include/arch
|
||||
|
||||
include/arch: Make.defs
|
||||
@$(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
|
||||
|
||||
# Link the configs/<board-name>/include directory to include/arch/board
|
||||
|
||||
include/arch/board: include/arch Make.defs include/arch
|
||||
@$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
|
||||
|
||||
# Link the configs/<board-name>/src dir to arch/<arch-name>/src/board
|
||||
|
||||
$(ARCH_SRC)/board: Make.defs
|
||||
@$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
|
||||
|
||||
# Link arch/<arch-name>/include/<chip-name> to arch/<arch-name>/include/chip
|
||||
|
||||
$(ARCH_SRC)/chip: Make.defs
|
||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
@$(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
|
||||
endif
|
||||
|
||||
# Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
|
||||
|
||||
include/arch/chip: include/arch Make.defs
|
||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
@$(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
|
||||
endif
|
||||
|
||||
dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip include/apps
|
||||
|
||||
# context
|
||||
#
|
||||
# The context target is invoked on each target build to assure that NuttX is
|
||||
# properly configured. The basic configuration steps include creation of the
|
||||
# the config.h and version.h header files in the include/nuttx directory and
|
||||
# the establishment of symbolic links to configured directories.
|
||||
|
||||
context: check_context include/nuttx/config.h include/nuttx/version.h include/math.h include/stdarg.h dirlinks
|
||||
@for dir in $(CONTEXTDIRS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" context; \
|
||||
done
|
||||
|
||||
# clean_context
|
||||
#
|
||||
# This is part of the distclean target. It removes all of the header files
|
||||
# and symbolic links created by the context target.
|
||||
|
||||
clean_context:
|
||||
@rm -f include/nuttx/config.h
|
||||
@rm -f include/nuttx/version.h
|
||||
@rm -f include/math.h
|
||||
@rm -f include/stdarg.h
|
||||
@$(DIRUNLINK) include/arch/board
|
||||
@$(DIRUNLINK) include/arch/chip
|
||||
@$(DIRUNLINK) include/arch
|
||||
@$(DIRUNLINK) $(ARCH_SRC)/board
|
||||
@$(DIRUNLINK) $(ARCH_SRC)/chip
|
||||
@$(DIRUNLINK) include/apps
|
||||
|
||||
# check_context
|
||||
#
|
||||
# This target checks if NuttX has been configured. NuttX is configured using
|
||||
# the script tools/configure.sh. That script will install certain files in
|
||||
# the top-level NuttX build directory. This target verifies that those
|
||||
# configuration files have been installed and that NuttX is ready to be built.
|
||||
|
||||
check_context:
|
||||
@if [ ! -e ${TOPDIR}/.config -o ! -e ${TOPDIR}/Make.defs ]; then \
|
||||
echo "" ; echo "Nuttx has not been configured:" ; \
|
||||
echo " cd tools; ./configure.sh <target>" ; echo "" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
# Archive targets. The target build sequency will first create a series of
|
||||
# libraries, one per configured source file directory. The final NuttX
|
||||
# execution will then be built from those libraries. The following targets
|
||||
# built those libraries.
|
||||
#
|
||||
# Possible kernel-mode builds
|
||||
|
||||
lib/libklib$(LIBEXT): context
|
||||
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" libklib$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
sched/libsched$(LIBEXT): context
|
||||
@$(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
$(ARCH_SRC)/libarch$(LIBEXT): context
|
||||
@$(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
net/libnet$(LIBEXT): context
|
||||
@$(MAKE) -C net TOPDIR="$(TOPDIR)" libnet$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
fs/libfs$(LIBEXT): context
|
||||
@$(MAKE) -C fs TOPDIR="$(TOPDIR)" libfs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
drivers/libdrivers$(LIBEXT): context
|
||||
@$(MAKE) -C drivers TOPDIR="$(TOPDIR)" libdrivers$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
binfmt/libbinfmt$(LIBEXT): context
|
||||
@$(MAKE) -C binfmt TOPDIR="$(TOPDIR)" libbinfmt$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
graphics/libgraphics$(LIBEXT): context
|
||||
@$(MAKE) -C graphics TOPDIR="$(TOPDIR)" libgraphics$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
syscall/libstubs$(LIBEXT): context
|
||||
@$(MAKE) -C syscall TOPDIR="$(TOPDIR)" libstubs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
# Possible user-mode builds
|
||||
|
||||
lib/libulib$(LIBEXT): context
|
||||
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" libulib$(LIBEXT)
|
||||
|
||||
libxx/liblibxx$(LIBEXT): context
|
||||
@$(MAKE) -C libxx TOPDIR="$(TOPDIR)" liblibxx$(LIBEXT)
|
||||
|
||||
mm/libmm$(LIBEXT): context
|
||||
@$(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
$(APPDIR)/libapps$(LIBEXT): context
|
||||
@$(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
|
||||
|
||||
syscall/libproxies$(LIBEXT): context
|
||||
@$(MAKE) -C syscall TOPDIR="$(TOPDIR)" libproxies$(LIBEXT)
|
||||
|
||||
# Possible non-kernel builds
|
||||
|
||||
lib/liblib$(LIBEXT): context
|
||||
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" liblib$(LIBEXT)
|
||||
|
||||
# pass1 and pass2
|
||||
#
|
||||
# If the 2 pass build option is selected, then this pass1 target is
|
||||
# configured to built before the pass2 target. This pass1 target may, as an
|
||||
# example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
|
||||
# incremental (relative) link object, but could be a static library (archive);
|
||||
# some modification to this Makefile would be required if CONFIG_PASS1_OBJECT
|
||||
# is an archive. Exactly what is performed during pass1 or what it generates
|
||||
# is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined.
|
||||
|
||||
pass1deps: context pass1dep $(USERLIBS)
|
||||
|
||||
pass1: pass1deps
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
@if [ -z "$(CONFIG_PASS1_BUILDIR)" ]; then \
|
||||
echo "ERROR: CONFIG_PASS1_BUILDIR not defined"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if [ ! -d "$(CONFIG_PASS1_BUILDIR)" ]; then \
|
||||
echo "ERROR: CONFIG_PASS1_BUILDIR does not exist"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if [ ! -f "$(CONFIG_PASS1_BUILDIR)/Makefile" ]; then \
|
||||
echo "ERROR: No Makefile in CONFIG_PASS1_BUILDIR"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(NUTTXLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
|
||||
endif
|
||||
|
||||
pass2deps: context pass2dep $(NUTTXLIBS)
|
||||
|
||||
pass2: pass2deps
|
||||
@$(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(NUTTXLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN)
|
||||
@if [ -w /tftpboot ] ; then \
|
||||
cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \
|
||||
fi
|
||||
ifeq ($(CONFIG_RRLOAD_BINARY),y)
|
||||
@echo "MK: $(BIN).rr"
|
||||
@$(TOPDIR)/tools/mkimage.sh --Prefix $(CROSSDEV) $(BIN) $(BIN).rr
|
||||
@if [ -w /tftpboot ] ; then \
|
||||
cp -f $(BIN).rr /tftpboot/$\(BIN).rr.$(CONFIG_ARCH); \
|
||||
fi
|
||||
endif
|
||||
ifeq ($(CONFIG_INTELHEX_BINARY),y)
|
||||
@echo "CP: $(BIN).hex"
|
||||
@$(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(BIN).hex
|
||||
endif
|
||||
ifeq ($(CONFIG_MOTOROLA_SREC),y)
|
||||
@echo "CP: $(BIN).srec"
|
||||
@$(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(BIN).srec
|
||||
endif
|
||||
ifeq ($(CONFIG_RAW_BINARY),y)
|
||||
@echo "CP: $(BIN).bin"
|
||||
@$(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(BIN).bin
|
||||
endif
|
||||
|
||||
# $(BIN)
|
||||
#
|
||||
# Create the final NuttX executable in a two pass build process. In the
|
||||
# normal case, all pass1 and pass2 dependencies are created then pass1
|
||||
# and pass2 targets are built. However, in some cases, you may need to build
|
||||
# pass1 depenencies and pass1 first, then build pass2 dependencies and pass2.
|
||||
# in that case, execute 'make pass1 pass2' from the command line.
|
||||
|
||||
$(BIN): pass1deps pass2deps pass1 pass2
|
||||
|
||||
# download
|
||||
#
|
||||
# This is a helper target that will rebuild NuttX and download it to the target
|
||||
# system in one step. The operation of this target depends completely upon
|
||||
# implementation of the DOWNLOAD command in the user Make.defs file. It will
|
||||
# generate an error an error if the DOWNLOAD command is not defined.
|
||||
|
||||
download: $(BIN)
|
||||
$(call DOWNLOAD, $<)
|
||||
|
||||
# pass1dep: Create pass1 build dependencies
|
||||
# pass2dep: Create pass2 build dependencies
|
||||
|
||||
pass1dep: context
|
||||
@for dir in $(USERDEPDIRS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \
|
||||
done
|
||||
|
||||
pass2dep: context
|
||||
@for dir in $(KERNDEPDIRS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend; \
|
||||
done
|
||||
|
||||
# Configuration targets
|
||||
#
|
||||
# These targets depend on the kconfig-frontends packages. To use these, you
|
||||
# must first download and install the kconfig-frontends package from this
|
||||
# location: http://ymorin.is-a-geek.org/projects/kconfig-frontends. See
|
||||
# misc/tools/README.txt for additional information.
|
||||
|
||||
config:
|
||||
@APPSDIR=${CONFIG_APPS_DIR} conf Kconfig
|
||||
|
||||
oldconfig:
|
||||
@APPSDIR=${CONFIG_APPS_DIR} conf --oldconfig Kconfig
|
||||
|
||||
menuconfig:
|
||||
@APPSDIR=${CONFIG_APPS_DIR} mconf Kconfig
|
||||
|
||||
# export
|
||||
#
|
||||
# The export target will package the NuttX libraries and header files into
|
||||
# an exportable package. Caveats: (1) These needs some extension for the KERNEL
|
||||
# build; it needs to receive USERLIBS and create a libuser.a). (2) The logic
|
||||
# in tools/mkexport.sh only supports GCC and, for example, explicitly assumes
|
||||
# that the archiver is 'ar'
|
||||
|
||||
export: pass2deps
|
||||
@tools/mkexport.sh -w$(WINTOOL) -t "$(TOPDIR)" -l "$(NUTTXLIBS)"
|
||||
|
||||
# General housekeeping targets: dependencies, cleaning, etc.
|
||||
#
|
||||
# depend: Create both PASS1 and PASS2 dependencies
|
||||
# clean: Removes derived object files, archives, executables, and
|
||||
# temporary files, but retains the configuration and context
|
||||
# files and directories.
|
||||
# distclean: Does 'clean' then also removes all configuration and context
|
||||
# files. This essentially restores the directory structure
|
||||
# to its original, unconfigured stated.
|
||||
|
||||
depend: pass1dep pass2dep
|
||||
|
||||
subdir_clean:
|
||||
@for dir in $(CLEANDIRS) ; do \
|
||||
if [ -e $$dir/Makefile ]; then \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" clean ; \
|
||||
fi \
|
||||
done
|
||||
@$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" clean
|
||||
@$(MAKE) -C mm -f Makefile.test TOPDIR="$(TOPDIR)" clean
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
@$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
|
||||
clean: subdir_clean
|
||||
@rm -f $(BIN) nuttx.* mm_test *.map _SAVED_APPS_config *~
|
||||
@rm -f nuttx-export*
|
||||
|
||||
subdir_distclean:
|
||||
@for dir in $(CLEANDIRS) ; do \
|
||||
if [ -e $$dir/Makefile ]; then \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" distclean ; \
|
||||
fi \
|
||||
done
|
||||
|
||||
distclean: clean subdir_distclean clean_context
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
@$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
|
||||
endif
|
||||
@rm -f Make.defs setenv.sh .config .config.old
|
||||
|
||||
# Application housekeeping targets. The APPDIR variable refers to the user
|
||||
# application directory. A sample apps/ directory is included with NuttX,
|
||||
# however, this is not treated as part of NuttX and may be replaced with a
|
||||
# different application directory. For the most part, the application
|
||||
# directory is treated like any other build directory in this script. However,
|
||||
# as a convenience, the following targets are included to support housekeeping
|
||||
# functions in the user application directory from the NuttX build directory.
|
||||
#
|
||||
# apps_clean: Perform the clean operation only in the user application
|
||||
# directory
|
||||
# apps_distclean: Perform the distclean operation only in the user application
|
||||
# directory. Note that the apps/.config file (inf any) is
|
||||
# preserved so that this is not a "full" distclean but more of a
|
||||
# configuration "reset." (There willnot be an apps/.config
|
||||
# file if the configuration was generated via make menuconfig).
|
||||
|
||||
apps_clean:
|
||||
ifneq ($(APPDIR),)
|
||||
@$(MAKE) -C "$(TOPDIR)/$(APPDIR)" TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
|
||||
apps_distclean:
|
||||
ifneq ($(APPDIR),)
|
||||
@if [ -r "$(TOPDIR)/$(APPDIR)/.config" ]; then \
|
||||
cp "$(TOPDIR)/$(APPDIR)/.config" _SAVED_APPS_config || \
|
||||
{ echo "Copy of $(APPDIR)/.config failed" ; exit 1 ; } \
|
||||
else \
|
||||
rm -f _SAVED_APPS_config; \
|
||||
fi
|
||||
@$(MAKE) -C "$(TOPDIR)/$(APPDIR)" TOPDIR="$(TOPDIR)" distclean
|
||||
@if [ -r _SAVED_APPS_config ]; then \
|
||||
@mv _SAVED_APPS_config "$(TOPDIR)/$(APPDIR)/.config" || \
|
||||
{ echo "Copy of _SAVED_APPS_config failed" ; exit 1 ; } \
|
||||
fi
|
||||
endif
|
||||
|
||||
|
||||
@@ -0,0 +1,749 @@
|
||||
############################################################################
|
||||
# Makefile.unix
|
||||
#
|
||||
# Copyright (C) 2007-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
TOPDIR := ${shell pwd | sed -e 's/ /\\ /g'}
|
||||
-include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
-include ${TOPDIR}/Make.defs
|
||||
|
||||
# Control build verbosity
|
||||
|
||||
ifeq ($(V),1)
|
||||
export Q :=
|
||||
else
|
||||
export Q := @
|
||||
endif
|
||||
|
||||
# Default tools
|
||||
|
||||
ifeq ($(DIRLINK),)
|
||||
DIRLINK = $(TOPDIR)/tools/link.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
endif
|
||||
|
||||
# This define is passed as EXTRADEFINES for kernel-mode builds. It is also passed
|
||||
# during PASS1 (but not PASS2) context and depend targets.
|
||||
|
||||
KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__}
|
||||
|
||||
# Process architecture and board-specific directories
|
||||
|
||||
ARCH_DIR = arch/$(CONFIG_ARCH)
|
||||
ARCH_SRC = $(ARCH_DIR)/src
|
||||
ARCH_INC = $(ARCH_DIR)/include
|
||||
BOARD_DIR = configs/$(CONFIG_ARCH_BOARD)
|
||||
|
||||
# Add-on directories. These may or may not be in place in the
|
||||
# NuttX source tree (they must be specifically installed)
|
||||
#
|
||||
# CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file.
|
||||
# The default value of CONFIG_APPS_DIR is ../apps. Ultimately, the application
|
||||
# will be built if APPDIR is defined. APPDIR will be defined if a directory containing
|
||||
# a Makefile is found at the path provided by CONFIG_APPS_DIR
|
||||
|
||||
ifeq ($(CONFIG_APPS_DIR),)
|
||||
CONFIG_APPS_DIR = ../apps
|
||||
endif
|
||||
APPDIR := ${shell if [ -r $(CONFIG_APPS_DIR)/Makefile ]; then echo "$(CONFIG_APPS_DIR)"; fi}
|
||||
|
||||
# All add-on directories.
|
||||
#
|
||||
# NUTTX_ADDONS is the list of directories built into the NuttX kernel.
|
||||
# USER_ADDONS is the list of directories that will be built into the user application
|
||||
|
||||
NUTTX_ADDONS :=
|
||||
USER_ADDONS :=
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USER_ADDONS += $(APPDIR)
|
||||
else
|
||||
NUTTX_ADDONS += $(APPDIR)
|
||||
endif
|
||||
|
||||
# Lists of build directories.
|
||||
#
|
||||
# FSDIRS depend on file descriptor support; NONFSDIRS do not (except for parts
|
||||
# of FSDIRS). We will exclude FSDIRS from the build if file descriptor
|
||||
# support is disabled
|
||||
# CONTEXTDIRS include directories that have special, one-time pre-build
|
||||
# requirements. Normally this includes things like auto-generation of
|
||||
# configuration specific files or creation of configurable symbolic links
|
||||
# USERDIRS - When NuttX is build is a monolithic kernel, this provides the
|
||||
# list of directories that must be built
|
||||
# OTHERDIRS - These are directories that are not built but probably should
|
||||
# be cleaned to prevent garbarge from collecting in them when changing
|
||||
# configurations.
|
||||
|
||||
NONFSDIRS = sched $(ARCH_SRC) $(NUTTX_ADDONS)
|
||||
FSDIRS = fs drivers binfmt
|
||||
CONTEXTDIRS = $(APPDIR)
|
||||
USERDIRS =
|
||||
OTHERDIRS = lib
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
|
||||
NONFSDIRS += syscall
|
||||
CONTEXTDIRS += syscall
|
||||
USERDIRS += syscall libc mm $(USER_ADDONS)
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
USERDIRS += libxx
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
NONFSDIRS += libc mm
|
||||
OTHERDIRS += syscall $(USER_ADDONS)
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
NONFSDIRS += libxx
|
||||
else
|
||||
OTHERDIRS += libxx
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
NONFSDIRS += graphics
|
||||
CONTEXTDIRS += graphics
|
||||
else
|
||||
OTHERDIRS += graphics
|
||||
endif
|
||||
|
||||
# CLEANDIRS are the directories that will clean in. These are
|
||||
# all directories that we know about.
|
||||
# KERNDEPDIRS are the directories in which we will build target dependencies.
|
||||
# If NuttX and applications are built separately (CONFIG_NUTTX_KERNEL),
|
||||
# then this holds only the directories containing kernel files.
|
||||
# USERDEPDIRS. If NuttX and applications are built separately (CONFIG_NUTTX_KERNEL),
|
||||
# then this holds only the directories containing user files.
|
||||
|
||||
CLEANDIRS = $(NONFSDIRS) $(FSDIRS) $(USERDIRS) $(OTHERDIRS)
|
||||
KERNDEPDIRS = $(NONFSDIRS)
|
||||
USERDEPDIRS = $(USERDIRS)
|
||||
|
||||
# Add file system directories to KERNDEPDIRS (they are already in CLEANDIRS)
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
KERNDEPDIRS += fs
|
||||
endif
|
||||
KERNDEPDIRS += drivers
|
||||
endif
|
||||
else
|
||||
KERNDEPDIRS += $(FSDIRS)
|
||||
endif
|
||||
|
||||
# Add networking directories to KERNDEPDIRS and CLEANDIRS
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
KERNDEPDIRS += net
|
||||
endif
|
||||
CLEANDIRS += net
|
||||
|
||||
#
|
||||
# Extra objects used in the final link.
|
||||
#
|
||||
# Pass 1 1ncremental (relative) link objects should be put into the
|
||||
# processor-specific source directory (where other link objects will
|
||||
# be created). If the pass1 obect is an archive, it could go anywhere.
|
||||
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
EXTRA_OBJS += $(CONFIG_PASS1_OBJECT)
|
||||
endif
|
||||
|
||||
# NUTTXLIBS is the list of NuttX libraries that is passed to the
|
||||
# processor-specific Makefile to build the final NuttX target.
|
||||
# Libraries in FSDIRS are excluded if file descriptor support
|
||||
# is disabled.
|
||||
# USERLIBS is the list of libraries used to build the final user-space
|
||||
# application
|
||||
|
||||
NUTTXLIBS = lib/libsched$(LIBEXT) lib/libarch$(LIBEXT)
|
||||
USERLIBS =
|
||||
|
||||
# Add libraries for syscall support. The C library will be needed by
|
||||
# both the kernel- and user-space builds. For now, the memory manager (mm)
|
||||
# is placed in user space (only).
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
NUTTXLIBS += lib/libstubs$(LIBEXT) lib/libkc$(LIBEXT)
|
||||
USERLIBS += lib/libproxies$(LIBEXT) lib/libuc$(LIBEXT) lib/libmm$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += lib/libmm$(LIBEXT) lib/libc$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for C++ support. CXX, CXXFLAGS, and COMPILEXX must
|
||||
# be defined in Make.defs for this to work!
|
||||
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USERLIBS += lib/libcxx$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += lib/libcxx$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add library for application support.
|
||||
|
||||
ifneq ($(APPDIR),)
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USERLIBS += lib/libapps$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += lib/libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add libraries for network support
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
NUTTXLIBS += lib/libnet$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for file system support
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
NUTTXLIBS += lib/libfs$(LIBEXT)
|
||||
endif
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
NUTTXLIBS += lib/libdrivers$(LIBEXT)
|
||||
endif
|
||||
else
|
||||
NUTTXLIBS += lib/libfs$(LIBEXT) lib/libdrivers$(LIBEXT) lib/libbinfmt$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for the NX graphics sub-system
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
NUTTXLIBS += lib/libgraphics$(LIBEXT)
|
||||
endif
|
||||
|
||||
# LINKLIBS derives from NUTTXLIBS and is simply the same list with the subdirectory removed
|
||||
|
||||
LINKLIBS = $(patsubst lib/%,%,$(NUTTXLIBS))
|
||||
|
||||
# This is the name of the final target (relative to the top level directorty)
|
||||
|
||||
BIN = nuttx$(EXEEXT)
|
||||
|
||||
all: $(BIN)
|
||||
.PHONY: context clean_context check_context export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
|
||||
|
||||
# Target used to copy include/nuttx/math.h. If CONFIG_ARCH_MATH_H is
|
||||
# defined, then there is an architecture specific math.h header file
|
||||
# that will be included indirectly from include/math.h. But first, we
|
||||
# have to copy math.h from include/nuttx/. to include/. Logic within
|
||||
# include/nuttx/math.h will hand the redirection to the architecture-
|
||||
# specific math.h header file.
|
||||
#
|
||||
# If the CONFIG_LIBM is defined, the Rhombus libm will be built at libc/math.
|
||||
# Definitions and prototypes for the Rhombus libm are also contained in
|
||||
# include/nuttx/math.h and so the file must also be copied in that case.
|
||||
#
|
||||
# If neither CONFIG_ARCH_MATH_H nor CONFIG_LIBM is defined, then no math.h
|
||||
# header file will be provided. You would want that behavior if (1) you
|
||||
# don't use libm, or (2) you want to use the math.h and libm provided
|
||||
# within your toolchain.
|
||||
|
||||
ifeq ($(CONFIG_ARCH_MATH_H),y)
|
||||
NEED_MATH_H = y
|
||||
else
|
||||
ifeq ($(CONFIG_LIBM),y)
|
||||
NEED_MATH_H = y
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(NEED_MATH_H),y)
|
||||
include/math.h: include/nuttx/math.h
|
||||
$(Q) cp -f include/nuttx/math.h include/math.h
|
||||
else
|
||||
include/math.h:
|
||||
endif
|
||||
|
||||
# The float.h header file defines the properties of your floating point
|
||||
# implementation. It would always be best to use your toolchain's float.h
|
||||
# header file but if none is avaiable, a default float.h header file will
|
||||
# provided if this option is selected. However there is no assurance that
|
||||
# the settings in this float.h are actually correct for your platform!
|
||||
|
||||
ifeq ($(CONFIG_ARCH_FLOAT_H),y)
|
||||
include/float.h: include/nuttx/float.h
|
||||
$(Q) cp -f include/nuttx/float.h include/float.h
|
||||
else
|
||||
include/float.h:
|
||||
endif
|
||||
|
||||
# Target used to copy include/nuttx/stdarg.h. If CONFIG_ARCH_STDARG_H is
|
||||
# defined, then there is an architecture specific stdarg.h header file
|
||||
# that will be included indirectly from include/stdarg.h. But first, we
|
||||
# have to copy stdarg.h from include/nuttx/. to include/.
|
||||
|
||||
ifeq ($(CONFIG_ARCH_STDARG_H),y)
|
||||
include/stdarg.h: include/nuttx/stdarg.h
|
||||
$(Q) cp -f include/nuttx/stdarg.h include/stdarg.h
|
||||
else
|
||||
include/stdarg.h:
|
||||
endif
|
||||
|
||||
# Targets used to build include/nuttx/version.h. Creation of version.h is
|
||||
# part of the overall NuttX configuration sequence. Notice that the
|
||||
# tools/mkversion tool is built and used to create include/nuttx/version.h
|
||||
|
||||
tools/mkversion$(HOSTEXEEXT):
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT)
|
||||
|
||||
$(TOPDIR)/.version:
|
||||
$(Q) if [ ! -f .version ]; then \
|
||||
echo "No .version file found, creating one"; \
|
||||
tools/version.sh -v 0.0 -b 0 .version; \
|
||||
chmod 755 .version; \
|
||||
fi
|
||||
|
||||
include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT)
|
||||
$(Q) tools/mkversion $(TOPDIR) > include/nuttx/version.h
|
||||
|
||||
# Targets used to build include/nuttx/config.h. Creation of config.h is
|
||||
# part of the overall NuttX configuration sequence. Notice that the
|
||||
# tools/mkconfig tool is built and used to create include/nuttx/config.h
|
||||
|
||||
tools/mkconfig$(HOSTEXEEXT):
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT)
|
||||
|
||||
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT)
|
||||
$(Q) tools/mkconfig $(TOPDIR) > include/nuttx/config.h
|
||||
|
||||
# Targets used to create dependencies
|
||||
|
||||
tools/mkdeps$(HOSTEXEEXT):
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkdeps$(HOSTEXEEXT)
|
||||
|
||||
# dirlinks, and helpers
|
||||
#
|
||||
# Directories links. Most of establishing the NuttX configuration involves
|
||||
# setting up symbolic links with 'generic' directory names to specific,
|
||||
# configured directories.
|
||||
#
|
||||
# Link the apps/include directory to include/apps
|
||||
|
||||
include/apps: Make.defs
|
||||
ifneq ($(APPDIR),)
|
||||
@echo "LN: include/apps -> $(APPDIR)/include"
|
||||
$(Q) if [ -d $(TOPDIR)/$(APPDIR)/include ]; then \
|
||||
$(DIRLINK) $(TOPDIR)/$(APPDIR)/include include/apps; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Link the arch/<arch-name>/include directory to include/arch
|
||||
|
||||
include/arch: Make.defs
|
||||
@echo "LN: include/arch -> $(ARCH_DIR)/include"
|
||||
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
|
||||
|
||||
# Link the configs/<board-name>/include directory to include/arch/board
|
||||
|
||||
include/arch/board: include/arch Make.defs include/arch
|
||||
@echo "LN: include/arch/board -> $(BOARD_DIR)/include"
|
||||
$(Q) $(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
|
||||
|
||||
# Link the configs/<board-name>/src dir to arch/<arch-name>/src/board
|
||||
|
||||
$(ARCH_SRC)/board: Make.defs
|
||||
@echo "LN: $(ARCH_SRC)/board -> $(BOARD_DIR)/src"
|
||||
$(Q) $(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
|
||||
|
||||
# Link arch/<arch-name>/include/<chip-name> to arch/<arch-name>/include/chip
|
||||
|
||||
$(ARCH_SRC)/chip: Make.defs
|
||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
@echo "LN: $(ARCH_SRC)/chip -> $(ARCH_SRC)/$(CONFIG_ARCH_CHIP)"
|
||||
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
|
||||
endif
|
||||
|
||||
# Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
|
||||
|
||||
include/arch/chip: include/arch Make.defs
|
||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
@echo "LN: include/arch/chip -> $(ARCH_INC)/$(CONFIG_ARCH_CHIP)"
|
||||
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
|
||||
endif
|
||||
|
||||
dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip include/apps
|
||||
|
||||
# context
|
||||
#
|
||||
# The context target is invoked on each target build to assure that NuttX is
|
||||
# properly configured. The basic configuration steps include creation of the
|
||||
# the config.h and version.h header files in the include/nuttx directory and
|
||||
# the establishment of symbolic links to configured directories.
|
||||
|
||||
context: check_context include/nuttx/config.h include/nuttx/version.h include/math.h include/float.h include/stdarg.h dirlinks
|
||||
$(Q) for dir in $(CONTEXTDIRS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" context; \
|
||||
done
|
||||
|
||||
# clean_context
|
||||
#
|
||||
# This is part of the distclean target. It removes all of the header files
|
||||
# and symbolic links created by the context target.
|
||||
|
||||
clean_context:
|
||||
$(call DELFILE, include/nuttx/config.h)
|
||||
$(call DELFILE, include/nuttx/version.h)
|
||||
$(call DELFILE, include/math.h)
|
||||
$(call DELFILE, include/stdarg.h)
|
||||
$(Q) $(DIRUNLINK) include/arch/board
|
||||
$(Q) $(DIRUNLINK) include/arch/chip
|
||||
$(Q) $(DIRUNLINK) include/arch
|
||||
$(Q) $(DIRUNLINK) $(ARCH_SRC)/board
|
||||
$(Q) $(DIRUNLINK) $(ARCH_SRC)/chip
|
||||
$(Q) $(DIRUNLINK) include/apps
|
||||
|
||||
# check_context
|
||||
#
|
||||
# This target checks if NuttX has been configured. NuttX is configured using
|
||||
# the script tools/configure.sh. That script will install certain files in
|
||||
# the top-level NuttX build directory. This target verifies that those
|
||||
# configuration files have been installed and that NuttX is ready to be built.
|
||||
|
||||
check_context:
|
||||
$(Q) if [ ! -e ${TOPDIR}/.config -o ! -e ${TOPDIR}/Make.defs ]; then \
|
||||
echo "" ; echo "Nuttx has not been configured:" ; \
|
||||
echo " cd tools; ./configure.sh <target>" ; echo "" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
# Archive targets. The target build sequency will first create a series of
|
||||
# libraries, one per configured source file directory. The final NuttX
|
||||
# execution will then be built from those libraries. The following targets
|
||||
# build those libraries.
|
||||
#
|
||||
# Possible kernel-mode builds
|
||||
|
||||
libc/libkc$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libc TOPDIR="$(TOPDIR)" libkc$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libkc$(LIBEXT): libc/libkc$(LIBEXT)
|
||||
$(Q) install libc/libkc$(LIBEXT) lib/libkc$(LIBEXT)
|
||||
|
||||
sched/libsched$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libsched$(LIBEXT): sched/libsched$(LIBEXT)
|
||||
$(Q) install sched/libsched$(LIBEXT) lib/libsched$(LIBEXT)
|
||||
|
||||
$(ARCH_SRC)/libarch$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libarch$(LIBEXT): $(ARCH_SRC)/libarch$(LIBEXT)
|
||||
$(Q) install $(ARCH_SRC)/libarch$(LIBEXT) lib/libarch$(LIBEXT)
|
||||
|
||||
net/libnet$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C net TOPDIR="$(TOPDIR)" libnet$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libnet$(LIBEXT): net/libnet$(LIBEXT)
|
||||
$(Q) install net/libnet$(LIBEXT) lib/libnet$(LIBEXT)
|
||||
|
||||
fs/libfs$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C fs TOPDIR="$(TOPDIR)" libfs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libfs$(LIBEXT): fs/libfs$(LIBEXT)
|
||||
$(Q) install fs/libfs$(LIBEXT) lib/libfs$(LIBEXT)
|
||||
|
||||
drivers/libdrivers$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C drivers TOPDIR="$(TOPDIR)" libdrivers$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libdrivers$(LIBEXT): drivers/libdrivers$(LIBEXT)
|
||||
$(Q) install drivers/libdrivers$(LIBEXT) lib/libdrivers$(LIBEXT)
|
||||
|
||||
binfmt/libbinfmt$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C binfmt TOPDIR="$(TOPDIR)" libbinfmt$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libbinfmt$(LIBEXT): binfmt/libbinfmt$(LIBEXT)
|
||||
$(Q) install binfmt/libbinfmt$(LIBEXT) lib/libbinfmt$(LIBEXT)
|
||||
|
||||
graphics/libgraphics$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C graphics TOPDIR="$(TOPDIR)" libgraphics$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libgraphics$(LIBEXT): graphics/libgraphics$(LIBEXT)
|
||||
$(Q) install graphics/libgraphics$(LIBEXT) lib/libgraphics$(LIBEXT)
|
||||
|
||||
syscall/libstubs$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C syscall TOPDIR="$(TOPDIR)" libstubs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libstubs$(LIBEXT): syscall/libstubs$(LIBEXT)
|
||||
$(Q) install syscall/libstubs$(LIBEXT) lib/libstubs$(LIBEXT)
|
||||
|
||||
# Possible user-mode builds
|
||||
|
||||
libc/libuc$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libc TOPDIR="$(TOPDIR)" libuc$(LIBEXT)
|
||||
|
||||
lib/libuc$(LIBEXT): libc/libuc$(LIBEXT)
|
||||
$(Q) install libc/libuc$(LIBEXT) lib/libuc$(LIBEXT)
|
||||
|
||||
libxx/libcxx$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libxx TOPDIR="$(TOPDIR)" libcxx$(LIBEXT)
|
||||
|
||||
lib/libcxx$(LIBEXT): libxx/libcxx$(LIBEXT)
|
||||
$(Q) install libxx/libcxx$(LIBEXT) lib/libcxx$(LIBEXT)
|
||||
|
||||
mm/libmm$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib/libmm$(LIBEXT): mm/libmm$(LIBEXT)
|
||||
$(Q) install mm/libmm$(LIBEXT) lib/libmm$(LIBEXT)
|
||||
|
||||
$(APPDIR)/libapps$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
|
||||
|
||||
lib/libapps$(LIBEXT): $(APPDIR)/libapps$(LIBEXT)
|
||||
$(Q) install $(APPDIR)/libapps$(LIBEXT) lib/libapps$(LIBEXT)
|
||||
|
||||
syscall/libproxies$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C syscall TOPDIR="$(TOPDIR)" libproxies$(LIBEXT)
|
||||
|
||||
lib/libproxies$(LIBEXT): syscall/libproxies$(LIBEXT)
|
||||
$(Q) install syscall/libproxies$(LIBEXT) lib/libproxies$(LIBEXT)
|
||||
|
||||
# Possible non-kernel builds
|
||||
|
||||
libc/libc$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libc TOPDIR="$(TOPDIR)" libc$(LIBEXT)
|
||||
|
||||
lib/libc$(LIBEXT): libc/libc$(LIBEXT)
|
||||
$(Q) install libc/libc$(LIBEXT) lib/libc$(LIBEXT)
|
||||
|
||||
# pass1 and pass2
|
||||
#
|
||||
# If the 2 pass build option is selected, then this pass1 target is
|
||||
# configured to built before the pass2 target. This pass1 target may, as an
|
||||
# example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
|
||||
# incremental (relative) link object, but could be a static library (archive);
|
||||
# some modification to this Makefile would be required if CONFIG_PASS1_OBJECT
|
||||
# is an archive. Exactly what is performed during pass1 or what it generates
|
||||
# is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined.
|
||||
|
||||
pass1deps: pass1dep $(USERLIBS)
|
||||
|
||||
pass1: pass1deps
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
$(Q) if [ -z "$(CONFIG_PASS1_BUILDIR)" ]; then \
|
||||
echo "ERROR: CONFIG_PASS1_BUILDIR not defined"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) if [ ! -d "$(CONFIG_PASS1_BUILDIR)" ]; then \
|
||||
echo "ERROR: CONFIG_PASS1_BUILDIR does not exist"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) if [ ! -f "$(CONFIG_PASS1_BUILDIR)/Makefile" ]; then \
|
||||
echo "ERROR: No Makefile in CONFIG_PASS1_BUILDIR"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
|
||||
endif
|
||||
|
||||
pass2deps: pass2dep $(NUTTXLIBS)
|
||||
|
||||
pass2: pass2deps
|
||||
$(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN)
|
||||
$(Q) if [ -w /tftpboot ] ; then \
|
||||
cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \
|
||||
fi
|
||||
ifeq ($(CONFIG_RRLOAD_BINARY),y)
|
||||
@echo "MK: $(BIN).rr"
|
||||
$(Q) $(TOPDIR)/tools/mkimage.sh --Prefix $(CROSSDEV) $(BIN) $(BIN).rr
|
||||
$(Q) if [ -w /tftpboot ] ; then \
|
||||
cp -f $(BIN).rr /tftpboot/$\(BIN).rr.$(CONFIG_ARCH); \
|
||||
fi
|
||||
endif
|
||||
ifeq ($(CONFIG_INTELHEX_BINARY),y)
|
||||
@echo "CP: $(BIN).hex"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(BIN).hex
|
||||
endif
|
||||
ifeq ($(CONFIG_MOTOROLA_SREC),y)
|
||||
@echo "CP: $(BIN).srec"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(BIN).srec
|
||||
endif
|
||||
ifeq ($(CONFIG_RAW_BINARY),y)
|
||||
@echo "CP: $(BIN).bin"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(BIN).bin
|
||||
endif
|
||||
|
||||
# $(BIN)
|
||||
#
|
||||
# Create the final NuttX executable in a two pass build process. In the
|
||||
# normal case, all pass1 and pass2 dependencies are created then pass1
|
||||
# and pass2 targets are built. However, in some cases, you may need to build
|
||||
# pass1 depenencies and pass1 first, then build pass2 dependencies and pass2.
|
||||
# in that case, execute 'make pass1 pass2' from the command line.
|
||||
|
||||
$(BIN): pass1deps pass2deps pass1 pass2
|
||||
|
||||
# download
|
||||
#
|
||||
# This is a helper target that will rebuild NuttX and download it to the target
|
||||
# system in one step. The operation of this target depends completely upon
|
||||
# implementation of the DOWNLOAD command in the user Make.defs file. It will
|
||||
# generate an error an error if the DOWNLOAD command is not defined.
|
||||
|
||||
download: $(BIN)
|
||||
$(call DOWNLOAD, $<)
|
||||
|
||||
# pass1dep: Create pass1 build dependencies
|
||||
# pass2dep: Create pass2 build dependencies
|
||||
|
||||
pass1dep: context tools/mkdeps$(HOSTEXEEXT)
|
||||
$(Q) for dir in $(USERDEPDIRS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \
|
||||
done
|
||||
|
||||
pass2dep: context tools/mkdeps$(HOSTEXEEXT)
|
||||
$(Q) for dir in $(KERNDEPDIRS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend; \
|
||||
done
|
||||
|
||||
# Configuration targets
|
||||
#
|
||||
# These targets depend on the kconfig-frontends packages. To use these, you
|
||||
# must first download and install the kconfig-frontends package from this
|
||||
# location: http://ymorin.is-a-geek.org/projects/kconfig-frontends. See
|
||||
# misc/tools/README.txt for additional information.
|
||||
|
||||
config:
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} conf Kconfig
|
||||
|
||||
oldconfig:
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} conf --oldconfig Kconfig
|
||||
|
||||
menuconfig:
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} mconf Kconfig
|
||||
|
||||
# export
|
||||
#
|
||||
# The export target will package the NuttX libraries and header files into
|
||||
# an exportable package. Caveats: (1) These needs some extension for the KERNEL
|
||||
# build; it needs to receive USERLIBS and create a libuser.a). (2) The logic
|
||||
# in tools/mkexport.sh only supports GCC and, for example, explicitly assumes
|
||||
# that the archiver is 'ar'
|
||||
|
||||
export: pass2deps
|
||||
$(Q) tools/mkexport.sh -w$(WINTOOL) -t "$(TOPDIR)" -l "$(NUTTXLIBS)"
|
||||
|
||||
# General housekeeping targets: dependencies, cleaning, etc.
|
||||
#
|
||||
# depend: Create both PASS1 and PASS2 dependencies
|
||||
# clean: Removes derived object files, archives, executables, and
|
||||
# temporary files, but retains the configuration and context
|
||||
# files and directories.
|
||||
# distclean: Does 'clean' then also removes all configuration and context
|
||||
# files. This essentially restores the directory structure
|
||||
# to its original, unconfigured stated.
|
||||
|
||||
depend: pass1dep pass2dep
|
||||
|
||||
subdir_clean:
|
||||
$(Q) for dir in $(CLEANDIRS) ; do \
|
||||
if [ -e $$dir/Makefile ]; then \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" clean ; \
|
||||
fi \
|
||||
done
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" clean
|
||||
$(Q) $(MAKE) -C mm -f Makefile.test TOPDIR="$(TOPDIR)" clean
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
|
||||
clean: subdir_clean
|
||||
$(call DELFILE, $(BIN))
|
||||
$(call DELFILE, nuttx.*)
|
||||
$(call DELFILE, mm_test)
|
||||
$(call DELFILE, *.map)
|
||||
$(call DELFILE, _SAVED_APPS_config)
|
||||
$(call DELFILE, nuttx-export*)
|
||||
$(call CLEAN)
|
||||
|
||||
subdir_distclean:
|
||||
$(Q) for dir in $(CLEANDIRS) ; do \
|
||||
if [ -e $$dir/Makefile ]; then \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" distclean ; \
|
||||
fi \
|
||||
done
|
||||
|
||||
distclean: clean subdir_distclean clean_context
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
|
||||
endif
|
||||
$(call DELFILE, Make.defs)
|
||||
$(call DELFILE, setenv.sh)
|
||||
$(call DELFILE, setenv.bat)
|
||||
$(call DELFILE, .config)
|
||||
$(call DELFILE, .config.old)
|
||||
|
||||
# Application housekeeping targets. The APPDIR variable refers to the user
|
||||
# application directory. A sample apps/ directory is included with NuttX,
|
||||
# however, this is not treated as part of NuttX and may be replaced with a
|
||||
# different application directory. For the most part, the application
|
||||
# directory is treated like any other build directory in this script. However,
|
||||
# as a convenience, the following targets are included to support housekeeping
|
||||
# functions in the user application directory from the NuttX build directory.
|
||||
#
|
||||
# apps_clean: Perform the clean operation only in the user application
|
||||
# directory
|
||||
# apps_distclean: Perform the distclean operation only in the user application
|
||||
# directory. Note that the apps/.config file (inf any) is
|
||||
# preserved so that this is not a "full" distclean but more of a
|
||||
# configuration "reset." (There willnot be an apps/.config
|
||||
# file if the configuration was generated via make menuconfig).
|
||||
|
||||
apps_clean:
|
||||
ifneq ($(APPDIR),)
|
||||
$(Q) $(MAKE) -C "$(TOPDIR)/$(APPDIR)" TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
|
||||
apps_distclean:
|
||||
ifneq ($(APPDIR),)
|
||||
$(Q) if [ -r "$(TOPDIR)/$(APPDIR)/.config" ]; then \
|
||||
cp "$(TOPDIR)/$(APPDIR)/.config" _SAVED_APPS_config || \
|
||||
{ echo "Copy of $(APPDIR)/.config failed" ; exit 1 ; } \
|
||||
else \
|
||||
rm -f _SAVED_APPS_config; \
|
||||
fi
|
||||
$(Q) $(MAKE) -C "$(TOPDIR)/$(APPDIR)" TOPDIR="$(TOPDIR)" distclean
|
||||
$(Q) if [ -r _SAVED_APPS_config ]; then \
|
||||
mv _SAVED_APPS_config "$(TOPDIR)/$(APPDIR)/.config" || \
|
||||
{ echo "Copy of _SAVED_APPS_config failed" ; exit 1 ; } \
|
||||
fi
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
############################################################################
|
||||
# Makefile.win
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
TOPDIR := ${shell echo %CD%}
|
||||
-include $(TOPDIR)\.config
|
||||
-include $(TOPDIR)\tools\Config.mk
|
||||
-include $(TOPDIR)\Make.defs
|
||||
|
||||
# Control build verbosity
|
||||
|
||||
ifeq ($(V),1)
|
||||
export Q :=
|
||||
else
|
||||
export Q := @
|
||||
endif
|
||||
|
||||
# This define is passed as EXTRADEFINES for kernel-mode builds. It is also passed
|
||||
# during PASS1 (but not PASS2) context and depend targets.
|
||||
|
||||
KDEFINE = ${shell $(TOPDIR)\tools\define.bat "$(CC)" __KERNEL__}
|
||||
|
||||
# Process architecture and board-specific directories
|
||||
|
||||
ARCH_DIR = arch\$(CONFIG_ARCH)
|
||||
ARCH_SRC = $(ARCH_DIR)\src
|
||||
ARCH_INC = $(ARCH_DIR)\include
|
||||
BOARD_DIR = configs\$(CONFIG_ARCH_BOARD)
|
||||
|
||||
# Add-on directories. These may or may not be in place in the
|
||||
# NuttX source tree (they must be specifically installed)
|
||||
#
|
||||
# CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file.
|
||||
# The default value of CONFIG_APPS_DIR is ..\apps. Ultimately, the application
|
||||
# will be built if APPDIR is defined. APPDIR will be defined if a directory containing
|
||||
# a Makefile is found at the path provided by CONFIG_APPS_DIR
|
||||
|
||||
ifeq ($(CONFIG_APPS_DIR),)
|
||||
CONFIG_APPS_DIR = ..\apps
|
||||
endif
|
||||
APPDIR := ${shell if exist "$(CONFIG_APPS_DIR)\Makefile" echo $(CONFIG_APPS_DIR)}
|
||||
|
||||
# All add-on directories.
|
||||
#
|
||||
# NUTTX_ADDONS is the list of directories built into the NuttX kernel.
|
||||
# USER_ADDONS is the list of directories that will be built into the user application
|
||||
|
||||
NUTTX_ADDONS :=
|
||||
USER_ADDONS :=
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USER_ADDONS += $(APPDIR)
|
||||
else
|
||||
NUTTX_ADDONS += $(APPDIR)
|
||||
endif
|
||||
|
||||
# Lists of build directories.
|
||||
#
|
||||
# FSDIRS depend on file descriptor support; NONFSDIRS do not (except for parts
|
||||
# of FSDIRS). We will exclude FSDIRS from the build if file descriptor
|
||||
# support is disabled
|
||||
# CONTEXTDIRS include directories that have special, one-time pre-build
|
||||
# requirements. Normally this includes things like auto-generation of
|
||||
# configuration specific files or creation of configurable symbolic links
|
||||
# USERDIRS - When NuttX is build is a monolithic kernel, this provides the
|
||||
# list of directories that must be built
|
||||
# OTHERDIRS - These are directories that are not built but probably should
|
||||
# be cleaned to prevent garbarge from collecting in them when changing
|
||||
# configurations.
|
||||
|
||||
NONFSDIRS = sched $(ARCH_SRC) $(NUTTX_ADDONS)
|
||||
FSDIRS = fs drivers binfmt
|
||||
CONTEXTDIRS = $(APPDIR)
|
||||
USERDIRS =
|
||||
OTHERDIRS = lib
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
|
||||
NONFSDIRS += syscall
|
||||
CONTEXTDIRS += syscall
|
||||
USERDIRS += syscall libc mm $(USER_ADDONS)
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
USERDIRS += libxx
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
NONFSDIRS += libc mm
|
||||
OTHERDIRS += syscall $(USER_ADDONS)
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
NONFSDIRS += libxx
|
||||
else
|
||||
OTHERDIRS += libxx
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
NONFSDIRS += graphics
|
||||
CONTEXTDIRS += graphics
|
||||
else
|
||||
OTHERDIRS += graphics
|
||||
endif
|
||||
|
||||
# CLEANDIRS are the directories that will clean in. These are
|
||||
# all directories that we know about.
|
||||
# KERNDEPDIRS are the directories in which we will build target dependencies.
|
||||
# If NuttX and applications are built separately (CONFIG_NUTTX_KERNEL),
|
||||
# then this holds only the directories containing kernel files.
|
||||
# USERDEPDIRS. If NuttX and applications are built separately (CONFIG_NUTTX_KERNEL),
|
||||
# then this holds only the directories containing user files.
|
||||
|
||||
CLEANDIRS = $(NONFSDIRS) $(FSDIRS) $(USERDIRS) $(OTHERDIRS)
|
||||
KERNDEPDIRS = $(NONFSDIRS)
|
||||
USERDEPDIRS = $(USERDIRS)
|
||||
|
||||
# Add file system directories to KERNDEPDIRS (they are already in CLEANDIRS)
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
KERNDEPDIRS += fs
|
||||
endif
|
||||
KERNDEPDIRS += drivers
|
||||
endif
|
||||
else
|
||||
KERNDEPDIRS += $(FSDIRS)
|
||||
endif
|
||||
|
||||
# Add networking directories to KERNDEPDIRS and CLEANDIRS
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
KERNDEPDIRS += net
|
||||
endif
|
||||
CLEANDIRS += net
|
||||
|
||||
#
|
||||
# Extra objects used in the final link.
|
||||
#
|
||||
# Pass 1 1ncremental (relative) link objects should be put into the
|
||||
# processor-specific source directory (where other link objects will
|
||||
# be created). If the pass1 obect is an archive, it could go anywhere.
|
||||
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
EXTRA_OBJS += $(CONFIG_PASS1_OBJECT)
|
||||
endif
|
||||
|
||||
# NUTTXLIBS is the list of NuttX libraries that is passed to the
|
||||
# processor-specific Makefile to build the final NuttX target.
|
||||
# Libraries in FSDIRS are excluded if file descriptor support
|
||||
# is disabled.
|
||||
# USERLIBS is the list of libraries used to build the final user-space
|
||||
# application
|
||||
|
||||
NUTTXLIBS = lib\libsched$(LIBEXT) lib\libarch$(LIBEXT)
|
||||
USERLIBS =
|
||||
|
||||
# Add libraries for syscall support. The C library will be needed by
|
||||
# both the kernel- and user-space builds. For now, the memory manager (mm)
|
||||
# is placed in user space (only).
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
NUTTXLIBS += lib\libstubs$(LIBEXT) lib\libkc$(LIBEXT)
|
||||
USERLIBS += lib\libproxies$(LIBEXT) lib\libuc$(LIBEXT) lib\libmm$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += lib\libmm$(LIBEXT) lib\libc$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for C++ support. CXX, CXXFLAGS, and COMPILEXX must
|
||||
# be defined in Make.defs for this to work!
|
||||
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USERLIBS += lib\libcxx$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += lib\libcxx$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add library for application support.
|
||||
|
||||
ifneq ($(APPDIR),)
|
||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||
USERLIBS += lib\libapps$(LIBEXT)
|
||||
else
|
||||
NUTTXLIBS += lib\libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add libraries for network support
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
NUTTXLIBS += lib\libnet$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for file system support
|
||||
|
||||
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
|
||||
NUTTXLIBS += lib\libfs$(LIBEXT)
|
||||
endif
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
NUTTXLIBS += lib\libdrivers$(LIBEXT)
|
||||
endif
|
||||
else
|
||||
NUTTXLIBS += lib\libfs$(LIBEXT) lib\libdrivers$(LIBEXT) lib\libbinfmt$(LIBEXT)
|
||||
endif
|
||||
|
||||
# Add libraries for the NX graphics sub-system
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
NUTTXLIBS += lib\libgraphics$(LIBEXT)
|
||||
endif
|
||||
|
||||
# LINKLIBS derives from NUTTXLIBS and is simply the same list with the subdirectory removed
|
||||
|
||||
LINKLIBS = $(patsubst lib\\%,%,$(NUTTXLIBS))
|
||||
|
||||
# This is the name of the final target (relative to the top level directorty)
|
||||
|
||||
BIN = nuttx$(EXEEXT)
|
||||
|
||||
all: $(BIN)
|
||||
.PHONY: context clean_context check_context export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
|
||||
|
||||
# Target used to copy include\nuttx\math.h. If CONFIG_ARCH_MATH_H is
|
||||
# defined, then there is an architecture specific math.h header file
|
||||
# that will be included indirectly from include\math.h. But first, we
|
||||
# have to copy math.h from include\nuttx\. to include\. Logic within
|
||||
# include\nuttx\math.h will hand the redirection to the architecture-
|
||||
# specific math.h header file.
|
||||
#
|
||||
# If the CONFIG_LIBM is defined, the Rhombus libm will be built at libc\math.
|
||||
# Definitions and prototypes for the Rhombus libm are also contained in
|
||||
# include\nuttx\math.h and so the file must also be copied in that case.
|
||||
#
|
||||
# If neither CONFIG_ARCH_MATH_H nor CONFIG_LIBM is defined, then no math.h
|
||||
# header file will be provided. You would want that behavior if (1) you
|
||||
# don't use libm, or (2) you want to use the math.h and libm provided
|
||||
# within your toolchain.
|
||||
|
||||
ifeq ($(CONFIG_ARCH_MATH_H),y)
|
||||
NEED_MATH_H = y
|
||||
else
|
||||
ifeq ($(CONFIG_LIBM),y)
|
||||
NEED_MATH_H = y
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(NEED_MATH_H),y)
|
||||
include\math.h: include\nuttx\math.h
|
||||
$(Q) cp -f include\nuttx\math.h include\math.h
|
||||
else
|
||||
include\math.h:
|
||||
endif
|
||||
|
||||
# The float.h header file defines the properties of your floating point
|
||||
# implementation. It would always be best to use your toolchain's float.h
|
||||
# header file but if none is avaiable, a default float.h header file will
|
||||
# provided if this option is selected. However there is no assurance that
|
||||
# the settings in this float.h are actually correct for your platform!
|
||||
|
||||
ifeq ($(CONFIG_ARCH_FLOAT_H),y)
|
||||
include\float.h: include\nuttx\float.h
|
||||
$(Q) cp -f include\nuttx\float.h include\float.h
|
||||
else
|
||||
include\float.h:
|
||||
endif
|
||||
|
||||
# Target used to copy include\nuttx\stdarg.h. If CONFIG_ARCH_STDARG_H is
|
||||
# defined, then there is an architecture specific stdarg.h header file
|
||||
# that will be included indirectly from include\stdarg.h. But first, we
|
||||
# have to copy stdarg.h from include\nuttx\. to include\.
|
||||
|
||||
ifeq ($(CONFIG_ARCH_STDARG_H),y)
|
||||
include\stdarg.h: include\nuttx\stdarg.h
|
||||
$(Q) cp -f include\nuttx\stdarg.h include\stdarg.h
|
||||
else
|
||||
include\stdarg.h:
|
||||
endif
|
||||
|
||||
# Targets used to build include\nuttx\version.h. Creation of version.h is
|
||||
# part of the overall NuttX configuration sequence. Notice that the
|
||||
# tools\mkversion tool is built and used to create include\nuttx\version.h
|
||||
|
||||
tools\mkversion$(HOSTEXEEXT):
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT)
|
||||
|
||||
$(TOPDIR)\.version:
|
||||
$(Q) if [ ! -f .version ]; then \
|
||||
echo "No .version file found, creating one"; \
|
||||
tools\version.sh -v 0.0 -b 0 .version; \
|
||||
chmod 755 .version; \
|
||||
fi
|
||||
|
||||
include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion$(HOSTEXEEXT)
|
||||
$(Q) tools\mkversion$(HOSTEXEEXT) $(TOPDIR) > include\nuttx\version.h
|
||||
|
||||
# Targets used to build include\nuttx\config.h. Creation of config.h is
|
||||
# part of the overall NuttX configuration sequence. Notice that the
|
||||
# tools\mkconfig tool is built and used to create include\nuttx\config.h
|
||||
|
||||
tools\mkconfig$(HOSTEXEEXT):
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT)
|
||||
|
||||
include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT)
|
||||
$(Q) tools\mkconfig$(HOSTEXEEXT) $(TOPDIR) > include\nuttx\config.h
|
||||
|
||||
# Targets used to create dependencies
|
||||
|
||||
tools\mkdeps$(HOSTEXEEXT):
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkdeps$(HOSTEXEEXT)
|
||||
|
||||
# dirlinks, and helpers
|
||||
#
|
||||
# Directories links. Most of establishing the NuttX configuration involves
|
||||
# setting up symbolic links with 'generic' directory names to specific,
|
||||
# configured directories.
|
||||
#
|
||||
# Link the apps\include directory to include\apps
|
||||
|
||||
include\apps: Make.defs
|
||||
ifneq ($(APPDIR),)
|
||||
@echo "LN: include\apps $(APPDIR)\include"
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d include\apps $(APPDIR)\include
|
||||
else
|
||||
$(Q) xcopy $(APPDIR)\include include\apps /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > include\apps\.fakelnk
|
||||
endif
|
||||
endif
|
||||
|
||||
# Link the arch\<arch-name>\include directory to include\arch
|
||||
|
||||
include\arch: Make.defs
|
||||
@echo "LN: include\arch -> $(ARCH_DIR)\include"
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d include\arch $(TOPDIR)\$(ARCH_DIR)\include
|
||||
else
|
||||
$(Q) xcopy $(TOPDIR)\$(ARCH_DIR)\include include\arch /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > include\arch\.fakelnk
|
||||
endif
|
||||
|
||||
# Link the configs\<board-name>\include directory to include\arch\board
|
||||
|
||||
include\arch\board: include\arch Make.defs include\arch
|
||||
@echo "LN: include\arch\board -> $(BOARD_DIR)\include"
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d include\arch\board $(TOPDIR)\$(BOARD_DIR)\include
|
||||
else
|
||||
$(Q) xcopy $(TOPDIR)\$(BOARD_DIR)\include include\arch\board /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > include\arch\board\.fakelnk
|
||||
endif
|
||||
|
||||
# Link the configs\<board-name>\src dir to arch\<arch-name>\src\board
|
||||
|
||||
$(ARCH_SRC)\board: Make.defs
|
||||
@echo "LN: $(ARCH_SRC)\board -> $(BOARD_DIR)\src"
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d $(ARCH_SRC)\board $(TOPDIR)\$(BOARD_DIR)\src
|
||||
else
|
||||
$(Q) xcopy $(TOPDIR)\$(BOARD_DIR)\src $(ARCH_SRC)\board /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > $(ARCH_SRC)\board\.fakelnk
|
||||
endif
|
||||
|
||||
# Link arch\<arch-name>\include\<chip-name> to arch\<arch-name>\include\chip
|
||||
|
||||
$(ARCH_SRC)\chip: Make.defs
|
||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
@echo "LN: $(ARCH_SRC)\chip -> $(ARCH_SRC)\$(CONFIG_ARCH_CHIP)"
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d $(ARCH_SRC)\chip $(TOPDIR)\$(ARCH_SRC)\$(CONFIG_ARCH_CHIP)
|
||||
else
|
||||
$(Q) xcopy $(TOPDIR)\$(ARCH_SRC)\$(CONFIG_ARCH_CHIP) $(ARCH_SRC)\chip /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > $(ARCH_SRC)\chip\.fakelnk
|
||||
endif
|
||||
endif
|
||||
|
||||
# Link arch\<arch-name>\src\<chip-name> to arch\<arch-name>\src\chip
|
||||
|
||||
include\arch\chip: include\arch Make.defs
|
||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
@echo "LN: include\arch\chip -> $(ARCH_INC)\$(CONFIG_ARCH_CHIP)"
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d include\arch\chip $(TOPDIR)\$(ARCH_INC)\$(CONFIG_ARCH_CHIP)
|
||||
else
|
||||
$(Q) xcopy $(TOPDIR)\$(ARCH_INC)\$(CONFIG_ARCH_CHIP) include\arch\chip /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > include\arch\chip\.fakelnk
|
||||
endif
|
||||
endif
|
||||
|
||||
dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip include\apps
|
||||
|
||||
# context
|
||||
#
|
||||
# The context target is invoked on each target build to assure that NuttX is
|
||||
# properly configured. The basic configuration steps include creation of the
|
||||
# the config.h and version.h header files in the include\nuttx directory and
|
||||
# the establishment of symbolic links to configured directories.
|
||||
|
||||
context: check_context include\nuttx\config.h include\nuttx\version.h include\math.h include\float.h include\stdarg.h dirlinks
|
||||
$(Q) for %%G in ($(CONTEXTDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" context )
|
||||
|
||||
# clean_context
|
||||
#
|
||||
# This is part of the distclean target. It removes all of the header files
|
||||
# and symbolic links created by the context target.
|
||||
|
||||
clean_context:
|
||||
$(call DELFILE, include\nuttx\config.h)
|
||||
$(call DELFILE, include\nuttx\version.h)
|
||||
$(call DELFILE, include\math.h)
|
||||
$(call DELFILE, include\stdarg.h)
|
||||
$(call DELDIR, include\arch\board)
|
||||
$(call DELDIR, include\arch\chip)
|
||||
$(call DELDIR, include\arch)
|
||||
$(call DELDIR, $(ARCH_SRC)\board)
|
||||
$(call DELDIR, $(ARCH_SRC)\chip)
|
||||
$(call DELDIR, include\apps)
|
||||
|
||||
# check_context
|
||||
#
|
||||
# This target checks if NuttX has been configured. NuttX is configured using
|
||||
# the script tools\configure.sh. That script will install certain files in
|
||||
# the top-level NuttX build directory. This target verifies that those
|
||||
# configuration files have been installed and that NuttX is ready to be built.
|
||||
|
||||
check_context:
|
||||
$(Q) if not exist $(TOPDIR)\.config echo "$(TOPDIR)\.config does not exist"
|
||||
$(Q) if not exist $(TOPDIR)\Make.defs echo "$(TOPDIR)\Make.defs does not exist"
|
||||
|
||||
# Archive targets. The target build sequency will first create a series of
|
||||
# libraries, one per configured source file directory. The final NuttX
|
||||
# execution will then be built from those libraries. The following targets
|
||||
# build those libraries.
|
||||
#
|
||||
# Possible kernel-mode builds
|
||||
|
||||
libc\libkc$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libc TOPDIR="$(TOPDIR)" libkc$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libkc$(LIBEXT): libc\libkc$(LIBEXT)
|
||||
$(Q) install libc\libkc$(LIBEXT) lib\libkc$(LIBEXT)
|
||||
|
||||
sched\libsched$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libsched$(LIBEXT): sched\libsched$(LIBEXT)
|
||||
$(Q) install sched\libsched$(LIBEXT) lib\libsched$(LIBEXT)
|
||||
|
||||
$(ARCH_SRC)\libarch$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" libarch$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libarch$(LIBEXT): $(ARCH_SRC)\libarch$(LIBEXT)
|
||||
$(Q) install $(ARCH_SRC)\libarch$(LIBEXT) lib\libarch$(LIBEXT)
|
||||
|
||||
net\libnet$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C net TOPDIR="$(TOPDIR)" libnet$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libnet$(LIBEXT): net\libnet$(LIBEXT)
|
||||
$(Q) install net\libnet$(LIBEXT) lib\libnet$(LIBEXT)
|
||||
|
||||
fs\libfs$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C fs TOPDIR="$(TOPDIR)" libfs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libfs$(LIBEXT): fs\libfs$(LIBEXT)
|
||||
$(Q) install fs\libfs$(LIBEXT) lib\libfs$(LIBEXT)
|
||||
|
||||
drivers\libdrivers$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C drivers TOPDIR="$(TOPDIR)" libdrivers$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libdrivers$(LIBEXT): drivers\libdrivers$(LIBEXT)
|
||||
$(Q) install drivers\libdrivers$(LIBEXT) lib\libdrivers$(LIBEXT)
|
||||
|
||||
binfmt\libbinfmt$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C binfmt TOPDIR="$(TOPDIR)" libbinfmt$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libbinfmt$(LIBEXT): binfmt\libbinfmt$(LIBEXT)
|
||||
$(Q) install binfmt\libbinfmt$(LIBEXT) lib\libbinfmt$(LIBEXT)
|
||||
|
||||
graphics\libgraphics$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C graphics TOPDIR="$(TOPDIR)" libgraphics$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libgraphics$(LIBEXT): graphics\libgraphics$(LIBEXT)
|
||||
$(Q) install graphics\libgraphics$(LIBEXT) lib\libgraphics$(LIBEXT)
|
||||
|
||||
syscall\libstubs$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C syscall TOPDIR="$(TOPDIR)" libstubs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libstubs$(LIBEXT): syscall\libstubs$(LIBEXT)
|
||||
$(Q) install syscall\libstubs$(LIBEXT) lib\libstubs$(LIBEXT)
|
||||
|
||||
# Possible user-mode builds
|
||||
|
||||
libc\libuc$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libc TOPDIR="$(TOPDIR)" libuc$(LIBEXT)
|
||||
|
||||
lib\libuc$(LIBEXT): libc\libuc$(LIBEXT)
|
||||
$(Q) install libc\libuc$(LIBEXT) lib\libuc$(LIBEXT)
|
||||
|
||||
libxx\libcxx$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libxx TOPDIR="$(TOPDIR)" libcxx$(LIBEXT)
|
||||
|
||||
lib\libcxx$(LIBEXT): libxx\libcxx$(LIBEXT)
|
||||
$(Q) install libxx\libcxx$(LIBEXT) lib\libcxx$(LIBEXT)
|
||||
|
||||
mm\libmm$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||
|
||||
lib\libmm$(LIBEXT): mm\libmm$(LIBEXT)
|
||||
$(Q) install mm\libmm$(LIBEXT) lib\libmm$(LIBEXT)
|
||||
|
||||
$(APPDIR)\libapps$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
|
||||
|
||||
lib\libapps$(LIBEXT): $(APPDIR)\libapps$(LIBEXT)
|
||||
$(Q) install $(APPDIR)\libapps$(LIBEXT) lib\libapps$(LIBEXT)
|
||||
|
||||
syscall\libproxies$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C syscall TOPDIR="$(TOPDIR)" libproxies$(LIBEXT)
|
||||
|
||||
lib\libproxies$(LIBEXT): syscall\libproxies$(LIBEXT)
|
||||
$(Q) install syscall\libproxies$(LIBEXT) lib\libproxies$(LIBEXT)
|
||||
|
||||
# Possible non-kernel builds
|
||||
|
||||
libc\libc$(LIBEXT): context
|
||||
$(Q) $(MAKE) -C libc TOPDIR="$(TOPDIR)" libc$(LIBEXT)
|
||||
|
||||
lib\libc$(LIBEXT): libc\libc$(LIBEXT)
|
||||
$(Q) install libc\libc$(LIBEXT) lib\libc$(LIBEXT)
|
||||
|
||||
# pass1 and pass2
|
||||
#
|
||||
# If the 2 pass build option is selected, then this pass1 target is
|
||||
# configured to built before the pass2 target. This pass1 target may, as an
|
||||
# example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
|
||||
# incremental (relative) link object, but could be a static library (archive);
|
||||
# some modification to this Makefile would be required if CONFIG_PASS1_OBJECT
|
||||
# is an archive. Exactly what is performed during pass1 or what it generates
|
||||
# is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined.
|
||||
|
||||
pass1deps: pass1dep $(USERLIBS)
|
||||
|
||||
pass1: pass1deps
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
$(Q) if [ -z "$(CONFIG_PASS1_BUILDIR)" ]; then \
|
||||
echo "ERROR: CONFIG_PASS1_BUILDIR not defined"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) if [ ! -d "$(CONFIG_PASS1_BUILDIR)" ]; then \
|
||||
echo "ERROR: CONFIG_PASS1_BUILDIR does not exist"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) if [ ! -f "$(CONFIG_PASS1_BUILDIR)\Makefile" ]; then \
|
||||
echo "ERROR: No Makefile in CONFIG_PASS1_BUILDIR"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
|
||||
endif
|
||||
|
||||
pass2deps: pass2dep $(NUTTXLIBS)
|
||||
|
||||
pass2: pass2deps
|
||||
$(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN)
|
||||
ifeq ($(CONFIG_RRLOAD_BINARY),y)
|
||||
@echo "MK: $(BIN).rr"
|
||||
$(Q) $(TOPDIR)\tools\mkimage.sh --Prefix $(CROSSDEV) $(BIN) $(BIN).rr
|
||||
endif
|
||||
ifeq ($(CONFIG_INTELHEX_BINARY),y)
|
||||
@echo "CP: $(BIN).hex"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(BIN).hex
|
||||
endif
|
||||
ifeq ($(CONFIG_MOTOROLA_SREC),y)
|
||||
@echo "CP: $(BIN).srec"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(BIN).srec
|
||||
endif
|
||||
ifeq ($(CONFIG_RAW_BINARY),y)
|
||||
@echo "CP: $(BIN).bin"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(BIN).bin
|
||||
endif
|
||||
|
||||
# $(BIN)
|
||||
#
|
||||
# Create the final NuttX executable in a two pass build process. In the
|
||||
# normal case, all pass1 and pass2 dependencies are created then pass1
|
||||
# and pass2 targets are built. However, in some cases, you may need to build
|
||||
# pass1 depenencies and pass1 first, then build pass2 dependencies and pass2.
|
||||
# in that case, execute 'make pass1 pass2' from the command line.
|
||||
|
||||
$(BIN): pass1deps pass2deps pass1 pass2
|
||||
|
||||
# download
|
||||
#
|
||||
# This is a helper target that will rebuild NuttX and download it to the target
|
||||
# system in one step. The operation of this target depends completely upon
|
||||
# implementation of the DOWNLOAD command in the user Make.defs file. It will
|
||||
# generate an error an error if the DOWNLOAD command is not defined.
|
||||
|
||||
download: $(BIN)
|
||||
$(call DOWNLOAD, $<)
|
||||
|
||||
# pass1dep: Create pass1 build dependencies
|
||||
# pass2dep: Create pass2 build dependencies
|
||||
|
||||
pass1dep: context tools\mkdeps$(HOSTEXEEXT)
|
||||
$(Q) for %%G in ($(USERDEPDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" depend )
|
||||
|
||||
pass2dep: context tools\mkdeps$(HOSTEXEEXT)
|
||||
$(Q) for %%G in ($(KERNDEPDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend )
|
||||
|
||||
# Configuration targets
|
||||
#
|
||||
# These targets depend on the kconfig-frontends packages. To use these, you
|
||||
# must first download and install the kconfig-frontends package from this
|
||||
# location: http://ymorin.is-a-geek.org/projects/kconfig-frontends. See
|
||||
# misc\tools\README.txt for additional information.
|
||||
|
||||
config:
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} conf Kconfig
|
||||
|
||||
oldconfig:
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} conf --oldconfig Kconfig
|
||||
|
||||
menuconfig:
|
||||
$(Q) APPSDIR=${CONFIG_APPS_DIR} mconf Kconfig
|
||||
|
||||
# export
|
||||
#
|
||||
# The export target will package the NuttX libraries and header files into
|
||||
# an exportable package. Caveats: (1) These needs some extension for the KERNEL
|
||||
# build; it needs to receive USERLIBS and create a libuser.a). (2) The logic
|
||||
# in tools\mkexport.sh only supports GCC and, for example, explicitly assumes
|
||||
# that the archiver is 'ar'
|
||||
|
||||
export: pass2deps
|
||||
$(Q) tools\mkexport.sh -w$(WINTOOL) -t "$(TOPDIR)" -l "$(NUTTXLIBS)"
|
||||
|
||||
# General housekeeping targets: dependencies, cleaning, etc.
|
||||
#
|
||||
# depend: Create both PASS1 and PASS2 dependencies
|
||||
# clean: Removes derived object files, archives, executables, and
|
||||
# temporary files, but retains the configuration and context
|
||||
# files and directories.
|
||||
# distclean: Does 'clean' then also removes all configuration and context
|
||||
# files. This essentially restores the directory structure
|
||||
# to its original, unconfigured stated.
|
||||
|
||||
depend: pass1dep pass2dep
|
||||
|
||||
subdir_clean:
|
||||
$(Q) for %%G in ($(CLEANDIRS)) do ( if exist %%G\Makefile $(MAKE) -C %%G TOPDIR="$(TOPDIR)" clean )
|
||||
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" clean
|
||||
$(Q) $(MAKE) -C mm -f Makefile.test TOPDIR="$(TOPDIR)" clean
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
|
||||
clean: subdir_clean
|
||||
$(call DELFILE, $(BIN))
|
||||
$(call DELFILE, nuttx.*)
|
||||
$(call DELFILE, mm_test)
|
||||
$(call DELFILE, *.map)
|
||||
$(call DELFILE, _SAVED_APPS_config)
|
||||
$(call DELFILE, nuttx-export*)
|
||||
$(call CLEAN)
|
||||
|
||||
subdir_distclean:
|
||||
$(Q) for %%G in ($(CLEANDIRS)) do ( if exist %%G\Makefile $(MAKE) -C %%G TOPDIR="$(TOPDIR)" distclean )
|
||||
|
||||
distclean: clean subdir_distclean clean_context
|
||||
ifeq ($(CONFIG_BUILD_2PASS),y)
|
||||
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
|
||||
endif
|
||||
$(call DELFILE, Make.defs)
|
||||
$(call DELFILE, setenv.sh)
|
||||
$(call DELFILE, setenv.bat)
|
||||
$(call DELFILE, .config)
|
||||
$(call DELFILE, .config.old)
|
||||
|
||||
# Application housekeeping targets. The APPDIR variable refers to the user
|
||||
# application directory. A sample apps\ directory is included with NuttX,
|
||||
# however, this is not treated as part of NuttX and may be replaced with a
|
||||
# different application directory. For the most part, the application
|
||||
# directory is treated like any other build directory in this script. However,
|
||||
# as a convenience, the following targets are included to support housekeeping
|
||||
# functions in the user application directory from the NuttX build directory.
|
||||
#
|
||||
# apps_clean: Perform the clean operation only in the user application
|
||||
# directory
|
||||
# apps_distclean: Perform the distclean operation only in the user application
|
||||
# directory. Note that the apps\.config file (inf any) is
|
||||
# preserved so that this is not a "full" distclean but more of a
|
||||
# configuration "reset." (There willnot be an apps\.config
|
||||
# file if the configuration was generated via make menuconfig).
|
||||
|
||||
apps_clean:
|
||||
ifneq ($(APPDIR),)
|
||||
$(Q) $(MAKE) -C "$(TOPDIR)\$(APPDIR)" TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
|
||||
apps_distclean:
|
||||
ifneq ($(APPDIR),)
|
||||
$(call DELFILE, _SAVED_APPS_config
|
||||
$(Q) if exist "$(TOPDIR)\$(APPDIR)\.config" ( cp "$(TOPDIR)\$(APPDIR)\.config" _SAVED_APPS_config )
|
||||
$(Q) $(MAKE) -C "$(TOPDIR)\$(APPDIR)" TOPDIR="$(TOPDIR)" distclean
|
||||
$(Q) if exist _SAVED_APPS_config ( mv _SAVED_APPS_config "$(TOPDIR)\$(APPDIR)\.config" )
|
||||
endif
|
||||
|
||||
+149
-13
@@ -18,6 +18,8 @@ README
|
||||
- Building
|
||||
- Re-building
|
||||
- Build Targets and Options
|
||||
- Native Windows Build
|
||||
- Installing GNUWin32
|
||||
o Cygwin Build Problems
|
||||
- Strange Path Problems
|
||||
- Window Native Toolchain Issues
|
||||
@@ -154,9 +156,15 @@ Notes about Header Files
|
||||
|
||||
Even though you should not use a foreign C-Library, you may still need
|
||||
to use other, external libraries with NuttX. In particular, you may
|
||||
need to use the math library, libm.a. The math libary header file,
|
||||
math.h, is a special case. If you do nothing, the standard math.h
|
||||
header file that is provided with your toolchain will be used.
|
||||
need to use the math library, libm.a. NuttX supports a generic, built-in
|
||||
math library that can be enabled using CONFIG_LIBM=y. However, you may
|
||||
still want to use a higher performance external math library that has
|
||||
been tuned for your CPU. Sometimes such such tuned math libraries are
|
||||
bundled with your toolchain.
|
||||
|
||||
The math libary header file, math.h, is a then special case. If you do
|
||||
nothing, the standard math.h header file that is provided with your
|
||||
toolchain will be used.
|
||||
|
||||
If you have a custom, architecture specific math.h header file, then
|
||||
that header file should be placed at arch/<cpu>/include/math.h. There
|
||||
@@ -171,6 +179,16 @@ Notes about Header Files
|
||||
than to include that archicture-specific math.h header file as the
|
||||
system math.h header file.
|
||||
|
||||
float.h
|
||||
|
||||
If you enable the generic, built-in math library, then that math library
|
||||
will expect your toolchain to provide the standard float.h header file.
|
||||
The float.h header file defines the properties of your floating point
|
||||
implementation. It would always be best to use your toolchain's float.h
|
||||
header file but if none is avaiable, a default float.h header file will
|
||||
provided if this option is selected. However, there is no assurance that
|
||||
the settings in this float.h are actually correct for your platform!
|
||||
|
||||
stdarg.h
|
||||
|
||||
In most cases, the correct version of stdarg.h is the version provided with your toolchain. However, sometimes there are issues with with using your toolchains stdarg.h. For example, it may attempt to draw in header files that do not exist in NuttX or perhaps the header files that is uses are not compatible with the NuttX header files. In those cases, you can use an architecture-specific stdarg.h header file by defining CONFIG_ARCH_STDARG_H=y.
|
||||
@@ -189,7 +207,8 @@ Instantiating "Canned" Configurations
|
||||
|
||||
Where <board-name> is the name of your development board and <config-dir>.
|
||||
Configuring NuttX requires only copying three files from the <config-dir>
|
||||
to the directly where you installed NuttX (TOPDIR):
|
||||
to the directory where you installed NuttX (TOPDIR) (and sometimes one
|
||||
additional file to the directory the NuttX application package (APPSDIR)):
|
||||
|
||||
Copy configs/<board-name>/<config-dir>/Make.def to ${TOPDIR}/Make.defs
|
||||
|
||||
@@ -211,6 +230,14 @@ to the directly where you installed NuttX (TOPDIR):
|
||||
included in the build and what is not. This file is also used
|
||||
to generate a C configuration header at include/nuttx/config.h.
|
||||
|
||||
Copy configs/<board-name>/<config-dir>/appconfig to ${APPSDIR}/.config
|
||||
|
||||
The appconfig file describes the applications that need to be
|
||||
built in the appliction directory (APPSDIR). Not all configurations
|
||||
have an appconfig file. This file is deprecated and will not be
|
||||
used with new defconfig files produced with the mconf configuration
|
||||
tool.
|
||||
|
||||
General information about configuring NuttX can be found in:
|
||||
|
||||
${TOPDIR}/configs/README.txt
|
||||
@@ -468,6 +495,101 @@ Build Targets and Options
|
||||
useful when adding new boards or tracking down compile time errors and
|
||||
warnings (Contributed by Richard Cochran).
|
||||
|
||||
Native Windows Build
|
||||
--------------------
|
||||
|
||||
The beginnings of a Windows native build are in place but still not full
|
||||
usable as of this writing. The windows native build logic is currently
|
||||
separate and must be started by:
|
||||
|
||||
make -f Makefile.win
|
||||
|
||||
This build:
|
||||
|
||||
- Uses all Windows style paths
|
||||
- Uses primarily Windows batch commands from cmd.exe, with
|
||||
- A few extensions from GNUWin32 (or MSYS is you prefer)
|
||||
|
||||
In this build, you cannot use a Cygwin or MSYS shell. Rather the build must
|
||||
be performed in a Windows CMD shell. Here is a better shell than than the
|
||||
standard issue, CMD shell: ConEmu which can be downloaded from:
|
||||
http://code.google.com/p/conemu-maximus5/
|
||||
|
||||
Build Tools. The build still relies on some Unix-like commands. I use
|
||||
the GNUWin32 tools that can be downloaded from http://gnuwin32.sourceforge.net/.
|
||||
The MSYS tools are probably also a option but are likely lower performance
|
||||
since they are based on Cygwin 1.3.
|
||||
|
||||
Host Compiler: I use the MingGW compiler which can be downloaded from
|
||||
http://www.mingw.org/. If you are using GNUWin32, then it is recommended
|
||||
the you not install the optional MSYS components as there may be conflicts.
|
||||
|
||||
Installing GNUWin32
|
||||
-------------------
|
||||
|
||||
The Windows native build will depend upon a few Unix-like tools that can be
|
||||
provided either by MSYS or GNUWin32. The GNUWin32 are available from
|
||||
http://gnuwin32.sourceforge.net/. GNUWin32 provides ports of tools with a
|
||||
GPL or similar open source license to modern MS-Windows (Microsoft Windows
|
||||
2000 / XP / 2003 / Vista / 2008 / 7). See
|
||||
http://gnuwin32.sourceforge.net/packages.html for a list of all of the tools
|
||||
available in the GNUWin32 package.
|
||||
|
||||
The SourceForge project is located here:
|
||||
http://sourceforge.net/projects/gnuwin32/. The project is still being
|
||||
actively supported (although some of the Windows ports have gotten very old).
|
||||
|
||||
Some commercial toolchains include a subset of the GNUWin32 tools in the
|
||||
installation. My recommendation is that you download the GNUWin32 tools
|
||||
directly from the sourceforge.net website so that you will know what you are
|
||||
using and can reproduce your build environment.
|
||||
|
||||
GNUWin32 Installation Steps:
|
||||
|
||||
The following steps will download and execute the GNUWin32 installer.
|
||||
|
||||
1. Download GetGNUWin32-x.x.x.exe from
|
||||
http://sourceforge.net/projects/getgnuwin32/files/. This is the
|
||||
installer. The current version as of this writing is 0.6.3.
|
||||
|
||||
2. Run the installer.
|
||||
|
||||
3. Accept the license.
|
||||
|
||||
4. Select the installation directory. My recommendation is the
|
||||
directory that contains this README file (<this-directory>).
|
||||
|
||||
5. After running GetGNUWin32-0.x.x.exe, you will have a new directory
|
||||
<this-directory>/GetGNUWin32
|
||||
|
||||
Note the the GNUWin32 installer didn't install GNUWin32. Instead, it
|
||||
installed another, smarter downloader. That downloader is the GNUWin32
|
||||
package management tool developed by the Open SSL project.
|
||||
|
||||
The following steps probably should be performed from inside a DOS shell.
|
||||
|
||||
6. Change to the directory created by GetGNUWin32-x.x.x.exe
|
||||
|
||||
cd GetGNUWin32
|
||||
|
||||
7. Execute the download.bat script. The download.bat script will download
|
||||
about 446 packages! Enough to have a very complete Linux-like environment
|
||||
under the DOS shell. This will take awhile. This step only downloads
|
||||
the packages and the next step will install the packages.
|
||||
|
||||
download
|
||||
|
||||
8. This step will install the downloaded packages. The argument of the
|
||||
install.bat script is the installation location. C:\gnuwin32 is the
|
||||
standard install location:
|
||||
|
||||
install C:\gnuwin32
|
||||
|
||||
NOTE: This installation step will install *all* GNUWin32 packages... far
|
||||
more than you will ever need. If disc space is a problem for you, you might
|
||||
need to perform a manual installation of the individual ZIP files that you
|
||||
will find in the <this directory>/GetGNUWin32/packages directory.
|
||||
|
||||
CYGWIN BUILD PROBLEMS
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -523,18 +645,16 @@ Window Native Toolchain Issues
|
||||
is not a long as you might think because there is no dependency checking
|
||||
if you are using a native Windows toolchain. That bring us to #3:
|
||||
|
||||
3. Dependencies are not made when using Windows versions of the GCC. This is
|
||||
because the dependencies are generated using Windows pathes which do not
|
||||
work with the Cygwin make.
|
||||
3. Dependencies are not made when using Windows versions of the GCC on a POSIX
|
||||
platform (i.e., Cygwin). This is because the dependencies are generated
|
||||
using Windows paths which do not work with the Cygwin make.
|
||||
|
||||
Support has been added for making dependencies with the windows-native toolchains.
|
||||
That support can be enabled by modifying your Make.defs file as follows:
|
||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||
|
||||
- MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||
+ MKDEP = $(TOPDIR)/tools/mkdeps.sh --winpaths "$(TOPDIR)"
|
||||
If you are building natively on Windows, then no such conflict exists
|
||||
and the best selection is:
|
||||
|
||||
If you have problems with the dependency build (for example, if you are not
|
||||
building on C:), then you may need to modify tools/mkdeps.sh
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.exe
|
||||
|
||||
General Pre-built Toolchain Issues
|
||||
|
||||
@@ -765,6 +885,8 @@ nuttx
|
||||
| | `- README.txt
|
||||
| |- stm3240g-eval/
|
||||
| | `- README.txt
|
||||
| |- stm32f100rc_generic/
|
||||
| | `- README.txt
|
||||
| |- stm32f4discovery/
|
||||
| | `- README.txt
|
||||
| |- sure-pic32mx/
|
||||
@@ -817,6 +939,8 @@ nuttx
|
||||
| `- README.txt
|
||||
|- lib/
|
||||
| `- README.txt
|
||||
|- libc/
|
||||
| `- README.txt
|
||||
|- libxx/
|
||||
| `- README.txt
|
||||
|- mm/
|
||||
@@ -828,6 +952,7 @@ nuttx
|
||||
|
||||
apps
|
||||
|- examples/
|
||||
| |- json/README.txt
|
||||
| |- pashello/README.txt
|
||||
| `- README.txt
|
||||
|- graphics/
|
||||
@@ -843,6 +968,8 @@ apps
|
||||
| | `- README.txt
|
||||
| |- ftpc
|
||||
| | `- README.txt
|
||||
| |- json
|
||||
| | `- README.txt
|
||||
| |- telnetd
|
||||
| | `- README.txt
|
||||
| `- README.txt
|
||||
@@ -864,3 +991,12 @@ apps
|
||||
| `- sysinfo
|
||||
| `- README.txt
|
||||
`- README.txt
|
||||
|
||||
NxWidgets
|
||||
|- Doxygen
|
||||
| `- README.txt
|
||||
|- tools
|
||||
| `- README.txt
|
||||
|- UnitTests
|
||||
| `- README.txt
|
||||
`- README.txt
|
||||
|
||||
@@ -3171,3 +3171,81 @@ Bugfixes (see the change log for details). Some of these are very important
|
||||
Vainish). Fix some field-width handling issues in sscanf()
|
||||
|
||||
As well as other, less critical bugs (see the ChangeLog for details)
|
||||
|
||||
NuttX-6.23
|
||||
^^^^^^^^^^
|
||||
|
||||
The 90th release of NuttX, Version 6.23, was made on November 5, 2012,
|
||||
and is available for download from the SourceForge website. Note
|
||||
that release consists of two tarballs: nuttx-6.23.tar.gz and
|
||||
apps-6.23.tar.gz. Both may be needed (see the top-level nuttx/README.txt
|
||||
file for build information).
|
||||
|
||||
This release corresponds with SVN release number: r5313
|
||||
|
||||
Note that all SVN information has been stripped from the tarballs. If you
|
||||
r5313 the SVN configuration, you should check out directly from SVN. Revision
|
||||
r5206 should equivalent to release 6.22 of NuttX 6.22:
|
||||
|
||||
svn checkout -r5313 svn://svn.code.sf.net/p/nuttx/code/trunk nuttx-code
|
||||
|
||||
Or
|
||||
|
||||
svn checkout -r5313 http://svn.code.sf.net/p/nuttx/code/trunk nuttx-code
|
||||
|
||||
Additional new features and extended functionality:
|
||||
|
||||
* RTOS: If both atexit() and on_exit() are enabled, use on_exit() to
|
||||
implement atexit(). Updates for RGMP 4.0.
|
||||
|
||||
* Binfmt: Add support for loading and executing ELF binary modules from
|
||||
a file system.
|
||||
|
||||
* Drivers: Maxim MAX11802 touchscreen controller (Petteri Aimonen)
|
||||
|
||||
* STM32 Driver: Implementation of /dev/random using the STM32 Random Number
|
||||
Generator (RNG).
|
||||
|
||||
* STM32 Boards: ADC support for the Shenzhou IV board. Relay support for
|
||||
the Shenzhou IV board.
|
||||
|
||||
* C Library: Support is now included for the add-on uClibc++ C++
|
||||
standard library support. This includes support for iostreams, strings,
|
||||
STL, RTTI, exceptions -- the complete C++ environment. (uClibc++ is
|
||||
provided as a separate add-on package due to licensing issues).
|
||||
|
||||
Optimized generic and ARM-specific memcpy() function. Optimized
|
||||
memset() function.
|
||||
|
||||
Add support for ferror(), feof(), and clearerror(). Add support for
|
||||
__cxa_atexit().
|
||||
|
||||
Math Library: Port of the math library from Rhombus OS by Nick Johnson
|
||||
(Darcy Gong).
|
||||
|
||||
* Applications: New NSH commands: ifup, ifdown, urlencode, urldecode,
|
||||
base64enc, bas64dec, md5 (Darcy Gong). Add support for NSH telnet login
|
||||
(Darcy Gong). Enancements to NSH ping command to support pinging hosts
|
||||
with very long round-trip times. Extensions to the ifconfig command
|
||||
Darcy Gong),
|
||||
|
||||
Many extensions to the webclient/wget and DNS resolver logic from Darcy
|
||||
Gong. JSON, Base64, URL encoding, and MD5 libraries contributed by Darcy
|
||||
Gong.
|
||||
|
||||
New examples: ELF loader, JSON, wgetjson, cxxtest, relays.
|
||||
|
||||
Bugfixes (see the change log for details). Some of these are very important
|
||||
(marked *critical*):
|
||||
|
||||
* Drivers: W25 SPI FLASH
|
||||
|
||||
* STM32 Drivers: ADC reset
|
||||
|
||||
* Graphics: Missing implementation of the blocked method (*critical*,
|
||||
Petteri Aimonen).
|
||||
|
||||
* C Library: Floating point numbers in printf and related formatting functions
|
||||
(Mike Smith), cf[get|set]speed() (Mike Smith)
|
||||
|
||||
As well as other, less critical bugs (see the ChangeLog for details)
|
||||
|
||||
+23
-32
@@ -14,8 +14,8 @@ nuttx/
|
||||
(2) C++ Support
|
||||
(6) Binary loaders (binfmt/)
|
||||
(17) Network (net/, drivers/net)
|
||||
(3) USB (drivers/usbdev, drivers/usbhost)
|
||||
(11) Libraries (lib/)
|
||||
(4) USB (drivers/usbdev, drivers/usbhost)
|
||||
(11) Libraries (libc/, )
|
||||
(9) File system/Generic drivers (fs/, drivers/)
|
||||
(5) Graphics subystem (graphics/)
|
||||
(1) Pascal add-on (pcode/)
|
||||
@@ -32,7 +32,7 @@ nuttx/
|
||||
(0) ARM/LPC43x (arch/arm/src/lpc43xx/)
|
||||
(3) ARM/STR71x (arch/arm/src/str71x/)
|
||||
(3) ARM/LM3S6918 (arch/arm/src/lm3s/)
|
||||
(7) ARM/STM32 (arch/arm/src/stm32/)
|
||||
(4) ARM/STM32 (arch/arm/src/stm32/)
|
||||
(3) AVR (arch/avr)
|
||||
(0) Intel x86 (arch/x86)
|
||||
(4) 8051 / MCS51 (arch/8051/)
|
||||
@@ -421,7 +421,7 @@ o Binary loaders (binfmt/)
|
||||
.word .LC3-(.LPIC4+4)
|
||||
.word .LC4-(.LPIC5+4)
|
||||
|
||||
This is good and bad. This is good because it means that .rodata.str1.1 can not
|
||||
This is good and bad. This is good because it means that .rodata.str1.1 can now
|
||||
reside in FLASH with .text and can be accessed using PC-relative addressing.
|
||||
That can be accomplished by simply moving the .rodata from the .data section to
|
||||
the .text section in the linker script. (The NXFLAT linker script is located at
|
||||
@@ -629,8 +629,13 @@ o USB (drivers/usbdev, drivers/usbhost)
|
||||
CDC/ACM serial driver might need the line coding data (that
|
||||
data is not used currenly, but it might be).
|
||||
|
||||
o Libraries (lib/)
|
||||
^^^^^^^^^^^^^^^^
|
||||
Title: USB HUB SUPPORT
|
||||
Description: Add support for USB hubs
|
||||
Status: Open
|
||||
Priority: Low/Unknown. This is a feature enhancement.
|
||||
|
||||
o Libraries (libc/)
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
Title: ENVIRON
|
||||
Description: The definition of environ in stdlib.h is bogus and will not
|
||||
@@ -643,7 +648,7 @@ o Libraries (lib/)
|
||||
Description: Need some minimal termios support... at a minimum, enough to
|
||||
switch between raw and "normal" modes to support behavior like
|
||||
that needed for readline().
|
||||
UPDATE: There is growing functionality in lib/termios/ and in the
|
||||
UPDATE: There is growing functionality in libc/termios/ and in the
|
||||
ioctl methods of several MCU serial drivers (stm32, lpc43, lpc17,
|
||||
pic32). However, as phrased, this bug cannot yet be closed since
|
||||
this "growing functionality" does not address all termios.h
|
||||
@@ -708,7 +713,7 @@ o Libraries (lib/)
|
||||
Priority:
|
||||
|
||||
Title: OLD dtoa NEEDS TO BE UPDATED
|
||||
Description: This implementation of dtoa in lib/stdio is old and will not
|
||||
Description: This implementation of dtoa in libc/stdio is old and will not
|
||||
work with some newer compilers. See
|
||||
http://patrakov.blogspot.com/2009/03/dont-use-old-dtoac.html
|
||||
Status: Open
|
||||
@@ -716,7 +721,7 @@ o Libraries (lib/)
|
||||
|
||||
Title: SYSLOG INTEGRATION
|
||||
Description: There are the beginnings of some system logging capabilities (see
|
||||
drivers/syslog, fs/fs_syslog.c, and lib/stdio/lib_librawprintf.c and
|
||||
drivers/syslog, fs/fs_syslog.c, and libc/stdio/lib_librawprintf.c and
|
||||
lib_liblowprintf.c. For NuttX, SYSLOG is a concept and includes,
|
||||
extends, and replaces the legacy NuttX debug ouput. Some additional
|
||||
integration is required to formalized this. For example:
|
||||
@@ -953,7 +958,7 @@ o Build system
|
||||
built configuration, only the multiple user mode can be supported
|
||||
with the NX server residing inside of the kernel space. In
|
||||
this case, most of the user end functions in graphics/nxmu
|
||||
must be moved to lib/nx and those functions must be built into
|
||||
must be moved to libc/nx and those functions must be built into
|
||||
libuser.a to be linked with the user-space code.
|
||||
A similar issue exists in NSH that uses some internal OS
|
||||
interfaces that would not be available in a kernel build
|
||||
@@ -1344,11 +1349,6 @@ o ARM/LM3S6918 (arch/arm/src/lm3s/)
|
||||
o ARM/STM32 (arch/arm/src/stm32/)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Title: NOR FLASH DRIVER
|
||||
Description: NOR Flash driver with FTL layer to support a file system.
|
||||
Status: Open
|
||||
Priority: Low
|
||||
|
||||
Title: USBSERIAL ISSUES
|
||||
Description A USB device-side driver is in place but not well tested. At
|
||||
present, the apps/examples/usbserial test sometimes fails. The situation
|
||||
@@ -1371,11 +1371,6 @@ o ARM/STM32 (arch/arm/src/stm32/)
|
||||
Status: Open
|
||||
Priority: Medium-High
|
||||
|
||||
Title: FSMC EXTERNAL MEMORY UNTESTED
|
||||
Description: FSMC external memory support is untested
|
||||
Status: Open
|
||||
Priority: Low
|
||||
|
||||
Title: DMA EXTENSIONS
|
||||
Description: DMA logic needs to be extended. DMA2, Channel 5, will not work
|
||||
because the DMA2 channels 4 & 5 share the same interrupt.
|
||||
@@ -1383,12 +1378,6 @@ o ARM/STM32 (arch/arm/src/stm32/)
|
||||
Priority: Low until someone needs DMA1, Channel 5 (ADC3, UART4_TX, TIM5_CH1, or
|
||||
TIM8_CH2).
|
||||
|
||||
Title: UNFINISHED DRIVERS
|
||||
Description: The following drivers are incomplete: DAC. The following drivers
|
||||
are untested: DMA on the F4, CAN.
|
||||
Status: Open
|
||||
Priority: Medium
|
||||
|
||||
Title: F4 SDIO MULTI-BLOCK TRANSFER FAILURES
|
||||
Description: If you use a large I/O buffer to access the file system, then the
|
||||
MMCSD driver will perform multiple block SD transfers. With DMA
|
||||
@@ -1412,13 +1401,15 @@ o ARM/STM32 (arch/arm/src/stm32/)
|
||||
Status: Open
|
||||
Priority: Low (I am not even sure if this is a problem yet).
|
||||
|
||||
Status: UNFINISHED STM32 F4 OTG FS HOST DRIVER
|
||||
Description: A quick-n-dirty leverage of the the LPC17xx host driver was put into
|
||||
the STM32 source to support development of the STM32 F4 OTG FS host
|
||||
driver. It is non-functional and still waiting for STM32 F4 logic
|
||||
to be added. Don't use it!
|
||||
Title: DMA FROM EXTERNAL, FSMC MEMORY
|
||||
Description: I have seen a problem on F1 where all SDIO DMAs work exist for
|
||||
write DMAs from FSMC memory (i.e., from FSMC memory to SDIO).
|
||||
Read transfers work fine (SDIO to FSMC memory). The failure is
|
||||
a data underrun error with zero bytes of data transferred. The
|
||||
workaround for now is to use DMA buffers allocted from internal
|
||||
SRAM.
|
||||
Status: Open
|
||||
Priority: Low (unless you need a host driver).
|
||||
Priority: Low
|
||||
|
||||
o AVR (arch/avr)
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#
|
||||
|
||||
if ARCH_ARM
|
||||
comment "ARM Options"
|
||||
|
||||
choice
|
||||
prompt "ARM chip selection"
|
||||
default ARCH_CHIP_STM32
|
||||
@@ -153,6 +155,9 @@ config ARCH_CHIP
|
||||
default "stm32" if ARCH_CHIP_STM32
|
||||
default "str71x" if ARCH_CHIP_STR71X
|
||||
|
||||
config ARCH_HAVE_CMNVECTOR
|
||||
bool
|
||||
|
||||
config ARMV7M_CMNVECTOR
|
||||
bool "Use common ARMv7-M vectors"
|
||||
default n
|
||||
@@ -239,6 +244,18 @@ config ARCH_CALIBRATION
|
||||
watch to measure the 100 second delay then adjust BOARD_LOOPSPERMSEC until
|
||||
the delay actually is 100 seconds.
|
||||
|
||||
config DEBUG_HARDFAULT
|
||||
bool "Verbose Hard-Fault Debug"
|
||||
default n
|
||||
depends on DEBUG && (ARCH_CORTEXM3 || ARCH_CORTEXM4)
|
||||
---help---
|
||||
Enables verbose debug output when a hard fault is occurs. This verbose
|
||||
output is sometimes helpful when debugging difficult hard fault problems,
|
||||
but may be more than you typcially want to see.
|
||||
|
||||
if ARCH_CORTEXM3 || ARCH_CORTEXM4
|
||||
source arch/arm/src/armv7-m/Kconfig
|
||||
endif
|
||||
if ARCH_CHIP_C5471
|
||||
source arch/arm/src/c5471/Kconfig
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/include/syscall.h
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Reference: "ELF for the ARM® Architecture," ARM IHI 0044D, current through
|
||||
* ABI release 2.08, October 28, 2009, ARM Limited.
|
||||
*
|
||||
* 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 __ARCH_ARM_INCLUDE_ELF_H
|
||||
#define __ARCH_ARM_INCLUDE_ELF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* 4.3.1 ELF Identification. Should have:
|
||||
*
|
||||
* e_machine = EM_ARM
|
||||
* e_ident[EI_CLASS] = ELFCLASS32
|
||||
* e_ident[EI_DATA] = ELFDATA2LSB (little endian) or ELFDATA2MSB (big endian)
|
||||
*/
|
||||
|
||||
#if 0 /* Defined in include/elf32.h */
|
||||
#define EM_ARM 40
|
||||
#endif
|
||||
|
||||
/* Table 4-2, ARM-specific e_flags */
|
||||
|
||||
#define EF_ARM_EABI_MASK 0xff000000
|
||||
#define EF_ARM_EABI_UNKNOWN 0x00000000
|
||||
#define EF_ARM_EABI_VER1 0x01000000
|
||||
#define EF_ARM_EABI_VER2 0x02000000
|
||||
#define EF_ARM_EABI_VER3 0x03000000
|
||||
#define EF_ARM_EABI_VER4 0x04000000
|
||||
#define EF_ARM_EABI_VER5 0x05000000
|
||||
|
||||
#define EF_ARM_BE8 0x00800000
|
||||
|
||||
/* Table 4-4, Processor specific section types */
|
||||
|
||||
#define SHT_ARM_EXIDX 0x70000001 /* Exception Index table */
|
||||
#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking pre-emption map */
|
||||
#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attributes */
|
||||
#define SHT_ARM_DEBUGOVERLAY 0x70000004
|
||||
#define SHT_ARM_OVERLAYSECTION 0x70000005
|
||||
|
||||
/* 4.7.1 Relocation codes
|
||||
*
|
||||
* S (when used on its own) is the address of the symbol.
|
||||
* A is the addend for the relocation.
|
||||
* P is the address of the place being relocated (derived from r_offset).
|
||||
* Pa is the adjusted address of the place being relocated, defined as (P & 0xFFFFFFFC).
|
||||
* T is 1 if the target symbol S has type STT_FUNC and the symbol addresses a Thumb instruction;
|
||||
* it is 0 otherwise.
|
||||
* B(S) is the addressing origin of the output segment defining the symbol S.
|
||||
* GOT_ORG is the addressing origin of the Global Offset Table
|
||||
* GOT(S) is the address of the GOT entry for the symbol S.
|
||||
*/
|
||||
|
||||
#define R_ARM_NONE 0 /* No relocation */
|
||||
#define R_ARM_PC24 1 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_ABS32 2 /* Data (S + A) | T */
|
||||
#define R_ARM_REL32 3 /* Data ((S + A) | T) - P */
|
||||
#define R_ARM_LDR_PC_G0 4 /* ARM S + A - P */
|
||||
#define R_ARM_ABS16 5 /* Data S + A */
|
||||
#define R_ARM_ABS12 6 /* ARM S + A */
|
||||
#define R_ARM_THM_ABS5 7 /* Thumb16 S + A */
|
||||
#define R_ARM_ABS8 8 /* Data S + A */
|
||||
#define R_ARM_SBREL32 9 /* Data ((S + A) | T) - B(S) */
|
||||
#define R_ARM_THM_CALL 10 /* Thumb32 ((S + A) | T) - P */
|
||||
#define R_ARM_THM_PC8 11 /* Thumb16 S + A - Pa */
|
||||
#define R_ARM_BREL_ADJ 12 /* Data ?B(S) + A */
|
||||
#define R_ARM_TLS_DESC 13 /* Data */
|
||||
#define R_ARM_THM_SWI8 14 /* Obsolete */
|
||||
#define R_ARM_XPC25 15 /* Obsolete */
|
||||
#define R_ARM_THM_XPC22 16 /* Obsolete */
|
||||
#define R_ARM_TLS_DTPMOD32 17 /* Data Module[S] */
|
||||
#define R_ARM_TLS_DTPOFF32 18 /* Data S + A - TLS */
|
||||
#define R_ARM_TLS_TPOFF32 19 /* Data S + A - tp */
|
||||
#define R_ARM_COPY 20 /* Miscellaneous */
|
||||
#define R_ARM_GLOB_DAT 21 /* Data (S + A) | T */
|
||||
#define R_ARM_JUMP_SLOT 22 /* Data (S + A) | T */
|
||||
#define R_ARM_RELATIVE 23 /* Data B(S) + A */
|
||||
#define R_ARM_GOTOFF32 24 /* Data ((S + A) | T) - GOT_ORG */
|
||||
#define R_ARM_BASE_PREL 25 /* Data B(S) + A - P */
|
||||
#define R_ARM_GOT_BREL 26 /* Data GOT(S) + A - GOT_ORG */
|
||||
#define R_ARM_PLT32 27 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_CALL 28 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_JUMP24 29 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_THM_JUMP24 30 /* Thumb32 ((S + A) | T) - P */
|
||||
#define R_ARM_BASE_ABS 31 /* Data B(S) + A */
|
||||
#define R_ARM_ALU_PCREL_7_0 32 /* Obsolete */
|
||||
#define R_ARM_ALU_PCREL_15_8 33 /* Obsolete */
|
||||
#define R_ARM_ALU_PCREL_23_15 34 /* Obsolete */
|
||||
#define R_ARM_LDR_SBREL_11_0_NC 35 /* ARM S + A - B(S) */
|
||||
#define R_ARM_ALU_SBREL_19_12_NC 36 /* ARM S + A - B(S) */
|
||||
#define R_ARM_ALU_SBREL_27_20_CK 37 /* ARM S + A - B(S) */
|
||||
#define R_ARM_TARGET1 38 /* Miscellaneous (S + A) | T or ((S + A) | T) - P */
|
||||
#define R_ARM_SBREL31 39 /* Data ((S + A) | T) - B(S) */
|
||||
#define R_ARM_V4BX 40 /* Miscellaneous */
|
||||
#define R_ARM_TARGET2 41 /* Miscellaneous */
|
||||
#define R_ARM_PREL31 42 /* Data ((S + A) | T) - P */
|
||||
#define R_ARM_MOVW_ABS_NC 43 /* ARM (S + A) | T */
|
||||
#define R_ARM_MOVT_ABS 44 /* ARM S + A */
|
||||
#define R_ARM_MOVW_PREL_NC 45 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_MOVT_PREL 46 /* ARM S + A - P */
|
||||
#define R_ARM_THM_MOVW_ABS_NC 47 /* Thumb32 (S + A) | T */
|
||||
#define R_ARM_THM_MOVT_ABS 48 /* Thumb32 S + A */
|
||||
#define R_ARM_THM_MOVW_PREL_NC 49 /* Thumb32 ((S + A) | T) - P */
|
||||
#define R_ARM_THM_MOVT_PREL 50 /* Thumb32 S + A - P */
|
||||
#define R_ARM_THM_JUMP19 51 /* Thumb32 ((S + A) | T) - P */
|
||||
#define R_ARM_THM_JUMP6 52 /* Thumb16 S + A - P */
|
||||
#define R_ARM_THM_ALU_PREL_11_0 53 /* Thumb32 ((S + A) | T) - Pa */
|
||||
#define R_ARM_THM_PC12 54 /* Thumb32 S + A - Pa */
|
||||
#define R_ARM_ABS32_NOI 55 /* Data S + A */
|
||||
#define R_ARM_REL32_NOI 56 /* Data S + A - P */
|
||||
#define R_ARM_ALU_PC_G0_NC 57 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_ALU_PC_G0 58 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_ALU_PC_G1_NC 59 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_ALU_PC_G1 60 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_ALU_PC_G2 61 /* ARM ((S + A) | T) - P */
|
||||
#define R_ARM_LDR_PC_G1 62 /* ARM S + A - P */
|
||||
#define R_ARM_LDR_PC_G2 63 /* ARM S + A - P */
|
||||
#define R_ARM_LDRS_PC_G0 64 /* ARM S + A - P */
|
||||
#define R_ARM_LDRS_PC_G1 65 /* ARM S + A - P */
|
||||
#define R_ARM_LDRS_PC_G2 66 /* ARM S + A - P */
|
||||
#define R_ARM_LDC_PC_G0 67 /* ARM S + A - P */
|
||||
#define R_ARM_LDC_PC_G1 68 /* ARM S + A - P */
|
||||
#define R_ARM_LDC_PC_G2 69 /* ARM S + A - P */
|
||||
#define R_ARM_ALU_SB_G0_NC 70 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_ALU_SB_G0 71 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_ALU_SB_G1_NC 72 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_ALU_SB_G1 73 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_ALU_SB_G2 74 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_LDR_SB_G0 75 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDR_SB_G1 76 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDR_SB_G2 77 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDRS_SB_G0 78 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDRS_SB_G1 79 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDRS_SB_G2 80 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDC_SB_G0 81 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDC_SB_G1 82 /* ARM S + A - B(S) */
|
||||
#define R_ARM_LDC_SB_G2 83 /* ARM S + A - B(S) */
|
||||
#define R_ARM_MOVW_BREL_NC 84 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_MOVT_BREL 85 /* ARM S + A - B(S) */
|
||||
#define R_ARM_MOVW_BREL 86 /* ARM ((S + A) | T) - B(S) */
|
||||
#define R_ARM_THM_MOVW_BREL_NC 87 /* Thumb32 ((S + A) | T) - B(S) */
|
||||
#define R_ARM_THM_MOVT_BREL 88 /* Thumb32 S + A - B(S) */
|
||||
#define R_ARM_THM_MOVW_BREL 89 /* Thumb32 ((S + A) | T) - B(S) */
|
||||
#define R_ARM_TLS_GOTDESC 90 /* Data */
|
||||
#define R_ARM_TLS_CALL 91 /* ARM */
|
||||
#define R_ARM_TLS_DESCSEQ 92 /* ARM TLS relaxation */
|
||||
#define R_ARM_THM_TLS_CALL 93 /* Thumb32 */
|
||||
#define R_ARM_PLT32_ABS 94 /* Data PLT(S) + A */
|
||||
#define R_ARM_GOT_ABS 95 /* Data GOT(S) + A */
|
||||
#define R_ARM_GOT_PREL 96 /* Data GOT(S) + A - P */
|
||||
#define R_ARM_GOT_BREL12 97 /* ARM GOT(S) + A - GOT_ORG */
|
||||
#define R_ARM_GOTOFF12 98 /* ARM S + A - GOT_ORG */
|
||||
#define R_ARM_GOTRELAX 99 /* Miscellaneous */
|
||||
#define R_ARM_GNU_VTENTRY 100 /* Data */
|
||||
#define R_ARM_GNU_VTINHERIT 101 /* Data */
|
||||
#define R_ARM_THM_JUMP11 102 /* Thumb16 S + A - P */
|
||||
#define R_ARM_THM_JUMP8 103 /* Thumb16 S + A - P */
|
||||
#define R_ARM_TLS_GD32 104 /* Data GOT(S) + A - P */
|
||||
#define R_ARM_TLS_LDM32 105 /* Data GOT(S) + A - P */
|
||||
#define R_ARM_TLS_LDO32 106 /* Data S + A - TLS */
|
||||
#define R_ARM_TLS_IE32 107 /* Data GOT(S) + A - P */
|
||||
#define R_ARM_TLS_LE32 108 /* Data S + A - tp */
|
||||
#define R_ARM_TLS_LDO12 109 /* ARM S + A - TLS */
|
||||
#define R_ARM_TLS_LE12 110 /* ARM S + A - tp */
|
||||
#define R_ARM_TLS_IE12GP 111 /* ARM GOT(S) + A - GOT_ORG */
|
||||
#define R_ARM_ME_TOO 128 /* Obsolete */
|
||||
#define R_ARM_THM_TLS_DESCSEQ16 129 /* Thumb16 */
|
||||
#define R_ARM_THM_TLS_DESCSEQ32 130 /* Thumb32 */
|
||||
|
||||
/* 5.2.1 Platform architecture compatibility data */
|
||||
|
||||
#define PT_ARM_ARCHEXT_FMTMSK 0xff000000
|
||||
#define PT_ARM_ARCHEXT_PROFMSK 0x00ff0000
|
||||
#define PT_ARM_ARCHEXT_ARCHMSK 0x000000ff
|
||||
|
||||
#define PT_ARM_ARCHEXT_FMT_OS 0x00000000
|
||||
#define PT_ARM_ARCHEXT_FMT_ABI 0x01000000
|
||||
|
||||
#define PT_ARM_ARCHEXT_PROF_NONE 0x00000000
|
||||
#define PT_ARM_ARCHEXT_PROF_ARM 0x00410000
|
||||
#define PT_ARM_ARCHEXT_PROF_RT 0x00520000
|
||||
#define PT_ARM_ARCHEXT_PROF_MC 0x004d0000
|
||||
#define PT_ARM_ARCHEXT_PROF_CLASSIC 0x00530000
|
||||
|
||||
#define PT_ARM_ARCHEXT_ARCH_UNKNOWN 0x00
|
||||
#define PT_ARM_ARCHEXT_ARCHv4 0x01
|
||||
#define PT_ARM_ARCHEXT_ARCHv4T 0x02
|
||||
#define PT_ARM_ARCHEXT_ARCHv5T 0x03
|
||||
#define PT_ARM_ARCHEXT_ARCHv5TE 0x04
|
||||
#define PT_ARM_ARCHEXT_ARCHv5TEJ 0x05
|
||||
#define PT_ARM_ARCHEXT_ARCHv6 0x06
|
||||
#define PT_ARM_ARCHEXT_ARCHv6KZ 0x07
|
||||
#define PT_ARM_ARCHEXT_ARCHv6T2 0x08
|
||||
#define PT_ARM_ARCHEXT_ARCHv6K 0x09
|
||||
#define PT_ARM_ARCHEXT_ARCHv7 0x0a
|
||||
#define PT_ARM_ARCHEXT_ARCHv6M 0x0b
|
||||
#define PT_ARM_ARCHEXT_ARCHv6SM 0x0c
|
||||
#define PT_ARM_ARCHEXT_ARCHv7EM 0x0d
|
||||
|
||||
/* Table 5-6, ARM-specific dynamic array tags */
|
||||
|
||||
#define DT_ARM_RESERVED1 0x70000000
|
||||
#define DT_ARM_SYMTABSZ 0x70000001
|
||||
#define DT_ARM_PREEMPTMAP 0x70000002
|
||||
#define DT_ARM_RESERVED2 0x70000003
|
||||
|
||||
#endif /* __ARCH_ARM_INCLUDE_ELF_H */
|
||||
@@ -59,12 +59,11 @@
|
||||
/* STM32 F100 Value Line ************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_CHIP_STM32F100C8) || defined(CONFIG_ARCH_CHIP_STM32F100CB) \
|
||||
|| defined(CONFIG_ARCH_CHIP_STM32F100R8) || defined(CONFIG_ARCH_CHIP_STM32F100RB) \
|
||||
|| defined(CONFIG_ARCH_CHIP_STM32F100V8) || defined(CONFIG_ARCH_CHIP_STM32F100VB)
|
||||
|| defined(CONFIG_ARCH_CHIP_STM32F100R8) || defined(CONFIG_ARCH_CHIP_STM32F100RB)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# define CONFIG_STM32_MEDIUMDENSITY 1 /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# define CONFIG_STM32_MEDIUMDENSITY 1 /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# define CONFIG_STM32_VALUELINE 1 /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -72,15 +71,110 @@
|
||||
# define STM32_NFSMC 0 /* FSMC */
|
||||
# define STM32_NATIM 1 /* One advanced timer TIM1 */
|
||||
# define STM32_NGTIM 3 /* 16-bit general timers TIM2,3,4 with DMA */
|
||||
# define STM32_NBTIM 0 /* No basic timers */
|
||||
# define STM32_NDMA 2 /* DMA1-2 */
|
||||
# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
|
||||
// TODO: there are also 3 additional timers (15-17) that don't fit any existing category
|
||||
# define STM32_NDMA 1 /* DMA1 */
|
||||
# define STM32_NSPI 2 /* SPI1-2 */
|
||||
# define STM32_NI2S 0 /* No I2S (?) */
|
||||
# define STM32_NI2S 0 /* No I2S */
|
||||
# define STM32_NUSART 3 /* USART1-3 */
|
||||
# define STM32_NI2C 2 /* I2C1-2 */
|
||||
# define STM32_NCAN 0 /* No CAN */
|
||||
# define STM32_NSDIO 0 /* No SDIO */
|
||||
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS */
|
||||
# define STM32_NGPIO 64 /* GPIOA-D */
|
||||
# define STM32_NADC 1 /* ADC1 */
|
||||
# define STM32_NDAC 2 /* DAC 1-2 */
|
||||
# define STM32_NCRC 1 /* CRC1 */
|
||||
# define STM32_NETHERNET 0 /* No ethernet */
|
||||
# define STM32_NRNG 0 /* No random number generator (RNG) */
|
||||
# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F100V8) || defined(CONFIG_ARCH_CHIP_STM32F100VB)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# define CONFIG_STM32_MEDIUMDENSITY 1 /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# define CONFIG_STM32_VALUELINE 1 /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
|
||||
# define STM32_NFSMC 0 /* FSMC */
|
||||
# define STM32_NATIM 1 /* One advanced timer TIM1 */
|
||||
# define STM32_NGTIM 3 /* 16-bit general timers TIM2,3,4 with DMA */
|
||||
# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
|
||||
// TODO: there are also 3 additional timers (15-17) that don't fit any existing category
|
||||
# define STM32_NDMA 1 /* DMA1 */
|
||||
# define STM32_NSPI 2 /* SPI1-2 */
|
||||
# define STM32_NI2S 0 /* No I2S */
|
||||
# define STM32_NUSART 3 /* USART1-3 */
|
||||
# define STM32_NI2C 2 /* I2C1-2 */
|
||||
# define STM32_NCAN 0 /* No CAN */
|
||||
# define STM32_NSDIO 0 /* No SDIO */
|
||||
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS */
|
||||
# define STM32_NGPIO 80 /* GPIOA-E */
|
||||
# define STM32_NADC 1 /* ADC1 */
|
||||
# define STM32_NDAC 2 /* DAC 1-2 */
|
||||
# define STM32_NCRC 1 /* CRC1 */
|
||||
# define STM32_NETHERNET 0 /* No ethernet */
|
||||
# define STM32_NRNG 0 /* No random number generator (RNG) */
|
||||
# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
|
||||
|
||||
/* STM32 F100 High-density value Line ************************************************************/
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F100RC) || defined(CONFIG_ARCH_CHIP_STM32F100RD) \
|
||||
|| defined(CONFIG_ARCH_CHIP_STM32F100RE)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# define CONFIG_STM32_VALUELINE 1 /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
|
||||
# define STM32_NFSMC 0 /* FSMC */
|
||||
# define STM32_NATIM 1 /* One advanced timer TIM1 */
|
||||
# define STM32_NGTIM 4 /* 16-bit general timers TIM2,3,4,5 with DMA */
|
||||
# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
|
||||
// TODO: there are also 6 additional timers (12-17) that don't fit any existing category
|
||||
# define STM32_NDMA 2 /* DMA1-2 */
|
||||
# define STM32_NSPI 3 /* SPI1-3 */
|
||||
# define STM32_NI2S 0 /* No I2S */
|
||||
# define STM32_NUSART 5 /* USART1-5 */
|
||||
# define STM32_NI2C 2 /* I2C1-2 */
|
||||
# define STM32_NCAN 0 /* No CAN */
|
||||
# define STM32_NSDIO 0 /* No SDIO */
|
||||
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS */
|
||||
# define STM32_NGPIO 64 /* GPIOA-D */
|
||||
# define STM32_NADC 1 /* ADC1 */
|
||||
# define STM32_NDAC 2 /* DAC 1-2 */
|
||||
# define STM32_NCRC 1 /* CRC1 */
|
||||
# define STM32_NETHERNET 0 /* No ethernet */
|
||||
# define STM32_NRNG 0 /* No random number generator (RNG) */
|
||||
# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F100VC) || defined(CONFIG_ARCH_CHIP_STM32F100VD) \
|
||||
|| defined(CONFIG_ARCH_CHIP_STM32F100VE)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# define CONFIG_STM32_VALUELINE 1 /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
|
||||
# define STM32_NFSMC 1 /* FSMC */
|
||||
# define STM32_NATIM 1 /* One advanced timer TIM1 */
|
||||
# define STM32_NGTIM 4 /* 16-bit general timers TIM2,3,4,5 with DMA */
|
||||
# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
|
||||
// TODO: there are also 6 additional timers (12-17) that don't fit any existing category
|
||||
# define STM32_NDMA 2 /* DMA1-2 */
|
||||
# define STM32_NSPI 3 /* SPI1-3 */
|
||||
# define STM32_NI2S 0 /* No I2S */
|
||||
# define STM32_NUSART 5 /* USART1-5 */
|
||||
# define STM32_NI2C 2 /* I2C1-2 */
|
||||
# define STM32_NCAN 0 /* No CAN */
|
||||
# define STM32_NSDIO 0 /* No SDIO */
|
||||
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS */
|
||||
# define STM32_NGPIO 80 /* GPIOA-E */
|
||||
# define STM32_NADC 1 /* ADC1 */
|
||||
# define STM32_NDAC 2 /* DAC 1-2 */
|
||||
@@ -96,9 +190,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F103RET6)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -129,9 +223,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F103VCT6) || defined(CONFIG_ARCH_CHIP_STM32F103VET6)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -162,9 +256,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F103ZET6)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -192,9 +286,9 @@
|
||||
/* STM32 F105/F107 Connectivity Line *******************************************************/
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F105VBT7)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# define CONFIG_STM32_CONNECTIVITYLINE 1 /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -221,9 +315,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F107VC)
|
||||
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# define CONFIG_STM32_CONNECTIVITYLINE 1 /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -251,9 +345,9 @@
|
||||
/* STM32 F2 Family ******************************************************************/
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F207IG) /* UFBGA-176 1024Kb FLASH 128Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# define CONFIG_STM32_STM32F20XX 1 /* STM32F205x and STM32F207x */
|
||||
@@ -283,9 +377,9 @@
|
||||
/* STM23 F4 Family ******************************************************************/
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F405RG) /* LQFP 64 10x10x1.4 1024Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -314,9 +408,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F405VG) /* LQFP 100 14x14x1.4 1024Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -345,9 +439,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F405ZG) /* LQFP 144 20x20x1.4 1024Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -376,9 +470,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F407VE) /* LQFP-100 512Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -407,9 +501,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F407VG) /* LQFP-100 14x14x1.4 1024Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -438,9 +532,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F407ZE) /* LQFP-144 512Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -469,9 +563,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F407ZG) /* LQFP 144 20x20x1.4 1024Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -500,9 +594,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F407IE) /* LQFP 176 24x24x1.4 512Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
@@ -531,9 +625,9 @@
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32F407IG) /* BGA 176; LQFP 176 24x24x1.4 1024Kb FLASH 192Kb SRAM */
|
||||
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F101x and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
|
||||
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
|
||||
# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
|
||||
# undef CONFIG_STM32_VALUELINE /* STM32F100x */
|
||||
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
|
||||
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
|
||||
|
||||
@@ -61,11 +61,13 @@
|
||||
* External interrupts (vectors >= 16)
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_STM32_VALUELINE) && defined(CONFIG_STM32_MEDIUMDENSITY)
|
||||
/* Value line devices */
|
||||
|
||||
#if defined(CONFIG_STM32_VALUELINE)
|
||||
# define STM32_IRQ_WWDG (16) /* 0: Window Watchdog interrupt */
|
||||
# define STM32_IRQ_PVD (17) /* 1: PVD through EXTI Line detection interrupt */
|
||||
# define STM32_IRQ_TAMPER (18) /* 2: Tamper interrupt */
|
||||
# define STM32_IRQ_RTC (19) /* 3: RTC global interrupt */
|
||||
# define STM32_IRQ_RTC (19) /* 3: RTC Wakeup through EXTI line interrupt */
|
||||
# define STM32_IRQ_FLASH (20) /* 4: Flash global interrupt */
|
||||
# define STM32_IRQ_RCC (21) /* 5: RCC global interrupt */
|
||||
# define STM32_IRQ_EXTI0 (22) /* 6: EXTI Line 0 interrupt */
|
||||
@@ -80,12 +82,18 @@
|
||||
# define STM32_IRQ_DMA1CH5 (31) /* 15: DMA1 Channel 5 global interrupt */
|
||||
# define STM32_IRQ_DMA1CH6 (32) /* 16: DMA1 Channel 6 global interrupt */
|
||||
# define STM32_IRQ_DMA1CH7 (33) /* 17: DMA1 Channel 7 global interrupt */
|
||||
# define STM32_IRQ_ADC12 (34) /* 18: ADC1 and ADC2 global interrupt */
|
||||
/* 19-22: reserved */
|
||||
# define STM32_IRQ_ADC1 (34) /* 18: ADC1 global interrupt */
|
||||
# define STM32_IRQ_RESERVED0 (35) /* 19: Reserved 0 */
|
||||
# define STM32_IRQ_RESERVED1 (36) /* 20: Reserved 1 */
|
||||
# define STM32_IRQ_RESERVED2 (37) /* 21: Reserved 2 */
|
||||
# define STM32_IRQ_RESERVED3 (38) /* 22: Reserved 3 */
|
||||
# define STM32_IRQ_EXTI95 (39) /* 23: EXTI Line[9:5] interrupts */
|
||||
# define STM32_IRQ_TIM1BRK (40) /* 24: TIM1 Break interrupt */
|
||||
# define STM32_IRQ_TIM1UP (41) /* 25: TIM1 Update interrupt (TIM16 global interrupt) */
|
||||
# define STM32_IRQ_TIM1TRGCOM (42) /* 26: TIM1 Trigger and Commutation interrupts (TIM17 global interrupt) */
|
||||
# define STM32_IRQ_TIM15 (40) /* TIM15 global interrupt */
|
||||
# define STM32_IRQ_TIM1UP (41) /* 25: TIM1 Update interrupt */
|
||||
# define STM32_IRQ_TIM16 (41) /* TIM16 global interrupt */
|
||||
# define STM32_IRQ_TIM1TRGCOM (42) /* 26: TIM1 Trigger and Commutation interrupts */
|
||||
# define STM32_IRQ_TIM17 (42) /* TIM17 global interrupt */
|
||||
# define STM32_IRQ_TIM1CC (43) /* 27: TIM1 Capture Compare interrupt */
|
||||
# define STM32_IRQ_TIM2 (44) /* 28: TIM2 global interrupt */
|
||||
# define STM32_IRQ_TIM3 (45) /* 29: TIM3 global interrupt */
|
||||
@@ -100,29 +108,30 @@
|
||||
# define STM32_IRQ_USART2 (54) /* 38: USART2 global interrupt */
|
||||
# define STM32_IRQ_USART3 (55) /* 39: USART3 global interrupt */
|
||||
# define STM32_IRQ_EXTI1510 (56) /* 40: EXTI Line[15:10] interrupts */
|
||||
# define STM32_IRQ_RTCALR (57) /* 41: RTC alarm through EXTI line interrupt */
|
||||
# define STM32_IRQ_RTCALR (57) /* 41: RTC alarms (A and B) through EXTI line interrupt */
|
||||
# define STM32_IRQ_CEC (58) /* 42: CEC global interrupt */
|
||||
# if defined(CONFIG_STM32_HIGHDENSITY)
|
||||
# define STM32_IRQ_TIM12 (59) /* 43: TIM12 global interrupt */
|
||||
# define STM32_IRQ_TIM13 (60) /* 44: TIM13 global interrupt */
|
||||
# define STM32_IRQ_TIM14 (61) /* 45: TIM14 global interrupt */
|
||||
/* 46-47: reserved */
|
||||
# define STM32_IRQ_FSMC (64) /* 48: FSMC global interrupt */
|
||||
/* 49: reserved */
|
||||
# define STM32_IRQ_TIM5 (66) /* 50: TIM5 global interrupt */
|
||||
# define STM32_IRQ_SPI3 (67) /* 51: SPI1 global interrupt */
|
||||
# define STM32_IRQ_UART4 (68) /* 52: USART2 global interrupt */
|
||||
# define STM32_IRQ_UART5 (69) /* 53: USART3 global interrupt */
|
||||
# else
|
||||
/* 43-53: reserved */
|
||||
# endif
|
||||
# define STM32_IRQ_TIM12 (59) /* 43: TIM12 global interrupt */
|
||||
# define STM32_IRQ_TIM13 (60) /* 44: TIM13 global interrupt */
|
||||
# define STM32_IRQ_TIM14 (61) /* 45: TIM14 global interrupt */
|
||||
# define STM32_IRQ_RESERVED4 (62) /* 46: Reserved 4 */
|
||||
# define STM32_IRQ_RESERVED5 (63) /* 47: Reserved 5 */
|
||||
# define STM32_IRQ_FSMC (64) /* 48: FSMC global interrupt */
|
||||
# define STM32_IRQ_RESERVED6 (65) /* 49: Reserved 6 */
|
||||
# define STM32_IRQ_TIM5 (66) /* 50: TIM5 global interrupt */
|
||||
# define STM32_IRQ_SPI3 (67) /* 51: SPI3 global interrupt */
|
||||
# define STM32_IRQ_UART4 (68) /* 52: USART2 global interrupt */
|
||||
# define STM32_IRQ_UART5 (69) /* 53: USART5 global interrupt */
|
||||
# define STM32_IRQ_TIM6 (70) /* 54: TIM6 global interrupt */
|
||||
# define STM32_IRQ_TIM7 (71) /* 55: TIM7 global interrupt */
|
||||
# define STM32_IRQ_DMA2CH1 (72) /* 56: DMA2 Channel 1 global interrupt */
|
||||
# define STM32_IRQ_DMA2CH2 (73) /* 57: DMA2 Channel 2 global interrupt */
|
||||
# define STM32_IRQ_DMA2CH3 (74) /* 58: DMA2 Channel 3 global interrupt */
|
||||
# define STM32_IRQ_DMA2CH45 (75) /* 59: DMA2 Channel 4 global interrupt */
|
||||
# define NR_IRQS (76)
|
||||
# define STM32_IRQ_DMA2CH45 (75) /* 59: DMA2 Channel 4 and 5 global interrupt */
|
||||
# define STM32_IRQ_DMA2CH5 (76) /* 60: DMA2 Channel 5 global interrupt */
|
||||
# define NR_IRQS (77)
|
||||
|
||||
/* Connectivity Line Devices */
|
||||
|
||||
#elif defined(CONFIG_STM32_CONNECTIVITYLINE)
|
||||
# define STM32_IRQ_WWDG (16) /* 0: Window Watchdog interrupt */
|
||||
# define STM32_IRQ_PVD (17) /* 1: PVD through EXTI Line detection interrupt */
|
||||
@@ -193,6 +202,9 @@
|
||||
# define STM32_IRQ_CAN2SCE (82) /* 66: CAN2 SCE interrupt */
|
||||
# define STM32_IRQ_OTGFS (83) /* 67: USB On The Go FS global interrupt */
|
||||
# define NR_IRQS (84)
|
||||
|
||||
/* Medium and High Density Devices */
|
||||
|
||||
#else
|
||||
# define STM32_IRQ_WWDG (16) /* 0: Window Watchdog interrupt */
|
||||
# define STM32_IRQ_PVD (17) /* 1: PVD through EXTI Line detection interrupt */
|
||||
|
||||
+97
-63
@@ -36,58 +36,90 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
-include chip/Make.defs
|
||||
|
||||
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
|
||||
ifeq ($(CONFIG_ARCH_CORTEXM3),y) # Cortex-M3 is ARMv7-M
|
||||
ARCH_SUBDIR = armv7-m
|
||||
ARCH_SUBDIR = armv7-m
|
||||
else
|
||||
ifeq ($(CONFIG_ARCH_CORTEXM4),y) # Cortex-M4 is ARMv7E-M
|
||||
ARCH_SUBDIR = armv7-m
|
||||
ARCH_SUBDIR = armv7-m
|
||||
else
|
||||
ARCH_SUBDIR = arm
|
||||
ARCH_SUBDIR = arm
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src
|
||||
NUTTX = "$(TOPDIR)\nuttx$(EXEEXT)"
|
||||
CFLAGS += -I$(ARCH_SRCDIR)\chip
|
||||
CFLAGS += -I$(ARCH_SRCDIR)\common
|
||||
CFLAGS += -I$(ARCH_SRCDIR)\$(ARCH_SUBDIR)
|
||||
CFLAGS += -I$(TOPDIR)\sched
|
||||
else
|
||||
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
|
||||
ifeq ($(WINTOOL),y)
|
||||
NUTTX = "${shell cygpath -w $(TOPDIR)/nuttx$(EXEEXT)}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/common}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/$(ARCH_SUBDIR)}"
|
||||
CFLAGS += -I "${shell cygpath -w $(TOPDIR)/sched}"
|
||||
else
|
||||
NUTTX = "$(TOPDIR)/nuttx$(EXEEXT)"
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/chip
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/common
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/$(ARCH_SUBDIR)
|
||||
CFLAGS += -I$(TOPDIR)/sched
|
||||
endif
|
||||
endif
|
||||
|
||||
HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
||||
|
||||
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
LDFLAGS += $(ARCHSCRIPT)
|
||||
|
||||
EXTRA_LIBS ?=
|
||||
EXTRA_LIBPATHS ?=
|
||||
LINKLIBS ?=
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BOARDMAKE = $(if $(wildcard .\board\Makefile),y,)
|
||||
LIBPATHS += -L"$(TOPDIR)\lib"
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LIBPATHS += -L"$(TOPDIR)\arch\$(CONFIG_ARCH)\src\board"
|
||||
endif
|
||||
|
||||
else
|
||||
BOARDMAKE = $(if $(wildcard ./board/Makefile),y,)
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
NUTTX = "${shell cygpath -w $(TOPDIR)/nuttx}"
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
|
||||
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
|
||||
-I "${shell cygpath -w $(ARCH_SRCDIR)/$(ARCH_SUBDIR)}" \
|
||||
-I "${shell cygpath -w $(TOPDIR)/sched}"
|
||||
else
|
||||
NUTTX = $(TOPDIR)/nuttx
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common \
|
||||
-I$(ARCH_SRCDIR)/$(ARCH_SUBDIR) -I$(TOPDIR)/sched
|
||||
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)/lib"}"
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)/arch/$(CONFIG_ARCH)/src/board"}"
|
||||
endif
|
||||
|
||||
HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
||||
|
||||
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
LDFLAGS = $(ARCHSCRIPT)
|
||||
EXTRA_LIBS ?=
|
||||
|
||||
LINKLIBS =
|
||||
ifeq ($(WINTOOL),y)
|
||||
LIBPATHS = ${shell for path in $(LINKLIBS); do dir=`dirname $(TOPDIR)/$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
|
||||
LIBPATHS += -L"${shell cygpath -w $(BOARDDIR)}"
|
||||
else
|
||||
LIBPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
|
||||
LIBPATHS += -L"$(BOARDDIR)"
|
||||
LIBPATHS += -L"$(TOPDIR)/lib"
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LIBPATHS += -L"$(TOPDIR)/arch/$(CONFIG_ARCH)/src/board"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
|
||||
|
||||
BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board
|
||||
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
LDLIBS += -lboard
|
||||
endif
|
||||
|
||||
LIBGCC = "${shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name}"
|
||||
LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
|
||||
GCC_LIBDIR := ${shell dirname $(LIBGCC)}
|
||||
|
||||
VPATH = chip:common:$(ARCH_SUBDIR)
|
||||
VPATH = chip:common:$(ARCH_SUBDIR)
|
||||
|
||||
all: $(HEAD_OBJ) libarch$(LIBEXT)
|
||||
|
||||
@@ -100,20 +132,21 @@ $(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
libarch$(LIBEXT): $(OBJS)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
$(call ARCHIVE, $@, $(OBJS))
|
||||
|
||||
board/libboard$(LIBEXT):
|
||||
@$(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) EXTRADEFINES=$(EXTRADEFINES)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) EXTRADEFINES=$(EXTRADEFINES)
|
||||
|
||||
nuttx: $(HEAD_OBJ) board/libboard$(LIBEXT)
|
||||
@echo "LD: nuttx"
|
||||
@$(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \
|
||||
--start-group $(LDLIBS) -lboard $(EXTRA_LIBS) $(LIBGCC) --end-group
|
||||
@$(NM) $(NUTTX)$(EXEEXT) | \
|
||||
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
|
||||
$(Q) echo "LD: nuttx"
|
||||
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
|
||||
-o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \
|
||||
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) $(NM) $(NUTTX)$(EXEEXT) | \
|
||||
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
|
||||
sort > $(TOPDIR)/System.map
|
||||
endif
|
||||
|
||||
# This is part of the top-level export target
|
||||
# Note that there may not be a head object if layout is handled
|
||||
@@ -121,37 +154,38 @@ nuttx: $(HEAD_OBJ) board/libboard$(LIBEXT)
|
||||
|
||||
export_head: board/libboard$(LIBEXT) $(HEAD_OBJ)
|
||||
ifneq ($(HEAD_OBJ),)
|
||||
@if [ -d "$(EXPORT_DIR)/startup" ]; then \
|
||||
$(Q) if [ -d "$(EXPORT_DIR)/startup" ]; then \
|
||||
cp -f $(HEAD_OBJ) "$(EXPORT_DIR)/startup"; \
|
||||
else \
|
||||
echo "$(EXPORT_DIR)/startup does not exist"; \
|
||||
exit 1; \
|
||||
fi
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Dependencies
|
||||
|
||||
.depend: Makefile chip/Make.defs $(SRCS)
|
||||
@if [ -e board/Makefile ]; then \
|
||||
$(MAKE) -C board TOPDIR="$(TOPDIR)" depend ; \
|
||||
fi
|
||||
@$(MKDEP) --dep-path chip --dep-path common --dep-path $(ARCH_SUBDIR) \
|
||||
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" depend
|
||||
endif
|
||||
$(Q) $(MKDEP) --dep-path chip --dep-path common --dep-path $(ARCH_SUBDIR) \
|
||||
"$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@if [ -e board/Makefile ]; then \
|
||||
$(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \
|
||||
fi
|
||||
@rm -f libarch$(LIBEXT) *~ .*.swp
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" clean
|
||||
endif
|
||||
$(call DELFILE, libarch$(LIBEXT))
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@if [ -e board/Makefile ]; then \
|
||||
$(MAKE) -C board TOPDIR="$(TOPDIR)" distclean ; \
|
||||
fi
|
||||
@rm -f Make.dep .depend
|
||||
ifeq ($(BOARDMAKE),y)
|
||||
$(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" distclean
|
||||
endif
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/arm/up_elf.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <elf32.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/elf.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arch_checkarch
|
||||
*
|
||||
* Description:
|
||||
* Given the ELF header in 'hdr', verify that the ELF file is appropriate
|
||||
* for the current, configured architecture. Every architecture that uses
|
||||
* the ELF loader must provide this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hdr - The ELF header read from the ELF file.
|
||||
*
|
||||
* Returned Value:
|
||||
* True if the architecture supports this ELF file.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool arch_checkarch(FAR const Elf32_Ehdr *ehdr)
|
||||
{
|
||||
/* Make sure it's an ARM executable */
|
||||
|
||||
if (ehdr->e_machine != EM_ARM)
|
||||
{
|
||||
bdbg("Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Make sure that 32-bit objects are supported */
|
||||
|
||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||
{
|
||||
bdbg("Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Verify endian-ness */
|
||||
|
||||
#ifdef CONFIG_ENDIAN_BIG
|
||||
if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB)
|
||||
#else
|
||||
if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
|
||||
#endif
|
||||
{
|
||||
bdbg("Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Make sure the entry point address is properly aligned */
|
||||
|
||||
if ((ehdr->e_entry & 3) != 0)
|
||||
{
|
||||
bdbg("Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
||||
return -ENOEXEC
|
||||
}
|
||||
|
||||
/* TODO: Check ABI here. */
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arch_relocate and arch_relocateadd
|
||||
*
|
||||
* Description:
|
||||
* Perform on architecture-specific ELF relocation. Every architecture
|
||||
* that uses the ELF loader must provide this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* rel - The relocation type
|
||||
* sym - The ELF symbol structure containing the fully resolved value.
|
||||
* addr - The address that requires the relocation.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) if the relocation was successful. Otherwise, a negated errno
|
||||
* value indicating the cause of the relocation failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int arch_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
|
||||
uintptr_t addr)
|
||||
{
|
||||
int32_t offset;
|
||||
|
||||
switch (ELF32_R_TYPE(rel->r_info))
|
||||
{
|
||||
case R_ARM_NONE:
|
||||
{
|
||||
/* No relocation */
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_PC24:
|
||||
case R_ARM_CALL:
|
||||
case R_ARM_JUMP24:
|
||||
{
|
||||
bvdbg("Performing PC24 [%d] link at addr %08lx [%08lx] to sym '%s' st_value=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t*)addr),
|
||||
sym, (long)sym->st_value);
|
||||
|
||||
offset = (*(uint32_t*)addr & 0x00ffffff) << 2;
|
||||
if (offset & 0x02000000)
|
||||
{
|
||||
offset -= 0x04000000;
|
||||
}
|
||||
|
||||
offset += sym->st_value - addr;
|
||||
if (offset & 3 || offset <= (int32_t) 0xfe000000 || offset >= (int32_t) 0x02000000)
|
||||
{
|
||||
bdbg(" ERROR: PC24 [%d] relocation out of range, offset=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), offset);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
offset >>= 2;
|
||||
|
||||
*(uint32_t*)addr &= 0xff000000;
|
||||
*(uint32_t*)addr |= offset & 0x00ffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_ABS32:
|
||||
case R_ARM_TARGET1: /* New ABI: TARGET1 always treated as ABS32 */
|
||||
{
|
||||
bvdbg("Performing ABS32 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
|
||||
(long)addr, (long)(*(uint32_t*)addr), sym, (long)sym->st_value);
|
||||
|
||||
*(uint32_t*)addr += sym->st_value;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_V4BX:
|
||||
{
|
||||
bvdbg("Performing V4BX link at addr=%08lx [%08lx]\n",
|
||||
(long)addr, (long)(*(uint32_t*)addr));
|
||||
|
||||
/* Preserve only Rm and the condition code */
|
||||
|
||||
*(uint32_t*)addr &= 0xf000000f;
|
||||
|
||||
/* Change instruction to 'mov pc, Rm' */
|
||||
|
||||
*(uint32_t*)addr |= 0x01a0f000;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_PREL31:
|
||||
{
|
||||
bvdbg("Performing PREL31 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
|
||||
(long)addr, (long)(*(uint32_t*)addr), sym, (long)sym->st_value);
|
||||
|
||||
offset = *(uint32_t*)addr + sym->st_value - addr;
|
||||
*(uint32_t*)addr = offset & 0x7fffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_MOVW_ABS_NC:
|
||||
case R_ARM_MOVT_ABS:
|
||||
{
|
||||
bvdbg("Performing MOVx_ABS [%d] link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t*)addr),
|
||||
sym, (long)sym->st_value);
|
||||
|
||||
offset = *(uint32_t*)addr;
|
||||
offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff);
|
||||
offset = (offset ^ 0x8000) - 0x8000;
|
||||
|
||||
offset += sym->st_value;
|
||||
if (ELF32_R_TYPE(rel->r_info) == R_ARM_MOVT_ABS)
|
||||
{
|
||||
offset >>= 16;
|
||||
}
|
||||
|
||||
*(uint32_t*)addr &= 0xfff0f000;
|
||||
*(uint32_t*)addr |= ((offset & 0xf000) << 4) | (offset & 0x0fff);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
bdbg("Unsupported relocation: %d\n", ELF32_R_TYPE(rel->r_info));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int arch_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
|
||||
uintptr_t addr)
|
||||
{
|
||||
bdbg("RELA relocation not supported\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
comment "ARMV7M Configuration Options"
|
||||
|
||||
choice
|
||||
prompt "Toolchain Selection"
|
||||
default ARMV7M_TOOLCHAIN_CODESOURCERYW if HOST_WINDOWS
|
||||
default ARMV7M_TOOLCHAIN_GNU_EABI if !HOST_WINDOWS
|
||||
|
||||
config ARMV7M_TOOLCHAIN_ATOLLIC
|
||||
bool "Atollic Lite/Pro for Windows"
|
||||
depends on HOST_WINDOWS
|
||||
|
||||
config ARMV7M_TOOLCHAIN_BUILDROOT
|
||||
bool "Buildroot (Cygwin or Linux)"
|
||||
depends on !WINDOWS_NATIVE
|
||||
|
||||
config ARMV7M_TOOLCHAIN_CODEREDL
|
||||
bool "CodeRed for Linux"
|
||||
depends on HOST_LINUX
|
||||
|
||||
config ARMV7M_TOOLCHAIN_CODEREDW
|
||||
bool "CodeRed for Windows"
|
||||
depends on HOST_WINDOWS
|
||||
|
||||
config ARMV7M_TOOLCHAIN_CODESOURCERYL
|
||||
bool "CodeSourcery GNU toolchain under Linux"
|
||||
depends on HOST_LINUX
|
||||
|
||||
config ARMV7M_TOOLCHAIN_CODESOURCERYW
|
||||
bool "CodeSourcery GNU toolchain under Windows"
|
||||
depends on HOST_WINDOWS
|
||||
|
||||
config ARMV7M_TOOLCHAIN_DEVKITARM
|
||||
bool "devkitARM GNU toolchain"
|
||||
depends on HOST_WINDOWS
|
||||
|
||||
config ARMV7M_TOOLCHAIN_GNU_EABI
|
||||
bool "Generic GNU EABI toolchain"
|
||||
---help---
|
||||
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
|
||||
configured for arm-none-eabi.
|
||||
|
||||
config ARMV7M_TOOLCHAIN_RAISONANCE
|
||||
bool "STMicro Raisonance for Windows"
|
||||
depends on HOST_WINDOWS
|
||||
|
||||
endchoice
|
||||
@@ -0,0 +1,266 @@
|
||||
############################################################################
|
||||
# arch/arm/src/armv7-m/Toolchain.defs
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Setup for the selected toolchain
|
||||
|
||||
#
|
||||
# Handle old-style chip-specific toolchain names in the absence of
|
||||
# a new-style toolchain specification, force the selection of a single
|
||||
# toolchain and allow the selected toolchain to be overridden by a
|
||||
# command-line selection.
|
||||
#
|
||||
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_LPC43_ATOLLIC_LITE) \
|
||||
$(CONFIG_STM32_ATOLLIC_LITE) \
|
||||
$(CONFIG_LPC43_ATOLLIC_PRO) \
|
||||
$(CONFIG_STM32_ATOLLIC_PRO) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= ATOLLIC
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_KINETIS_BUILDROOT) \
|
||||
$(CONFIG_LM3S_BUILDROOT) \
|
||||
$(CONFIG_LPC17_BUILDROOT) \
|
||||
$(CONFIG_LPC43_BUILDROOT) \
|
||||
$(CONFIG_SAM3U_BUILDROOT) \
|
||||
$(CONFIG_STM32_BUILDROOT) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= BUILDROOT
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_LPC17_CODEREDL) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_CODEREDL) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= CODEREDL
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_LPC17_CODEREDW) \
|
||||
$(CONFIG_LPC43_CODEREDW) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_CODEREDW) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= CODEREDW
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_KINETIS_CODESOURCERYL) \
|
||||
$(CONFIG_LM3S_CODESOURCERYL) \
|
||||
$(CONFIG_LPC17_CODESOURCERYL) \
|
||||
$(CONFIG_LPC43_CODESOURCERYL) \
|
||||
$(CONFIG_SAM3U_CODESOURCERYL) \
|
||||
$(CONFIG_STM32_CODESOURCERYL) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= CODESOURCERYL
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_KINETIS_CODESOURCERYW) \
|
||||
$(CONFIG_LM3S_CODESOURCERYW) \
|
||||
$(CONFIG_LPC17_CODESOURCERYW) \
|
||||
$(CONFIG_LPC43_CODESOURCERYW) \
|
||||
$(CONFIG_SAM3U_CODESOURCERYW) \
|
||||
$(CONFIG_STM32_CODESOURCERYW) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= CODESOURCERYW
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_KINETIS_DEVKITARM) \
|
||||
$(CONFIG_LM3S_DEVKITARM) \
|
||||
$(CONFIG_LPC17_DEVKITARM) \
|
||||
$(CONFIG_LPC43_DEVKITARM) \
|
||||
$(CONFIG_SAM3U_DEVKITARM) \
|
||||
$(CONFIG_STM32_DEVKITARM) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= DEVKITARM
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= GNU_EABI
|
||||
endif
|
||||
ifeq ($(filter y, \
|
||||
$(CONFIG_STM32_RAISONANCE) \
|
||||
$(CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE) \
|
||||
),y)
|
||||
CONFIG_ARMV7M_TOOLCHAIN ?= RAISONANCE
|
||||
endif
|
||||
|
||||
#
|
||||
# Supported toolchains
|
||||
#
|
||||
# TODO - It's likely that all of these toolchains now support the
|
||||
# CortexM4. Since they are all GCC-based, we could almost
|
||||
# certainly simplify this further.
|
||||
#
|
||||
# Each toolchain definition should set:
|
||||
#
|
||||
# CROSSDEV The GNU toolchain triple (command prefix)
|
||||
# ARCROSSDEV If required, an alternative prefix used when
|
||||
# invoking ar and nm.
|
||||
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
|
||||
# FPU options, etc.
|
||||
# MAXOPTIMIZATION The maximum optimization level that results in
|
||||
# reliable code generation.
|
||||
#
|
||||
|
||||
# Atollic toolchain under Windows
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),ATOLLIC)
|
||||
CROSSDEV = arm-atollic-eabi-
|
||||
ARCROSSDEV = arm-atollic-eabi-
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
WINTOOL = y
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
|
||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
else
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=soft
|
||||
endif
|
||||
else ifeq ($(CONFIG_ARCH_CORTEXM3),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
endif
|
||||
|
||||
# NuttX buildroot under Linux or Cygwin
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),BUILDROOT)
|
||||
# OABI
|
||||
# CROSSDEV = arm-nuttx-elf-
|
||||
# ARCROSSDEV = arm-nuttx-elf-
|
||||
# ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft
|
||||
# EABI
|
||||
CROSSDEV = arm-nuttx-eabi-
|
||||
ARCROSSDEV = arm-nuttx-eabi-
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -Os
|
||||
endif
|
||||
|
||||
# Code Red RedSuite under Linux
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CODEREDL)
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCROSSDEV = arm-none-eabi-
|
||||
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
|
||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
else
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=soft
|
||||
endif
|
||||
else ifeq ($(CONFIG_ARCH_CORTEXM3),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
endif
|
||||
|
||||
# Code Red RedSuite under Windows
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CODEREDW)
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCROSSDEV = arm-none-eabi-
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
WINTOOL = y
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
|
||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
else
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=soft
|
||||
endif
|
||||
else ifeq ($(CONFIG_ARCH_CORTEXM3),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
endif
|
||||
|
||||
# CodeSourcery under Linux
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CODESOURCERYL)
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCROSSDEV = arm-none-eabi-
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -O2
|
||||
endif
|
||||
|
||||
# CodeSourcery under Windows
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CODESOURCERYW)
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCROSSDEV = arm-none-eabi-
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
WINTOOL = y
|
||||
endif
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
|
||||
# devkitARM under Windows
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),DEVKITARM)
|
||||
CROSSDEV = arm-eabi-
|
||||
ARCROSSDEV = arm-eabi-
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
WINTOOL = y
|
||||
endif
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
|
||||
# Generic GNU EABI toolchain on OS X, Linux or any typical Posix system
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),GNU_EABI)
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCROSSDEV = arm-none-eabi-
|
||||
MAXOPTIMIZATION = -O3
|
||||
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
|
||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
else
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=soft
|
||||
endif
|
||||
else ifeq ($(CONFIG_ARCH_CORTEXM3),y)
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
endif
|
||||
|
||||
# Raisonance RIDE7 under Windows
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),RAISONANCE)
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCROSSDEV = arm-none-eabi-
|
||||
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
WINTOOL = y
|
||||
endif
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
endif
|
||||
@@ -0,0 +1,450 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/armv7-m/up_elf.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <elf32.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/elf.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arch_checkarch
|
||||
*
|
||||
* Description:
|
||||
* Given the ELF header in 'hdr', verify that the ELF file is appropriate
|
||||
* for the current, configured architecture. Every architecture that uses
|
||||
* the ELF loader must provide this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hdr - The ELF header read from the ELF file.
|
||||
*
|
||||
* Returned Value:
|
||||
* True if the architecture supports this ELF file.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool arch_checkarch(FAR const Elf32_Ehdr *ehdr)
|
||||
{
|
||||
/* Make sure it's an ARM executable */
|
||||
|
||||
if (ehdr->e_machine != EM_ARM)
|
||||
{
|
||||
bdbg("Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Make sure that 32-bit objects are supported */
|
||||
|
||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||
{
|
||||
bdbg("Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Verify endian-ness */
|
||||
|
||||
#ifdef CONFIG_ENDIAN_BIG
|
||||
if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB)
|
||||
#else
|
||||
if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
|
||||
#endif
|
||||
{
|
||||
bdbg("Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* TODO: Check ABI here. */
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arch_relocate and arch_relocateadd
|
||||
*
|
||||
* Description:
|
||||
* Perform on architecture-specific ELF relocation. Every architecture
|
||||
* that uses the ELF loader must provide this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* rel - The relocation type
|
||||
* sym - The ELF symbol structure containing the fully resolved value.
|
||||
* addr - The address that requires the relocation.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) if the relocation was successful. Otherwise, a negated errno
|
||||
* value indicating the cause of the relocation failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int arch_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
|
||||
uintptr_t addr)
|
||||
{
|
||||
int32_t offset;
|
||||
uint32_t upper_insn;
|
||||
uint32_t lower_insn;
|
||||
|
||||
switch (ELF32_R_TYPE(rel->r_info))
|
||||
{
|
||||
case R_ARM_NONE:
|
||||
{
|
||||
/* No relocation */
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_PC24:
|
||||
case R_ARM_CALL:
|
||||
case R_ARM_JUMP24:
|
||||
{
|
||||
bvdbg("Performing PC24 [%d] link at addr %08lx [%08lx] to sym '%s' st_value=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t*)addr),
|
||||
sym, (long)sym->st_value);
|
||||
|
||||
offset = (*(uint32_t*)addr & 0x00ffffff) << 2;
|
||||
if (offset & 0x02000000)
|
||||
{
|
||||
offset -= 0x04000000;
|
||||
}
|
||||
|
||||
offset += sym->st_value - addr;
|
||||
if (offset & 3 || offset <= (int32_t) 0xfe000000 || offset >= (int32_t) 0x02000000)
|
||||
{
|
||||
bdbg(" ERROR: PC24 [%d] relocation out of range, offset=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), offset);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
offset >>= 2;
|
||||
|
||||
*(uint32_t*)addr &= 0xff000000;
|
||||
*(uint32_t*)addr |= offset & 0x00ffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_ABS32:
|
||||
case R_ARM_TARGET1: /* New ABI: TARGET1 always treated as ABS32 */
|
||||
{
|
||||
bvdbg("Performing ABS32 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
|
||||
(long)addr, (long)(*(uint32_t*)addr), sym, (long)sym->st_value);
|
||||
|
||||
*(uint32_t*)addr += sym->st_value;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_THM_CALL:
|
||||
case R_ARM_THM_JUMP24:
|
||||
{
|
||||
uint32_t S;
|
||||
uint32_t J1;
|
||||
uint32_t J2;
|
||||
|
||||
/* Thumb BL and B.W instructions. Encoding:
|
||||
*
|
||||
* upper_insn:
|
||||
*
|
||||
* 1 1 1 1 1 1
|
||||
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||
* +----------+---+-------------------------------+--------------+
|
||||
* |1 1 1 |OP1| OP2 | | 32-Bit Instructions
|
||||
* +----------+---+--+-----+----------------------+--------------+
|
||||
* |1 1 1 | 1 0| S | imm10 | BL Instruction
|
||||
* +----------+------+-----+-------------------------------------+
|
||||
*
|
||||
* lower_insn:
|
||||
*
|
||||
* 1 1 1 1 1 1
|
||||
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||
* +---+---------------------------------------------------------+
|
||||
* |OP | | 32-Bit Instructions
|
||||
* +---+--+---+---+---+------------------------------------------+
|
||||
* |1 1 |J1 | 1 |J2 | imm11 | BL Instruction
|
||||
* +------+---+---+---+------------------------------------------+
|
||||
*
|
||||
* The branch target is encoded in these bits:
|
||||
*
|
||||
* S = upper_insn[10]
|
||||
* imm10 = upper_insn[0:9]
|
||||
* imm11 = lower_insn[0:10]
|
||||
* J1 = lower_insn[13]
|
||||
* J2 = lower_insn[11]
|
||||
*/
|
||||
|
||||
upper_insn = (uint32_t)(*(uint16_t*)addr);
|
||||
lower_insn = (uint32_t)(*(uint16_t*)(addr + 2));
|
||||
|
||||
bvdbg("Performing THM_JUMP24 [%d] link at addr=%08lx [%04x %04x] to sym=%p st_value=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), (long)addr, (int)upper_insn, (int)lower_insn,
|
||||
sym, (long)sym->st_value);
|
||||
|
||||
/* Extract the 25-bit offset from the 32-bit instruction:
|
||||
*
|
||||
* offset[24] = S
|
||||
* offset[23] = ~(J1 ^ S)
|
||||
* offset[22] = ~(J2 ^ S)]
|
||||
* offset[12:21] = imm10
|
||||
* offset[1:11] = imm11
|
||||
* offset[0] = 0
|
||||
*/
|
||||
|
||||
S = (upper_insn >> 10) & 1;
|
||||
J1 = (lower_insn >> 13) & 1;
|
||||
J2 = (lower_insn >> 11) & 1;
|
||||
|
||||
offset = (S << 24) | /* S - > offset[24] */
|
||||
((~(J1 ^ S) & 1) << 23) | /* J1 -> offset[23] */
|
||||
((~(J2 ^ S) & 1) << 22) | /* J2 -> offset[22] */
|
||||
((upper_insn & 0x03ff) << 12) | /* imm10 -> offset[12:21] */
|
||||
((lower_insn & 0x07ff) << 1); /* imm11 -> offset[1:11] */
|
||||
/* 0 -> offset[0] */
|
||||
|
||||
/* Sign extend */
|
||||
|
||||
if (offset & 0x01000000)
|
||||
{
|
||||
offset -= 0x02000000;
|
||||
}
|
||||
|
||||
/* And perform the relocation */
|
||||
|
||||
bvdbg(" S=%d J1=%d J2=%d offset=%08lx branch target=%08lx\n",
|
||||
S, J1, J2, (long)offset, offset + sym->st_value - addr);
|
||||
|
||||
offset += sym->st_value - addr;
|
||||
|
||||
/* Is this a function symbol? If so, then the branch target must be
|
||||
* an odd Thumb address
|
||||
*/
|
||||
|
||||
if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC && (offset & 1) == 0)
|
||||
{
|
||||
bdbg(" ERROR: JUMP24 [%d] requires odd offset, offset=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), offset);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check the range of the offset */
|
||||
|
||||
if (offset <= (int32_t)0xff000000 || offset >= (int32_t)0x01000000)
|
||||
{
|
||||
bdbg(" ERROR: JUMP24 [%d] relocation out of range, branch taget=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), offset);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Now, reconstruct the 32-bit instruction using the new, relocated
|
||||
* branch target.
|
||||
*/
|
||||
|
||||
S = (offset >> 24) & 1;
|
||||
J1 = S ^ (~(offset >> 23) & 1);
|
||||
J2 = S ^ (~(offset >> 22) & 1);
|
||||
|
||||
upper_insn = ((upper_insn & 0xf800) | (S << 10) | ((offset >> 12) & 0x03ff));
|
||||
*(uint16_t*)addr = (uint16_t)upper_insn;
|
||||
|
||||
lower_insn = ((lower_insn & 0xd000) | (J1 << 13) | (J2 << 11) | ((offset >> 1) & 0x07ff));
|
||||
*(uint16_t*)(addr + 2) = (uint16_t)lower_insn;
|
||||
|
||||
bvdbg(" S=%d J1=%d J2=%d insn [%04x %04x]\n",
|
||||
S, J1, J2, (int)upper_insn, (int)lower_insn);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_V4BX:
|
||||
{
|
||||
bvdbg("Performing V4BX link at addr=%08lx [%08lx]\n",
|
||||
(long)addr, (long)(*(uint32_t*)addr));
|
||||
|
||||
/* Preserve only Rm and the condition code */
|
||||
|
||||
*(uint32_t*)addr &= 0xf000000f;
|
||||
|
||||
/* Change instruction to 'mov pc, Rm' */
|
||||
|
||||
*(uint32_t*)addr |= 0x01a0f000;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_PREL31:
|
||||
{
|
||||
bvdbg("Performing PREL31 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
|
||||
(long)addr, (long)(*(uint32_t*)addr), sym, (long)sym->st_value);
|
||||
|
||||
offset = *(uint32_t*)addr + sym->st_value - addr;
|
||||
*(uint32_t*)addr = offset & 0x7fffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_MOVW_ABS_NC:
|
||||
case R_ARM_MOVT_ABS:
|
||||
{
|
||||
bvdbg("Performing MOVx_ABS [%d] link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t*)addr),
|
||||
sym, (long)sym->st_value);
|
||||
|
||||
offset = *(uint32_t*)addr;
|
||||
offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff);
|
||||
offset = (offset ^ 0x8000) - 0x8000;
|
||||
|
||||
offset += sym->st_value;
|
||||
if (ELF32_R_TYPE(rel->r_info) == R_ARM_MOVT_ABS)
|
||||
{
|
||||
offset >>= 16;
|
||||
}
|
||||
|
||||
*(uint32_t*)addr &= 0xfff0f000;
|
||||
*(uint32_t*)addr |= ((offset & 0xf000) << 4) | (offset & 0x0fff);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_ARM_THM_MOVW_ABS_NC:
|
||||
case R_ARM_THM_MOVT_ABS:
|
||||
{
|
||||
/* Thumb BL and B.W instructions. Encoding:
|
||||
*
|
||||
* upper_insn:
|
||||
*
|
||||
* 1 1 1 1 1 1
|
||||
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||
* +----------+---+-------------------------------+--------------+
|
||||
* |1 1 1 |OP1| OP2 | | 32-Bit Instructions
|
||||
* +----------+---+--+-----+----------------------+--------------+
|
||||
* |1 1 1 | 1 0| i | 1 0 1 1 0 0 | imm4 | MOVT Instruction
|
||||
* +----------+------+-----+----------------------+--------------+
|
||||
*
|
||||
* lower_insn:
|
||||
*
|
||||
* 1 1 1 1 1 1
|
||||
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||
* +---+---------------------------------------------------------+
|
||||
* |OP | | 32-Bit Instructions
|
||||
* +---+----------+--------------+-------------------------------+
|
||||
* |0 | imm3 | Rd | imm8 | MOVT Instruction
|
||||
* +---+----------+--------------+-------------------------------+
|
||||
*
|
||||
* The 16-bit immediate value is encoded in these bits:
|
||||
*
|
||||
* i = imm16[11] = upper_insn[10]
|
||||
* imm4 = imm16[12:15] = upper_insn[3:0]
|
||||
* imm3 = imm16[8:10] = lower_insn[14:12]
|
||||
* imm8 = imm16[0:7] = lower_insn[7:0]
|
||||
*/
|
||||
|
||||
upper_insn = (uint32_t)(*(uint16_t*)addr);
|
||||
lower_insn = (uint32_t)(*(uint16_t*)(addr + 2));
|
||||
|
||||
bvdbg("Performing THM_MOVx [%d] link at addr=%08lx [%04x %04x] to sym=%p st_value=%08lx\n",
|
||||
ELF32_R_TYPE(rel->r_info), (long)addr, (int)upper_insn, (int)lower_insn,
|
||||
sym, (long)sym->st_value);
|
||||
|
||||
/* Extract the 16-bit offset from the 32-bit instruction */
|
||||
|
||||
offset = ((upper_insn & 0x000f) << 12) | /* imm4 -> imm16[8:10] */
|
||||
((upper_insn & 0x0400) << 1) | /* i -> imm16[11] */
|
||||
((lower_insn & 0x7000) >> 4) | /* imm3 -> imm16[8:10] */
|
||||
(lower_insn & 0x00ff); /* imm8 -> imm16[0:7] */
|
||||
|
||||
/* Sign extend */
|
||||
|
||||
offset = (offset ^ 0x8000) - 0x8000;
|
||||
|
||||
/* And perform the relocation */
|
||||
|
||||
bvdbg(" offset=%08lx branch target=%08lx\n",
|
||||
(long)offset, offset + sym->st_value);
|
||||
|
||||
offset += sym->st_value;
|
||||
|
||||
/* Update the immediate value in the instruction. For MOVW we want the bottom
|
||||
* 16-bits; for MOVT we want the top 16-bits.
|
||||
*/
|
||||
|
||||
if (ELF32_R_TYPE(rel->r_info) == R_ARM_THM_MOVT_ABS)
|
||||
{
|
||||
offset >>= 16;
|
||||
}
|
||||
|
||||
upper_insn = ((upper_insn & 0xfbf0) | ((offset & 0xf000) >> 12) | ((offset & 0x0800) >> 1));
|
||||
*(uint16_t*)addr = (uint16_t)upper_insn;
|
||||
|
||||
lower_insn = ((lower_insn & 0x8f00) | ((offset & 0x0700) << 4) | (offset & 0x00ff));
|
||||
*(uint16_t*)(addr + 2) = (uint16_t)lower_insn;
|
||||
|
||||
bvdbg(" insn [%04x %04x]\n",
|
||||
(int)upper_insn, (int)lower_insn);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
bdbg("Unsupported relocation: %d\n", ELF32_R_TYPE(rel->r_info));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int arch_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
|
||||
uintptr_t addr)
|
||||
{
|
||||
bdbg("RELA relocation not supported\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
Executable → Regular
@@ -57,9 +57,7 @@
|
||||
|
||||
/* Debug output from this file may interfere with context switching! */
|
||||
|
||||
#undef DEBUG_HARDFAULTS /* Define to debug hard faults */
|
||||
|
||||
#ifdef DEBUG_HARDFAULTS
|
||||
#ifdef CONFIG_DEBUG_HARDFAULT
|
||||
# define hfdbg(format, arg...) lldbg(format, ##arg)
|
||||
#else
|
||||
# define hfdbg(x...)
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
/************************************************************************************
|
||||
* nuttx/arch/arm/src/armv7-m/up_memcpy.S
|
||||
*
|
||||
* armv7m-optimised memcpy, contributed by Mike Smith. Apparently in the public
|
||||
* domain and is re-released here under the modified BSD license:
|
||||
*
|
||||
* Obtained via a posting on the Stellaris forum:
|
||||
* http://e2e.ti.com/support/microcontrollers/\
|
||||
* stellaris_arm_cortex-m3_microcontroller/f/473/t/44360.aspx
|
||||
*
|
||||
* Posted by rocksoft on Jul 24, 2008 10:19 AM
|
||||
*
|
||||
* Hi,
|
||||
*
|
||||
* I recently finished a "memcpy" replacement and thought it might be useful for
|
||||
* others...
|
||||
*
|
||||
* I've put some instructions and the code here:
|
||||
*
|
||||
* http://www.rock-software.net/downloads/memcpy/
|
||||
*
|
||||
* Hope it works for you as well as it did for me.
|
||||
*
|
||||
* Liam.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Global Symbols
|
||||
************************************************************************************/
|
||||
|
||||
.global memcpy
|
||||
|
||||
.syntax unified
|
||||
.thumb
|
||||
.cpu cortex-m3
|
||||
.file "up_memcpy.S"
|
||||
|
||||
/************************************************************************************
|
||||
* .text
|
||||
************************************************************************************/
|
||||
|
||||
.text
|
||||
|
||||
/************************************************************************************
|
||||
* Private Constant Data
|
||||
************************************************************************************/
|
||||
|
||||
/* We have 16 possible alignment combinations of src and dst, this jump table
|
||||
* directs the copy operation
|
||||
*
|
||||
* Bits: Src=00, Dst=00 - Long to Long copy
|
||||
* Bits: Src=00, Dst=01 - Long to Byte before half word
|
||||
* Bits: Src=00, Dst=10 - Long to Half word
|
||||
* Bits: Src=00, Dst=11 - Long to Byte before long word
|
||||
* Bits: Src=01, Dst=00 - Byte before half word to long
|
||||
* Bits: Src=01, Dst=01 - Byte before half word to byte before half word -
|
||||
* Same alignment
|
||||
* Bits: Src=01, Dst=10 - Byte before half word to half word
|
||||
* Bits: Src=01, Dst=11 - Byte before half word to byte before long word
|
||||
* Bits: Src=10, Dst=00 - Half word to long word
|
||||
* Bits: Src=10, Dst=01 - Half word to byte before half word
|
||||
* Bits: Src=10, Dst=10 - Half word to half word - Same Alignment
|
||||
* Bits: Src=10, Dst=11 - Half word to byte before long word
|
||||
* Bits: Src=11, Dst=00 - Byte before long word to long word
|
||||
* Bits: Src=11, Dst=01 - Byte before long word to byte before half word
|
||||
* Bits: Src=11, Dst=11 - Byte before long word to half word
|
||||
* Bits: Src=11, Dst=11 - Byte before long word to Byte before long word -
|
||||
* Same alignment
|
||||
*/
|
||||
|
||||
MEM_DataCopyTable:
|
||||
.byte (MEM_DataCopy0 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy1 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy2 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy3 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy4 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy5 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy6 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy7 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy8 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy9 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy10 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy11 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy12 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy13 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy14 - MEM_DataCopyJump) >> 1
|
||||
.byte (MEM_DataCopy15 - MEM_DataCopyJump) >> 1
|
||||
|
||||
.align 2
|
||||
|
||||
MEM_LongCopyTable:
|
||||
.byte (MEM_LongCopyEnd - MEM_LongCopyJump) >> 1 /* 0 bytes left */
|
||||
.byte 0 /* 4 bytes left */
|
||||
.byte (1 * 10) >> 1 /* 8 bytes left */
|
||||
.byte (2 * 10) >> 1 /* 12 bytes left */
|
||||
.byte (3 * 10) >> 1 /* 16 bytes left */
|
||||
.byte (4 * 10) >> 1 /* 20 bytes left */
|
||||
.byte (5 * 10) >> 1 /* 24 bytes left */
|
||||
.byte (6 * 10) >> 1 /* 28 bytes left */
|
||||
.byte (7 * 10) >> 1 /* 32 bytes left */
|
||||
.byte (8 * 10) >> 1 /* 36 bytes left */
|
||||
|
||||
.align 2
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
/************************************************************************************
|
||||
* Name: memcpy
|
||||
*
|
||||
* Description:
|
||||
* Optimised "general" copy routine
|
||||
*
|
||||
* Input Parameters:
|
||||
* r0 = destination, r1 = source, r2 = length
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
.thumb_func
|
||||
memcpy:
|
||||
push {r14}
|
||||
|
||||
/* This allows the inner workings to "assume" a minimum amount of bytes */
|
||||
/* Quickly check for very short copies */
|
||||
|
||||
cmp r2, #4
|
||||
blt MEM_DataCopyBytes
|
||||
|
||||
and r14, r0, #3 /* Get destination alignment bits */
|
||||
bfi r14, r1, #2, #2 /* Get source alignment bits */
|
||||
ldr r3, =MEM_DataCopyTable /* Jump table base */
|
||||
tbb [r3, r14] /* Perform jump on src/dst alignment bits */
|
||||
MEM_DataCopyJump:
|
||||
|
||||
.align 4
|
||||
|
||||
/* Bits: Src=01, Dst=01 - Byte before half word to byte before half word - Same alignment
|
||||
* 3 bytes to read for long word aligning
|
||||
*/
|
||||
|
||||
MEM_DataCopy5:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=10, Dst=10 - Half word to half word - Same Alignment
|
||||
* 2 bytes to read for long word aligning
|
||||
*/
|
||||
|
||||
MEM_DataCopy10:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=11, Dst=11 - Byte before long word to Byte before long word - Same alignment
|
||||
* 1 bytes to read for long word aligning
|
||||
*/
|
||||
|
||||
MEM_DataCopy15:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=00, Dst=00 - Long to Long copy */
|
||||
|
||||
MEM_DataCopy0:
|
||||
/* Save regs that may be used by memcpy */
|
||||
|
||||
push {r4-r12}
|
||||
|
||||
/* Check for short word-aligned copy */
|
||||
|
||||
cmp r2, #0x28
|
||||
blt MEM_DataCopy0_2
|
||||
|
||||
/* Bulk copy loop */
|
||||
|
||||
MEM_DataCopy0_1:
|
||||
ldmia r1!, {r3-r12}
|
||||
stmia r0!, {r3-r12}
|
||||
sub r2, r2, #0x28
|
||||
cmp r2, #0x28
|
||||
bge MEM_DataCopy0_1
|
||||
|
||||
/* Copy remaining long words */
|
||||
|
||||
MEM_DataCopy0_2:
|
||||
/* Copy remaining long words */
|
||||
|
||||
ldr r14, =MEM_LongCopyTable
|
||||
lsr r11, r2, #0x02
|
||||
tbb [r14, r11]
|
||||
|
||||
/* longword copy branch table anchor */
|
||||
|
||||
MEM_LongCopyJump:
|
||||
ldr.w r3, [r1], #0x04 /* 4 bytes remain */
|
||||
str.w r3, [r0], #0x04
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r4} /* 8 bytes remain */
|
||||
stmia.w r0!, {r3-r4}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r5} /* 12 bytes remain */
|
||||
stmia.w r0!, {r3-r5}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r6} /* 16 bytes remain */
|
||||
stmia.w r0!, {r3-r6}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r7} /* 20 bytes remain */
|
||||
stmia.w r0!, {r3-r7}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r8} /* 24 bytes remain */
|
||||
stmia.w r0!, {r3-r8}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r9} /* 28 bytes remain */
|
||||
stmia.w r0!, {r3-r9}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r10} /* 32 bytes remain */
|
||||
stmia.w r0!, {r3-r10}
|
||||
b MEM_LongCopyEnd
|
||||
ldmia.w r1!, {r3-r11} /* 36 bytes remain */
|
||||
stmia.w r0!, {r3-r11}
|
||||
|
||||
MEM_LongCopyEnd:
|
||||
pop {r4-r12}
|
||||
and r2, r2, #0x03 /* All the longs have been copied */
|
||||
|
||||
/* Deal with up to 3 remaining bytes */
|
||||
|
||||
MEM_DataCopyBytes:
|
||||
/* Deal with up to 3 remaining bytes */
|
||||
|
||||
cmp r2, #0x00
|
||||
it eq
|
||||
popeq {pc}
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
subs r2, r2, #0x01
|
||||
it eq
|
||||
popeq {pc}
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
subs r2, r2, #0x01
|
||||
it eq
|
||||
popeq {pc}
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
pop {pc}
|
||||
|
||||
.align 4
|
||||
|
||||
/* Bits: Src=01, Dst=11 - Byte before half word to byte before long word
|
||||
* 3 bytes to read for long word aligning the source
|
||||
*/
|
||||
|
||||
MEM_DataCopy7:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=10, Dst=00 - Half word to long word
|
||||
* 2 bytes to read for long word aligning the source
|
||||
*/
|
||||
|
||||
MEM_DataCopy8:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=11, Dst=01 - Byte before long word to byte before half word
|
||||
* 1 byte to read for long word aligning the source
|
||||
*/
|
||||
|
||||
MEM_DataCopy13:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=00, Dst=10 - Long to Half word */
|
||||
|
||||
MEM_DataCopy2:
|
||||
cmp r2, #0x28
|
||||
blt MEM_DataCopy2_1
|
||||
|
||||
/* Save regs */
|
||||
|
||||
push {r4-r12}
|
||||
|
||||
/* Bulk copy loop */
|
||||
|
||||
MEM_DataCopy2_2:
|
||||
ldmia r1!, {r3-r12}
|
||||
|
||||
strh r3, [r0], #0x02
|
||||
|
||||
lsr r3, r3, #0x10
|
||||
bfi r3, r4, #0x10, #0x10
|
||||
lsr r4, r4, #0x10
|
||||
bfi r4, r5, #0x10, #0x10
|
||||
lsr r5, r5, #0x10
|
||||
bfi r5, r6, #0x10, #0x10
|
||||
lsr r6, r6, #0x10
|
||||
bfi r6, r7, #0x10, #0x10
|
||||
lsr r7, r7, #0x10
|
||||
bfi r7, r8, #0x10, #0x10
|
||||
lsr r8, r8, #0x10
|
||||
bfi r8, r9, #0x10, #0x10
|
||||
lsr r9, r9, #0x10
|
||||
bfi r9, r10, #0x10, #0x10
|
||||
lsr r10, r10, #0x10
|
||||
bfi r10, r11, #0x10, #0x10
|
||||
lsr r11, r11, #0x10
|
||||
bfi r11, r12, #0x10, #0x10
|
||||
stmia r0!, {r3-r11}
|
||||
lsr r12, r12, #0x10
|
||||
strh r12, [r0], #0x02
|
||||
|
||||
sub r2, r2, #0x28
|
||||
cmp r2, #0x28
|
||||
bge MEM_DataCopy2_2
|
||||
pop {r4-r12}
|
||||
|
||||
MEM_DataCopy2_1: /* Read longs and write 2 x half words */
|
||||
cmp r2, #4
|
||||
blt MEM_DataCopyBytes
|
||||
ldr r3, [r1], #0x04
|
||||
strh r3, [r0], #0x02
|
||||
lsr r3, r3, #0x10
|
||||
strh r3, [r0], #0x02
|
||||
sub r2, r2, #0x04
|
||||
b MEM_DataCopy2
|
||||
|
||||
/* Bits: Src=01, Dst=00 - Byte before half word to long
|
||||
* Bits: Src=01, Dst=10 - Byte before half word to half word
|
||||
* 3 bytes to read for long word aligning the source
|
||||
*/
|
||||
|
||||
MEM_DataCopy4:
|
||||
MEM_DataCopy6:
|
||||
/* Read B and write B */
|
||||
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=10, Dst=01 - Half word to byte before half word
|
||||
* Bits: Src=10, Dst=11 - Half word to byte before long word
|
||||
* 2 bytes to read for long word aligning the source
|
||||
*/
|
||||
|
||||
MEM_DataCopy9:
|
||||
MEM_DataCopy11:
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=11, Dst=00 -chm Byte before long word to long word
|
||||
* Bits: Src=11, Dst=11 - Byte before long word to half word
|
||||
* 1 byte to read for long word aligning the source
|
||||
*/
|
||||
|
||||
MEM_DataCopy12:
|
||||
MEM_DataCopy14:
|
||||
/* Read B and write B */
|
||||
|
||||
ldrb r3, [r1], #0x01
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x01
|
||||
|
||||
/* Bits: Src=00, Dst=01 - Long to Byte before half word
|
||||
* Bits: Src=00, Dst=11 - Long to Byte before long word
|
||||
*/
|
||||
|
||||
MEM_DataCopy1: /* Read longs, write B->H->B */
|
||||
MEM_DataCopy3:
|
||||
cmp r2, #4
|
||||
blt MEM_DataCopyBytes
|
||||
ldr r3, [r1], #0x04
|
||||
strb r3, [r0], #0x01
|
||||
lsr r3, r3, #0x08
|
||||
strh r3, [r0], #0x02
|
||||
lsr r3, r3, #0x10
|
||||
strb r3, [r0], #0x01
|
||||
sub r2, r2, #0x04
|
||||
b MEM_DataCopy3
|
||||
|
||||
.size memcpy, .-memcpy
|
||||
.end
|
||||
Executable → Regular
Executable → Regular
@@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
* lib/string/lib_memset.c
|
||||
/****************************************************************************
|
||||
* arch/arm/src/common/arm-elf.h
|
||||
*
|
||||
* Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
|
||||
* 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
|
||||
@@ -31,29 +31,23 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Compilation Switches
|
||||
************************************************************/
|
||||
#ifndef __ARCH_ARM_SRC_ARM_ELF_H
|
||||
#define __ARCH_ARM_SRC_ARM_ELF_H
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_MEMSET
|
||||
void *memset(void *s, int c, size_t n)
|
||||
{
|
||||
unsigned char *p = (unsigned char*)s;
|
||||
while (n-- > 0) *p++ = c;
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_ARM_ELF_H */
|
||||
+501
-121
File diff suppressed because it is too large
Load Diff
@@ -41,23 +41,31 @@ endif
|
||||
|
||||
CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S
|
||||
CMN_CSRCS = up_assert.c up_blocktask.c up_copystate.c \
|
||||
up_createstack.c up_mdelay.c up_udelay.c up_exit.c \
|
||||
up_initialize.c up_initialstate.c up_interruptcontext.c \
|
||||
up_memfault.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c \
|
||||
up_releasepending.c up_releasestack.c up_reprioritizertr.c \
|
||||
up_schedulesigaction.c up_sigdeliver.c up_systemreset.c \
|
||||
up_unblocktask.c up_usestack.c up_doirq.c up_hardfault.c up_svcall.c \
|
||||
up_stackcheck.c
|
||||
up_createstack.c up_mdelay.c up_udelay.c up_exit.c \
|
||||
up_initialize.c up_initialstate.c up_interruptcontext.c \
|
||||
up_memfault.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c \
|
||||
up_releasepending.c up_releasestack.c up_reprioritizertr.c \
|
||||
up_schedulesigaction.c up_sigdeliver.c up_systemreset.c \
|
||||
up_unblocktask.c up_usestack.c up_doirq.c up_hardfault.c up_svcall.c \
|
||||
up_stackcheck.c
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y)
|
||||
CMN_ASRCS += up_exception.S
|
||||
CMN_CSRCS += up_vectors.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_MEMCPY),y)
|
||||
CMN_ASRCS += up_memcpy.S
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_STACK),y)
|
||||
CMN_CSRCS += up_checkstack.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ELF),y)
|
||||
CMN_CSRCS += up_elf.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||
CMN_ASRCS += up_fpu.S
|
||||
endif
|
||||
@@ -68,9 +76,9 @@ endif
|
||||
|
||||
CHIP_ASRCS =
|
||||
CHIP_CSRCS = stm32_allocateheap.c stm32_start.c stm32_rcc.c stm32_lse.c \
|
||||
stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c stm32_irq.c \
|
||||
stm32_timerisr.c stm32_dma.c stm32_lowputc.c stm32_serial.c \
|
||||
stm32_spi.c stm32_sdio.c stm32_tim.c stm32_i2c.c stm32_waste.c
|
||||
stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c stm32_irq.c \
|
||||
stm32_timerisr.c stm32_dma.c stm32_lowputc.c stm32_serial.c \
|
||||
stm32_spi.c stm32_sdio.c stm32_tim.c stm32_i2c.c stm32_waste.c
|
||||
|
||||
ifeq ($(CONFIG_USBDEV),y)
|
||||
ifeq ($(CONFIG_STM32_USB),y)
|
||||
|
||||
@@ -835,14 +835,6 @@ struct eth_rxdesc_s
|
||||
* Public Functions
|
||||
****************************************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* STM32_NETHERNET > 0 */
|
||||
#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32_ETH_H */
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* Copyright (C) 2012 Michael Smith. All Rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Uros Platise <uros.platise@isotel.eu>
|
||||
* Michael Smith
|
||||
* Freddie Chopin <freddie_chopin@op.pl>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -49,6 +51,87 @@
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Alternate Pin Functions: */
|
||||
|
||||
/* ADC */
|
||||
|
||||
#define GPIO_ADC1_IN0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC1_IN3 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC1_IN4 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_ADC1_IN5 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#define GPIO_ADC1_IN6 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
|
||||
#define GPIO_ADC1_IN7 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ADC1_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN9 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN10 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN11 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN12 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC1_IN13 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
#define GPIO_ADC1_IN14 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ADC1_IN15 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
|
||||
|
||||
/* CEC */
|
||||
#if defined(CONFIG_STM32_CEC_REMAP)
|
||||
# define GPIO_CEC (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10)
|
||||
#else
|
||||
# define GPIO_CEC (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8)
|
||||
#endif
|
||||
|
||||
/* DAC
|
||||
* Note from RM0041, 11.2: "Once the DAC channelx is enabled, the corresponding
|
||||
* GPIO pin (PA4 or PA5) is automatically connected to the analog converter
|
||||
* output (DAC_OUTx). In order to avoid parasitic consumption, the PA4 or PA5
|
||||
* pin should first be configured to analog (AIN)."
|
||||
*/
|
||||
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
|
||||
/* FSMC */
|
||||
|
||||
/* TODO - VL devices in 100- and 144-pin packages have FSMC */
|
||||
|
||||
/* I2C */
|
||||
|
||||
#if defined(CONFIG_STM32_I2C1_REMAP)
|
||||
# define GPIO_I2C1_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8)
|
||||
# define GPIO_I2C1_SDA (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9)
|
||||
#else
|
||||
# define GPIO_I2C1_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN6)
|
||||
# define GPIO_I2C1_SDA (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN7)
|
||||
#endif
|
||||
#define GPIO_I2C1_SMBA (GPIO_ALT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5)
|
||||
|
||||
#define GPIO_I2C2_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10)
|
||||
#define GPIO_I2C2_SDA (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11)
|
||||
#define GPIO_I2C2_SMBA (GPIO_ALT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12)
|
||||
|
||||
/* SPI */
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1_REMAP)
|
||||
# define GPIO_SPI1_NSS (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
|
||||
# define GPIO_SPI1_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN3)
|
||||
# define GPIO_SPI1_MISO (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN4)
|
||||
# define GPIO_SPI1_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5)
|
||||
#else
|
||||
# define GPIO_SPI1_NSS (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN4)
|
||||
# define GPIO_SPI1_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN5)
|
||||
# define GPIO_SPI1_MISO (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN6)
|
||||
# define GPIO_SPI1_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7)
|
||||
#endif
|
||||
|
||||
#define GPIO_SPI2_NSS (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12)
|
||||
#define GPIO_SPI2_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13)
|
||||
#define GPIO_SPI2_MISO (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN14)
|
||||
#define GPIO_SPI2_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN15)
|
||||
|
||||
#define GPIO_SPI3_NSS (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN15)
|
||||
#define GPIO_SPI3_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN3)
|
||||
#define GPIO_SPI3_MISO (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN4)
|
||||
#define GPIO_SPI3_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5)
|
||||
|
||||
/* TIMERS */
|
||||
|
||||
#if defined(CONFIG_STM32_TIM1_FULL_REMAP)
|
||||
@@ -186,6 +269,77 @@
|
||||
# define GPIO_TIM4_CH4OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9)
|
||||
#endif
|
||||
|
||||
#define GPIO_TIM5_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_TIM5_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_TIM5_CH2IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_TIM5_CH2OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_TIM5_CH3IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_TIM5_CH3OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_TIM5_CH4IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_TIM5_CH4OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN3)
|
||||
|
||||
#if defined(CONFIG_STM32_TIM12_REMAP)
|
||||
# define GPIO_TIM12_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN12)
|
||||
# define GPIO_TIM12_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12)
|
||||
# define GPIO_TIM12_CH2IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN13)
|
||||
# define GPIO_TIM12_CH2OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13)
|
||||
#else
|
||||
# define GPIO_TIM12_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
|
||||
# define GPIO_TIM12_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4)
|
||||
# define GPIO_TIM12_CH2IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
|
||||
# define GPIO_TIM12_CH2OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32_TIM13_REMAP)
|
||||
# define GPIO_TIM13_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
|
||||
# define GPIO_TIM13_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN0)
|
||||
#else
|
||||
# define GPIO_TIM13_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN8)
|
||||
# define GPIO_TIM13_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN8)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32_TIM14_REMAP)
|
||||
# define GPIO_TIM14_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
|
||||
# define GPIO_TIM14_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN1)
|
||||
#else
|
||||
# define GPIO_TIM14_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN9)
|
||||
# define GPIO_TIM14_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN9)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32_TIM15_REMAP)
|
||||
# define GPIO_TIM15_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN14)
|
||||
# define GPIO_TIM15_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN14)
|
||||
# define GPIO_TIM15_CH2IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN15)
|
||||
# define GPIO_TIM15_CH2OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN15)
|
||||
#else
|
||||
# define GPIO_TIM15_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
# define GPIO_TIM15_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN2)
|
||||
# define GPIO_TIM15_CH2IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
# define GPIO_TIM15_CH2OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN3)
|
||||
#endif
|
||||
#define GPIO_TIM15_BKIN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN9)
|
||||
#define GPIO_TIM15_CH1N (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN15)
|
||||
|
||||
#if defined(CONFIG_STM32_TIM16_REMAP)
|
||||
# define GPIO_TIM16_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
|
||||
# define GPIO_TIM16_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN6)
|
||||
#else
|
||||
# define GPIO_TIM16_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8)
|
||||
# define GPIO_TIM16_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8)
|
||||
#endif
|
||||
#define GPIO_TIM16_BKIN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN5)
|
||||
#define GPIO_TIM16_CH1N (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN6)
|
||||
|
||||
#if defined(CONFIG_STM32_TIM17_REMAP)
|
||||
# define GPIO_TIM17_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
|
||||
# define GPIO_TIM17_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7)
|
||||
#else
|
||||
# define GPIO_TIM17_CH1IN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN9)
|
||||
# define GPIO_TIM17_CH1OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9)
|
||||
#endif
|
||||
#define GPIO_TIM17_BKIN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN10)
|
||||
#define GPIO_TIM17_CH1N (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN7)
|
||||
|
||||
/* USART */
|
||||
|
||||
#if defined(CONFIG_STM32_USART1_REMAP)
|
||||
@@ -230,38 +384,10 @@
|
||||
# define GPIO_USART3_RTS (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN14)
|
||||
#endif
|
||||
|
||||
/* SPI */
|
||||
#define GPIO_UART4_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN10)
|
||||
#define GPIO_UART4_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN11)
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1_REMAP)
|
||||
# define GPIO_SPI1_NSS (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
|
||||
# define GPIO_SPI1_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN3)
|
||||
# define GPIO_SPI1_MISO (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN4)
|
||||
# define GPIO_SPI1_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5)
|
||||
#else
|
||||
# define GPIO_SPI1_NSS (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN4)
|
||||
# define GPIO_SPI1_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN5)
|
||||
# define GPIO_SPI1_MISO (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN6)
|
||||
# define GPIO_SPI1_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7)
|
||||
#endif
|
||||
|
||||
#define GPIO_SPI2_NSS (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12)
|
||||
#define GPIO_SPI2_SCK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13)
|
||||
#define GPIO_SPI2_MISO (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN14)
|
||||
#define GPIO_SPI2_MOSI (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN15)
|
||||
|
||||
/* I2C */
|
||||
|
||||
#if defined(CONFIG_STM32_I2C1_REMAP)
|
||||
# define GPIO_I2C1_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8)
|
||||
# define GPIO_I2C1_SDA (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9)
|
||||
#else
|
||||
# define GPIO_I2C1_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN6)
|
||||
# define GPIO_I2C1_SDA (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN7)
|
||||
#endif
|
||||
#define GPIO_I2C1_SMBA (GPIO_ALT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5)
|
||||
|
||||
#define GPIO_I2C2_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10)
|
||||
#define GPIO_I2C2_SDA (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11)
|
||||
#define GPIO_I2C2_SMBA (GPIO_ALT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12)
|
||||
#define GPIO_UART5_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN12)
|
||||
#define GPIO_UART5_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN2)
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F100_PINMAP_H */
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
|
||||
#if 0 /* Needs further investigation */
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUTz|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -50,53 +50,53 @@
|
||||
|
||||
/* ADC */
|
||||
|
||||
#define GPIO_ADC1_IN0 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN1 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN2 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC1_IN3 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC1_IN4 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_ADC1_IN5 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#define GPIO_ADC1_IN6 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
|
||||
#define GPIO_ADC1_IN7 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ADC1_IN8 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN9 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN10 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN11 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN12 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC1_IN13 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
#define GPIO_ADC1_IN14 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ADC1_IN15 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
|
||||
#define GPIO_ADC1_IN0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC1_IN3 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC1_IN4 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_ADC1_IN5 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#define GPIO_ADC1_IN6 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
|
||||
#define GPIO_ADC1_IN7 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ADC1_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN9 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN10 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC1_IN11 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC1_IN12 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC1_IN13 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
#define GPIO_ADC1_IN14 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ADC1_IN15 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
|
||||
|
||||
#define GPIO_ADC2_IN0 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC2_IN1 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC2_IN2 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC2_IN3 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC2_IN4 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_ADC2_IN5 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#define GPIO_ADC2_IN6 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
|
||||
#define GPIO_ADC2_IN7 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ADC2_IN8 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
|
||||
#define GPIO_ADC2_IN9 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
|
||||
#define GPIO_ADC2_IN10 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC2_IN11 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC2_IN12 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC2_IN13 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
#define GPIO_ADC2_IN14 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ADC2_IN15 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
|
||||
#define GPIO_ADC2_IN0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC2_IN1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC2_IN2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC2_IN3 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC2_IN4 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_ADC2_IN5 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#define GPIO_ADC2_IN6 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
|
||||
#define GPIO_ADC2_IN7 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ADC2_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
|
||||
#define GPIO_ADC2_IN9 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
|
||||
#define GPIO_ADC2_IN10 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC2_IN11 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC2_IN12 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC2_IN13 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
#define GPIO_ADC2_IN14 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ADC2_IN15 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
|
||||
|
||||
#define GPIO_ADC3_IN0 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC3_IN1 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC3_IN2 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC3_IN3 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC3_IN4 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN6)
|
||||
#define GPIO_ADC3_IN5 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN7)
|
||||
#define GPIO_ADC3_IN6 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN8)
|
||||
#define GPIO_ADC3_IN7 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN9)
|
||||
#define GPIO_ADC3_IN8 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN10)
|
||||
#define GPIO_ADC3_IN10 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC3_IN11 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC3_IN12 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC3_IN13 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
#define GPIO_ADC3_IN0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_ADC3_IN1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ADC3_IN2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
|
||||
#define GPIO_ADC3_IN3 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
|
||||
#define GPIO_ADC3_IN4 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN6)
|
||||
#define GPIO_ADC3_IN5 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN7)
|
||||
#define GPIO_ADC3_IN6 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN8)
|
||||
#define GPIO_ADC3_IN7 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN9)
|
||||
#define GPIO_ADC3_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN10)
|
||||
#define GPIO_ADC3_IN10 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_ADC3_IN11 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_ADC3_IN12 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_ADC3_IN13 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
|
||||
|
||||
/* DAC - "Once the DAC channelx is enabled, the corresponding GPIO pin
|
||||
* (PA4 or PA5) is automatically connected to the analog converter output
|
||||
@@ -104,8 +104,8 @@
|
||||
* should first be configured to analog (AIN)."
|
||||
*/
|
||||
|
||||
#define GPIO_DAC_OUT1 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN10)
|
||||
#define GPIO_DAC_OUT2 (GPIO_ALT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PIN10)
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
|
||||
/* TIMERS */
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#endif
|
||||
|
||||
#if 0 /* Needs further investigation */
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUTz|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#endif
|
||||
|
||||
#if 0 /* Needs further investigation */
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUTz|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT1 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_DAC_OUT2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#define STM32_AFIO_EXTICR2_OFFSET 0x000c /* External interrupt configuration register 2 */
|
||||
#define STM32_AFIO_EXTICR3_OFFSET 0x0010 /* External interrupt configuration register 3 */
|
||||
#define STM32_AFIO_EXTICR4_OFFSET 0x0014 /* External interrupt configuration register 4 */
|
||||
#define STM32_AFIO_MAPR2_OFFSET 0x001c /* AF remap and debug I/O configuration register 2 */
|
||||
|
||||
/* Register Addresses ***************************************************************/
|
||||
|
||||
@@ -373,5 +374,27 @@
|
||||
#define AFIO_EXTICR4_EXTI15_SHIFT (12) /* Bits 15-12: EXTI 15 configuration */
|
||||
#define AFIO_EXTICR4_EXTI15_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR4_EXTI15_SHIFT)
|
||||
|
||||
/* AF remap and debug I/O configuration register 2 */
|
||||
|
||||
#ifdef CONFIG_STM32_VALUELINE
|
||||
# define AFIO_MAPR2_TIM15_REMAP (1 << 0) /* Bit 0: TIM15 remapping */
|
||||
# define AFIO_MAPR2_TIM16_REMAP (1 << 1) /* Bit 1: TIM16 remapping */
|
||||
# define AFIO_MAPR2_TIM17_REMAP (1 << 2) /* Bit 2: TIM17 remapping */
|
||||
# define AFIO_MAPR2_CEC_REMAP (1 << 3) /* Bit 3: CEC remapping */
|
||||
# define AFIO_MAPR2_TIM1_DMA_REMAP (1 << 4) /* Bit 4: TIM1 DMA remapping */
|
||||
#else
|
||||
# define AFIO_MAPR2_TIM9_REMAP (1 << 5) /* Bit 5: TIM9 remapping */
|
||||
# define AFIO_MAPR2_TIM10_REMAP (1 << 6) /* Bit 6: TIM10 remapping */
|
||||
# define AFIO_MAPR2_TIM11_REMAP (1 << 7) /* Bit 7: TIM11 remapping */
|
||||
#endif
|
||||
#define AFIO_MAPR2_TIM13_REMAP (1 << 8) /* Bit 8: TIM13 remapping */
|
||||
#define AFIO_MAPR2_TIM14_REMAP (1 << 9) /* Bit 9: TIM14 remapping */
|
||||
#define AFIO_MAPR2_FSMC_NADV (1 << 10) /* Bit 10: NADV connect/disconnect */
|
||||
#ifdef CONFIG_STM32_VALUELINE
|
||||
# define AFIO_MAPR2_TIM67_DAC_DMA_REMAP (1 << 11) /* Bit 11: TIM67_DAC DMA remapping */
|
||||
# define AFIO_MAPR2_TIM12_REMAP (1 << 12) /* Bit 12: TIM12 remapping */
|
||||
# define AFIO_MAPR2_MISC_REMAP (1 << 13) /* Bit 13: Miscellaneous features remapping */
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F10XXX_GPIO_H */
|
||||
|
||||
|
||||
@@ -60,7 +60,9 @@
|
||||
#define STM32_TIM5_BASE 0x40000c00 /* 0x40000c00 - 0x40000fff: TIM5 timer */
|
||||
#define STM32_TIM6_BASE 0x40001000 /* 0x40001000 - 0x400013ff: TIM6 timer */
|
||||
#define STM32_TIM7_BASE 0x40001400 /* 0x40001400 - 0x400007ff: TIM7 timer */
|
||||
/* 0x40001800 - 0x40000fff: Reserved */
|
||||
#define STM32_TIM12_BASE 0x40001800 /* 0x40001800 - 0x40001bff: TIM12 timer */
|
||||
#define STM32_TIM13_BASE 0x40001c00 /* 0x40001c00 - 0x40001fff: TIM13 timer */
|
||||
#define STM32_TIM14_BASE 0x40002000 /* 0x40002000 - 0x400023ff: TIM14 timer */
|
||||
#define STM32_RTC_BASE 0x40002800 /* 0x40002800 - 0x40002bff: RTC */
|
||||
#define STM32_WWDG_BASE 0x40002c00 /* 0x40002C00 - 0x40002fff: Window watchdog (WWDG) */
|
||||
#define STM32_IWDG_BASE 0x40003000 /* 0x40003000 - 0x400033ff: Independent watchdog (IWDG) */
|
||||
@@ -83,8 +85,8 @@
|
||||
#define STM32_BKP_BASE 0x40006c00 /* 0x40006c00 - 0x40006fff: Backup registers (BKP) */
|
||||
#define STM32_PWR_BASE 0x40007000 /* 0x40007000 - 0x400073ff: Power control PWR */
|
||||
#define STM32_DAC_BASE 0x40007400 /* 0x40007400 - 0x400077ff: DAC */
|
||||
/* 0x40007800 - 0x4000ffff: Reserved */
|
||||
|
||||
#define STM32_CEC_BASE 0x40007800 /* 0x40007800 - 0x40007bff: CEC */
|
||||
/* 0x40007c00 - 0x4000ffff: Reserved */
|
||||
/* APB2 bus */
|
||||
|
||||
#define STM32_AFIO_BASE 0x40010000 /* 0x40010000 - 0x400103ff: AFIO */
|
||||
@@ -102,44 +104,49 @@
|
||||
#define STM32_SPI1_BASE 0x40013000 /* 0x40013000 - 0x400133ff: SPI1 */
|
||||
#define STM32_TIM8_BASE 0x40013400 /* 0x40013400 - 0x400137ff: TIM8 timer */
|
||||
#define STM32_USART1_BASE 0x40013800 /* 0x40013800 - 0x40013bff: USART1 */
|
||||
#define STM32_ADC3_BASE 0x40012800 /* 0x40012800 - 0x40013fff: ADC3 */
|
||||
/* 0x40014000 - 0x40017fff: Reserved */
|
||||
#define STM32_ADC3_BASE 0x40012800 /* 0x40012800 - 0x40013c00: ADC3 */
|
||||
/* 0x40013c00 - 0x40013fff: Reserved */
|
||||
#define STM32_TIM15_BASE 0x40014400 /* 0x40014400 - 0x400147ff: TIM15 */
|
||||
#define STM32_TIM16_BASE 0x40014400 /* 0x40014400 - 0x400147ff: TIM16 */
|
||||
#define STM32_TIM17_BASE 0x40014800 /* 0x40014800 - 0x40014bff: TIM17 */
|
||||
/* 0x40014c00 - 0x4001ffff: Reserved */
|
||||
|
||||
/* AHB bus */
|
||||
|
||||
#define STM32_SDIO_BASE 0x40018000 /* 0x40018000 - 0x400183ff: SDIO */
|
||||
/* 0x40018400 - 0x40017fff: Reserved */
|
||||
#define STM32_DMA1_BASE 0x40020000 /* 0x40020000 - 0x400203ff: DMA1 */
|
||||
#define STM32_DMA2_BASE 0x40020400 /* 0x40020000 - 0x400207ff: DMA2 */
|
||||
/* 0x40020800 - 0x40020fff: Reserved */
|
||||
#define STM32_RCC_BASE 0x40021000 /* 0x40021000 - 0x400213ff: Reset and Clock control RCC */
|
||||
/* 0x40021400 - 0x40021fff: Reserved */
|
||||
#define STM32_OTGFS_BASE 0x50000000 /* 0x50000000 - 0x500003ff: USB OTG FS */
|
||||
#define STM32_FLASHIF_BASE 0x40022000 /* 0x40022000 - 0x400223ff: Flash memory interface */
|
||||
#define STM32_CRC_BASE 0x40028000 /* 0x40023000 - 0x400233ff: CRC */
|
||||
/* 0x40023400 - 0x40027fff: Reserved */
|
||||
#define STM32_ETHERNET_BASE 0x40028000 /* 0x40028000 - 0x40029fff: Ethernet */
|
||||
/* 0x40030000 - 0x4fffffff: Reserved */
|
||||
#define STM32_SDIO_BASE 0x40018000 /* 0x40018000 - 0x400183ff: SDIO */
|
||||
/* 0x40018400 - 0x40017fff: Reserved */
|
||||
#define STM32_DMA1_BASE 0x40020000 /* 0x40020000 - 0x400203ff: DMA1 */
|
||||
#define STM32_DMA2_BASE 0x40020400 /* 0x40020000 - 0x400207ff: DMA2 */
|
||||
/* 0x40020800 - 0x40020fff: Reserved */
|
||||
#define STM32_RCC_BASE 0x40021000 /* 0x40021000 - 0x400213ff: Reset and Clock control RCC */
|
||||
/* 0x40021400 - 0x40021fff: Reserved */
|
||||
#define STM32_OTGFS_BASE 0x50000000 /* 0x50000000 - 0x500003ff: USB OTG FS */
|
||||
#define STM32_FLASHIF_BASE 0x40022000 /* 0x40022000 - 0x400223ff: Flash memory interface */
|
||||
#define STM32_CRC_BASE 0x40028000 /* 0x40023000 - 0x400233ff: CRC */
|
||||
/* 0x40023400 - 0x40027fff: Reserved */
|
||||
#define STM32_ETHERNET_BASE 0x40028000 /* 0x40028000 - 0x40029fff: Ethernet */
|
||||
/* 0x40030000 - 0x4fffffff: Reserved */
|
||||
|
||||
/* Peripheral BB base */
|
||||
|
||||
#define STM32_PERIPHBB_BASE 0x42000000
|
||||
#define STM32_PERIPHBB_BASE 0x42000000
|
||||
|
||||
/* Flexible SRAM controller (FSMC) */
|
||||
|
||||
#define STM32_FSMC_BANK1 0x60000000 /* 0x60000000-0x6fffffff: 256Mb NOR/SRAM */
|
||||
#define STM32_FSMC_BANK2 0x70000000 /* 0x70000000-0x7fffffff: 256Mb NAND FLASH */
|
||||
#define STM32_FSMC_BANK3 0x80000000 /* 0x80000000-0x8fffffff: 256Mb NAND FLASH */
|
||||
#define STM32_FSMC_BANK4 0x90000000 /* 0x90000000-0x9fffffff: 256Mb PC CARD*/
|
||||
#define STM32_IS_EXTSRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_FSMC_BANK1)
|
||||
#define STM32_FSMC_BANK1 0x60000000 /* 0x60000000-0x6fffffff: 256Mb NOR/SRAM */
|
||||
#define STM32_FSMC_BANK2 0x70000000 /* 0x70000000-0x7fffffff: 256Mb NAND FLASH */
|
||||
#define STM32_FSMC_BANK3 0x80000000 /* 0x80000000-0x8fffffff: 256Mb NAND FLASH */
|
||||
#define STM32_FSMC_BANK4 0x90000000 /* 0x90000000-0x9fffffff: 256Mb PC CARD*/
|
||||
#define STM32_IS_EXTSRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_FSMC_BANK1)
|
||||
|
||||
#define STM32_FSMC_BASE 0xa0000000 /* 0xa0000000-0xbfffffff: 512Mb FSMC register block */
|
||||
#define STM32_FSMC_BASE 0xa0000000 /* 0xa0000000-0xbfffffff: 512Mb FSMC register block */
|
||||
|
||||
/* Other registers -- see armv7-m/nvic.h for standard Cortex-M3 registers in this
|
||||
* address range
|
||||
*/
|
||||
|
||||
#define STM32_SCS_BASE 0xe000e000
|
||||
#define STM32_DEBUGMCU_BASE 0xe0042000
|
||||
#define STM32_SCS_BASE 0xe000e000
|
||||
#define STM32_DEBUGMCU_BASE 0xe0042000
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F10XXX_MEMORYMAP_H */
|
||||
|
||||
|
||||
@@ -163,7 +163,9 @@
|
||||
# define RCC_CFGR_PLLMUL_CLKx14 (12 << RCC_CFGR_PLLMUL_SHIFT) /* 1100: PLL input clock x 14 */
|
||||
# define RCC_CFGR_PLLMUL_CLKx15 (13 << RCC_CFGR_PLLMUL_SHIFT) /* 1101: PLL input clock x 15 */
|
||||
# define RCC_CFGR_PLLMUL_CLKx16 (14 << RCC_CFGR_PLLMUL_SHIFT) /* 111x: PLL input clock x 16 */
|
||||
#define RCC_CFGR_USBPRE (1 << 22) /* Bit 22: USB prescaler */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_CFGR_USBPRE (1 << 22) /* Bit 22: USB prescaler */
|
||||
#endif
|
||||
#define RCC_CFGR_MCO_SHIFT (24) /* Bits 26-24: Microcontroller Clock Output */
|
||||
#define RCC_CFGR_MCO_MASK (0x0f << RCC_CFGR_MCO_SHIFT)
|
||||
# define RCC_CFGR_NOCLK (0 << RCC_CFGR_MCO_SHIFT) /* 0xx: No clock */
|
||||
@@ -207,12 +209,22 @@
|
||||
#define TCC_APB2RSTR_IOPFRST (1 << 7) /* Bit 7: IO port F reset */
|
||||
#define TCC_APB2RSTR_IOPGRST (1 << 8) /* Bit 8: IO port G reset */
|
||||
#define RCC_APB2RSTR_ADC1RST (1 << 9) /* Bit 9: ADC 1 interface reset */
|
||||
#define RCC_APB2RSTR_ADC2RST (1 << 10) /* Bit 10: ADC 2 interface reset */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB2RSTR_ADC2RST (1 << 10) /* Bit 10: ADC 2 interface reset */
|
||||
#endif
|
||||
#define RCC_APB2RSTR_TIM1RST (1 << 11) /* Bit 11: TIM1 Timer reset */
|
||||
#define RCC_APB2RSTR_SPI1RST (1 << 12) /* Bit 12: SPI 1 reset */
|
||||
#define RCC_APB2RSTR_TIM8RST (1 << 13) /* Bit 13: TIM8 Timer reset */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB2RSTR_TIM8RST (1 << 13) /* Bit 13: TIM8 Timer reset */
|
||||
#endif
|
||||
#define RCC_APB2RSTR_USART1RST (1 << 14) /* Bit 14: USART1 reset */
|
||||
#define RCC_APB2RSTR_ADC3RST (1 << 15) /* Bit 15: ADC3 interface reset */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB2RSTR_ADC3RST (1 << 15) /* Bit 15: ADC3 interface reset */
|
||||
#else
|
||||
# define RCC_APB2RSTR_TIM15RST (1 << 16) /* Bit 16: TIM15 reset */
|
||||
# define RCC_APB2RSTR_TIM16RST (1 << 17) /* Bit 17: TIM16 reset */
|
||||
# define RCC_APB2RSTR_TIM17RST (1 << 18) /* Bit 18: TIM17 reset */
|
||||
#endif
|
||||
|
||||
/* APB1 Peripheral reset register */
|
||||
|
||||
@@ -222,6 +234,11 @@
|
||||
#define RCC_APB1RSTR_TIM5RST (1 << 3) /* Bit 3: Timer 5 reset */
|
||||
#define RCC_APB1RSTR_TIM6RST (1 << 4) /* Bit 4: Timer 6 reset */
|
||||
#define RCC_APB1RSTR_TIM7RST (1 << 5) /* Bit 5: Timer 7 reset */
|
||||
#ifdef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB1RSTR_TIM12RST (1 << 6) /* Bit 6: TIM12 reset */
|
||||
# define RCC_APB1RSTR_TIM13RST (1 << 7) /* Bit 7: TIM13 reset */
|
||||
# define RCC_APB1RSTR_TIM14RST (1 << 8) /* Bit 8: TIM14 reset */
|
||||
#endif
|
||||
#define RCC_APB1RSTR_WWDGRST (1 << 11) /* Bit 11: Window Watchdog reset */
|
||||
#define RCC_APB1RSTR_SPI2RST (1 << 14) /* Bit 14: SPI 2 reset */
|
||||
#define RCC_APB1RSTR_SPI3RST (1 << 15) /* Bit 15: SPI 3 reset */
|
||||
@@ -231,12 +248,17 @@
|
||||
#define RCC_APB1RSTR_UART5RST (1 << 20) /* Bit 18: UART 5 reset */
|
||||
#define RCC_APB1RSTR_I2C1RST (1 << 21) /* Bit 21: I2C 1 reset */
|
||||
#define RCC_APB1RSTR_I2C2RST (1 << 22) /* Bit 22: I2C 2 reset */
|
||||
#define RCC_APB1RSTR_USBRST (1 << 23) /* Bit 23: USB reset */
|
||||
#define RCC_APB1RSTR_CAN1RST (1 << 25) /* Bit 25: CAN1 reset */
|
||||
#define RCC_APB1RSTR_CAN2RST (1 << 26) /* Bit 26: CAN2 reset */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB1RSTR_USBRST (1 << 23) /* Bit 23: USB reset */
|
||||
# define RCC_APB1RSTR_CAN1RST (1 << 25) /* Bit 25: CAN1 reset */
|
||||
# define RCC_APB1RSTR_CAN2RST (1 << 26) /* Bit 26: CAN2 reset */
|
||||
#endif
|
||||
#define RCC_APB1RSTR_BKPRST (1 << 27) /* Bit 27: Backup interface reset */
|
||||
#define RCC_APB1RSTR_PWRRST (1 << 28) /* Bit 28: Power interface reset */
|
||||
#define RCC_APB1RSTR_DACRST (1 << 29) /* Bit 29: DAC interface reset */
|
||||
#ifdef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB1RSTR_CECRST (1 << 30) /* Bit 30: CEC reset */
|
||||
#endif
|
||||
|
||||
/* AHB Peripheral Clock enable register */
|
||||
|
||||
@@ -246,7 +268,9 @@
|
||||
#define RCC_AHBENR_FLITFEN (1 << 4) /* Bit 4: FLITF clock enable */
|
||||
#define RCC_AHBENR_CRCEN (1 << 6) /* Bit 6: CRC clock enable */
|
||||
#define RCC_AHBENR_FSMCEN (1 << 8) /* Bit 8: FSMC clock enable */
|
||||
#define RCC_AHBENR_SDIOEN (1 << 10) /* Bit 10: SDIO clock enable */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_AHBENR_SDIOEN (1 << 10) /* Bit 10: SDIO clock enable */
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_CONNECTIVITYLINE
|
||||
# define RCC_AHBENR_ETHMACEN (1 << 14) /* Bit 14: Ethernet MAC clock enable */
|
||||
# define RCC_AHBENR_ETHMACTXEN (1 << 15) /* Bit 15: Ethernet MAC TX clock enable */
|
||||
@@ -272,12 +296,22 @@
|
||||
#define RCC_APB2ENR_IOPFEN (1 << 7) /* Bit 7: I/O port F clock enable */
|
||||
#define RCC_APB2ENR_IOPGEN (1 << 8) /* Bit 8: I/O port G clock enable */
|
||||
#define RCC_APB2ENR_ADC1EN (1 << 9) /* Bit 9: ADC 1 interface clock enable */
|
||||
#define RCC_APB2ENR_ADC2EN (1 << 10) /* Bit 10: ADC 2 interface clock enable */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB2ENR_ADC2EN (1 << 10) /* Bit 10: ADC 2 interface clock enable */
|
||||
#endif
|
||||
#define RCC_APB2ENR_TIM1EN (1 << 11) /* Bit 11: TIM1 Timer clock enable */
|
||||
#define RCC_APB2ENR_SPI1EN (1 << 12) /* Bit 12: SPI 1 clock enable */
|
||||
#define RCC_APB2ENR_TIM8EN (1 << 13) /* Bit 13: TIM8 Timer clock enable */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB2ENR_TIM8EN (1 << 13) /* Bit 13: TIM8 Timer clock enable */
|
||||
#endif
|
||||
#define RCC_APB2ENR_USART1EN (1 << 14) /* Bit 14: USART1 clock enable */
|
||||
#define RCC_APB2ENR_ADC3EN (1 << 15) /* Bit 14: ADC3 interface clock enable */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB2ENR_ADC3EN (1 << 15) /* Bit 14: ADC3 interface clock enable */
|
||||
#else
|
||||
# define RCC_APB2ENR_TIM15EN (1 << 16) /* Bit 16: TIM15 clock enable */
|
||||
# define RCC_APB2ENR_TIM16EN (1 << 17) /* Bit 17: TIM16 clock enable */
|
||||
# define RCC_APB2ENR_TIM17EN (1 << 18) /* Bit 18: TIM17 clock enable */
|
||||
#endif
|
||||
|
||||
/* APB1 Peripheral Clock enable register */
|
||||
|
||||
@@ -287,6 +321,11 @@
|
||||
#define RCC_APB1ENR_TIM5EN (1 << 3) /* Bit 3: Timer 5 clock enable */
|
||||
#define RCC_APB1ENR_TIM6EN (1 << 4) /* Bit 4: Timer 6 clock enable */
|
||||
#define RCC_APB1ENR_TIM7EN (1 << 5) /* Bit 5: Timer 7 clock enable */
|
||||
#ifdef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB1ENR_TIM12EN (1 << 6) /* Bit 6: Timer 12 clock enable */
|
||||
# define RCC_APB1ENR_TIM13EN (1 << 7) /* Bit 7: Timer 13 clock enable */
|
||||
# define RCC_APB1ENR_TIM14EN (1 << 8) /* Bit 8: Timer 14 clock enable */
|
||||
#endif
|
||||
#define RCC_APB1ENR_WWDGEN (1 << 11) /* Bit 11: Window Watchdog clock enable */
|
||||
#define RCC_APB1ENR_SPI2EN (1 << 14) /* Bit 14: SPI 2 clock enable */
|
||||
#define RCC_APB1ENR_SPI3EN (1 << 15) /* Bit 15: SPI 3 clock enable */
|
||||
@@ -296,12 +335,17 @@
|
||||
#define RCC_APB1ENR_UART5EN (1 << 20) /* Bit 20: UART 5 clock enable */
|
||||
#define RCC_APB1ENR_I2C1EN (1 << 21) /* Bit 21: I2C 1 clock enable */
|
||||
#define RCC_APB1ENR_I2C2EN (1 << 22) /* Bit 22: I2C 2 clock enable */
|
||||
#define RCC_APB1ENR_USBEN (1 << 23) /* Bit 23: USB clock enable */
|
||||
#define RCC_APB1ENR_CAN1EN (1 << 25) /* Bit 25: CAN1 clock enable */
|
||||
#define RCC_APB1ENR_CAN2EN (1 << 26) /* Bit 25: CAN2 clock enable */
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB1ENR_USBEN (1 << 23) /* Bit 23: USB clock enable */
|
||||
# define RCC_APB1ENR_CAN1EN (1 << 25) /* Bit 25: CAN1 clock enable */
|
||||
# define RCC_APB1ENR_CAN2EN (1 << 26) /* Bit 25: CAN2 clock enable */
|
||||
#endif
|
||||
#define RCC_APB1ENR_BKPEN (1 << 27) /* Bit 27: Backup interface clock enable */
|
||||
#define RCC_APB1ENR_PWREN (1 << 28) /* Bit 28: Power interface clock enable */
|
||||
#define RCC_APB1ENR_DACEN (1 << 29) /* Bit 29: DAC interface clock enable */
|
||||
#ifdef CONFIG_STM32_VALUELINE
|
||||
# define RCC_APB1ENR_CECEN (1 << 30) /* Bit 30: CEC clock enable */
|
||||
#endif
|
||||
|
||||
/* Backup domain control register */
|
||||
|
||||
@@ -331,7 +375,7 @@
|
||||
|
||||
#if defined(CONFIG_STM32_VALUELINE) || defined(CONFIG_STM32_CONNECTIVITYLINE)
|
||||
|
||||
/* Clock configuration register 2 (For connectivity line only) */
|
||||
/* Clock configuration register 2 (For value line and connectivity line only) */
|
||||
|
||||
#define RCC_CFGR2_PREDIV1_SHIFT (0)
|
||||
#define RCC_CFGR2_PREDIV1_MASK (0x0f << RCC_CFGR2_PREDIV1_SHIFT)
|
||||
@@ -352,6 +396,10 @@
|
||||
# define RCC_CFGR2_PREDIV1d15 (14 << RCC_CFGR2_PREDIV1_SHIFT)
|
||||
# define RCC_CFGR2_PREDIV1d16 (15 << RCC_CFGR2_PREDIV1_SHIFT)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_CONNECTIVITYLINE
|
||||
|
||||
#define RCC_CFGR2_PREDIV2_SHIFT (4)
|
||||
#define RCC_CFGR2_PREDIV2_MASK (0x0f << RCC_CFGR2_PREDIV2_SHIFT)
|
||||
# define RCC_CFGR2_PREDIV2d1 (0 << RCC_CFGR2_PREDIV2_SHIFT)
|
||||
|
||||
@@ -49,15 +49,77 @@
|
||||
* definition that provides the number of supported vectors.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARMV7M_CMNVECTOR
|
||||
# ifdef CONFIG_ARMV7M_CMNVECTOR
|
||||
|
||||
/* Reserve 60 interrupt table entries for I/O interrupts. */
|
||||
/* Reserve 61 interrupt table entries for I/O interrupts. */
|
||||
|
||||
# define ARMV7M_PERIPHERAL_INTERRUPTS 60
|
||||
# define ARMV7M_PERIPHERAL_INTERRUPTS 61
|
||||
|
||||
#else
|
||||
# error This target requires CONFIG_ARMV7M_CMNVECTOR
|
||||
#endif /* CONFIG_ARMV7M_CMNVECTOR */
|
||||
|
||||
VECTOR(stm32_wwdg, STM32_IRQ_WWDG) /* Vector 16+0: Window Watchdog interrupt */
|
||||
VECTOR(stm32_pvd, STM32_IRQ_PVD) /* Vector 16+1: PVD through EXTI Line detection interrupt */
|
||||
VECTOR(stm32_tamper, STM32_IRQ_TAMPER) /* Vector 16+2: Tamper interrupt */
|
||||
VECTOR(stm32_rtc, STM32_IRQ_RTC) /* Vector 16+3: RTC Wakeup through EXTI line interrupt */
|
||||
VECTOR(stm32_flash, STM32_IRQ_FLASH) /* Vector 16+4: Flash global interrupt */
|
||||
VECTOR(stm32_rcc, STM32_IRQ_RCC) /* Vector 16+5: RCC global interrupt */
|
||||
VECTOR(stm32_exti0, STM32_IRQ_EXTI0) /* Vector 16+6: EXTI Line 0 interrupt */
|
||||
VECTOR(stm32_exti1, STM32_IRQ_EXTI1) /* Vector 16+7: EXTI Line 1 interrupt */
|
||||
VECTOR(stm32_exti2, STM32_IRQ_EXTI2) /* Vector 16+8: EXTI Line 2 interrupt */
|
||||
VECTOR(stm32_exti3, STM32_IRQ_EXTI3) /* Vector 16+9: EXTI Line 3 interrupt */
|
||||
VECTOR(stm32_exti4, STM32_IRQ_EXTI4) /* Vector 16+10: EXTI Line 4 interrupt */
|
||||
VECTOR(stm32_dma1ch1, STM32_IRQ_DMA1CH1) /* Vector 16+11: DMA1 Channel 1 global interrupt */
|
||||
VECTOR(stm32_dma1ch2, STM32_IRQ_DMA1CH2) /* Vector 16+12: DMA1 Channel 2 global interrupt */
|
||||
VECTOR(stm32_dma1ch3, STM32_IRQ_DMA1CH3) /* Vector 16+13: DMA1 Channel 3 global interrupt */
|
||||
VECTOR(stm32_dma1ch4, STM32_IRQ_DMA1CH4) /* Vector 16+14: DMA1 Channel 4 global interrupt */
|
||||
VECTOR(stm32_dma1ch5, STM32_IRQ_DMA1CH5) /* Vector 16+15: DMA1 Channel 5 global interrupt */
|
||||
VECTOR(stm32_dma1ch6, STM32_IRQ_DMA1CH6) /* Vector 16+16: DMA1 Channel 6 global interrupt */
|
||||
VECTOR(stm32_dma1ch7, STM32_IRQ_DMA1CH7) /* Vector 16+17: DMA1 Channel 7 global interrupt */
|
||||
VECTOR(stm32_adc1, STM32_IRQ_ADC1) /* Vector 16+18: ADC1 global interrupt */
|
||||
UNUSED(STM32_IRQ_RESERVED0) /* Vector 16+19: Reserved 0 */
|
||||
UNUSED(STM32_IRQ_RESERVED1) /* Vector 16+20: Reserved 1 */
|
||||
UNUSED(STM32_IRQ_RESERVED2) /* Vector 16+21: Reserved 2 */
|
||||
UNUSED(STM32_IRQ_RESERVED3) /* Vector 16+22: Reserved 3 */
|
||||
VECTOR(stm32_exti95, STM32_IRQ_EXTI95) /* Vector 16+23: EXTI Line[9:5] interrupts */
|
||||
VECTOR(stm32_tim1brk, STM32_IRQ_TIM1BRK) /* Vector 16+24: TIM1 Break interrupt; TIM15 global interrupt */
|
||||
VECTOR(stm32_tim1up, STM32_IRQ_TIM1UP) /* Vector 16+25: TIM1 Update interrupt; TIM16 global interrupt */
|
||||
VECTOR(stm32_tim1trgcom, STM32_IRQ_TIM1TRGCOM) /* Vector 16+26: TIM1 Trigger and Commutation interrupts; TIM17 global interrupt */
|
||||
VECTOR(stm32_tim1cc, STM32_IRQ_TIM1CC) /* Vector 16+27: TIM1 Capture Compare interrupt */
|
||||
VECTOR(stm32_tim2, STM32_IRQ_TIM2) /* Vector 16+28: TIM2 global interrupt */
|
||||
VECTOR(stm32_tim3, STM32_IRQ_TIM3) /* Vector 16+29: TIM3 global interrupt */
|
||||
VECTOR(stm32_tim4, STM32_IRQ_TIM4) /* Vector 16+30: TIM4 global interrupt */
|
||||
VECTOR(stm32_i2c1ev, STM32_IRQ_I2C1EV) /* Vector 16+31: I2C1 event interrupt */
|
||||
VECTOR(stm32_i2c1er, STM32_IRQ_I2C1ER) /* Vector 16+32: I2C1 error interrupt */
|
||||
VECTOR(stm32_i2c2ev, STM32_IRQ_I2C2EV) /* Vector 16+33: I2C2 event interrupt */
|
||||
VECTOR(stm32_i2c2er, STM32_IRQ_I2C2ER) /* Vector 16+34: I2C2 error interrupt */
|
||||
VECTOR(stm32_spi1, STM32_IRQ_SPI1) /* Vector 16+35: SPI1 global interrupt */
|
||||
VECTOR(stm32_spi2, STM32_IRQ_SPI2) /* Vector 16+36: SPI2 global interrupt */
|
||||
VECTOR(stm32_usart1, STM32_IRQ_USART1) /* Vector 16+37: USART1 global interrupt */
|
||||
VECTOR(stm32_usart2, STM32_IRQ_USART2) /* Vector 16+38: USART2 global interrupt */
|
||||
VECTOR(stm32_usart3, STM32_IRQ_USART3) /* Vector 16+39: USART3 global interrupt */
|
||||
VECTOR(stm32_exti1510, STM32_IRQ_EXTI1510) /* Vector 16+40: EXTI Line[15:10] interrupts */
|
||||
VECTOR(stm32_rtcalr, STM32_IRQ_RTCALR) /* Vector 16+41: RTC alarms (A and B) through EXTI line interrupt */
|
||||
VECTOR(stm32_cec, STM32_IRQ_CEC) /* Vector 16+42: CEC global interrupt */
|
||||
VECTOR(stm32_tim12, STM32_IRQ_TIM12) /* Vector 16+43: TIM12 global interrupt */
|
||||
VECTOR(stm32_tim13, STM32_IRQ_TIM13) /* Vector 16+44: TIM13 global interrupt */
|
||||
VECTOR(stm32_tim14, STM32_IRQ_TIM14) /* Vector 16+45: TIM14 global interrupt */
|
||||
UNUSED(STM32_IRQ_RESERVED4) /* Vector 16+46: Reserved 4 */
|
||||
UNUSED(STM32_IRQ_RESERVED5) /* Vector 16+47: Reserved 5 */
|
||||
VECTOR(stm32_fsmc, STM32_IRQ_FSMC) /* Vector 16+48: FSMC global interrupt */
|
||||
UNUSED(STM32_IRQ_RESERVED6) /* Vector 16+49: Reserved 6 */
|
||||
VECTOR(stm32_tim5, STM32_IRQ_TIM5) /* Vector 16+50: TIM5 global interrupt */
|
||||
VECTOR(stm32_spi3, STM32_IRQ_SPI3) /* Vector 16+51: SPI3 global interrupt */
|
||||
VECTOR(stm32_uart4, STM32_IRQ_UART4) /* Vector 16+52: USART2 global interrupt */
|
||||
VECTOR(stm32_uart5, STM32_IRQ_UART5) /* Vector 16+53: USART5 global interrupt */
|
||||
VECTOR(stm32_tim6, STM32_IRQ_TIM6) /* Vector 16+54: TIM6 global interrupt */
|
||||
VECTOR(stm32_tim7, STM32_IRQ_TIM7) /* Vector 16+55: TIM7 global interrupt */
|
||||
VECTOR(stm32_dma2ch1, STM32_IRQ_DMA2CH1) /* Vector 16+56: DMA2 Channel 1 global interrupt */
|
||||
VECTOR(stm32_dma2ch2, STM32_IRQ_DMA2CH2) /* Vector 16+57: DMA2 Channel 2 global interrupt */
|
||||
VECTOR(stm32_dma2ch3, STM32_IRQ_DMA2CH3) /* Vector 16+58: DMA2 Channel 3 global interrupt */
|
||||
VECTOR(stm32_dma2ch45, STM32_IRQ_DMA2CH45) /* Vector 16+59: DMA2 Channel 4 and 5 global interrupt */
|
||||
VECTOR(stm32_dma2ch5, STM32_IRQ_DMA2CH5) /* Vector 16+60: DMA2 Channel 5 global interrupt */
|
||||
|
||||
# endif /* CONFIG_ARMV7M_CMNVECTOR */
|
||||
|
||||
#elif defined(CONFIG_STM32_CONNECTIVITYLINE)
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
#define GPIO_ETH_MII_TX_EN_2 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTG|GPIO_PIN11)
|
||||
#define GPIO_ETH_PPS_OUT_1 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5)
|
||||
#define GPIO_ETH_PPS_OUT_2 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTG|GPIO_PIN8)
|
||||
#define GPIO_ETH_RMII_CRS_DV (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULLGPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ETH_RMII_CRS_DV (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ETH_RMII_REF_CLK (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ETH_RMII_RXD0 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ETH_RMII_RXD1 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN5)
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
#define GPIO_ETH_MII_TX_EN_2 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTG|GPIO_PIN11)
|
||||
#define GPIO_ETH_PPS_OUT_1 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5)
|
||||
#define GPIO_ETH_PPS_OUT_2 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTG|GPIO_PIN8)
|
||||
#define GPIO_ETH_RMII_CRS_DV (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULLGPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ETH_RMII_CRS_DV (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN7)
|
||||
#define GPIO_ETH_RMII_REF_CLK (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN1)
|
||||
#define GPIO_ETH_RMII_RXD0 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_ETH_RMII_RXD1 (GPIO_ALT|GPIO_AF11|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN5)
|
||||
|
||||
@@ -720,10 +720,10 @@ static int adc_timinit(FAR struct stm32_dev_s *priv)
|
||||
|
||||
case 4: /* TimerX TRGO event */
|
||||
{
|
||||
#warning "TRGO support not yet implemented"
|
||||
|
||||
/* TODO: TRGO support not yet implemented */
|
||||
/* Set the event TRGO */
|
||||
|
||||
ccenable = 0;
|
||||
egr = GTIM_EGR_TG;
|
||||
|
||||
/* Set the duty cycle by writing to the CCR register for this channel */
|
||||
@@ -1128,7 +1128,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
|
||||
avdbg("intf: ADC%d\n", priv->intf);
|
||||
flags = irqsave();
|
||||
|
||||
/* Enable ADC reset state */
|
||||
/* Enable ADC reset state */
|
||||
|
||||
adc_rccreset(priv, true);
|
||||
|
||||
@@ -1326,6 +1326,10 @@ static int adc_setup(FAR struct adc_dev_s *dev)
|
||||
ret = irq_attach(priv->irq, priv->isr);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* Make sure that the ADC device is in the powered up, reset state */
|
||||
|
||||
adc_reset(dev);
|
||||
|
||||
/* Enable the ADC interrupt */
|
||||
|
||||
avdbg("Enable the ADC interrupt: irq=%d\n", priv->irq);
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
|
||||
#if defined(ADC1_HAVE_TIMER) || defined(ADC2_HAVE_TIMER) || defined(ADC3_HAVE_TIMER)
|
||||
# define ADC_HAVE_TIMER 1
|
||||
# if defined(CONFIG_STM32_STM32F10XX) && defined(CONFIG_STM32_FORCEPOWER)
|
||||
# if defined(CONFIG_STM32_STM32F10XX) && !defined(CONFIG_STM32_FORCEPOWER)
|
||||
# warning "CONFIG_STM32_FORCEPOWER must be defined to enable the timer(s)"
|
||||
# endif
|
||||
#else
|
||||
|
||||
@@ -2594,6 +2594,17 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv)
|
||||
}
|
||||
up_mdelay(PHY_RESET_DELAY);
|
||||
|
||||
/* Perform any necessary, board-specific PHY initialization */
|
||||
|
||||
#ifdef CONFIG_STM32_PHYINIT
|
||||
ret = stm32_phy_boardinitialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
ndbg("Failed to initialize the PHY: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Special workaround for the Davicom DM9161 PHY is required. */
|
||||
|
||||
#ifdef CONFIG_PHY_DM9161
|
||||
|
||||
@@ -66,14 +66,13 @@ extern "C" {
|
||||
* Function: stm32_ethinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the Ethernet driver for one interface. If the STM32 chip
|
||||
* supports multiple Ethernet controllers, then board specific logic
|
||||
* must implement up_netinitialize() and call this function to initialize
|
||||
* the desired interfaces.
|
||||
* Initialize the Ethernet driver for one interface. If the STM32 chip supports
|
||||
* multiple Ethernet controllers, then board specific logic must implement
|
||||
* up_netinitialize() and call this function to initialize the desired interfaces.
|
||||
*
|
||||
* Parameters:
|
||||
* intf - In the case where there are multiple EMACs, this value
|
||||
* identifies which EMAC is to be initialized.
|
||||
* intf - In the case where there are multiple EMACs, this value identifies which
|
||||
* EMAC is to be initialized.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
@@ -86,6 +85,30 @@ extern "C" {
|
||||
EXTERN int stm32_ethinitialize(int intf);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Function: stm32_phy_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* Some boards require specialized initialization of the PHY before it can be used.
|
||||
* This may include such things as configuring GPIOs, resetting the PHY, etc. If
|
||||
* CONFIG_STM32_PHYINIT is defined in the configuration then the board specific
|
||||
* logic must provide stm32_phyinitialize(); The STM32 Ethernet driver will call
|
||||
* this function one time before it first uses the PHY.
|
||||
*
|
||||
* Parameters:
|
||||
* intf - Always zero for now.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_PHYINIT
|
||||
EXTERN int stm32_phy_boardinitialize(int intf);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -67,6 +67,14 @@
|
||||
# define STM32_CONSOLE_2STOP CONFIG_USART1_2STOP
|
||||
# define STM32_CONSOLE_TX GPIO_USART1_TX
|
||||
# define STM32_CONSOLE_RX GPIO_USART1_RX
|
||||
# ifdef CONFIG_USART1_RS485
|
||||
# define STM32_CONSOLE_RS485_DIR GPIO_USART1_RS485_DIR
|
||||
# if (CONFIG_USART1_RS485_DIR_POLARITY == 0)
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY false
|
||||
# else
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY true
|
||||
# endif
|
||||
# endif
|
||||
#elif defined(CONFIG_USART2_SERIAL_CONSOLE)
|
||||
# define STM32_CONSOLE_BASE STM32_USART2_BASE
|
||||
# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY
|
||||
@@ -76,6 +84,14 @@
|
||||
# define STM32_CONSOLE_2STOP CONFIG_USART2_2STOP
|
||||
# define STM32_CONSOLE_TX GPIO_USART2_TX
|
||||
# define STM32_CONSOLE_RX GPIO_USART2_RX
|
||||
# ifdef CONFIG_USART2_RS485
|
||||
# define STM32_CONSOLE_RS485_DIR GPIO_USART2_RS485_DIR
|
||||
# if (CONFIG_USART2_RS485_DIR_POLARITY == 0)
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY false
|
||||
# else
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY true
|
||||
# endif
|
||||
# endif
|
||||
#elif defined(CONFIG_USART3_SERIAL_CONSOLE)
|
||||
# define STM32_CONSOLE_BASE STM32_USART3_BASE
|
||||
# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY
|
||||
@@ -85,6 +101,14 @@
|
||||
# define STM32_CONSOLE_2STOP CONFIG_USART3_2STOP
|
||||
# define STM32_CONSOLE_TX GPIO_USART3_TX
|
||||
# define STM32_CONSOLE_RX GPIO_USART3_RX
|
||||
# ifdef CONFIG_USART3_RS485
|
||||
# define STM32_CONSOLE_RS485_DIR GPIO_USART3_RS485_DIR
|
||||
# if (CONFIG_USART3_RS485_DIR_POLARITY == 0)
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY false
|
||||
# else
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY true
|
||||
# endif
|
||||
# endif
|
||||
#elif defined(CONFIG_UART4_SERIAL_CONSOLE)
|
||||
# define STM32_CONSOLE_BASE STM32_UART4_BASE
|
||||
# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY
|
||||
@@ -94,6 +118,14 @@
|
||||
# define STM32_CONSOLE_2STOP CONFIG_UART4_2STOP
|
||||
# define STM32_CONSOLE_TX GPIO_UART4_TX
|
||||
# define STM32_CONSOLE_RX GPIO_UART4_RX
|
||||
# ifdef CONFIG_UART4_RS485
|
||||
# define STM32_CONSOLE_RS485_DIR GPIO_UART4_RS485_DIR
|
||||
# if (CONFIG_UART4_RS485_DIR_POLARITY == 0)
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY false
|
||||
# else
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY true
|
||||
# endif
|
||||
# endif
|
||||
#elif defined(CONFIG_UART5_SERIAL_CONSOLE)
|
||||
# define STM32_CONSOLE_BASE STM32_UART5_BASE
|
||||
# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY
|
||||
@@ -103,6 +135,14 @@
|
||||
# define STM32_CONSOLE_2STOP CONFIG_UART5_2STOP
|
||||
# define STM32_CONSOLE_TX GPIO_UART5_TX
|
||||
# define STM32_CONSOLE_RX GPIO_UART5_RX
|
||||
# ifdef CONFIG_UART5_RS485
|
||||
# define STM32_CONSOLE_RS485_DIR GPIO_UART5_RS485_DIR
|
||||
# if (CONFIG_UART5_RS485_DIR_POLARITY == 0)
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY false
|
||||
# else
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY true
|
||||
# endif
|
||||
# endif
|
||||
#elif defined(CONFIG_USART6_SERIAL_CONSOLE)
|
||||
# define STM32_CONSOLE_BASE STM32_USART6_BASE
|
||||
# define STM32_APBCLOCK STM32_PCLK2_FREQUENCY
|
||||
@@ -112,6 +152,14 @@
|
||||
# define STM32_CONSOLE_2STOP CONFIG_USART6_2STOP
|
||||
# define STM32_CONSOLE_TX GPIO_USART6_TX
|
||||
# define STM32_CONSOLE_RX GPIO_USART6_RX
|
||||
# ifdef CONFIG_USART6_RS485
|
||||
# define STM32_CONSOLE_RS485_DIR GPIO_USART6_RS485_DIR
|
||||
# if (CONFIG_USART6_RS485_DIR_POLARITY == 0)
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY false
|
||||
# else
|
||||
# define STM32_CONSOLE_RS485_DIR_POLARITY true
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* CR1 settings */
|
||||
@@ -230,10 +278,19 @@ void up_lowputc(char ch)
|
||||
/* Wait until the TX data register is empty */
|
||||
|
||||
while ((getreg32(STM32_CONSOLE_BASE + STM32_USART_SR_OFFSET) & USART_SR_TXE) == 0);
|
||||
#if STM32_CONSOLE_RS485_DIR
|
||||
stm32_gpiowrite(STM32_CONSOLE_RS485_DIR, STM32_CONSOLE_RS485_DIR_POLARITY);
|
||||
#endif
|
||||
|
||||
/* Then send the character */
|
||||
|
||||
putreg32((uint32_t)ch, STM32_CONSOLE_BASE + STM32_USART_DR_OFFSET);
|
||||
|
||||
#if STM32_CONSOLE_RS485_DIR
|
||||
while ((getreg32(STM32_CONSOLE_BASE + STM32_USART_SR_OFFSET) & USART_SR_TC) == 0);
|
||||
stm32_gpiowrite(STM32_CONSOLE_RS485_DIR, !STM32_CONSOLE_RS485_DIR_POLARITY);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -328,7 +385,14 @@ void stm32_lowsetup(void)
|
||||
|
||||
#ifdef STM32_CONSOLE_TX
|
||||
stm32_configgpio(STM32_CONSOLE_TX);
|
||||
stm32_configgpio(STM32_CONSOLE_TX);
|
||||
#endif
|
||||
#ifdef STM32_CONSOLE_RX
|
||||
stm32_configgpio(STM32_CONSOLE_RX);
|
||||
#endif
|
||||
|
||||
#if STM32_CONSOLE_RS485_DIR
|
||||
stm32_configgpio(STM32_CONSOLE_RS485_DIR);
|
||||
stm32_gpiowrite(STM32_CONSOLE_RS485_DIR, !STM32_CONSOLE_RS485_DIR_POLARITY);
|
||||
#endif
|
||||
|
||||
/* Enable and configure the selected console device */
|
||||
@@ -382,7 +446,14 @@ void stm32_lowsetup(void)
|
||||
|
||||
#ifdef STM32_CONSOLE_TX
|
||||
stm32_configgpio(STM32_CONSOLE_TX);
|
||||
stm32_configgpio(STM32_CONSOLE_TX);
|
||||
#endif
|
||||
#ifdef STM32_CONSOLE_RX
|
||||
stm32_configgpio(STM32_CONSOLE_RX);
|
||||
#endif
|
||||
|
||||
#if STM32_CONSOLE_RS485_DIR
|
||||
stm32_configgpio(STM32_CONSOLE_RS485_DIR);
|
||||
stm32_gpiowrite(STM32_CONSOLE_RS485_DIR, !STM32_CONSOLE_RS485_DIR_POLARITY);
|
||||
#endif
|
||||
|
||||
/* Enable and configure the selected console device */
|
||||
|
||||
@@ -3651,10 +3651,14 @@ static int stm32_epout_configure(FAR struct stm32_ep_s *privep, uint8_t eptype,
|
||||
regval = stm32_getreg(regaddr);
|
||||
if ((regval & OTGFS_DOEPCTL_USBAEP) == 0)
|
||||
{
|
||||
regval &= ~(OTGFS_DOEPCTL_MPSIZ_MASK | OTGFS_DIEPCTL_EPTYP_MASK | OTGFS_DIEPCTL_TXFNUM_MASK);
|
||||
if (regval & OTGFS_DOEPCTL_NAKSTS)
|
||||
{
|
||||
regval |= OTGFS_DOEPCTL_CNAK;
|
||||
}
|
||||
|
||||
regval &= ~(OTGFS_DOEPCTL_MPSIZ_MASK | OTGFS_DOEPCTL_EPTYP_MASK);
|
||||
regval |= mpsiz;
|
||||
regval |= (eptype << OTGFS_DOEPCTL_EPTYP_SHIFT);
|
||||
regval |= (eptype << OTGFS_DIEPCTL_TXFNUM_SHIFT);
|
||||
regval |= (OTGFS_DOEPCTL_SD0PID | OTGFS_DOEPCTL_USBAEP);
|
||||
stm32_putreg(regval, regaddr);
|
||||
|
||||
@@ -3743,6 +3747,11 @@ static int stm32_epin_configure(FAR struct stm32_ep_s *privep, uint8_t eptype,
|
||||
regval = stm32_getreg(regaddr);
|
||||
if ((regval & OTGFS_DIEPCTL_USBAEP) == 0)
|
||||
{
|
||||
if (regval & OTGFS_DIEPCTL_NAKSTS)
|
||||
{
|
||||
regval |= OTGFS_DIEPCTL_CNAK;
|
||||
}
|
||||
|
||||
regval &= ~(OTGFS_DIEPCTL_MPSIZ_MASK | OTGFS_DIEPCTL_EPTYP_MASK | OTGFS_DIEPCTL_TXFNUM_MASK);
|
||||
regval |= mpsiz;
|
||||
regval |= (eptype << OTGFS_DIEPCTL_EPTYP_SHIFT);
|
||||
@@ -3900,7 +3909,7 @@ static void stm32_epout_disable(FAR struct stm32_ep_s *privep)
|
||||
* Name: stm32_epin_disable
|
||||
*
|
||||
* Description:
|
||||
* Diable an IN endpoint will no longer be used
|
||||
* Disable an IN endpoint when it will no longer be used
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
@@ -3912,6 +3921,17 @@ static void stm32_epin_disable(FAR struct stm32_ep_s *privep)
|
||||
|
||||
usbtrace(TRACE_EPDISABLE, privep->epphy);
|
||||
|
||||
/* After USB reset, the endpoint will already be deactivated by the
|
||||
* hardware. Trying to disable again will just hang in the wait.
|
||||
*/
|
||||
|
||||
regaddr = STM32_OTGFS_DIEPCTL(privep->epphy);
|
||||
regval = stm32_getreg(regaddr);
|
||||
if ((regval & OTGFS_DIEPCTL_USBAEP) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure that there is no pending IPEPNE interrupt (because we are
|
||||
* to poll this bit below).
|
||||
*/
|
||||
|
||||
@@ -607,6 +607,7 @@ static FAR struct stm32_lowerhalf_s *stm32_tim2lower(int tim)
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_TIM3_QE
|
||||
case 3:
|
||||
return &g_tim3lower;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_TIM4_QE
|
||||
case 4:
|
||||
|
||||
@@ -96,6 +96,19 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Currently RS-485 support cannot be enabled when RXDMA is in use due to lack
|
||||
* of testing - RS-485 support was developed on STM32F1x
|
||||
*/
|
||||
|
||||
# if (defined(CONFIG_USART1_RXDMA) && defined(CONFIG_USART1_RS485)) || \
|
||||
(defined(CONFIG_USART2_RXDMA) && defined(CONFIG_USART2_RS485)) || \
|
||||
(defined(CONFIG_USART3_RXDMA) && defined(CONFIG_USART3_RS485)) || \
|
||||
(defined(CONFIG_UART4_RXDMA) && defined(CONFIG_UART4_RS485)) || \
|
||||
(defined(CONFIG_UART5_RXDMA) && defined(CONFIG_UART5_RS485)) || \
|
||||
(defined(CONFIG_USART6_RXDMA) && defined(CONFIG_USART6_RS485))
|
||||
# error "RXDMA and RS-485 cannot be enabled at the same time for the same U[S]ART"
|
||||
# endif
|
||||
|
||||
/* For the F4, there are alternate DMA channels for USART1 and 6.
|
||||
* Logic in the board.h file make the DMA channel selection by defining
|
||||
* the following in the board.h file.
|
||||
@@ -219,6 +232,11 @@ struct up_dev_s
|
||||
uint32_t rxdmanext; /* Next byte in the DMA buffer to be read */
|
||||
char *const rxfifo; /* Receive DMA buffer */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RS485
|
||||
const uint32_t rs485_dir_gpio; /* U[S]ART RS-485 DIR GPIO pin configuration */
|
||||
const bool rs485_dir_polarity; /* U[S]ART RS-485 DIR pin state for TX enabled */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -415,6 +433,15 @@ static struct up_dev_s g_usart1priv =
|
||||
.rxfifo = g_usart1rxfifo,
|
||||
#endif
|
||||
.vector = up_interrupt_usart1,
|
||||
|
||||
#ifdef CONFIG_USART1_RS485
|
||||
.rs485_dir_gpio = GPIO_USART1_RS485_DIR,
|
||||
# if (CONFIG_USART1_RS485_DIR_POLARITY == 0)
|
||||
.rs485_dir_polarity = false,
|
||||
# else
|
||||
.rs485_dir_polarity = true,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -468,6 +495,15 @@ static struct up_dev_s g_usart2priv =
|
||||
.rxfifo = g_usart2rxfifo,
|
||||
#endif
|
||||
.vector = up_interrupt_usart2,
|
||||
|
||||
#ifdef CONFIG_USART2_RS485
|
||||
.rs485_dir_gpio = GPIO_USART2_RS485_DIR,
|
||||
# if (CONFIG_USART2_RS485_DIR_POLARITY == 0)
|
||||
.rs485_dir_polarity = false,
|
||||
# else
|
||||
.rs485_dir_polarity = true,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -521,6 +557,15 @@ static struct up_dev_s g_usart3priv =
|
||||
.rxfifo = g_usart3rxfifo,
|
||||
#endif
|
||||
.vector = up_interrupt_usart3,
|
||||
|
||||
#ifdef CONFIG_USART3_RS485
|
||||
.rs485_dir_gpio = GPIO_USART3_RS485_DIR,
|
||||
# if (CONFIG_USART3_RS485_DIR_POLARITY == 0)
|
||||
.rs485_dir_polarity = false,
|
||||
# else
|
||||
.rs485_dir_polarity = true,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -570,6 +615,15 @@ static struct up_dev_s g_uart4priv =
|
||||
.rxfifo = g_uart4rxfifo,
|
||||
#endif
|
||||
.vector = up_interrupt_uart4,
|
||||
|
||||
#ifdef CONFIG_UART4_RS485
|
||||
.rs485_dir_gpio = GPIO_UART4_RS485_DIR,
|
||||
# if (CONFIG_UART4_RS485_DIR_POLARITY == 0)
|
||||
.rs485_dir_polarity = false,
|
||||
# else
|
||||
.rs485_dir_polarity = true,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -619,6 +673,15 @@ static struct up_dev_s g_uart5priv =
|
||||
.rxfifo = g_uart5rxfifo,
|
||||
#endif
|
||||
.vector = up_interrupt_uart5,
|
||||
|
||||
#ifdef CONFIG_UART5_RS485
|
||||
.rs485_dir_gpio = GPIO_UART5_RS485_DIR,
|
||||
# if (CONFIG_UART5_RS485_DIR_POLARITY == 0)
|
||||
.rs485_dir_polarity = false,
|
||||
# else
|
||||
.rs485_dir_polarity = true,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -672,6 +735,15 @@ static struct up_dev_s g_usart6priv =
|
||||
.rxfifo = g_usart6rxfifo,
|
||||
#endif
|
||||
.vector = up_interrupt_usart6,
|
||||
|
||||
#ifdef CONFIG_USART6_RS485
|
||||
.rs485_dir_gpio = GPIO_USART6_RS485_DIR,
|
||||
# if (CONFIG_USART6_RS485_DIR_POLARITY == 0)
|
||||
.rs485_dir_polarity = false,
|
||||
# else
|
||||
.rs485_dir_polarity = true,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -744,8 +816,8 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
|
||||
/* And restore the interrupt state (see the interrupt enable/usage table above) */
|
||||
|
||||
cr = up_serialin(priv, STM32_USART_CR1_OFFSET);
|
||||
cr &= ~(USART_CR1_RXNEIE|USART_CR1_TXEIE|USART_CR1_PEIE);
|
||||
cr |= (ie & (USART_CR1_RXNEIE|USART_CR1_TXEIE|USART_CR1_PEIE));
|
||||
cr &= ~(USART_CR1_USED_INTS);
|
||||
cr |= (ie & (USART_CR1_USED_INTS));
|
||||
up_serialout(priv, STM32_USART_CR1_OFFSET, cr);
|
||||
|
||||
cr = up_serialin(priv, STM32_USART_CR3_OFFSET);
|
||||
@@ -772,7 +844,7 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
|
||||
* USART_CR1_IDLEIE 4 USART_SR_IDLE Idle Line Detected (not used)
|
||||
* USART_CR1_RXNEIE 5 USART_SR_RXNE Received Data Ready to be Read
|
||||
* " " USART_SR_ORE Overrun Error Detected
|
||||
* USART_CR1_TCIE 6 USART_SR_TC Transmission Complete (not used)
|
||||
* USART_CR1_TCIE 6 USART_SR_TC Transmission Complete (used only for RS-485)
|
||||
* USART_CR1_TXEIE 7 USART_SR_TXE Transmit Data Register Empty
|
||||
* USART_CR1_PEIE 8 USART_SR_PE Parity Error
|
||||
*
|
||||
@@ -791,7 +863,7 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
|
||||
* overlap. This logic would fail if we needed the break interrupt!
|
||||
*/
|
||||
|
||||
*ie = (cr1 & (USART_CR1_RXNEIE|USART_CR1_TXEIE|USART_CR1_PEIE)) | (cr3 & USART_CR3_EIE);
|
||||
*ie = (cr1 & (USART_CR1_USED_INTS)) | (cr3 & USART_CR3_EIE);
|
||||
}
|
||||
|
||||
/* Disable all interrupts */
|
||||
@@ -946,6 +1018,14 @@ static int up_setup(struct uart_dev_s *dev)
|
||||
stm32_configgpio(priv->rts_gpio);
|
||||
}
|
||||
|
||||
#if HAVE_RS485
|
||||
if (priv->rs485_dir_gpio != 0)
|
||||
{
|
||||
stm32_configgpio(priv->rs485_dir_gpio);
|
||||
stm32_gpiowrite(priv->rs485_dir_gpio, !priv->rs485_dir_polarity);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure CR2 */
|
||||
/* Clear CLKEN, CPOL, CPHA, LBCL, and interrupt enable bits */
|
||||
|
||||
@@ -1217,7 +1297,7 @@ static int up_interrupt_common(struct up_dev_s *priv)
|
||||
* USART_CR1_IDLEIE 4 USART_SR_IDLE Idle Line Detected (not used)
|
||||
* USART_CR1_RXNEIE 5 USART_SR_RXNE Received Data Ready to be Read
|
||||
* " " USART_SR_ORE Overrun Error Detected
|
||||
* USART_CR1_TCIE 6 USART_SR_TC Transmission Complete (not used)
|
||||
* USART_CR1_TCIE 6 USART_SR_TC Transmission Complete (used only for RS-485)
|
||||
* USART_CR1_TXEIE 7 USART_SR_TXE Transmit Data Register Empty
|
||||
* USART_CR1_PEIE 8 USART_SR_PE Parity Error
|
||||
*
|
||||
@@ -1232,6 +1312,21 @@ static int up_interrupt_common(struct up_dev_s *priv)
|
||||
* being used.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_RS485
|
||||
/* Transmission of whole buffer is over - TC is set, TXEIE is cleared.
|
||||
* Note - this should be first, to have the most recent TC bit value from
|
||||
* SR register - sending data affects TC, but without refresh we will not
|
||||
* know that...
|
||||
*/
|
||||
|
||||
if ((priv->sr & USART_SR_TC) != 0 && (priv->ie & USART_CR1_TCIE) != 0 &&
|
||||
(priv->ie & USART_CR1_TXEIE) == 0)
|
||||
{
|
||||
stm32_gpiowrite(priv->rs485_dir_gpio, !priv->rs485_dir_polarity);
|
||||
up_restoreusartint(priv, priv->ie & ~USART_CR1_TCIE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Handle incoming, receive bytes. */
|
||||
|
||||
if ((priv->sr & USART_SR_RXNE) != 0 && (priv->ie & USART_CR1_RXNEIE) != 0)
|
||||
@@ -1265,13 +1360,14 @@ static int up_interrupt_common(struct up_dev_s *priv)
|
||||
|
||||
if ((priv->sr & USART_SR_TXE) != 0 && (priv->ie & USART_CR1_TXEIE) != 0)
|
||||
{
|
||||
/* Transmit data regiser empty ... process outgoing bytes */
|
||||
/* Transmit data register empty ... process outgoing bytes */
|
||||
|
||||
uart_xmitchars(&priv->dev);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1611,6 +1707,10 @@ static bool up_dma_rxavailable(struct uart_dev_s *dev)
|
||||
static void up_send(struct uart_dev_s *dev, int ch)
|
||||
{
|
||||
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
|
||||
#ifdef HAVE_RS485
|
||||
if (priv->rs485_dir_gpio != 0)
|
||||
stm32_gpiowrite(priv->rs485_dir_gpio, priv->rs485_dir_polarity);
|
||||
#endif
|
||||
up_serialout(priv, STM32_USART_DR_OFFSET, (uint32_t)ch);
|
||||
}
|
||||
|
||||
@@ -1631,7 +1731,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
|
||||
*
|
||||
* Enable Bit Status Meaning Usage
|
||||
* ------------------ --- --------------- ---------------------------- ----------
|
||||
* USART_CR1_TCIE 6 USART_SR_TC Transmission Complete (not used)
|
||||
* USART_CR1_TCIE 6 USART_SR_TC Transmission Complete (used only for RS-485)
|
||||
* USART_CR1_TXEIE 7 USART_SR_TXE Transmit Data Register Empty
|
||||
* USART_CR3_CTSIE 10 USART_SR_CTS CTS flag (not used)
|
||||
*/
|
||||
@@ -1642,7 +1742,20 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
|
||||
/* Set to receive an interrupt when the TX data register is empty */
|
||||
|
||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
||||
up_restoreusartint(priv, priv->ie | USART_CR1_TXEIE);
|
||||
uint16_t ie = priv->ie | USART_CR1_TXEIE;
|
||||
|
||||
/* If RS-485 is supported on this U[S]ART, then also enable the
|
||||
* transmission complete interrupt.
|
||||
*/
|
||||
|
||||
# ifdef HAVE_RS485
|
||||
if (priv->rs485_dir_gpio != 0)
|
||||
{
|
||||
ie |= USART_CR1_TCIE;
|
||||
}
|
||||
# endif
|
||||
|
||||
up_restoreusartint(priv, ie);
|
||||
|
||||
/* Fake a TX interrupt here by just calling uart_xmitchars() with
|
||||
* interrupts disabled (note this may recurse).
|
||||
@@ -1657,6 +1770,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
|
||||
|
||||
up_restoreusartint(priv, priv->ie & ~USART_CR1_TXEIE);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,20 @@
|
||||
# undef SERIAL_HAVE_ONLY_DMA
|
||||
#endif
|
||||
|
||||
/* Is RS-485 used? */
|
||||
|
||||
#if defined(CONFIG_USART1_RS485) || defined(CONFIG_USART2_RS485) || \
|
||||
defined(CONFIG_USART3_RS485) || defined(CONFIG_UART4_RS485) || \
|
||||
defined(CONFIG_UART5_RS485) || defined(CONFIG_USART6_RS485)
|
||||
# define HAVE_RS485 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RS485
|
||||
# define USART_CR1_USED_INTS (USART_CR1_RXNEIE | USART_CR1_TXEIE | USART_CR1_PEIE | USART_CR1_TCIE)
|
||||
#else
|
||||
# define USART_CR1_USED_INTS (USART_CR1_RXNEIE | USART_CR1_TXEIE | USART_CR1_PEIE)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
|
||||
@@ -92,7 +92,11 @@ static inline void rcc_reset(void)
|
||||
putreg32(regval, STM32_RCC_CR);
|
||||
|
||||
regval = getreg32(STM32_RCC_CFGR); /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */
|
||||
regval &= ~(RCC_CFGR_PLLSRC|RCC_CFGR_PLLXTPRE|RCC_CFGR_PLLMUL_MASK|RCC_CFGR_USBPRE);
|
||||
regval &= ~(RCC_CFGR_PLLSRC|RCC_CFGR_PLLXTPRE|RCC_CFGR_PLLMUL_MASK
|
||||
#ifndef CONFIG_STM32_VALUELINE
|
||||
|RCC_CFGR_USBPRE
|
||||
#endif
|
||||
);
|
||||
putreg32(regval, STM32_RCC_CFGR);
|
||||
|
||||
putreg32(0, STM32_RCC_CIR); /* Disable all interrupts */
|
||||
@@ -224,6 +228,27 @@ static inline void rcc_enableapb1(void)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_TIM12
|
||||
/* Timer 12 clock enable */
|
||||
#ifdef CONFIG_STM32_FORCEPOWER
|
||||
regval |= RCC_APB1ENR_TIM12EN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_TIM13
|
||||
/* Timer 13 clock enable */
|
||||
#ifdef CONFIG_STM32_FORCEPOWER
|
||||
regval |= RCC_APB1ENR_TIM13EN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_TIM14
|
||||
/* Timer 14 clock enable */
|
||||
#ifdef CONFIG_STM32_FORCEPOWER
|
||||
regval |= RCC_APB1ENR_TIM14EN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_WWDG
|
||||
/* Window Watchdog clock enable */
|
||||
|
||||
@@ -315,6 +340,13 @@ static inline void rcc_enableapb1(void)
|
||||
|
||||
regval |= RCC_APB1ENR_DACEN;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_CEC
|
||||
/* CEC clock enable */
|
||||
|
||||
regval |= RCC_APB1ENR_CECEN;
|
||||
#endif
|
||||
|
||||
putreg32(regval, STM32_RCC_APB1ENR);
|
||||
}
|
||||
|
||||
@@ -404,6 +436,28 @@ static inline void rcc_enableapb2(void)
|
||||
|
||||
regval |= RCC_APB2ENR_ADC3EN;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_TIM15
|
||||
/* TIM15 Timer clock enable */
|
||||
#ifdef CONFIG_STM32_FORCEPOWER
|
||||
regval |= RCC_APB2ENR_TIM15EN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_TIM16
|
||||
/* TIM16 Timer clock enable */
|
||||
#ifdef CONFIG_STM32_FORCEPOWER
|
||||
regval |= RCC_APB2ENR_TIM16EN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_TIM17
|
||||
/* TIM17 Timer clock enable */
|
||||
#ifdef CONFIG_STM32_FORCEPOWER
|
||||
regval |= RCC_APB2ENR_TIM17EN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
putreg32(regval, STM32_RCC_APB2ENR);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,45 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config BINFMT_DISABLE
|
||||
bool "Disble BINFMT support"
|
||||
default n
|
||||
---help---
|
||||
By default, support for loadable binary formats is built. This logic
|
||||
may be suppressed be defining this setting.
|
||||
|
||||
if !BINFMT_DISABLE
|
||||
|
||||
config NXFLAT
|
||||
bool "Enable the NXFLAT Binary Format"
|
||||
default n
|
||||
---help---
|
||||
Enable support for the NXFLAT binary format. Default: n
|
||||
|
||||
if NXFLAT
|
||||
source binfmt/libnxflat/Kconfig
|
||||
endif
|
||||
|
||||
config ELF
|
||||
bool "Enable the ELF Binary Format"
|
||||
default n
|
||||
---help---
|
||||
Enable support for the ELF binary format. Default: n
|
||||
|
||||
if ELF
|
||||
source binfmt/libelf/Kconfig
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
config BINFMT_CONSTRUCTORS
|
||||
bool "C++ Static Constructor Support"
|
||||
default n
|
||||
depends on HAVE_CXX && ELF # FIX ME: Currently only supported for ELF
|
||||
---help---
|
||||
Build in support for C++ constructors in loaded modules.
|
||||
|
||||
config SYMTAB_ORDEREDBYNAME
|
||||
bool "Symbol Tables Ordered by Name"
|
||||
default n
|
||||
|
||||
+34
-39
@@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# nxflat/Makefile
|
||||
#
|
||||
# Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,67 +36,62 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
INCDIROPT = -w
|
||||
INCDIROPT = -w
|
||||
endif
|
||||
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/sched}
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(TOPDIR)$(DELIM)sched"}
|
||||
|
||||
ifeq ($(CONFIG_NXFLAT),y)
|
||||
include libnxflat/Make.defs
|
||||
LIBNXFLAT_CSRCS += nxflat.c
|
||||
endif
|
||||
# Basic BINFMT source files
|
||||
|
||||
BINFMT_ASRCS =
|
||||
BINFMT_CSRCS = binfmt_globals.c binfmt_register.c binfmt_unregister.c \
|
||||
binfmt_loadmodule.c binfmt_unloadmodule.c binfmt_execmodule.c \
|
||||
binfmt_exec.c binfmt_dumpmodule.c
|
||||
BINFMT_ASRCS =
|
||||
BINFMT_CSRCS = binfmt_globals.c binfmt_register.c binfmt_unregister.c \
|
||||
binfmt_loadmodule.c binfmt_unloadmodule.c binfmt_execmodule.c \
|
||||
binfmt_exec.c binfmt_dumpmodule.c
|
||||
|
||||
SYMTAB_ASRCS =
|
||||
SYMTAB_CSRCS = symtab_findbyname.c symtab_findbyvalue.c \
|
||||
symtab_findorderedbyname.c symtab_findorderedbyvalue.c
|
||||
# Symbol table source files
|
||||
|
||||
SUBDIRS = libnxflat
|
||||
BINFMT_CSRCS += symtab_findbyname.c symtab_findbyvalue.c \
|
||||
symtab_findorderedbyname.c symtab_findorderedbyvalue.c
|
||||
|
||||
ASRCS = $(BINFMT_ASRCS) $(SYMTAB_ASRCS) $(LIBNXFLAT_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
# Add configured binary modules
|
||||
|
||||
CSRCS = $(BINFMT_CSRCS) $(SYMTAB_CSRCS) $(LIBNXFLAT_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
VPATH =
|
||||
SUBDIRS =
|
||||
DEPPATH = --dep-path .
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
include libnxflat$(DELIM)Make.defs
|
||||
include libelf$(DELIM)Make.defs
|
||||
|
||||
BIN = libbinfmt$(LIBEXT)
|
||||
BINFMT_AOBJS = $(BINFMT_ASRCS:.S=$(OBJEXT))
|
||||
BINFMT_COBJS = $(BINFMT_CSRCS:.c=$(OBJEXT))
|
||||
|
||||
VPATH = libnxflat
|
||||
BINFMT_SRCS = $(BINFMT_ASRCS) $(BINFMT_CSRCS)
|
||||
BINFMT_OBJS = $(BINFMT_AOBJS) $(BINFMT_COBJS)
|
||||
|
||||
all: $(BIN)
|
||||
BIN = libbinfmt$(LIBEXT)
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
all: $(BIN)
|
||||
|
||||
$(BINFMT_AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(BINFMT_COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
$(BIN): $(BINFMT_OBJS)
|
||||
$(call ARCHIVE, $@, $(BINFMT_OBJS))
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) --dep-path . --dep-path libnxflat \
|
||||
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
.depend: Makefile $(BINFMT_SRCS)
|
||||
$(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(BINFMT_SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f $(BIN) *~ .*.swp
|
||||
$(call DELFILE, $(BIN))
|
||||
$(call CLEAN)
|
||||
@( for dir in $(SUBDIRS); do \
|
||||
rm -f $${dir}/*~ $${dir}/.*.swp; \
|
||||
done ; )
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* binfmt/binfmt_dumpmodule.c
|
||||
*
|
||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt_internal.h"
|
||||
|
||||
@@ -90,8 +90,12 @@ int dump_module(FAR const struct binary_s *bin)
|
||||
bdbg(" filename: %s\n", bin->filename);
|
||||
bdbg(" argv: %p\n", bin->argv);
|
||||
bdbg(" entrypt: %p\n", bin->entrypt);
|
||||
bdbg(" ispace: %p size=%d\n", bin->ispace, bin->isize);
|
||||
bdbg(" dspace: %p\n", bin->dspace);
|
||||
bdbg(" mapped: %p size=%d\n", bin->mapped, bin->mapsize);
|
||||
bdbg(" alloc: %p %p %p\n", bin->alloc[0], bin->alloc[1], bin->alloc[2]);
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
bdbg(" ctors: %p nctors=%d\n", bin->ctors, bin->nctors);
|
||||
bdbg(" dtors: %p ndtors=%d\n", bin->dtors, bin->ndtors);
|
||||
#endif
|
||||
bdbg(" stacksize: %d\n", bin->stacksize);
|
||||
}
|
||||
return OK;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt_internal.h"
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "os_internal.h"
|
||||
#include "binfmt_internal.h"
|
||||
@@ -70,6 +70,39 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_ctors
|
||||
*
|
||||
* Description:
|
||||
* Execute C++ static constructors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
static inline void exec_ctors(FAR const struct binary_s *binp)
|
||||
{
|
||||
binfmt_ctor_t *ctor = binp->ctors;
|
||||
int i;
|
||||
|
||||
/* Execute each constructor */
|
||||
|
||||
for (i = 0; i < binp->nctors; i++)
|
||||
{
|
||||
bvdbg("Calling ctor %d at %p\n", i, (FAR void *)ctor);
|
||||
|
||||
(*ctor)();
|
||||
ctor++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -87,7 +120,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
int exec_module(FAR const struct binary_s *binp, int priority)
|
||||
{
|
||||
FAR _TCB *tcb;
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
@@ -100,14 +133,14 @@ int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
/* Sanity checking */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!bin || !bin->ispace || !bin->entrypt || bin->stacksize <= 0)
|
||||
if (!binp || !binp->entrypt || binp->stacksize <= 0)
|
||||
{
|
||||
err = EINVAL;
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
bdbg("Executing %s\n", bin->filename);
|
||||
bdbg("Executing %s\n", binp->filename);
|
||||
|
||||
/* Allocate a TCB for the new task. */
|
||||
|
||||
@@ -121,7 +154,7 @@ int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
/* Allocate the stack for the new task */
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
stack = (FAR uint32_t*)malloc(bin->stacksize);
|
||||
stack = (FAR uint32_t*)malloc(binp->stacksize);
|
||||
if (!tcb)
|
||||
{
|
||||
err = ENOMEM;
|
||||
@@ -130,11 +163,13 @@ int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
|
||||
/* Initialize the task */
|
||||
|
||||
ret = task_init(tcb, bin->filename, priority, stack, bin->stacksize, bin->entrypt, bin->argv);
|
||||
ret = task_init(tcb, binp->filename, priority, stack,
|
||||
binp->stacksize, binp->entrypt, binp->argv);
|
||||
#else
|
||||
/* Initialize the task */
|
||||
|
||||
ret = task_init(tcb, bin->filename, priority, stack, bin->entrypt, bin->argv);
|
||||
ret = task_init(tcb, binp->filename, priority, stack,
|
||||
binp->entrypt, binp->argv);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -143,10 +178,12 @@ int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
goto errout_with_stack;
|
||||
}
|
||||
|
||||
/* Add the DSpace address as the PIC base address */
|
||||
/* Add the D-Space address as the PIC base address. By convention, this
|
||||
* must be the first allocated address space.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PIC
|
||||
tcb->dspace = bin->dspace;
|
||||
tcb->dspace = binp->alloc[0];
|
||||
|
||||
/* Re-initialize the task's initial state to account for the new PIC base */
|
||||
|
||||
@@ -157,6 +194,12 @@ int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
|
||||
pid = tcb->pid;
|
||||
|
||||
/* Execute all of the C++ static constructors */
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
exec_ctors(binp);
|
||||
#endif
|
||||
|
||||
/* Then activate the task at the provided priority */
|
||||
|
||||
ret = task_activate(tcb);
|
||||
@@ -166,6 +209,7 @@ int exec_module(FAR const struct binary_s *bin, int priority)
|
||||
bdbg("task_activate() failed: %d\n", err);
|
||||
goto errout_with_stack;
|
||||
}
|
||||
|
||||
return (int)pid;
|
||||
|
||||
errout_with_stack:
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#ifndef CONFIG_BINFMT_DISABLE
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt_internal.h"
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt_internal.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* binfmt/binfmt_loadmodule.c
|
||||
*
|
||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt_internal.h"
|
||||
|
||||
@@ -67,6 +67,39 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_dtors
|
||||
*
|
||||
* Description:
|
||||
* Execute C++ static constructors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
static inline void exec_dtors(FAR const struct binary_s *binp)
|
||||
{
|
||||
binfmt_dtor_t *dtor = binp->dtors;
|
||||
int i;
|
||||
|
||||
/* Execute each destructor */
|
||||
|
||||
for (i = 0; i < binp->ndtors; i++)
|
||||
{
|
||||
bvdbg("Calling dtor %d at %p\n", i, (FAR void *)dtor);
|
||||
|
||||
(*dtor)();
|
||||
dtor++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -76,7 +109,12 @@
|
||||
*
|
||||
* Description:
|
||||
* Unload a (non-executing) module from memory. If the module has
|
||||
* been started (via exec_module), calling this will be fatal.
|
||||
* been started (via exec_module) and has not exited, calling this will
|
||||
* be fatal.
|
||||
*
|
||||
* However, this function must be called after the module exist. How
|
||||
* this is done is up to your logic. Perhaps you register it to be
|
||||
* called by on_exit()?
|
||||
*
|
||||
* Returned Value:
|
||||
* This is a NuttX internal function so it follows the convention that
|
||||
@@ -85,22 +123,40 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int unload_module(FAR const struct binary_s *bin)
|
||||
int unload_module(FAR const struct binary_s *binp)
|
||||
{
|
||||
if (bin)
|
||||
int i;
|
||||
|
||||
if (binp)
|
||||
{
|
||||
if (bin->ispace)
|
||||
|
||||
/* Execute C++ desctructors */
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
exec_dtors(binp);
|
||||
#endif
|
||||
|
||||
/* Unmap mapped address spaces */
|
||||
|
||||
if (binp->mapped)
|
||||
{
|
||||
bvdbg("Unmapping ISpace: %p\n", bin->ispace);
|
||||
munmap(bin->ispace, bin->isize);
|
||||
bvdbg("Unmapping address space: %p\n", binp->mapped);
|
||||
|
||||
munmap(binp->mapped, binp->mapsize);
|
||||
}
|
||||
|
||||
if (bin->dspace)
|
||||
/* Free allocated address spaces */
|
||||
|
||||
for (i = 0; i < BINFMT_NALLOC; i++)
|
||||
{
|
||||
bvdbg("Freeing DSpace: %p\n", bin->dspace);
|
||||
free(bin->dspace);
|
||||
if (binp->alloc[i])
|
||||
{
|
||||
bvdbg("Freeing alloc[%d]: %p\n", i, binp->alloc[i]);
|
||||
free(binp->alloc[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt_internal.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
/****************************************************************************
|
||||
* binfmt/elf.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <elf32.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#ifdef CONFIG_ELF
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be
|
||||
* defined or CONFIG_ELF_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
|
||||
# undef CONFIG_ELF_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ELF_STACKSIZE
|
||||
# define CONFIG_ELF_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ELF_DUMPBUFFER
|
||||
# define elf_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
|
||||
#else
|
||||
# define elf_dumpbuffer(m,b,n)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) (a < b ? a : b)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int elf_loadbinary(FAR struct binary_s *binp);
|
||||
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT)
|
||||
static void elf_dumploadinfo(FAR struct elf_loadinfo_s *loadinfo);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct binfmt_s g_elfbinfmt =
|
||||
{
|
||||
NULL, /* next */
|
||||
elf_loadbinary, /* load */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_dumploadinfo
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT)
|
||||
static void elf_dumploadinfo(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
bdbg("LOAD_INFO:\n");
|
||||
bdbg(" elfalloc: %08lx\n", (long)loadinfo->elfalloc);
|
||||
bdbg(" elfsize: %ld\n", (long)loadinfo->elfsize);
|
||||
bdbg(" filelen: %ld\n", (long)loadinfo->filelen);
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
bdbg(" ctoralloc: %08lx\n", (long)loadinfo->ctoralloc);
|
||||
bdbg(" ctors: %08lx\n", (long)loadinfo->ctors);
|
||||
bdbg(" nctors: %d\n", loadinfo->nctors);
|
||||
bdbg(" dtoralloc: %08lx\n", (long)loadinfo->dtoralloc);
|
||||
bdbg(" dtors: %08lx\n", (long)loadinfo->dtors);
|
||||
bdbg(" ndtors: %d\n", loadinfo->ndtors);
|
||||
#endif
|
||||
bdbg(" filfd: %d\n", loadinfo->filfd);
|
||||
bdbg(" symtabidx: %d\n", loadinfo->symtabidx);
|
||||
bdbg(" strtabidx: %d\n", loadinfo->strtabidx);
|
||||
|
||||
bdbg("ELF Header:\n");
|
||||
bdbg(" e_ident: %02x %02x %02x %02x\n",
|
||||
loadinfo->ehdr.e_ident[0], loadinfo->ehdr.e_ident[1],
|
||||
loadinfo->ehdr.e_ident[2], loadinfo->ehdr.e_ident[3]);
|
||||
bdbg(" e_type: %04x\n", loadinfo->ehdr.e_type);
|
||||
bdbg(" e_machine: %04x\n", loadinfo->ehdr.e_machine);
|
||||
bdbg(" e_version: %08x\n", loadinfo->ehdr.e_version);
|
||||
bdbg(" e_entry: %08lx\n", (long)loadinfo->ehdr.e_entry);
|
||||
bdbg(" e_phoff: %d\n", loadinfo->ehdr.e_phoff);
|
||||
bdbg(" e_shoff: %d\n", loadinfo->ehdr.e_shoff);
|
||||
bdbg(" e_flags: %08x\n" , loadinfo->ehdr.e_flags);
|
||||
bdbg(" e_ehsize: %d\n", loadinfo->ehdr.e_ehsize);
|
||||
bdbg(" e_phentsize: %d\n", loadinfo->ehdr.e_phentsize);
|
||||
bdbg(" e_phnum: %d\n", loadinfo->ehdr.e_phnum);
|
||||
bdbg(" e_shentsize: %d\n", loadinfo->ehdr.e_shentsize);
|
||||
bdbg(" e_shnum: %d\n", loadinfo->ehdr.e_shnum);
|
||||
bdbg(" e_shstrndx: %d\n", loadinfo->ehdr.e_shstrndx);
|
||||
|
||||
if (loadinfo->shdr && loadinfo->ehdr.e_shnum > 0)
|
||||
{
|
||||
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
|
||||
bdbg("Sections %d:\n", i);
|
||||
bdbg(" sh_name: %08x\n", shdr->sh_name);
|
||||
bdbg(" sh_type: %08x\n", shdr->sh_type);
|
||||
bdbg(" sh_flags: %08x\n", shdr->sh_flags);
|
||||
bdbg(" sh_addr: %08x\n", shdr->sh_addr);
|
||||
bdbg(" sh_offset: %d\n", shdr->sh_offset);
|
||||
bdbg(" sh_size: %d\n", shdr->sh_size);
|
||||
bdbg(" sh_link: %d\n", shdr->sh_link);
|
||||
bdbg(" sh_info: %d\n", shdr->sh_info);
|
||||
bdbg(" sh_addralign: %d\n", shdr->sh_addralign);
|
||||
bdbg(" sh_entsize: %d\n", shdr->sh_entsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define elf_dumploadinfo(i)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loadbinary
|
||||
*
|
||||
* Description:
|
||||
* Verify that the file is an ELF binary and, if so, load the ELF
|
||||
* binary into memory
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int elf_loadbinary(struct binary_s *binp)
|
||||
{
|
||||
struct elf_loadinfo_s loadinfo; /* Contains globals for libelf */
|
||||
int ret;
|
||||
|
||||
bvdbg("Loading file: %s\n", binp->filename);
|
||||
|
||||
/* Initialize the xflat library to load the program binary. */
|
||||
|
||||
ret = elf_init(binp->filename, &loadinfo);
|
||||
elf_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
bdbg("Failed to initialize for load of ELF program: %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Load the program binary */
|
||||
|
||||
ret = elf_load(&loadinfo);
|
||||
elf_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
bdbg("Failed to load ELF program binary: %d\n", ret);
|
||||
goto errout_with_init;
|
||||
}
|
||||
|
||||
/* Bind the program to the exported symbol table */
|
||||
|
||||
ret = elf_bind(&loadinfo, binp->exports, binp->nexports);
|
||||
if (ret != 0)
|
||||
{
|
||||
bdbg("Failed to bind symbols program binary: %d\n", ret);
|
||||
goto errout_with_load;
|
||||
}
|
||||
|
||||
/* Return the load information */
|
||||
|
||||
binp->entrypt = (main_t)(loadinfo.elfalloc + loadinfo.ehdr.e_entry);
|
||||
binp->alloc[0] = (FAR void *)loadinfo.elfalloc;
|
||||
binp->stacksize = CONFIG_ELF_STACKSIZE;
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
/* Save information about constructors. NOTE: desctructors are not
|
||||
* yet supported.
|
||||
*/
|
||||
|
||||
binp->alloc[1] = loadinfo.ctoralloc;
|
||||
binp->ctors = loadinfo.ctors;
|
||||
binp->nctors = loadinfo.nctors;
|
||||
|
||||
binp->alloc[2] = loadinfo.dtoralloc;
|
||||
binp->dtors = loadinfo.dtors;
|
||||
binp->ndtors = loadinfo.ndtors;
|
||||
#endif
|
||||
|
||||
elf_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
|
||||
MIN(loadinfo.allocsize - loadinfo.ehdr.e_entry, 512));
|
||||
|
||||
elf_uninit(&loadinfo);
|
||||
return OK;
|
||||
|
||||
errout_with_load:
|
||||
elf_unload(&loadinfo);
|
||||
errout_with_init:
|
||||
elf_uninit(&loadinfo);
|
||||
errout:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_initialize
|
||||
*
|
||||
* Description:
|
||||
* ELF support is built unconditionally. However, it order to
|
||||
* use this binary format, this function must be called during system
|
||||
* format in order to register the ELF binary format.
|
||||
*
|
||||
* Returned Value:
|
||||
* This is a NuttX internal function so it follows the convention that
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Register ourselves as a binfmt loader */
|
||||
|
||||
bvdbg("Registering ELF\n");
|
||||
|
||||
ret = register_binfmt(&g_elfbinfmt);
|
||||
if (ret != 0)
|
||||
{
|
||||
bdbg("Failed to register binfmt: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Unregister the ELF binary loader
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void elf_uninitialize(void)
|
||||
{
|
||||
unregister_binfmt(&g_elfbinfmt);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ELF */
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config ELF_ALIGN_LOG2
|
||||
int "Log2 Section Alignment"
|
||||
default 2
|
||||
---help---
|
||||
Align all sections to this Log2 value: 0->1, 1->2, 2->4, etc.
|
||||
|
||||
config ELF_STACKSIZE
|
||||
int "ELF Stack Size"
|
||||
default 2048
|
||||
---help---
|
||||
This is the default stack size that will will be used when starting ELF binaries.
|
||||
|
||||
config ELF_BUFFERSIZE
|
||||
int "ELF I/O Buffer Size"
|
||||
default 128
|
||||
---help---
|
||||
This is an I/O buffer that is used to access the ELF file. Variable length items
|
||||
will need to be read (such as symbol names). This is really just this initial
|
||||
size of the buffer; it will be reallocated as necessary to hold large symbol
|
||||
names). Default: 128
|
||||
|
||||
config ELF_BUFFERINCR
|
||||
int "ELF I/O Buffer Realloc Increment"
|
||||
default 32
|
||||
---help---
|
||||
This is an I/O buffer that is used to access the ELF file. Variable length items
|
||||
will need to be read (such as symbol names). This value specifies the size
|
||||
increment to use each time the buffer is reallocated. Default: 32
|
||||
|
||||
config ELF_DUMPBUFFER
|
||||
bool "Dump ELF buffers"
|
||||
default n
|
||||
depends on DEBUG && DEBUG_VERBOSE
|
||||
---help---
|
||||
Dump various ELF buffers for debug purposes
|
||||
@@ -0,0 +1,58 @@
|
||||
############################################################################
|
||||
# binfmt/libelf/Make.defs
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_ELF),y)
|
||||
|
||||
# ELF application interfaces
|
||||
|
||||
BINFMT_CSRCS += elf.c
|
||||
|
||||
# ELF library
|
||||
|
||||
BINFMT_CSRCS += libelf_bind.c libelf_init.c libelf_iobuffer.c libelf_load.c \
|
||||
libelf_read.c libelf_sections.c libelf_symbols.c libelf_uninit.c \
|
||||
libelf_unload.c libelf_verify.c
|
||||
|
||||
ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y)
|
||||
BINFMT_CSRCS += libelf_ctors.c libelf_dtors.c
|
||||
endif
|
||||
|
||||
# Hook the libelf subdirectory into the build
|
||||
|
||||
VPATH += libelf
|
||||
SUBDIRS += libelf
|
||||
DEPPATH += --dep-path libelf
|
||||
|
||||
endif
|
||||
@@ -0,0 +1,129 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/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 = . ;
|
||||
}
|
||||
|
||||
.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) }
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf.h
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BINFMT_LIBELF_LIBELF_H
|
||||
#define __BINFMT_LIBELF_LIBELF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <elf32.h>
|
||||
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_verifyheader
|
||||
*
|
||||
* Description:
|
||||
* Given the header from a possible ELF executable, verify that it is
|
||||
* an ELF executable.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_verifyheader(FAR const Elf32_Ehdr *header);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_read
|
||||
*
|
||||
* Description:
|
||||
* Read 'readsize' bytes from the object file at 'offset'
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_read(FAR struct elf_loadinfo_s *loadinfo, FAR uint8_t *buffer,
|
||||
size_t readsize, off_t offset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loadshdrs
|
||||
*
|
||||
* Description:
|
||||
* Loads section headers into memory.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_findsection
|
||||
*
|
||||
* Description:
|
||||
* A section by its name.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
* sectname - Name of the section to find
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the index to the section is returned; A negated errno value
|
||||
* is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_findsection(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const char *sectname);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_findsymtab
|
||||
*
|
||||
* Description:
|
||||
* Find the symbol table section.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_findsymtab(FAR struct elf_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_readsym
|
||||
*
|
||||
* Description:
|
||||
* Read the ELFT symbol structure at the specfied index into memory.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
* index - Symbol table index
|
||||
* sym - Location to return the table entry
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
|
||||
FAR Elf32_Sym *sym);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_symvalue
|
||||
*
|
||||
* Description:
|
||||
* Get the value of a symbol. The updated value of the symbol is returned
|
||||
* in the st_value field of the symbol table entry.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
* sym - Symbol table entry (value might be undefined)
|
||||
* exports - The symbol table to use for resolving undefined symbols.
|
||||
* nexports - Number of symbols in the symbol table.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
|
||||
FAR const struct symtab_s *exports, int nexports);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_freebuffers
|
||||
*
|
||||
* Description:
|
||||
* Release all working buffers.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_freebuffers(FAR struct elf_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_allocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Perform the initial allocation of the I/O buffer, if it has not already
|
||||
* been allocated.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_allocbuffer(FAR struct elf_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_reallocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Increase the size of I/O buffer by the specified buffer increment.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_reallocbuffer(FAR struct elf_loadinfo_s *loadinfo, size_t increment);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_findctors
|
||||
*
|
||||
* Description:
|
||||
* Find C++ static constructors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loaddtors
|
||||
*
|
||||
* Description:
|
||||
* Load pointers to static destructors into an in-memory array.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo);
|
||||
#endif
|
||||
|
||||
#endif /* __BINFMT_LIBELF_LIBELF_H */
|
||||
@@ -0,0 +1,306 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_bind.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <elf32.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be
|
||||
* defined or CONFIG_ELF_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
|
||||
# undef CONFIG_ELF_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ELF_BUFFERSIZE
|
||||
# define CONFIG_ELF_BUFFERSIZE 128
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ELF_DUMPBUFFER
|
||||
# define elf_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
|
||||
#else
|
||||
# define elf_dumpbuffer(m,b,n)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_readsym
|
||||
*
|
||||
* Description:
|
||||
* Read the ELFT symbol structure at the specfied index into memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int elf_readrel(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const Elf32_Shdr *relsec,
|
||||
int index, FAR Elf32_Rel *rel)
|
||||
{
|
||||
off_t offset;
|
||||
|
||||
/* Verify that the symbol table index lies within symbol table */
|
||||
|
||||
if (index < 0 || index > (relsec->sh_size / sizeof(Elf32_Rel)))
|
||||
{
|
||||
bdbg("Bad relocation symbol index: %d\n", index);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get the file offset to the symbol table entry */
|
||||
|
||||
offset = relsec->sh_offset + sizeof(Elf32_Rel) * index;
|
||||
|
||||
/* And, finally, read the symbol table entry into memory */
|
||||
|
||||
return elf_read(loadinfo, (FAR uint8_t*)rel, sizeof(Elf32_Rel), offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_relocate and elf_relocateadd
|
||||
*
|
||||
* Description:
|
||||
* Perform all relocations associated with a section.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int elf_relocate(FAR struct elf_loadinfo_s *loadinfo, int relidx,
|
||||
FAR const struct symtab_s *exports, int nexports)
|
||||
|
||||
{
|
||||
FAR Elf32_Shdr *relsec = &loadinfo->shdr[relidx];
|
||||
FAR Elf32_Shdr *dstsec = &loadinfo->shdr[relsec->sh_info];
|
||||
Elf32_Rel rel;
|
||||
Elf32_Sym sym;
|
||||
uintptr_t addr;
|
||||
int symidx;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Examine each relocation in the section. 'relsec' is the section
|
||||
* containing the relations. 'dstsec' is the section containing the data
|
||||
* to be relocated.
|
||||
*/
|
||||
|
||||
for (i = 0; i < relsec->sh_size / sizeof(Elf32_Rel); i++)
|
||||
{
|
||||
/* Read the relocation entry into memory */
|
||||
|
||||
ret = elf_readrel(loadinfo, relsec, i, &rel);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Section %d reloc %d: Failed to read relocation entry: %d\n",
|
||||
relidx, i, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Get the symbol table index for the relocation. This is contained
|
||||
* in a bit-field within the r_info element.
|
||||
*/
|
||||
|
||||
symidx = ELF32_R_SYM(rel.r_info);
|
||||
|
||||
/* Read the symbol table entry into memory */
|
||||
|
||||
ret = elf_readsym(loadinfo, symidx, &sym);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Section %d reloc %d: Failed to read symbol[%d]: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Get the value of the symbol (in sym.st_value) */
|
||||
|
||||
ret = elf_symvalue(loadinfo, &sym, exports, nexports);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Calculate the relocation address */
|
||||
|
||||
if (rel.r_offset < 0 || rel.r_offset > dstsec->sh_size - sizeof(uint32_t))
|
||||
{
|
||||
bdbg("Section %d reloc %d: Relocation address out of range, offset %d size %d\n",
|
||||
relidx, i, rel.r_offset, dstsec->sh_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
addr = dstsec->sh_addr + rel.r_offset;
|
||||
|
||||
/* Now perform the architecture-specific relocation */
|
||||
|
||||
ret = arch_relocate(&rel, &sym, addr);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Section %d reloc %d: Relocation failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int elf_relocateadd(FAR struct elf_loadinfo_s *loadinfo, int relidx,
|
||||
FAR const struct symtab_s *exports, int nexports)
|
||||
{
|
||||
bdbg("Not implemented\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_bind
|
||||
*
|
||||
* Description:
|
||||
* Bind the imported symbol names in the loaded module described by
|
||||
* 'loadinfo' using the exported symbol values provided by 'symtab'.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_bind(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const struct symtab_s *exports, int nexports)
|
||||
{
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Find the symbol and string tables */
|
||||
|
||||
ret = elf_findsymtab(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Allocate an I/O buffer. This buffer is used by elf_symname() to
|
||||
* accumulate the variable length symbol name.
|
||||
*/
|
||||
|
||||
ret = elf_allocbuffer(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_allocbuffer failed: %d\n", ret);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Process relocations in every allocated section */
|
||||
|
||||
for (i = 1; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
/* Get the index to the relocation section */
|
||||
|
||||
int infosec = loadinfo->shdr[i].sh_info;
|
||||
if (infosec >= loadinfo->ehdr.e_shnum)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Make sure that the section is allocated. We can't relocated
|
||||
* sections that were not loaded into memory.
|
||||
*/
|
||||
|
||||
if ((loadinfo->shdr[infosec].sh_flags & SHF_ALLOC) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Process the relocations by type */
|
||||
|
||||
if (loadinfo->shdr[i].sh_type == SHT_REL)
|
||||
{
|
||||
ret = elf_relocate(loadinfo, i, exports, nexports);
|
||||
}
|
||||
else if (loadinfo->shdr[i].sh_type == SHT_RELA)
|
||||
{
|
||||
ret = elf_relocateadd(loadinfo, i, exports, nexports);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Flush the instruction cache before starting the newly loaded module */
|
||||
|
||||
#ifdef CONFIG_ELF_ICACHE
|
||||
arch_flushicache((FAR void*)loadinfo->elfalloc, loadinfo->elfsize);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_ctors.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loadctors
|
||||
*
|
||||
* Description:
|
||||
* Load pointers to static constructors into an in-memory array.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
FAR Elf32_Shdr *shdr;
|
||||
size_t ctorsize;
|
||||
int ctoridx;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
DEBUGASSERT(loadinfo->ctors == NULL);
|
||||
|
||||
/* Allocate an I/O buffer if necessary. This buffer is used by
|
||||
* elf_sectname() to accumulate the variable length symbol name.
|
||||
*/
|
||||
|
||||
ret = elf_allocbuffer(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_allocbuffer failed: %d\n", ret);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Find the index to the section named ".ctors." NOTE: On old ABI system,
|
||||
* .ctors is the name of the section containing the list of constructors;
|
||||
* On newer systems, the similar section is called .init_array. It is
|
||||
* expected that the linker script will force the section name to be ".ctors"
|
||||
* in either case.
|
||||
*/
|
||||
|
||||
ctoridx = elf_findsection(loadinfo, ".ctors");
|
||||
if (ctoridx < 0)
|
||||
{
|
||||
/* This may not be a failure. -ENOENT indicates that the file has no
|
||||
* static constructor section.
|
||||
*/
|
||||
|
||||
bvdbg("elf_findsection .ctors section failed: %d\n", ctoridx);
|
||||
return ret == -ENOENT ? OK : ret;
|
||||
}
|
||||
|
||||
/* Now we can get a pointer to the .ctor section in the section header
|
||||
* table.
|
||||
*/
|
||||
|
||||
shdr = &loadinfo->shdr[ctoridx];
|
||||
|
||||
/* Get the size of the .ctor section and the number of constructors that
|
||||
* will need to be called.
|
||||
*/
|
||||
|
||||
ctorsize = shdr->sh_size;
|
||||
loadinfo->nctors = ctorsize / sizeof(binfmt_ctor_t);
|
||||
|
||||
bvdbg("ctoridx=%d ctorsize=%d sizeof(binfmt_ctor_t)=%d nctors=%d\n",
|
||||
ctoridx, ctorsize, sizeof(binfmt_ctor_t), loadinfo->nctors);
|
||||
|
||||
/* Check if there are any constructors. It is not an error if there
|
||||
* are none.
|
||||
*/
|
||||
|
||||
if (loadinfo->nctors > 0)
|
||||
{
|
||||
/* Check an assumption that we made above */
|
||||
|
||||
DEBUGASSERT(shdr->sh_size == loadinfo->nctors * sizeof(binfmt_ctor_t));
|
||||
|
||||
/* In the old ABI, the .ctors section is not allocated. In that case,
|
||||
* we need to allocate memory to hold the .ctors and then copy the
|
||||
* from the file into the allocated memory.
|
||||
*
|
||||
* SHF_ALLOC indicates that the section requires memory during
|
||||
* execution.
|
||||
*/
|
||||
|
||||
if ((shdr->sh_flags & SHF_ALLOC) == 0)
|
||||
{
|
||||
/* Allocate memory to hold a copy of the .ctor section */
|
||||
|
||||
loadinfo->ctoralloc = (binfmt_ctor_t*)kmalloc(ctorsize);
|
||||
if (!loadinfo->ctoralloc)
|
||||
{
|
||||
bdbg("Failed to allocate memory for .ctors\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
loadinfo->ctors = (binfmt_ctor_t *)loadinfo->ctoralloc;
|
||||
|
||||
/* Read the section header table into memory */
|
||||
|
||||
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->ctors, ctorsize,
|
||||
shdr->sh_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Failed to allocate .ctors: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Fix up all of the .ctor addresses. Since the addresses
|
||||
* do not lie in allocated memory, there will be no relocation
|
||||
* section for them.
|
||||
*/
|
||||
|
||||
for (i = 0; i < loadinfo->nctors; i++)
|
||||
{
|
||||
FAR uintptr_t *ptr = (uintptr_t *)((FAR void *)(&loadinfo->ctors)[i]);
|
||||
|
||||
bvdbg("ctor %d: %08lx + %08lx = %08lx\n",
|
||||
i, *ptr, loadinfo->elfalloc, *ptr + loadinfo->elfalloc);
|
||||
|
||||
*ptr += loadinfo->elfalloc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Save the address of the .ctors (actually, .init_array) where it was
|
||||
* loaded into memory. Since the .ctors lie in allocated memory, they
|
||||
* will be relocated via the normal mechanism.
|
||||
*/
|
||||
|
||||
loadinfo->ctors = (binfmt_ctor_t*)shdr->sh_addr;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BINFMT_CONSTRUCTORS */
|
||||
@@ -0,0 +1,215 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_dtors.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loaddtors
|
||||
*
|
||||
* Description:
|
||||
* Load pointers to static destructors into an in-memory array.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
FAR Elf32_Shdr *shdr;
|
||||
size_t dtorsize;
|
||||
int dtoridx;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
DEBUGASSERT(loadinfo->dtors == NULL);
|
||||
|
||||
/* Allocate an I/O buffer if necessary. This buffer is used by
|
||||
* elf_sectname() to accumulate the variable length symbol name.
|
||||
*/
|
||||
|
||||
ret = elf_allocbuffer(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_allocbuffer failed: %d\n", ret);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Find the index to the section named ".dtors." NOTE: On old ABI system,
|
||||
* .dtors is the name of the section containing the list of destructors;
|
||||
* On newer systems, the similar section is called .fini_array. It is
|
||||
* expected that the linker script will force the section name to be ".dtors"
|
||||
* in either case.
|
||||
*/
|
||||
|
||||
dtoridx = elf_findsection(loadinfo, ".dtors");
|
||||
if (dtoridx < 0)
|
||||
{
|
||||
/* This may not be a failure. -ENOENT indicates that the file has no
|
||||
* static destructor section.
|
||||
*/
|
||||
|
||||
bvdbg("elf_findsection .dtors section failed: %d\n", dtoridx);
|
||||
return ret == -ENOENT ? OK : ret;
|
||||
}
|
||||
|
||||
/* Now we can get a pointer to the .dtor section in the section header
|
||||
* table.
|
||||
*/
|
||||
|
||||
shdr = &loadinfo->shdr[dtoridx];
|
||||
|
||||
/* Get the size of the .dtor section and the number of destructors that
|
||||
* will need to be called.
|
||||
*/
|
||||
|
||||
dtorsize = shdr->sh_size;
|
||||
loadinfo->ndtors = dtorsize / sizeof(binfmt_dtor_t);
|
||||
|
||||
bvdbg("dtoridx=%d dtorsize=%d sizeof(binfmt_dtor_t)=%d ndtors=%d\n",
|
||||
dtoridx, dtorsize, sizeof(binfmt_dtor_t), loadinfo->ndtors);
|
||||
|
||||
/* Check if there are any destructors. It is not an error if there
|
||||
* are none.
|
||||
*/
|
||||
|
||||
if (loadinfo->ndtors > 0)
|
||||
{
|
||||
/* Check an assumption that we made above */
|
||||
|
||||
DEBUGASSERT(shdr->sh_size == loadinfo->ndtors * sizeof(binfmt_dtor_t));
|
||||
|
||||
/* In the old ABI, the .dtors section is not allocated. In that case,
|
||||
* we need to allocate memory to hold the .dtors and then copy the
|
||||
* from the file into the allocated memory.
|
||||
*
|
||||
* SHF_ALLOC indicates that the section requires memory during
|
||||
* execution.
|
||||
*/
|
||||
|
||||
if ((shdr->sh_flags & SHF_ALLOC) == 0)
|
||||
{
|
||||
/* Allocate memory to hold a copy of the .dtor section */
|
||||
|
||||
loadinfo->ctoralloc = (binfmt_dtor_t*)kmalloc(dtorsize);
|
||||
if (!loadinfo->ctoralloc)
|
||||
{
|
||||
bdbg("Failed to allocate memory for .dtors\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
loadinfo->dtors = (binfmt_dtor_t *)loadinfo->ctoralloc;
|
||||
|
||||
/* Read the section header table into memory */
|
||||
|
||||
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->dtors, dtorsize,
|
||||
shdr->sh_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Failed to allocate .dtors: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Fix up all of the .dtor addresses. Since the addresses
|
||||
* do not lie in allocated memory, there will be no relocation
|
||||
* section for them.
|
||||
*/
|
||||
|
||||
for (i = 0; i < loadinfo->ndtors; i++)
|
||||
{
|
||||
FAR uintptr_t *ptr = (uintptr_t *)((FAR void *)(&loadinfo->dtors)[i]);
|
||||
|
||||
bvdbg("dtor %d: %08lx + %08lx = %08lx\n",
|
||||
i, *ptr, loadinfo->elfalloc, *ptr + loadinfo->elfalloc);
|
||||
|
||||
*ptr += loadinfo->elfalloc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Save the address of the .dtors (actually, .init_array) where it was
|
||||
* loaded into memory. Since the .dtors lie in allocated memory, they
|
||||
* will be relocated via the normal mechanism.
|
||||
*/
|
||||
|
||||
loadinfo->dtors = (binfmt_dtor_t*)shdr->sh_addr;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BINFMT_CONSTRUCTORS */
|
||||
@@ -0,0 +1,202 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_init.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <elf32.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be
|
||||
* defined or CONFIG_ELF_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
|
||||
# undef CONFIG_ELF_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ELF_DUMPBUFFER
|
||||
# define elf_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
|
||||
#else
|
||||
# define elf_dumpbuffer(m,b,n)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_filelen
|
||||
*
|
||||
* Description:
|
||||
* Get the size of the ELF file
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int elf_filelen(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const char *filename)
|
||||
{
|
||||
struct stat buf;
|
||||
int ret;
|
||||
|
||||
/* Get the file stats */
|
||||
|
||||
ret = stat(filename, &buf);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errval = errno;
|
||||
bdbg("Failed to fstat file: %d\n", errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
/* Verify that it is a regular file */
|
||||
|
||||
if (!S_ISREG(buf.st_mode))
|
||||
{
|
||||
bdbg("Not a regular file. mode: %d\n", buf.st_mode);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* TODO: Verify that the file is readable. Not really important because
|
||||
* we will detect this when we try to open the file read-only.
|
||||
*/
|
||||
|
||||
/* Return the size of the file in the loadinfo structure */
|
||||
|
||||
loadinfo->filelen = buf.st_size;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_init
|
||||
*
|
||||
* Description:
|
||||
* This function is called to configure the library to process an ELF
|
||||
* program binary.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
bvdbg("filename: %s loadinfo: %p\n", filename, loadinfo);
|
||||
|
||||
/* Clear the load info structure */
|
||||
|
||||
memset(loadinfo, 0, sizeof(struct elf_loadinfo_s));
|
||||
|
||||
/* Get the length of the file. */
|
||||
|
||||
ret = elf_filelen(loadinfo, filename);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_filelen failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Open the binary file for reading (only) */
|
||||
|
||||
loadinfo->filfd = open(filename, O_RDONLY);
|
||||
if (loadinfo->filfd < 0)
|
||||
{
|
||||
int errval = errno;
|
||||
bdbg("Failed to open ELF binary %s: %d\n", filename, errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
/* Read the ELF ehdr from offset 0 */
|
||||
|
||||
ret = elf_read(loadinfo, (FAR uint8_t*)&loadinfo->ehdr, sizeof(Elf32_Ehdr), 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Failed to read ELF header: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
elf_dumpbuffer("ELF header", (FAR const uint8_t*)&loadinfo->ehdr, sizeof(Elf32_Ehdr));
|
||||
|
||||
/* Verify the ELF header */
|
||||
|
||||
ret = elf_verifyheader(&loadinfo->ehdr);
|
||||
if (ret <0)
|
||||
{
|
||||
/* This may not be an error because we will be called to attempt loading
|
||||
* EVERY binary. If elf_verifyheader() does not recognize the ELF header,
|
||||
* it will -ENOEXEC whcih simply informs the system that the file is not an
|
||||
* ELF file. elf_verifyheader() will return other errors if the ELF header
|
||||
* is not correctly formed.
|
||||
*/
|
||||
|
||||
bdbg("Bad ELF header: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/elf_iobuffer.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_allocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Perform the initial allocation of the I/O buffer, if it has not already
|
||||
* been allocated.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_allocbuffer(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Has a buffer been allocated> */
|
||||
|
||||
if (!loadinfo->iobuffer)
|
||||
{
|
||||
/* No.. allocate one now */
|
||||
|
||||
loadinfo->iobuffer = (FAR uint8_t *)kmalloc(CONFIG_ELF_BUFFERSIZE);
|
||||
if (!loadinfo->iobuffer)
|
||||
{
|
||||
bdbg("Failed to allocate an I/O buffer\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
loadinfo->buflen = CONFIG_ELF_BUFFERSIZE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_reallocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Increase the size of I/O buffer by the specified buffer increment.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_reallocbuffer(FAR struct elf_loadinfo_s *loadinfo, size_t increment)
|
||||
{
|
||||
FAR void *buffer;
|
||||
size_t newsize;
|
||||
|
||||
/* Get the new size of the allocation */
|
||||
|
||||
newsize = loadinfo->buflen + increment;
|
||||
|
||||
/* And perform the reallocation */
|
||||
|
||||
buffer = krealloc((FAR void *)loadinfo->iobuffer, newsize);
|
||||
if (!buffer)
|
||||
{
|
||||
bdbg("Failed to reallocate the I/O buffer\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Save the new buffer info */
|
||||
|
||||
loadinfo->iobuffer = buffer;
|
||||
loadinfo->buflen = newsize;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_load.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <elf32.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ELF_ALIGN_MASK ((1 << CONFIG_ELF_ALIGN_LOG2) - 1)
|
||||
#define ELF_ALIGNUP(a) (((unsigned long)(a) + ELF_ALIGN_MASK) & ~ELF_ALIGN_MASK)
|
||||
#define ELF_ALIGNDOWN(a) ((unsigned long)(a) & ~ELF_ALIGN_MASK)
|
||||
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_elfsize
|
||||
*
|
||||
* Description:
|
||||
* Calculate total memory allocation for the ELF file.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void elf_elfsize(struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
size_t elfsize;
|
||||
int i;
|
||||
|
||||
/* Accumulate the size each section into memory that is marked SHF_ALLOC */
|
||||
|
||||
elfsize = 0;
|
||||
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
|
||||
|
||||
/* SHF_ALLOC indicates that the section requires memory during
|
||||
* execution.
|
||||
*/
|
||||
|
||||
if ((shdr->sh_flags & SHF_ALLOC) != 0)
|
||||
{
|
||||
elfsize += ELF_ALIGNUP(shdr->sh_size);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save the allocation size */
|
||||
|
||||
loadinfo->elfsize = elfsize;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loadfile
|
||||
*
|
||||
* Description:
|
||||
* Allocate memory for the file and read the section data into the
|
||||
* allocated memory. Section addresses in the shdr[] are updated to point
|
||||
* to the corresponding position in the allocated memory.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
FAR uint8_t *dest;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Allocate (and zero) memory for the ELF file. */
|
||||
|
||||
loadinfo->elfalloc = (uintptr_t)kzalloc(loadinfo->elfsize);
|
||||
if (!loadinfo->elfalloc)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Read each section into memory that is marked SHF_ALLOC + SHT_NOBITS */
|
||||
|
||||
bvdbg("Loaded sections:\n");
|
||||
dest = (FAR uint8_t*)loadinfo->elfalloc;
|
||||
|
||||
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
|
||||
|
||||
/* SHF_ALLOC indicates that the section requires memory during
|
||||
* execution */
|
||||
|
||||
if ((shdr->sh_flags & SHF_ALLOC) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* SHT_NOBITS indicates that there is no data in the file for the
|
||||
* section.
|
||||
*/
|
||||
|
||||
if (shdr->sh_type != SHT_NOBITS)
|
||||
{
|
||||
/* Read the section data from sh_offset to dest */
|
||||
|
||||
ret = elf_read(loadinfo, dest, shdr->sh_size, shdr->sh_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Failed to read section %d: %d\n", i, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update sh_addr to point to copy in memory */
|
||||
|
||||
bvdbg("%d. %08x->%08x\n", i, (long)shdr->sh_addr, (long)dest);
|
||||
shdr->sh_addr = (uintptr_t)dest;
|
||||
|
||||
/* Setup the memory pointer for the next time through the loop */
|
||||
|
||||
dest += ELF_ALIGNUP(shdr->sh_size);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_load
|
||||
*
|
||||
* Description:
|
||||
* Loads the binary into memory, allocating memory, performing relocations
|
||||
* and inializing the data and bss segments.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_load(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
bvdbg("loadinfo: %p\n", loadinfo);
|
||||
DEBUGASSERT(loadinfo && loadinfo->filfd >= 0);
|
||||
|
||||
/* Load section headers into memory */
|
||||
|
||||
ret = elf_loadshdrs(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_loadshdrs failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
/* Determine total size to allocate */
|
||||
|
||||
elf_elfsize(loadinfo);
|
||||
|
||||
/* Allocate memory and load sections into memory */
|
||||
|
||||
ret = elf_loadfile(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_loadfile failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
/* Load static constructors and destructors. */
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
ret = elf_loadctors(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_loadctors failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
ret = elf_loaddtors(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_loaddtors failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
||||
/* Error exits */
|
||||
|
||||
errout_with_buffers:
|
||||
elf_unload(loadinfo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_read.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <elf32.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#undef ELF_DUMP_READDATA /* Define to dump all file data read */
|
||||
#define DUMPER lib_rawprintf /* If ELF_DUMP_READDATA is defined, this
|
||||
* is the API used to dump data */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_dumpreaddata
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(ELF_DUMP_READDATA)
|
||||
static inline void elf_dumpreaddata(char *buffer, int buflen)
|
||||
{
|
||||
uint32_t *buf32 = (uint32_t*)buffer;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < buflen; i += 32)
|
||||
{
|
||||
DUMPER("%04x:", i);
|
||||
for (j = 0; j < 32; j += sizeof(uint32_t))
|
||||
{
|
||||
DUMPER(" %08x", *buf32++);
|
||||
}
|
||||
DUMPER("\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define elf_dumpreaddata(b,n)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_read
|
||||
*
|
||||
* Description:
|
||||
* Read 'readsize' bytes from the object file at 'offset'
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_read(FAR struct elf_loadinfo_s *loadinfo, FAR uint8_t *buffer,
|
||||
size_t readsize, off_t offset)
|
||||
{
|
||||
ssize_t nbytes; /* Number of bytes read */
|
||||
off_t rpos; /* Position returned by lseek */
|
||||
|
||||
bvdbg("Read %ld bytes from offset %ld\n", (long)readsize, (long)offset);
|
||||
|
||||
/* Loop until all of the requested data has been read. */
|
||||
|
||||
while (readsize > 0)
|
||||
{
|
||||
/* Seek to the next read position */
|
||||
|
||||
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
|
||||
if (rpos != offset)
|
||||
{
|
||||
int errval = errno;
|
||||
bdbg("Failed to seek to position %ld: %d\n", (long)offset, errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
/* Read the file data at offset into the user buffer */
|
||||
|
||||
nbytes = read(loadinfo->filfd, buffer, readsize);
|
||||
if (nbytes < 0)
|
||||
{
|
||||
int errval = errno;
|
||||
|
||||
/* EINTR just means that we received a signal */
|
||||
|
||||
if (errval != EINTR)
|
||||
{
|
||||
bdbg("Read of .data failed: %d\n", errval);
|
||||
return -errval;
|
||||
}
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
{
|
||||
bdbg("Unexpected end of file\n");
|
||||
return -ENODATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
readsize -= nbytes;
|
||||
buffer += nbytes;
|
||||
offset += nbytes;
|
||||
}
|
||||
}
|
||||
|
||||
elf_dumpreaddata(buffer, readsize);
|
||||
return OK;
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_sections.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_sectname
|
||||
*
|
||||
* Description:
|
||||
* Get the symbol name in loadinfo->iobuffer[].
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int elf_sectname(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const Elf32_Shdr *shdr)
|
||||
{
|
||||
FAR Elf32_Shdr *shstr;
|
||||
FAR uint8_t *buffer;
|
||||
off_t offset;
|
||||
size_t readlen;
|
||||
size_t bytesread;
|
||||
int shstrndx;
|
||||
int ret;
|
||||
|
||||
/* Get the section header table index of the entry associated with the
|
||||
* section name string table. If the file has no section name string table,
|
||||
* this member holds the value SH_UNDEF.
|
||||
*/
|
||||
|
||||
shstrndx = loadinfo->ehdr.e_shstrndx;
|
||||
if (shstrndx == SHN_UNDEF)
|
||||
{
|
||||
bdbg("No section header string table\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get the section name string table section header */
|
||||
|
||||
shstr = &loadinfo->shdr[shstrndx];
|
||||
|
||||
/* Get the file offset to the string that is the name of the section. This
|
||||
* is the sum of:
|
||||
*
|
||||
* shstr->sh_offset: The file offset to the first byte of the section
|
||||
* header string table data.
|
||||
* shdr->sh_name: The offset to the name of the section in the section
|
||||
* name table
|
||||
*/
|
||||
|
||||
offset = shstr->sh_offset + shdr->sh_name;
|
||||
|
||||
/* Loop until we get the entire section name into memory */
|
||||
|
||||
buffer = loadinfo->iobuffer;
|
||||
bytesread = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Get the number of bytes to read */
|
||||
|
||||
readlen = loadinfo->buflen - bytesread;
|
||||
if (offset + readlen > loadinfo->filelen)
|
||||
{
|
||||
readlen = loadinfo->filelen - offset;
|
||||
if (readlen <= 0)
|
||||
{
|
||||
bdbg("At end of file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read that number of bytes into the array */
|
||||
|
||||
buffer = &loadinfo->iobuffer[bytesread];
|
||||
ret = elf_read(loadinfo, buffer, readlen, offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Failed to read section name\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bytesread += readlen;
|
||||
|
||||
/* Did we read the NUL terminator? */
|
||||
|
||||
if (memchr(buffer, '\0', readlen) != NULL)
|
||||
{
|
||||
/* Yes, the buffer contains a NUL terminator. */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* No.. then we have to read more */
|
||||
|
||||
ret = elf_reallocbuffer(loadinfo, CONFIG_ELF_BUFFERINCR);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_reallocbuffer failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* We will not get here */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_loadshdrs
|
||||
*
|
||||
* Description:
|
||||
* Loads section headers into memory.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
size_t shdrsize;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(loadinfo->shdr == NULL);
|
||||
|
||||
/* Verify that there are sections */
|
||||
|
||||
if (loadinfo->ehdr.e_shnum < 1)
|
||||
{
|
||||
bdbg("No sections(?)\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get the total size of the section header table */
|
||||
|
||||
shdrsize = (size_t)loadinfo->ehdr.e_shentsize * (size_t)loadinfo->ehdr.e_shnum;
|
||||
if(loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen)
|
||||
{
|
||||
bdbg("Insufficent space in file for section header table\n");
|
||||
return -ESPIPE;
|
||||
}
|
||||
|
||||
/* Allocate memory to hold a working copy of the sector header table */
|
||||
|
||||
loadinfo->shdr = (FAR Elf32_Shdr*)kmalloc(shdrsize);
|
||||
if (!loadinfo->shdr)
|
||||
{
|
||||
bdbg("Failed to allocate the section header table. Size: %ld\n", (long)shdrsize);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Read the section header table into memory */
|
||||
|
||||
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->shdr, shdrsize, loadinfo->ehdr.e_shoff);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("Failed to read section header table: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_findsection
|
||||
*
|
||||
* Description:
|
||||
* A section by its name.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
* sectname - Name of the section to find
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the index to the section is returned; A negated errno value
|
||||
* is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_findsection(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const char *sectname)
|
||||
{
|
||||
FAR const Elf32_Shdr *shdr;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Search through the shdr[] array in loadinfo for a section named 'sectname' */
|
||||
|
||||
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
/* Get the name of this section */
|
||||
|
||||
shdr = &loadinfo->shdr[i];
|
||||
ret = elf_sectname(loadinfo, shdr);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_sectname failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check if the name of this section is 'sectname' */
|
||||
|
||||
bvdbg("%d. Comparing \"%s\" and .\"%s\"\n",
|
||||
i, loadinfo->iobuffer, sectname);
|
||||
|
||||
if (strcmp((FAR const char *)loadinfo->iobuffer, sectname) == 0)
|
||||
{
|
||||
/* We found it... return the index */
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
/* We failed to find a section with this name. */
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_symbols.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <elf32.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ELF_BUFFERINCR
|
||||
# define CONFIG_ELF_BUFFERINCR 32
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_symname
|
||||
*
|
||||
* Description:
|
||||
* Get the symbol name in loadinfo->iobuffer[].
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int elf_symname(FAR struct elf_loadinfo_s *loadinfo,
|
||||
FAR const Elf32_Sym *sym)
|
||||
{
|
||||
FAR uint8_t *buffer;
|
||||
off_t offset;
|
||||
size_t readlen;
|
||||
size_t bytesread;
|
||||
int ret;
|
||||
|
||||
/* Get the file offset to the string that is the name of the symbol. The
|
||||
* st_name member holds an offset into the file's symbol string table.
|
||||
*/
|
||||
|
||||
if (sym->st_name == 0)
|
||||
{
|
||||
bdbg("Symbol has no name\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
offset = loadinfo->shdr[loadinfo->strtabidx].sh_offset + sym->st_name;
|
||||
|
||||
/* Loop until we get the entire symbol name into memory */
|
||||
|
||||
bytesread = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Get the number of bytes to read */
|
||||
|
||||
readlen = loadinfo->buflen - bytesread;
|
||||
if (offset + readlen > loadinfo->filelen)
|
||||
{
|
||||
readlen = loadinfo->filelen - offset;
|
||||
if (readlen <= 0)
|
||||
{
|
||||
bdbg("At end of file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read that number of bytes into the array */
|
||||
|
||||
buffer = &loadinfo->iobuffer[bytesread];
|
||||
ret = elf_read(loadinfo, buffer, readlen, offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_read failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bytesread += readlen;
|
||||
|
||||
/* Did we read the NUL terminator? */
|
||||
|
||||
if (memchr(buffer, '\0', readlen) != NULL)
|
||||
{
|
||||
/* Yes, the buffer contains a NUL terminator. */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* No.. then we have to read more */
|
||||
|
||||
ret = elf_reallocbuffer(loadinfo, CONFIG_ELF_BUFFERINCR);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("elf_reallocbuffer failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* We will not get here */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_findsymtab
|
||||
*
|
||||
* Description:
|
||||
* Find the symbol table section.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_findsymtab(FAR struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Find the symbol table section header and its associated string table */
|
||||
|
||||
for (i = 1; i < loadinfo->ehdr.e_shnum; i++)
|
||||
{
|
||||
if (loadinfo->shdr[i].sh_type == SHT_SYMTAB)
|
||||
{
|
||||
loadinfo->symtabidx = i;
|
||||
loadinfo->strtabidx = loadinfo->shdr[i].sh_link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Verify that there is a symbol and string table */
|
||||
|
||||
if (loadinfo->symtabidx == 0)
|
||||
{
|
||||
bdbg("No symbols in ELF file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_readsym
|
||||
*
|
||||
* Description:
|
||||
* Read the ELFT symbol structure at the specfied index into memory.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
* index - Symbol table index
|
||||
* sym - Location to return the table entry
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
|
||||
FAR Elf32_Sym *sym)
|
||||
{
|
||||
FAR Elf32_Shdr *symtab = &loadinfo->shdr[loadinfo->symtabidx];
|
||||
off_t offset;
|
||||
|
||||
/* Verify that the symbol table index lies within symbol table */
|
||||
|
||||
if (index < 0 || index > (symtab->sh_size / sizeof(Elf32_Sym)))
|
||||
{
|
||||
bdbg("Bad relocation symbol index: %d\n", index);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get the file offset to the symbol table entry */
|
||||
|
||||
offset = symtab->sh_offset + sizeof(Elf32_Sym) * index;
|
||||
|
||||
/* And, finally, read the symbol table entry into memory */
|
||||
|
||||
return elf_read(loadinfo, (FAR uint8_t*)sym, sizeof(Elf32_Sym), offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_symvalue
|
||||
*
|
||||
* Description:
|
||||
* Get the value of a symbol. The updated value of the symbol is returned
|
||||
* in the st_value field of the symbol table entry.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loadinfo - Load state information
|
||||
* sym - Symbol table entry (value might be undefined)
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
|
||||
FAR const struct symtab_s *exports, int nexports)
|
||||
{
|
||||
FAR const struct symtab_s *symbol;
|
||||
uintptr_t secbase;
|
||||
int ret;
|
||||
|
||||
switch (sym->st_shndx)
|
||||
{
|
||||
case SHN_COMMON:
|
||||
{
|
||||
/* NuttX ELF modules should be compiled with -fno-common. */
|
||||
|
||||
bdbg("SHN_COMMON: Re-compile with -fno-common\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
case SHN_ABS:
|
||||
{
|
||||
/* st_value already holds the correct value */
|
||||
|
||||
bvdbg("SHN_ABS: st_value=%08lx\n", (long)sym->st_value);
|
||||
return OK;
|
||||
}
|
||||
|
||||
case SHN_UNDEF:
|
||||
{
|
||||
/* Get the name of the undefined symbol */
|
||||
|
||||
ret = elf_symname(loadinfo, sym);
|
||||
if (ret < 0)
|
||||
{
|
||||
bdbg("SHN_UNDEF: Failed to get symbol name: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check if the base code exports a symbol of this name */
|
||||
|
||||
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
|
||||
symbol = symtab_findorderedbyname(exports, (FAR char *)loadinfo->iobuffer, nexports);
|
||||
#else
|
||||
symbol = symtab_findbyname(exports, (FAR char *)loadinfo->iobuffer, nexports);
|
||||
#endif
|
||||
if (!symbol)
|
||||
{
|
||||
bdbg("SHN_UNDEF: Exported symbol \"%s\" not found\n", loadinfo->iobuffer);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Yes... add the exported symbol value to the ELF symbol table entry */
|
||||
|
||||
bvdbg("SHN_ABS: name=%s %08x+%08x=%08x\n",
|
||||
loadinfo->iobuffer, sym->st_value, symbol->sym_value,
|
||||
sym->st_value + symbol->sym_value);
|
||||
|
||||
sym->st_value += (Elf32_Word)((uintptr_t)symbol->sym_value);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
secbase = loadinfo->shdr[sym->st_shndx].sh_addr;
|
||||
|
||||
bvdbg("Other: %08x+%08x=%08x\n",
|
||||
sym->st_value, secbase, sym->st_value + secbase);
|
||||
|
||||
sym->st_value += secbase;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_uninit.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_uninit
|
||||
*
|
||||
* Description:
|
||||
* Releases any resources committed by elf_init(). This essentially
|
||||
* undoes the actions of elf_init.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_uninit(struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Free all working buffers */
|
||||
|
||||
elf_freebuffers(loadinfo);
|
||||
|
||||
/* Close the ELF file */
|
||||
|
||||
if (loadinfo->filfd >= 0)
|
||||
{
|
||||
close(loadinfo->filfd);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_freebuffers
|
||||
*
|
||||
* Description:
|
||||
* Release all working buffers.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_freebuffers(struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Release all working allocations */
|
||||
|
||||
if (loadinfo->shdr)
|
||||
{
|
||||
kfree((FAR void *)loadinfo->shdr);
|
||||
loadinfo->shdr = NULL;
|
||||
}
|
||||
|
||||
if (loadinfo->iobuffer)
|
||||
{
|
||||
kfree((FAR void *)loadinfo->iobuffer);
|
||||
loadinfo->iobuffer = NULL;
|
||||
loadinfo->buflen = 0;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/libelf_unload.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_unload
|
||||
*
|
||||
* Description:
|
||||
* This function unloads the object from memory. This essentially
|
||||
* undoes the actions of elf_load.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_unload(struct elf_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Free all working buffers */
|
||||
|
||||
elf_freebuffers(loadinfo);
|
||||
|
||||
/* Release memory holding the relocated ELF image */
|
||||
|
||||
if (loadinfo->elfalloc != 0)
|
||||
{
|
||||
kfree((FAR void *)loadinfo->elfalloc);
|
||||
loadinfo->elfalloc = 0;
|
||||
}
|
||||
|
||||
loadinfo->elfsize = 0;
|
||||
|
||||
/* Release memory used to hold static constructors and destructors */
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
if (loadinfo->ctoralloc != 0)
|
||||
{
|
||||
kfree(loadinfo->ctoralloc);
|
||||
loadinfo->ctoralloc = NULL;
|
||||
}
|
||||
|
||||
loadinfo->ctors = NULL;
|
||||
loadinfo->nctors = 0;
|
||||
|
||||
if (loadinfo->dtoralloc != 0)
|
||||
{
|
||||
kfree(loadinfo->dtoralloc);
|
||||
loadinfo->dtoralloc = NULL;
|
||||
}
|
||||
|
||||
loadinfo->dtors = NULL;
|
||||
loadinfo->ndtors = 0;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libelf/elf_verify.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char g_elfmagic[EI_MAGIC_SIZE] = { 0x7f, 'E', 'L', 'F' };
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_verifyheader
|
||||
*
|
||||
* Description:
|
||||
* Given the header from a possible ELF executable, verify that it
|
||||
* is an ELF executable.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
* -ENOEXEC : Not an ELF file
|
||||
* -EINVAL : Not a relocatable ELF file or not supported by the current,
|
||||
* configured architecture.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int elf_verifyheader(FAR const Elf32_Ehdr *ehdr)
|
||||
{
|
||||
if (!ehdr)
|
||||
{
|
||||
bdbg("NULL ELF header!");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Verify that the magic number indicates an ELF file */
|
||||
|
||||
if (memcmp(ehdr->e_ident, g_elfmagic, EI_MAGIC_SIZE) != 0)
|
||||
{
|
||||
bvdbg("Not ELF magic {%02x, %02x, %02x, %02x}\n",
|
||||
ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2], ehdr->e_ident[3]);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Verify that this is a relocatable file */
|
||||
|
||||
if (ehdr->e_type != ET_REL)
|
||||
{
|
||||
bdbg("Not a relocatable file: e_type=%d\n", ehdr->e_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Verify that this file works with the currently configured architecture */
|
||||
|
||||
if (arch_checkarch(ehdr))
|
||||
{
|
||||
bdbg("Not a supported architecture\n");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
/* Looks good so far... we still might find some problems later. */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,8 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config NXFLAT_DUMPBUFFER
|
||||
bool "Dump NXFLAT buffers"
|
||||
default n
|
||||
depends on DEBUG && DEBUG_VERBOSE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################################
|
||||
# nxflat/lib/Make.defs
|
||||
# binfmt/libnxflat/Make.defs
|
||||
#
|
||||
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@@ -33,7 +33,22 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
LIBNXFLAT_ASRCS =
|
||||
LIBNXFLAT_CSRCS = libnxflat_init.c libnxflat_uninit.c libnxflat_load.c \
|
||||
libnxflat_unload.c libnxflat_verify.c libnxflat_read.c \
|
||||
libnxflat_bind.c
|
||||
ifeq ($(CONFIG_NXFLAT),y)
|
||||
|
||||
# NXFLAT application interfaces
|
||||
|
||||
BINFMT_CSRCS += nxflat.c
|
||||
|
||||
# NXFLAT library
|
||||
|
||||
BINFMT_CSRCS += libnxflat_init.c libnxflat_uninit.c libnxflat_load.c \
|
||||
libnxflat_unload.c libnxflat_verify.c libnxflat_read.c \
|
||||
libnxflat_bind.c
|
||||
|
||||
# Hook the libnxflat subdirectory into the build
|
||||
|
||||
VPATH += libnxflat
|
||||
SUBDIRS += libnxflat
|
||||
DEPPATH += --dep-path libnxflat
|
||||
|
||||
endif
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/symtab.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -263,7 +263,6 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
|
||||
result = OK;
|
||||
switch (NXFLAT_RELOC_TYPE(reloc.r_info))
|
||||
{
|
||||
|
||||
/* NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit offset
|
||||
* into I-Space at the offset.
|
||||
* Fixup: Add mapped I-Space address to the offset.
|
||||
@@ -329,6 +328,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
|
||||
nxflat_dumpbuffer("GOT", (FAR const uint8_t*)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||
offset < loadinfo->isize + loadinfo->dsize);
|
||||
|
||||
imports = (struct nxflat_import_s*)
|
||||
(offset - loadinfo->isize + loadinfo->dspace->region);
|
||||
(offset - loadinfo->isize + loadinfo->dspace->region);
|
||||
|
||||
/* Now, traverse the list of imported symbols and attempt to bind
|
||||
* each symbol to the value exported by from the exported symbol
|
||||
@@ -396,41 +396,41 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||
*/
|
||||
|
||||
for (i = 0; i < nimports; i++)
|
||||
{
|
||||
bvdbg("Import[%d] (%08p) offset: %08x func: %08x\n",
|
||||
i, &imports[i], imports[i].i_funcname, imports[i].i_funcaddress);
|
||||
{
|
||||
bvdbg("Import[%d] (%08p) offset: %08x func: %08x\n",
|
||||
i, &imports[i], imports[i].i_funcname, imports[i].i_funcaddress);
|
||||
|
||||
/* Get a pointer to the imported symbol name. The name itself
|
||||
* lies in the TEXT segment. But the reference to the name
|
||||
* lies in DATA segment. Therefore, the name reference should
|
||||
* have been relocated when the module was loaded.
|
||||
*/
|
||||
/* Get a pointer to the imported symbol name. The name itself
|
||||
* lies in the TEXT segment. But the reference to the name
|
||||
* lies in DATA segment. Therefore, the name reference should
|
||||
* have been relocated when the module was loaded.
|
||||
*/
|
||||
|
||||
offset = imports[i].i_funcname;
|
||||
DEBUGASSERT(offset < loadinfo->isize);
|
||||
|
||||
symname = (char*)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
||||
symname = (char*)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
||||
|
||||
/* Find the exported symbol value for this this symbol name. */
|
||||
/* Find the exported symbol value for this this symbol name. */
|
||||
|
||||
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
|
||||
symbol = symtab_findorderedbyname(exports, symname, nexports);
|
||||
#else
|
||||
symbol = symtab_findbyname(exports, symname, nexports);
|
||||
#endif
|
||||
if (!symbol)
|
||||
{
|
||||
bdbg("Exported symbol \"%s\" not found\n", symname);
|
||||
if (!symbol)
|
||||
{
|
||||
bdbg("Exported symbol \"%s\" not found\n", symname);
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
/* And put this into the module's import structure. */
|
||||
/* And put this into the module's import structure. */
|
||||
|
||||
imports[i].i_funcaddress = (uint32_t)symbol->sym_value;
|
||||
imports[i].i_funcaddress = (uint32_t)symbol->sym_value;
|
||||
|
||||
bvdbg("Bound import[%d] (%08p) to export '%s' (%08x)\n",
|
||||
i, &imports[i], symname, imports[i].i_funcaddress);
|
||||
}
|
||||
bvdbg("Bound import[%d] (%08p) to export '%s' (%08x)\n",
|
||||
i, &imports[i], symname, imports[i].i_funcaddress);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dump the relocation import table */
|
||||
@@ -441,6 +441,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||
nxflat_dumpbuffer("Imports", (FAR const uint8_t*)imports, nimports * sizeof(struct nxflat_import_s));
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -484,9 +485,10 @@ int nxflat_bind(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||
*/
|
||||
|
||||
memset((void*)(loadinfo->dspace->region + loadinfo->datasize),
|
||||
0, loadinfo->bsssize);
|
||||
0, loadinfo->bsssize);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
@@ -112,8 +112,9 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
||||
loadinfo->filfd = open(filename, O_RDONLY);
|
||||
if (loadinfo->filfd < 0)
|
||||
{
|
||||
bdbg("Failed to open NXFLAT binary %s: %d\n", filename, ret);
|
||||
return -errno;
|
||||
int errval = errno;
|
||||
bdbg("Failed to open NXFLAT binary %s: %d\n", filename, errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
/* Read the NXFLAT header from offset 0 */
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
@@ -62,24 +62,6 @@
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_BINFMT)
|
||||
static const char g_relocrel32i[] = "RELOC_REL32I";
|
||||
static const char g_relocrel32d[] = "RELOC_REL32D";
|
||||
static const char g_relocabs32[] = "RELOC_AB32";
|
||||
static const char g_undefined[] = "UNDEFINED";
|
||||
|
||||
static const char *g_reloctype[] =
|
||||
{
|
||||
g_relocrel32i,
|
||||
g_relocrel32d,
|
||||
g_relocabs32,
|
||||
g_undefined
|
||||
};
|
||||
# define RELONAME(rl) g_reloctype[NXFLAT_RELOC_TYPE(rl)]
|
||||
#else
|
||||
# define RELONAME(rl) "(no name)"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
@@ -129,8 +129,9 @@ int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer, int readsize,
|
||||
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
|
||||
if (rpos != offset)
|
||||
{
|
||||
bdbg("Failed to seek to position %d: %d\n", offset, errno);
|
||||
return -errno;
|
||||
int errval = errno;
|
||||
bdbg("Failed to seek to position %d: %d\n", offset, errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
/* Read the file data at offset into the user buffer */
|
||||
@@ -138,10 +139,11 @@ int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer, int readsize,
|
||||
nbytes = read(loadinfo->filfd, bufptr, bytesleft);
|
||||
if (nbytes < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
int errval = errno;
|
||||
if (errval != EINTR)
|
||||
{
|
||||
bdbg("Read of .data failed: %d\n", errno);
|
||||
return -errno;
|
||||
bdbg("Read of .data failed: %d\n", errval);
|
||||
return -errval;
|
||||
}
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
#include <unistd.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
@@ -56,10 +57,6 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxflat_swap32
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
||||
@@ -42,8 +42,9 @@
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -91,10 +92,10 @@ int nxflat_verifyheader(const struct nxflat_hdr_s *header)
|
||||
if (strncmp(header->h_magic, NXFLAT_MAGIC, 4) != 0)
|
||||
{
|
||||
bdbg("Unrecognized magic=\"%c%c%c%c\"\n",
|
||||
header->h_magic[0], header->h_magic[1],
|
||||
header->h_magic[2], header->h_magic[3]);
|
||||
header->h_magic[0], header->h_magic[1],
|
||||
header->h_magic[2], header->h_magic[3]);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -47,8 +47,8 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <nuttx/binfmt.h>
|
||||
#include <nuttx/nxflat.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
|
||||
#ifdef CONFIG_NXFLAT
|
||||
|
||||
@@ -158,7 +158,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
|
||||
nxflat_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
bdbg("Failed to initialize for load of NXFLT program: %d\n", ret);
|
||||
bdbg("Failed to initialize for load of NXFLAT program: %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
|
||||
nxflat_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
bdbg("Failed to load NXFLT program binary: %d\n", ret);
|
||||
bdbg("Failed to load NXFLAT program binary: %d\n", ret);
|
||||
goto errout_with_init;
|
||||
}
|
||||
|
||||
@@ -181,16 +181,18 @@ static int nxflat_loadbinary(struct binary_s *binp)
|
||||
goto errout_with_load;
|
||||
}
|
||||
|
||||
/* Return the load information */
|
||||
/* Return the load information. By convention, D-space address
|
||||
* space is stored as the first allocated memory.
|
||||
*/
|
||||
|
||||
binp->entrypt = (main_t)(loadinfo.ispace + loadinfo.entryoffs);
|
||||
binp->ispace = (void*)loadinfo.ispace;
|
||||
binp->dspace = (void*)loadinfo.dspace;
|
||||
binp->isize = loadinfo.isize;
|
||||
binp->mapped = (void*)loadinfo.ispace;
|
||||
binp->alloc[0] = (void*)loadinfo.dspace;
|
||||
binp->mapsize = loadinfo.isize;
|
||||
binp->stacksize = loadinfo.stacksize;
|
||||
|
||||
nxflat_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
|
||||
MIN(binp->isize - loadinfo.entryoffs,512));
|
||||
MIN(loadinfo.isize - loadinfo.entryoffs, 512));
|
||||
|
||||
nxflat_uninit(&loadinfo);
|
||||
return OK;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/symtab.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/symtab.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/symtab.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/symtab.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
+136
-43
@@ -103,14 +103,23 @@ Make.defs -- This makefile fragment provides architecture and
|
||||
|
||||
Tools: CC, LD, AR, NM, OBJCOPY, OBJDUMP
|
||||
Tool options: CFLAGS, LDFLAGS
|
||||
COMPILE, ASSEMBLE, ARCHIVE, CLEAN, and MKDEP macros
|
||||
|
||||
When this makefile fragment runs, it will be passed TOPDIR which
|
||||
is the path to the root directory of the build. This makefile
|
||||
fragment may include ${TOPDIR}/.config to perform configuration
|
||||
specific settings. For example, the CFLAGS will most likely be
|
||||
fragment should include:
|
||||
|
||||
$(TOPDIR)/.config : Nuttx configuration
|
||||
$(TOPDIR)/tools/Config.mk : Common definitions
|
||||
|
||||
Definitions in the Make.defs file probably depend on some of the
|
||||
settings in the .config file. For example, the CFLAGS will most likely be
|
||||
different if CONFIG_DEBUG=y.
|
||||
|
||||
The included tools/Config.mk file contains additional definitions that may
|
||||
be overriden in the architecture-specific Make.defs file as necessary:
|
||||
|
||||
COMPILE, ASSEMBLE, ARCHIVE, CLEAN, and MKDEP macros
|
||||
|
||||
defconfig -- This is a configuration file similar to the Linux
|
||||
configuration file. In contains variable/value pairs like:
|
||||
|
||||
@@ -171,7 +180,6 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_RAW_BINARY - make a raw binary format file used with many
|
||||
different loaders using the GNU objcopy program. This option
|
||||
should not be selected if you are not using the GNU toolchain.
|
||||
CONFIG_HAVE_LIBM - toolchain supports libm.a
|
||||
CONFIG_HAVE_CXX - toolchain supports C++ and CXX, CXXFLAGS, and
|
||||
COMPILEXX have been defined in the configurations Make.defs
|
||||
file.
|
||||
@@ -318,7 +326,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_RR_INTERVAL - The round robin timeslice will be set
|
||||
this number of milliseconds; Round robin scheduling can
|
||||
be disabled by setting this value to zero.
|
||||
CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
|
||||
CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
|
||||
scheduler to monitor system performance
|
||||
CONFIG_TASK_NAME_SIZE - Specifies that maximum size of a
|
||||
task name to save in the TCB. Useful if scheduler
|
||||
@@ -346,7 +354,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority
|
||||
inheritance is enabled. It defines the maximum number of
|
||||
different threads (minus one) that can take counts on a
|
||||
semaphore with priority inheritance support. This may be
|
||||
semaphore with priority inheritance support. This may be
|
||||
set to zero if priority inheritance is disabled OR if you
|
||||
are only using semaphores as mutexes (only one holder) OR
|
||||
if no more than two threads participate using a counting
|
||||
@@ -372,9 +380,6 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_SDCLONE_DISABLE. Disable cloning of all socket
|
||||
desciptors by task_create() when a new task is started. If
|
||||
set, all sockets will appear to be closed in the new task.
|
||||
CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
|
||||
This format will support execution of NuttX binaries located
|
||||
in a ROMFS filesystem (see examples/nxflat).
|
||||
CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
|
||||
handle delayed processing from interrupt handlers. This feature
|
||||
is required for some drivers but, if there are not complaints,
|
||||
@@ -418,6 +423,39 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
where 'app' is the application name. If not defined, CONFIG_USER_ENTRYPOINT
|
||||
defaults to user_start.
|
||||
|
||||
Binary Loaders:
|
||||
CONFIG_BINFMT_DISABLE - By default, support for loadable binary formats
|
||||
is built.
|
||||
This logic may be suppressed be defining this setting.
|
||||
CONFIG_BINFMT_CONSTRUCTORS - Build in support for C++ constructors in
|
||||
loaded modules.
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME - Symbol tables are order by name (rather
|
||||
than value).
|
||||
CONFIG_NXFLAT. Enable support for the NXFLAT binary format. This format
|
||||
will support execution of NuttX binaries located in a ROMFS filesystem
|
||||
(see apps/examples/nxflat).
|
||||
CONFIG_ELF - Enable support for the ELF binary format. This format will
|
||||
support execution of ELF binaries copied from a file system and
|
||||
relocated into RAM (see apps/examples/elf).
|
||||
|
||||
If CONFIG_ELF is selected, then these additional options are available:
|
||||
|
||||
CONFIG_ELF_ALIGN_LOG2 - Align all sections to this Log2 value: 0->1,
|
||||
1->2, 2->4, etc.
|
||||
CONFIG_ELF_STACKSIZE - This is the default stack size that will will
|
||||
be used when starting ELF binaries.
|
||||
CONFIG_ELF_BUFFERSIZE - This is an I/O buffer that is used to access
|
||||
the ELF file. Variable length items will need to be read (such as
|
||||
symbol names). This is really just this initial size of the buffer;
|
||||
it will be reallocated as necessary to hold large symbol names).
|
||||
Default: 128
|
||||
CONFIG_ELF_BUFFERINCR - This is an I/O buffer that is used to access
|
||||
the ELF file. Variable length items will need to be read (such as
|
||||
symbol names). This value specifies the size increment to use each
|
||||
time the buffer is reallocated. Default: 32
|
||||
CONFIG_ELF_DUMPBUFFER - Dump various ELF buffers for debug purposes.
|
||||
This option requires CONFIG_DEBUG and CONFIG_DEBUG_VERBOSE.
|
||||
|
||||
System Logging:
|
||||
CONFIG_SYSLOG enables general system logging support.
|
||||
CONFIG_SYSLOG_DEVPATH - The full path to the system logging device. Default
|
||||
@@ -503,7 +541,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
from the end of RAM for page tables or other system usage. The
|
||||
configuration settings and linker directives must be cognizant of that:
|
||||
CONFIG_PAGING_NDATA should be defined to prevent the data region from
|
||||
extending all the way to the end of memory.
|
||||
extending all the way to the end of memory.
|
||||
CONFIG_PAGING_DEFPRIO - The default, minimum priority of the page fill
|
||||
worker thread. The priority of the page fill work thread will be boosted
|
||||
boosted dynmically so that it matches the priority of the task on behalf
|
||||
@@ -517,7 +555,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
transfer is completed. Default: Undefined (non-blocking).
|
||||
CONFIG_PAGING_WORKPERIOD - The page fill worker thread will wake periodically
|
||||
even if there is no mapping to do. This selection controls that wake-up
|
||||
period (in microseconds). This wake-up a failsafe that will handle any
|
||||
period (in microseconds). This wake-up a failsafe that will handle any
|
||||
cases where a single is lost (that would really be a bug and shouldn't
|
||||
happen!) and also supports timeouts for case of non-blocking, asynchronous
|
||||
fills (see CONFIG_PAGING_TIMEOUT_TICKS).
|
||||
@@ -529,7 +567,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
Some architecture-specific settings. Defaults are architecture specific.
|
||||
If you don't know what you are doing, it is best to leave these undefined
|
||||
and try the system defaults:
|
||||
|
||||
|
||||
CONFIG_PAGING_VECPPAGE - This the physical address of the page in
|
||||
memory to be mapped to the vector address.
|
||||
CONFIG_PAGING_VECL2PADDR - This is the physical address of the L2
|
||||
@@ -552,7 +590,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
devices. CONFIG_PAGING_SDSLOT identifies the slot number of the SD
|
||||
device to initialize. This must be undefined if SD is not being used.
|
||||
This should be defined to be zero for the typical device that has
|
||||
only a single slot (See CONFIG_MMCSD_NSLOTS). If defined,
|
||||
only a single slot (See CONFIG_MMCSD_NSLOTS). If defined,
|
||||
CONFIG_PAGING_SDSLOT will instruct certain board-specific logic to
|
||||
initialize the media in this SD slot.
|
||||
CONFIG_PAGING_M25PX - Use the m25px.c FLASH driver. If this is selected,
|
||||
@@ -621,6 +659,37 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_ARCH_STRNCPY, CONFIG_ARCH_STRLEN, CONFIG_ARCH_STRNLEN
|
||||
CONFIG_ARCH_BZERO
|
||||
|
||||
If CONFIG_ARCH_MEMCPY is not selected, then you make also select Daniel
|
||||
Vik's optimized implementation of memcpy():
|
||||
|
||||
CONFIG_MEMCPY_VIK - Select this option to use the optimized memcpy()
|
||||
function by Daniel Vik. Select this option for improved performance
|
||||
at the expense of increased size. See licensing information in the
|
||||
top-level COPYING file. Default: n
|
||||
|
||||
And if CONFIG_MEMCPY_VIK is selected, the following tuning options are available:
|
||||
|
||||
CONFIG_MEMCPY_PRE_INC_PTRS - Use pre-increment of pointers. Default is
|
||||
post increment of pointers.
|
||||
|
||||
CONFIG_MEMCPY_INDEXED_COPY - Copying data using array indexing. Using
|
||||
this option, disables the CONFIG_MEMCPY_PRE_INC_PTRS option.
|
||||
|
||||
CONFIG_MEMCPY_64BIT - Compiles memcpy for architectures that suppport
|
||||
64-bit operations efficiently.
|
||||
|
||||
If CONFIG_ARCH_MEMSET is not selected, then the following option is
|
||||
also available:
|
||||
|
||||
CONFIG_MEMSET_OPTSPEED - Select this option to use a version of memcpy()
|
||||
optimized for speed. Default: memcpy() is optimized for size.
|
||||
|
||||
And if CONFIG_MEMSET_OPTSPEED is selected, the following tuning option is
|
||||
available:
|
||||
|
||||
CONFIG_MEMSET_64BIT - Compiles memset() for architectures that suppport
|
||||
64-bit operations efficiently.
|
||||
|
||||
The architecture may provide custom versions of certain standard header
|
||||
files:
|
||||
|
||||
@@ -663,6 +732,15 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
don't select CONFIG_ARCH_MATH_H, the redirecting math.h header file will
|
||||
stay out-of-the-way in include/nuttx/.
|
||||
|
||||
CONFIG_ARCH_FLOAT_H
|
||||
If you enable the generic, built-in math library, then that math library
|
||||
will expect your toolchain to provide the standard float.h header file.
|
||||
The float.h header file defines the properties of your floating point
|
||||
implementation. It would always be best to use your toolchain's float.h
|
||||
header file but if none is avaiable, a default float.h header file will
|
||||
provided if this option is selected. However, there is no assurance that
|
||||
the settings in this float.h are actually correct for your platform!
|
||||
|
||||
CONFIG_ARCH_STDARG_H - There is also a redirecting version of stdarg.h in
|
||||
the source tree as well. It also resides out-of-the-way at include/nuttx/stdarg.h.
|
||||
This is because you should normally use your toolchain's stdarg.h file. But
|
||||
@@ -693,7 +771,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
If CONFIG_ARCH_ROMGETC is defined, then the architecture logic
|
||||
must export the function up_romgetc(). up_romgetc() will simply
|
||||
read one byte of data from the instruction space.
|
||||
|
||||
|
||||
If CONFIG_ARCH_ROMGETC, certain C stdio functions are effected:
|
||||
(1) All format strings in printf, fprintf, sprintf, etc. are
|
||||
assumed to lie in FLASH (string arguments for %s are still assumed
|
||||
@@ -763,7 +841,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
much sense in supporting FAT date and time unless you have a
|
||||
hardware RTC or other way to get the time and date.
|
||||
CONFIG_FS_NXFFS: Enable NuttX FLASH file system (NXFF) support.
|
||||
CONFIG_NXFFS_ERASEDSTATE: The erased state of FLASH.
|
||||
CONFIG_NXFFS_ERASEDSTATE: The erased state of FLASH.
|
||||
This must have one of the values of 0xff or 0x00.
|
||||
Default: 0xff.
|
||||
CONFIG_NXFFS_PACKTHRESHOLD: When packing flash file data,
|
||||
@@ -917,7 +995,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
|
||||
CONFIG_INPUT
|
||||
Enables general support for input devices
|
||||
|
||||
|
||||
CONFIG_INPUT_TSC2007
|
||||
If CONFIG_INPUT is selected, then this setting will enable building
|
||||
of the TI TSC2007 touchscreen driver.
|
||||
@@ -932,14 +1010,14 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
Enables support for the SPI interface (not currenly supported)
|
||||
CONFIG_STMPE811_I2C
|
||||
Enables support for the I2C interface
|
||||
CONFIG_STMPE811_MULTIPLE
|
||||
CONFIG_STMPE811_MULTIPLE
|
||||
Can be defined to support multiple STMPE811 devices on board.
|
||||
CONFIG_STMPE811_ACTIVELOW
|
||||
Interrupt is generated by an active low signal (or falling edge).
|
||||
CONFIG_STMPE811_EDGE
|
||||
Interrupt is generated on an edge (vs. on the active level)
|
||||
CONFIG_STMPE811_NPOLLWAITERS
|
||||
Maximum number of threads that can be waiting on poll() (ignored if
|
||||
Maximum number of threads that can be waiting on poll() (ignored if
|
||||
CONFIG_DISABLE_POLL is set).
|
||||
CONFIG_STMPE811_TSC_DISABLE
|
||||
Disable driver touchscreen functionality.
|
||||
@@ -1048,21 +1126,21 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
port. The default data link layer for uIP is Ethernet. If CONFIG_NET_SLIP
|
||||
is defined in the NuttX configuration file, then SLIP will be supported.
|
||||
The basic differences between the SLIP and Ethernet configurations is that
|
||||
when SLIP is selected:
|
||||
when SLIP is selected:
|
||||
|
||||
* The link level header (that comes before the IP header) is omitted.
|
||||
* All MAC address processing is suppressed.
|
||||
* The link level header (that comes before the IP header) is omitted.
|
||||
* All MAC address processing is suppressed.
|
||||
* ARP is disabled.
|
||||
|
||||
If CONFIG_NET_SLIP is not selected, then Ethernet will be used (there is
|
||||
no need to define anything special in the configuration file to use
|
||||
Ethernet -- it is the default).
|
||||
Ethernet -- it is the default).
|
||||
|
||||
CONFIG_NET_SLIP -- Enables building of the SLIP driver. SLIP requires
|
||||
at least one IP protocols selected and the following additional
|
||||
network settings: CONFIG_NET_NOINTS and CONFIG_NET_MULTIBUFFER.
|
||||
CONFIG_NET_BUFSIZE *must* be set to 296. Other optional configuration
|
||||
settings that affect the SLIP driver: CONFIG_NET_STATISTICS.
|
||||
settings that affect the SLIP driver: CONFIG_NET_STATISTICS.
|
||||
Default: Ethernet
|
||||
|
||||
If SLIP is selected, then the following SLIP options are available:
|
||||
@@ -1078,6 +1156,10 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
|
||||
CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
|
||||
CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
|
||||
CONFIG_NET_RESOLV_MAXRESPONSE - This setting determines the maximum
|
||||
size of response message that can be received by the DNS resolver.
|
||||
The default is 96 but may need to be larger on enterprise networks
|
||||
(perhaps 176).
|
||||
|
||||
THTTPD
|
||||
|
||||
@@ -1099,7 +1181,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
to run before killing them.
|
||||
CONFIG_THTTPD_CHARSET- The default character set name to use with
|
||||
text MIME types.
|
||||
CONFIG_THTTPD_IOBUFFERSIZE -
|
||||
CONFIG_THTTPD_IOBUFFERSIZE -
|
||||
CONFIG_THTTPD_INDEX_NAMES - A list of index filenames to check. The
|
||||
files are searched for in this order.
|
||||
CONFIG_AUTH_FILE - The file to use for authentication. If this is
|
||||
@@ -1131,7 +1213,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
You can also leave both options undefined, and thttpd will not do
|
||||
anything special about tildes. Enabling both options is an error.
|
||||
Typical values, if they're defined, are "users" for
|
||||
CONFIG_THTTPD_TILDE_MAP1 and "public_html"forCONFIG_THTTPD_TILDE_MAP2.
|
||||
CONFIG_THTTPD_TILDE_MAP1 and "public_html"forCONFIG_THTTPD_TILDE_MAP2.
|
||||
CONFIG_THTTPD_GENERATE_INDICES
|
||||
CONFIG_THTTPD_URLPATTERN - If defined, then it will be used to match
|
||||
and verify referrers.
|
||||
@@ -1189,7 +1271,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
USB host HID class driver. Requires CONFIG_USBHOST=y,
|
||||
CONFIG_USBHOST_INT_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0,
|
||||
CONFIG_SCHED_WORKQUEUE=y, and CONFIG_DISABLE_SIGNALS=n.
|
||||
|
||||
|
||||
CONFIG_HIDKBD_POLLUSEC
|
||||
Device poll rate in microseconds. Default: 100 milliseconds.
|
||||
CONFIG_HIDKBD_DEFPRIO
|
||||
@@ -1208,7 +1290,7 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
If set to y all 231 possible scancodes will be converted to
|
||||
something. Default: 104 key US keyboard.
|
||||
CONFIG_HIDKBD_NODEBOUNCE
|
||||
If set to y normal debouncing is disabled. Default:
|
||||
If set to y normal debouncing is disabled. Default:
|
||||
Debounce enabled (No repeat keys).
|
||||
|
||||
USB host mass storage class driver. Requires CONFIG_USBHOST=y,
|
||||
@@ -1245,12 +1327,12 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
Configure the CDC serial driver as part of a composite driver
|
||||
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||
CONFIG_CDCACM_IFNOBASE
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
be defined to offset the CDC/ACM interface numbers so that they are
|
||||
unique and contiguous. When used with the Mass Storage driver, the
|
||||
correct value for this offset is zero.
|
||||
CONFIG_CDCACM_STRBASE
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
be defined to offset the CDC/ACM string numbers so that they are
|
||||
unique and contiguous. When used with the Mass Storage driver, the
|
||||
correct value for this offset is four (this value actuallly only needs
|
||||
@@ -1309,13 +1391,13 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
Configure the mass storage driver as part of a composite driver
|
||||
(only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||
CONFIG_USBMSC_IFNOBASE
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
be defined to offset the mass storage interface number so that it is
|
||||
unique and contiguous. When used with the CDC/ACM driver, the
|
||||
correct value for this offset is two (because of the two CDC/ACM
|
||||
interfaces that will precede it).
|
||||
CONFIG_USBMSC_STRBASE
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
If the CDC driver is part of a composite device, then this may need to
|
||||
be defined to offset the mass storage string numbers so that they are
|
||||
unique and contiguous. When used with the CDC/ACM driver, the
|
||||
correct value for this offset is four (or perhaps 5 or 6, depending
|
||||
@@ -1523,10 +1605,15 @@ configs/avr32dev1
|
||||
configs/c5471evm
|
||||
This is a port to the Spectrum Digital C5471 evaluation board. The
|
||||
TMS320C5471 is a dual core processor from TI with an ARM7TDMI general
|
||||
purpose processor and a c54 DSP. It is also known as TMS320DA180 or just DA180.
|
||||
purpose processor and a c54 DSP. It is also known as TMS320DA180 or just DA180.
|
||||
NuttX runs on the ARM core and is built with a GNU arm-nuttx-elf toolchain*.
|
||||
This port is complete and verified.
|
||||
|
||||
configs/cloudctrl
|
||||
Darcy's CloudController board. This is a small network relay development
|
||||
board. Based on the Shenzhou IV development board design. It is based on
|
||||
the STM32F107VC MCU.
|
||||
|
||||
configs/compal_e88 and compal_e99
|
||||
These directories contain the board support for compal e88 and e99 phones.
|
||||
These ports are based on patches contributed by Denis Carikli for both the
|
||||
@@ -1539,23 +1626,23 @@ configs/demo9s12ne64
|
||||
is code complete but has not yet been verified.
|
||||
|
||||
configs/ea3131
|
||||
Embedded Artists EA3131 Development board. This board is based on the
|
||||
Embedded Artists EA3131 Development board. This board is based on the
|
||||
an NXP LPC3131 MCU. This OS is built with the arm-nuttx-elf toolchain*.
|
||||
STATUS: This port is complete and mature.
|
||||
|
||||
configs/ea3152
|
||||
Embedded Artists EA3152 Development board. This board is based on the
|
||||
Embedded Artists EA3152 Development board. This board is based on the
|
||||
an NXP LPC3152 MCU. This OS is built with the arm-nuttx-elf toolchain*.
|
||||
STATUS: This port is has not be exercised well, but since it is
|
||||
a simple derivative of the ea3131, it should be fully functional.
|
||||
|
||||
configs/eagle100
|
||||
Micromint Eagle-100 Development board. This board is based on the
|
||||
Micromint Eagle-100 Development board. This board is based on the
|
||||
an ARM Cortex-M3 MCU, the Luminary LM3S6918. This OS is built with the
|
||||
arm-nuttx-elf toolchain*. STATUS: This port is complete and mature.
|
||||
|
||||
configs/ekk-lm3s9b96
|
||||
TI/Stellaris EKK-LM3S9B96 board. This board is based on the
|
||||
TI/Stellaris EKK-LM3S9B96 board. This board is based on the
|
||||
an EKK-LM3S9B96 which is a Cortex-M3.
|
||||
|
||||
configs/ez80f0910200kitg
|
||||
@@ -1583,13 +1670,13 @@ configs/kwikstik-k40.
|
||||
|
||||
configs/lincoln60
|
||||
NuttX port to the Micromint Lincoln 60 board.
|
||||
|
||||
|
||||
configs/lm3s6432-s2e
|
||||
Stellaris RDK-S2E Reference Design Kit and the MDL-S2E Ethernet to
|
||||
Serial module.
|
||||
|
||||
configs/lm3s6965-ek
|
||||
Stellaris LM3S6965 Evaluation Kit. This board is based on the
|
||||
Stellaris LM3S6965 Evaluation Kit. This board is based on the
|
||||
an ARM Cortex-M3 MCU, the Luminary/TI LM3S6965. This OS is built with the
|
||||
arm-nuttx-elf toolchain*. STATUS: This port is complete and mature.
|
||||
|
||||
@@ -1646,7 +1733,7 @@ configs/ntosd-dm320
|
||||
toolchain*: see
|
||||
|
||||
http://wiki.neurostechnology.com/index.php/OSD_1.0_Developer_Home
|
||||
|
||||
|
||||
There are some differences between the Dev Board and the currently
|
||||
available commercial v1.0 Boards. See
|
||||
|
||||
@@ -1716,7 +1803,7 @@ configs/qemu-i486
|
||||
hardwared (Google the Bifferboard).
|
||||
|
||||
configs/rgmp
|
||||
RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project for
|
||||
RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project for
|
||||
running GPOS and RTOS simultaneously on multi-processor platforms. You can
|
||||
port your favorite RTOS to RGMP together with an unmodified Linux to form a
|
||||
hybrid operating system. This makes your application able to use both RTOS
|
||||
@@ -1757,8 +1844,14 @@ configs/stm3240g-eval
|
||||
microcontroller (ARM Cortex-M4 with FPU). This port uses a GNU Cortex-M4
|
||||
toolchain (such as CodeSourcery).
|
||||
|
||||
configs/stm32f100rc_generic
|
||||
STMicro STM32F100RC generic board based on STM32F100RC high-density value line
|
||||
chip. This "generic" configuration is not very usable out-of-box, but can be
|
||||
used as a starting point to creating new configs with similar STM32
|
||||
high-density value line chips.
|
||||
|
||||
configs/stm32f4discovery
|
||||
STMicro STM32F4-Discovery board boased on the STMIcro STM32F407VGT6 MCU.
|
||||
STMicro STM32F4-Discovery board based on the STMIcro STM32F407VGT6 MCU.
|
||||
|
||||
configs/sure-pic32mx
|
||||
The "Advanced USB Storage Demo Board," Model DB-DP11215, from Sure
|
||||
@@ -1795,7 +1888,7 @@ configs/vsn
|
||||
|
||||
configs/xtrs
|
||||
TRS80 Model 3. This port uses a vintage computer based on the Z80.
|
||||
An emulator for this computer is available to run TRS80 programs on a
|
||||
An emulator for this computer is available to run TRS80 programs on a
|
||||
linux platform (http://www.tim-mann.org/xtrs.html).
|
||||
|
||||
configs/z16f2800100zcog
|
||||
@@ -1846,7 +1939,7 @@ And if configs/<board-name>/<config-dir>/appconfig exists and your
|
||||
application directory is not in the standard loction (../apps), then
|
||||
you should also specify the location of the application directory on the
|
||||
command line like:
|
||||
|
||||
|
||||
cd tools
|
||||
./configure.sh -a <app-dir> <board-name>/<config-dir>
|
||||
|
||||
|
||||
@@ -39,12 +39,8 @@
|
||||
# Make.defs in the per-config directories.
|
||||
#
|
||||
|
||||
#
|
||||
# We only support building with the ARM bare-metal toolchain from
|
||||
# https://launchpad.net/gcc-arm-embedded on Windows, Linux or Mac OS.
|
||||
#
|
||||
|
||||
CROSSDEV = arm-none-eabi-
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
|
||||
@@ -93,6 +93,9 @@ CONFIG_ARCH_MATH_H=y
|
||||
|
||||
CONFIG_ARMV7M_CMNVECTOR=y
|
||||
|
||||
# default to a generic arm-none-eabi toolchain
|
||||
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y
|
||||
|
||||
#
|
||||
# JTAG Enable settings (by default JTAG-DP and SW-DP are enabled):
|
||||
#
|
||||
@@ -767,6 +770,8 @@ CONFIG_FS_ROMFS=y
|
||||
# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
|
||||
# Default is 20MHz, current setting 24 MHz
|
||||
#
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_SPI=y
|
||||
CONFIG_MMCSD_NSLOTS=1
|
||||
CONFIG_MMCSD_READONLY=n
|
||||
CONFIG_MMCSD_SPICLOCK=24000000
|
||||
|
||||
@@ -39,12 +39,8 @@
|
||||
# Make.defs in the per-config directories.
|
||||
#
|
||||
|
||||
#
|
||||
# We only support building with the ARM bare-metal toolchain from
|
||||
# https://launchpad.net/gcc-arm-embedded on Windows, Linux or Mac OS.
|
||||
#
|
||||
|
||||
CROSSDEV = arm-none-eabi-
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
|
||||
@@ -89,6 +89,9 @@ CONFIG_ARCH_CALIBRATION=n
|
||||
CONFIG_ARCH_DMA=n
|
||||
CONFIG_ARMV7M_CMNVECTOR=y
|
||||
|
||||
# default to a generic arm-none-eabi toolchain
|
||||
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y
|
||||
|
||||
#
|
||||
# JTAG Enable settings (by default JTAG-DP and SW-DP are disabled):
|
||||
#
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
include ${TOPDIR}/.config
|
||||
|
||||
include $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/common/Make.defs
|
||||
@@ -1,43 +0,0 @@
|
||||
############################################################################
|
||||
# configs/stm3210e-eval/nsh/appconfig
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Path to example in apps/examples containing the user_start entry point
|
||||
|
||||
CONFIGURED_APPS += examples/nsh
|
||||
|
||||
CONFIGURED_APPS += system/readline
|
||||
CONFIGURED_APPS += nshlib
|
||||
CONFIGURED_APPS += reboot
|
||||
|
||||
@@ -1,565 +0,0 @@
|
||||
############################################################################
|
||||
# configs/px4io/nsh/defconfig
|
||||
#
|
||||
# Copyright (C) 2009-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.
|
||||
#
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
|
||||
# processor architecture.
|
||||
# CONFIG_ARCH_family - for use in C code. This identifies the
|
||||
# particular chip family that the architecture is implemented
|
||||
# in.
|
||||
# CONFIG_ARCH_architecture - for use in C code. This identifies the
|
||||
# specific architecture within the chip familyl.
|
||||
# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
|
||||
# CONFIG_ARCH_CHIP_name - For use in C code
|
||||
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
|
||||
# the board that supports the particular chip or SoC.
|
||||
# CONFIG_ARCH_BOARD_name - for use in C code
|
||||
# CONFIG_ENDIAN_BIG - define if big endian (default is little endian)
|
||||
# CONFIG_BOARD_LOOPSPERMSEC - for delay loops
|
||||
# CONFIG_DRAM_SIZE - Describes the installed DRAM.
|
||||
# CONFIG_DRAM_START - The start address of DRAM (physical)
|
||||
# CONFIG_DRAM_END - Last address+1 of installed RAM
|
||||
# CONFIG_ARCH_IRQPRIO - The ST32F100CB supports interrupt prioritization
|
||||
# CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
|
||||
# stack. If defined, this symbol is the size of the interrupt
|
||||
# stack in bytes. If not defined, the user task stacks will be
|
||||
# used during interrupt handling.
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader.
|
||||
# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
|
||||
# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture.
|
||||
# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
|
||||
# cause a 100 second delay during boot-up. This 100 second delay
|
||||
# serves no purpose other than it allows you to calibrate
|
||||
# CONFIG_BOARD_LOOPSPERMSEC. You simply use a stop watch to measure
|
||||
# the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until
|
||||
# the delay actually is 100 seconds.
|
||||
# CONFIG_ARCH_DMA - Support DMA initialization
|
||||
#
|
||||
CONFIG_ARCH=arm
|
||||
CONFIG_ARCH_ARM=y
|
||||
CONFIG_ARCH_CORTEXM3=y
|
||||
CONFIG_ARCH_CHIP=stm32
|
||||
CONFIG_ARCH_CHIP_STM32F100C8=y
|
||||
CONFIG_ARCH_BOARD=px4io
|
||||
CONFIG_ARCH_BOARD_PX4IO=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=24000
|
||||
CONFIG_DRAM_SIZE=0x00002000
|
||||
CONFIG_DRAM_START=0x20000000
|
||||
CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE)
|
||||
CONFIG_ARCH_IRQPRIO=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=n
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_BOOTLOADER=n
|
||||
CONFIG_ARCH_LEDS=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CALIBRATION=n
|
||||
CONFIG_ARCH_DMA=n
|
||||
CONFIG_ARMV7M_CMNVECTOR=y
|
||||
|
||||
#
|
||||
# JTAG Enable settings (by default JTAG-DP and SW-DP are disabled):
|
||||
#
|
||||
# CONFIG_STM32_DFU - Use the DFU bootloader, not JTAG
|
||||
#
|
||||
# JTAG Enable options:
|
||||
#
|
||||
# CONFIG_STM32_JTAG_FULL_ENABLE - Enables full SWJ (JTAG-DP + SW-DP)
|
||||
# CONFIG_STM32_JTAG_NOJNTRST_ENABLE - Enables full SWJ (JTAG-DP + SW-DP)
|
||||
# but without JNTRST.
|
||||
# CONFIG_STM32_JTAG_SW_ENABLE - Set JTAG-DP disabled and SW-DP enabled
|
||||
#
|
||||
CONFIG_STM32_DFU=n
|
||||
CONFIG_STM32_JTAG_FULL_ENABLE=y
|
||||
CONFIG_STM32_JTAG_NOJNTRST_ENABLE=n
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=n
|
||||
|
||||
#
|
||||
# Individual subsystems can be enabled:
|
||||
# AHB:
|
||||
CONFIG_STM32_DMA1=n
|
||||
CONFIG_STM32_DMA2=n
|
||||
CONFIG_STM32_CRC=n
|
||||
# APB1:
|
||||
# Timers 2,3 and 4 are owned by the PWM driver
|
||||
CONFIG_STM32_TIM2=n
|
||||
CONFIG_STM32_TIM3=n
|
||||
CONFIG_STM32_TIM4=n
|
||||
CONFIG_STM32_TIM5=n
|
||||
CONFIG_STM32_TIM6=n
|
||||
CONFIG_STM32_TIM7=n
|
||||
CONFIG_STM32_WWDG=n
|
||||
CONFIG_STM32_SPI2=n
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_STM32_USART3=y
|
||||
CONFIG_STM32_I2C1=y
|
||||
CONFIG_STM32_I2C2=n
|
||||
CONFIG_STM32_BKP=n
|
||||
CONFIG_STM32_PWR=n
|
||||
CONFIG_STM32_DAC=n
|
||||
# APB2:
|
||||
CONFIG_STM32_ADC1=y
|
||||
CONFIG_STM32_ADC2=n
|
||||
# TIM1 is owned by the HRT
|
||||
CONFIG_STM32_TIM1=n
|
||||
CONFIG_STM32_SPI1=n
|
||||
CONFIG_STM32_TIM8=n
|
||||
CONFIG_STM32_USART1=y
|
||||
CONFIG_STM32_ADC3=n
|
||||
|
||||
#
|
||||
# Timer and I2C devices may need to the following to force power to be applied:
|
||||
#
|
||||
#CONFIG_STM32_FORCEPOWER=y
|
||||
|
||||
#
|
||||
# STM32F100 specific serial device driver settings
|
||||
#
|
||||
# CONFIG_USARTn_SERIAL_CONSOLE - selects the USARTn for the
|
||||
# console and ttys0 (default is the USART1).
|
||||
# CONFIG_USARTn_RXBUFSIZE - Characters are buffered as received.
|
||||
# This specific the size of the receive buffer
|
||||
# CONFIG_USARTn_TXBUFSIZE - Characters are buffered before
|
||||
# being sent. This specific the size of the transmit buffer
|
||||
# CONFIG_USARTn_BAUD - The configure BAUD of the UART. Must be
|
||||
# CONFIG_USARTn_BITS - The number of bits. Must be either 7 or 8.
|
||||
# CONFIG_USARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
|
||||
# CONFIG_USARTn_2STOP - Two stop bits
|
||||
#
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_SERIAL_CONSOLE=n
|
||||
CONFIG_USART3_SERIAL_CONSOLE=n
|
||||
|
||||
CONFIG_USART1_TXBUFSIZE=64
|
||||
CONFIG_USART2_TXBUFSIZE=64
|
||||
CONFIG_USART3_TXBUFSIZE=64
|
||||
|
||||
CONFIG_USART1_RXBUFSIZE=64
|
||||
CONFIG_USART2_RXBUFSIZE=64
|
||||
CONFIG_USART3_RXBUFSIZE=64
|
||||
|
||||
CONFIG_USART1_BAUD=57600
|
||||
CONFIG_USART2_BAUD=115200
|
||||
CONFIG_USART3_BAUD=115200
|
||||
|
||||
CONFIG_USART1_BITS=8
|
||||
CONFIG_USART2_BITS=8
|
||||
CONFIG_USART3_BITS=8
|
||||
|
||||
CONFIG_USART1_PARITY=0
|
||||
CONFIG_USART2_PARITY=0
|
||||
CONFIG_USART3_PARITY=0
|
||||
|
||||
CONFIG_USART1_2STOP=0
|
||||
CONFIG_USART2_2STOP=0
|
||||
CONFIG_USART3_2STOP=0
|
||||
|
||||
#
|
||||
# PX4IO specific driver settings
|
||||
#
|
||||
# CONFIG_HRT_TIMER
|
||||
# Enables the high-resolution timer. The board definition must
|
||||
# set HRT_TIMER and HRT_TIMER_CHANNEL to the timer and capture/
|
||||
# compare channels to be used.
|
||||
# CONFIG_HRT_PPM
|
||||
# Enables R/C PPM input using the HRT. The board definition must
|
||||
# set HRT_PPM_CHANNEL to the timer capture/compare channel to be
|
||||
# used, and define GPIO_PPM_IN to configure the appropriate timer
|
||||
# GPIO.
|
||||
# CONFIG_PWM_SERVO
|
||||
# Enables the PWM servo driver. The driver configuration must be
|
||||
# supplied by the board support at initialisation time.
|
||||
# Note that USART2 must be disabled on the PX4 board for this to
|
||||
# be available.
|
||||
#
|
||||
#
|
||||
CONFIG_HRT_TIMER=y
|
||||
CONFIG_HRT_PPM=y
|
||||
CONFIG_PWM_SERVO=y
|
||||
|
||||
#
|
||||
# General build options
|
||||
#
|
||||
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
|
||||
# BSPs from www.ridgerun.com using the tools/mkimage.sh script
|
||||
# CONFIG_INTELHEX_BINARY - make the Intel HEX binary format
|
||||
# used with many different loaders using the GNU objcopy program
|
||||
# Should not be selected if you are not using the GNU toolchain.
|
||||
# CONFIG_MOTOROLA_SREC - make the Motorola S-Record binary format
|
||||
# used with many different loaders using the GNU objcopy program
|
||||
# Should not be selected if you are not using the GNU toolchain.
|
||||
# CONFIG_RAW_BINARY - make a raw binary format file used with many
|
||||
# different loaders using the GNU objcopy program. This option
|
||||
# should not be selected if you are not using the GNU toolchain.
|
||||
# CONFIG_HAVE_LIBM - toolchain supports libm.a
|
||||
#
|
||||
CONFIG_RRLOAD_BINARY=n
|
||||
CONFIG_INTELHEX_BINARY=n
|
||||
CONFIG_MOTOROLA_SREC=n
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_HAVE_LIBM=n
|
||||
|
||||
#
|
||||
# General OS setup
|
||||
#
|
||||
# CONFIG_APPS_DIR - Identifies the relative path to the directory
|
||||
# that builds the application to link with NuttX. Default: ../apps
|
||||
# CONFIG_DEBUG - enables built-in debug options
|
||||
# CONFIG_DEBUG_VERBOSE - enables verbose debug output
|
||||
# CONFIG_DEBUG_SYMBOLS - build without optimization and with
|
||||
# debug symbols (needed for use with a debugger).
|
||||
# CONFIG_HAVE_CXX - Enable support for C++
|
||||
# CONFIG_HAVE_CXXINITIALIZE - The platform-specific logic includes support
|
||||
# for initialization of static C++ instances for this architecture
|
||||
# and for the selected toolchain (via up_cxxinitialize()).
|
||||
# CONFIG_MM_REGIONS - If the architecture includes multiple
|
||||
# regions of memory to allocate from, this specifies the
|
||||
# number of memory regions that the memory manager must
|
||||
# handle and enables the API mm_addregion(start, end);
|
||||
# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot
|
||||
# time console output
|
||||
# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz
|
||||
# or MSEC_PER_TICK=10. This setting may be defined to
|
||||
# inform NuttX that the processor hardware is providing
|
||||
# system timer interrupts at some interrupt interval other
|
||||
# than 10 msec.
|
||||
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
|
||||
# this number of milliseconds; Round robin scheduling can
|
||||
# be disabled by setting this value to zero.
|
||||
# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
|
||||
# scheduler to monitor system performance
|
||||
# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a
|
||||
# task name to save in the TCB. Useful if scheduler
|
||||
# instrumentation is selected. Set to zero to disable.
|
||||
# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
|
||||
# Used to initialize the internal time logic.
|
||||
# CONFIG_GREGORIAN_TIME - Enables Gregorian time conversions.
|
||||
# You would only need this if you are concerned about accurate
|
||||
# time conversions in the past or in the distant future.
|
||||
# CONFIG_JULIAN_TIME - Enables Julian time conversions. You
|
||||
# would only need this if you are concerned about accurate
|
||||
# time conversion in the distand past. You must also define
|
||||
# CONFIG_GREGORIAN_TIME in order to use Julian time.
|
||||
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
|
||||
# provides /dev/console. Enables stdout, stderr, stdin.
|
||||
# CONFIG_DEV_LOWCONSOLE - Use the simple, low-level serial console
|
||||
# driver (minimul support)
|
||||
# CONFIG_MUTEX_TYPES: Set to enable support for recursive and
|
||||
# errorcheck mutexes. Enables pthread_mutexattr_settype().
|
||||
# CONFIG_PRIORITY_INHERITANCE : Set to enable support for priority
|
||||
# inheritance on mutexes and semaphores.
|
||||
# CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority
|
||||
# inheritance is enabled. It defines the maximum number of
|
||||
# different threads (minus one) that can take counts on a
|
||||
# semaphore with priority inheritance support. This may be
|
||||
# set to zero if priority inheritance is disabled OR if you
|
||||
# are only using semaphores as mutexes (only one holder) OR
|
||||
# if no more than two threads participate using a counting
|
||||
# semaphore.
|
||||
# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled,
|
||||
# then this setting is the maximum number of higher priority
|
||||
# threads (minus 1) than can be waiting for another thread
|
||||
# to release a count on a semaphore. This value may be set
|
||||
# to zero if no more than one thread is expected to wait for
|
||||
# a semaphore.
|
||||
# CONFIG_FDCLONE_DISABLE. Disable cloning of all file descriptors
|
||||
# by task_create() when a new task is started. If set, all
|
||||
# files/drivers will appear to be closed in the new task.
|
||||
# CONFIG_FDCLONE_STDIO. Disable cloning of all but the first
|
||||
# three file descriptors (stdin, stdout, stderr) by task_create()
|
||||
# when a new task is started. If set, all files/drivers will
|
||||
# appear to be closed in the new task except for stdin, stdout,
|
||||
# and stderr.
|
||||
# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket
|
||||
# desciptors by task_create() when a new task is started. If
|
||||
# set, all sockets will appear to be closed in the new task.
|
||||
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
|
||||
# This format will support execution of NuttX binaries located
|
||||
# in a ROMFS filesystem (see examples/nxflat).
|
||||
# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
|
||||
# handle delayed processing from interrupt handlers. This feature
|
||||
# is required for some drivers but, if there are not complaints,
|
||||
# can be safely disabled. The worker thread also performs
|
||||
# garbage collection -- completing any delayed memory deallocations
|
||||
# from interrupt handlers. If the worker thread is disabled,
|
||||
# then that clean will be performed by the IDLE thread instead
|
||||
# (which runs at the lowest of priority and may not be appropriate
|
||||
# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE
|
||||
# is enabled, then the following options can also be used:
|
||||
# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker
|
||||
# thread. Default: 50
|
||||
# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for
|
||||
# work in units of microseconds. Default: 50*1000 (50 MS).
|
||||
# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker
|
||||
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
|
||||
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
|
||||
# the worker thread. Default: 4
|
||||
#
|
||||
#CONFIG_APPS_DIR=
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_HAVE_CXX=n
|
||||
CONFIG_HAVE_CXXINITIALIZE=n
|
||||
CONFIG_MM_REGIONS=1
|
||||
CONFIG_MM_SMALL=y
|
||||
CONFIG_ARCH_LOWPUTC=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_INSTRUMENTATION=n
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_START_YEAR=2009
|
||||
CONFIG_START_MONTH=9
|
||||
CONFIG_START_DAY=21
|
||||
CONFIG_GREGORIAN_TIME=n
|
||||
CONFIG_JULIAN_TIME=n
|
||||
CONFIG_DEV_CONSOLE=y
|
||||
CONFIG_DEV_LOWCONSOLE=n
|
||||
CONFIG_MUTEX_TYPES=n
|
||||
CONFIG_PRIORITY_INHERITANCE=n
|
||||
CONFIG_SEM_PREALLOCHOLDERS=0
|
||||
CONFIG_SEM_NNESTPRIO=0
|
||||
CONFIG_FDCLONE_DISABLE=n
|
||||
CONFIG_FDCLONE_STDIO=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_NXFLAT=n
|
||||
CONFIG_SCHED_WORKQUEUE=n
|
||||
CONFIG_SCHED_WORKPRIORITY=50
|
||||
CONFIG_SCHED_WORKPERIOD=(50*1000)
|
||||
CONFIG_SCHED_WORKSTACKSIZE=512
|
||||
CONFIG_SIG_SIGWORK=4
|
||||
|
||||
#
|
||||
# The following can be used to disable categories of
|
||||
# APIs supported by the OS. If the compiler supports
|
||||
# weak functions, then it should not be necessary to
|
||||
# disable functions unless you want to restrict usage
|
||||
# of those APIs.
|
||||
#
|
||||
# There are certain dependency relationships in these
|
||||
# features.
|
||||
#
|
||||
# o mq_notify logic depends on signals to awaken tasks
|
||||
# waiting for queues to become full or empty.
|
||||
# o pthread_condtimedwait() depends on signals to wake
|
||||
# up waiting tasks.
|
||||
#
|
||||
CONFIG_DISABLE_CLOCK=n
|
||||
CONFIG_DISABLE_POSIX_TIMERS=y
|
||||
CONFIG_DISABLE_PTHREAD=n
|
||||
CONFIG_DISABLE_SIGNALS=n
|
||||
CONFIG_DISABLE_MQUEUE=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
|
||||
#
|
||||
# Misc libc settings
|
||||
#
|
||||
# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a
|
||||
# little smaller if we do not support fieldwidthes
|
||||
#
|
||||
CONFIG_NOPRINTF_FIELDWIDTH=n
|
||||
|
||||
#
|
||||
# Allow for architecture optimized implementations
|
||||
#
|
||||
# The architecture can provide optimized versions of the
|
||||
# following to improve system performance
|
||||
#
|
||||
CONFIG_ARCH_MEMCPY=n
|
||||
CONFIG_ARCH_MEMCMP=n
|
||||
CONFIG_ARCH_MEMMOVE=n
|
||||
CONFIG_ARCH_MEMSET=n
|
||||
CONFIG_ARCH_STRCMP=n
|
||||
CONFIG_ARCH_STRCPY=n
|
||||
CONFIG_ARCH_STRNCPY=n
|
||||
CONFIG_ARCH_STRLEN=n
|
||||
CONFIG_ARCH_STRNLEN=n
|
||||
CONFIG_ARCH_BZERO=n
|
||||
|
||||
#
|
||||
# Sizes of configurable things (0 disables)
|
||||
#
|
||||
# CONFIG_MAX_TASKS - The maximum number of simultaneously
|
||||
# active tasks. This value must be a power of two.
|
||||
# CONFIG_MAX_TASK_ARGS - This controls the maximum number of
|
||||
# of parameters that a task may receive (i.e., maxmum value
|
||||
# of 'argc')
|
||||
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
|
||||
# specific data that can be retained
|
||||
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
|
||||
# descriptors (one for each open)
|
||||
# CONFIG_NFILE_STREAMS - The maximum number of streams that
|
||||
# can be fopen'ed
|
||||
# CONFIG_NAME_MAX - The maximum size of a file name.
|
||||
# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate
|
||||
# on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
|
||||
# CONFIG_NUNGET_CHARS - Number of characters that can be
|
||||
# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
|
||||
# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message
|
||||
# structures. The system manages a pool of preallocated
|
||||
# message structures to minimize dynamic allocations
|
||||
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
|
||||
# a fixed payload size given by this settin (does not include
|
||||
# other message structure overhead.
|
||||
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
|
||||
# can be passed to a watchdog handler
|
||||
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
|
||||
# structures. The system manages a pool of preallocated
|
||||
# watchdog structures to minimize dynamic allocations
|
||||
# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX
|
||||
# timer structures. The system manages a pool of preallocated
|
||||
# timer structures to minimize dynamic allocations. Set to
|
||||
# zero for all dynamic allocations.
|
||||
#
|
||||
CONFIG_MAX_TASKS=4
|
||||
CONFIG_MAX_TASK_ARGS=4
|
||||
CONFIG_NPTHREAD_KEYS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=6
|
||||
CONFIG_NFILE_STREAMS=4
|
||||
CONFIG_NAME_MAX=32
|
||||
CONFIG_STDIO_BUFFER_SIZE=64
|
||||
CONFIG_NUNGET_CHARS=2
|
||||
CONFIG_PREALLOC_MQ_MSGS=1
|
||||
CONFIG_MQ_MAXMSGSIZE=32
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_PREALLOC_WDOGS=3
|
||||
CONFIG_PREALLOC_TIMERS=1
|
||||
|
||||
|
||||
#
|
||||
# Settings for apps/nshlib
|
||||
#
|
||||
# CONFIG_NSH_BUILTIN_APPS - Support external registered,
|
||||
# "named" applications that can be executed from the NSH
|
||||
# command line (see apps/README.txt for more information).
|
||||
# CONFIG_NSH_FILEIOSIZE - Size of a static I/O buffer
|
||||
# CONFIG_NSH_STRERROR - Use strerror(errno)
|
||||
# CONFIG_NSH_LINELEN - Maximum length of one command line
|
||||
# CONFIG_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi
|
||||
# CONFIG_NSH_DISABLESCRIPT - Disable scripting support
|
||||
# CONFIG_NSH_DISABLEBG - Disable background commands
|
||||
# CONFIG_NSH_ROMFSETC - Use startup script in /etc
|
||||
# CONFIG_NSH_CONSOLE - Use serial console front end
|
||||
# CONFIG_NSH_TELNET - Use telnetd console front end
|
||||
# CONFIG_NSH_ARCHINIT - Platform provides architecture
|
||||
# specific initialization (nsh_archinitialize()).
|
||||
#
|
||||
# If CONFIG_NSH_TELNET is selected:
|
||||
# CONFIG_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size
|
||||
# CONFIG_NSH_DHCPC - Obtain address using DHCP
|
||||
# CONFIG_NSH_IPADDR - Provides static IP address
|
||||
# CONFIG_NSH_DRIPADDR - Provides static router IP address
|
||||
# CONFIG_NSH_NETMASK - Provides static network mask
|
||||
# CONFIG_NSH_NOMAC - Use a bogus MAC address
|
||||
#
|
||||
# If CONFIG_NSH_ROMFSETC is selected:
|
||||
# CONFIG_NSH_ROMFSMOUNTPT - ROMFS mountpoint
|
||||
# CONFIG_NSH_INITSCRIPT - Relative path to init script
|
||||
# CONFIG_NSH_ROMFSDEVNO - ROMFS RAM device minor
|
||||
# CONFIG_NSH_ROMFSSECTSIZE - ROMF sector size
|
||||
# CONFIG_NSH_FATDEVNO - FAT FS RAM device minor
|
||||
# CONFIG_NSH_FATSECTSIZE - FAT FS sector size
|
||||
# CONFIG_NSH_FATNSECTORS - FAT FS number of sectors
|
||||
# CONFIG_NSH_FATMOUNTPT - FAT FS mountpoint
|
||||
#
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=64
|
||||
CONFIG_NSH_STRERROR=n
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_NESTDEPTH=1
|
||||
CONFIG_NSH_DISABLESCRIPT=y
|
||||
CONFIG_NSH_DISABLEBG=n
|
||||
CONFIG_NSH_ROMFSETC=n
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
CONFIG_NSH_TELNET=n
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_IOBUFFER_SIZE=256
|
||||
#CONFIG_NSH_STACKSIZE=1024
|
||||
CONFIG_NSH_DHCPC=n
|
||||
CONFIG_NSH_NOMAC=n
|
||||
CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_NSH_ROMFSMOUNTPT="/etc"
|
||||
CONFIG_NSH_INITSCRIPT="init.d/rcS"
|
||||
CONFIG_NSH_ROMFSDEVNO=0
|
||||
CONFIG_NSH_ROMFSSECTSIZE=64
|
||||
CONFIG_NSH_FATDEVNO=1
|
||||
CONFIG_NSH_FATSECTSIZE=512
|
||||
CONFIG_NSH_FATNSECTORS=1024
|
||||
CONFIG_NSH_FATMOUNTPT=/tmp
|
||||
|
||||
#
|
||||
# Architecture-specific NSH options
|
||||
#
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=0
|
||||
CONFIG_NSH_MMCSDSLOTNO=0
|
||||
CONFIG_NSH_MMCSDMINOR=0
|
||||
|
||||
#
|
||||
# Stack and heap information
|
||||
#
|
||||
# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP
|
||||
# operation from FLASH but must copy initialized .data sections to RAM.
|
||||
# (should also be =n for the STM3210E-EVAL which always runs from flash)
|
||||
# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH
|
||||
# but copy themselves entirely into RAM for better performance.
|
||||
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
|
||||
# all stack operations outside of the nuttx model.
|
||||
# CONFIG_STACK_POINTER - The initial stack pointer (arm7tdmi only)
|
||||
# CONFIG_IDLETHREAD_STACKSIZE - The size of the initial stack.
|
||||
# This is the thread that (1) performs the inital boot of the system up
|
||||
# to the point where user_start() is spawned, and (2) there after is the
|
||||
# IDLE thread that executes only when there is no other thread ready to
|
||||
# run.
|
||||
# CONFIG_USERMAIN_STACKSIZE - The size of the stack to allocate
|
||||
# for the main user thread that begins at the user_start() entry point.
|
||||
# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size
|
||||
# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size
|
||||
# CONFIG_HEAP_BASE - The beginning of the heap
|
||||
# CONFIG_HEAP_SIZE - The size of the heap
|
||||
#
|
||||
CONFIG_BOOT_RUNFROMFLASH=n
|
||||
CONFIG_BOOT_COPYTORAM=n
|
||||
CONFIG_CUSTOM_STACK=n
|
||||
CONFIG_STACK_POINTER=
|
||||
CONFIG_IDLETHREAD_STACKSIZE=800
|
||||
CONFIG_USERMAIN_STACKSIZE=1024
|
||||
CONFIG_PTHREAD_STACK_MIN=256
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=512
|
||||
CONFIG_HEAP_BASE=
|
||||
CONFIG_HEAP_SIZE=
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
# configs/stm3210e-eval/dfu/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
if [ "$(basename $0)" = "setenv.sh" ] ; then
|
||||
echo "You must source this script, not run it!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi
|
||||
|
||||
WD=`pwd`
|
||||
export RIDE_BIN="/cygdrive/c/Program Files/Raisonance/Ride/arm-gcc/bin"
|
||||
export BUILDROOT_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
|
||||
export PATH="${BUILDROOT_BIN}:${RIDE_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||
|
||||
echo "PATH : ${PATH}"
|
||||
+41
-35
@@ -47,7 +47,8 @@ config CAN_EXTID
|
||||
bool "CAN extended IDs"
|
||||
default n
|
||||
---help---
|
||||
Enables support for the 29-bit extended ID. Default Standard 11-bit IDs.
|
||||
Enables support for the 29-bit extended ID. Default Standard 11-bit
|
||||
IDs.
|
||||
|
||||
config CAN_FIFOSIZE
|
||||
int "CAN driver I/O buffer size"
|
||||
@@ -83,10 +84,10 @@ config PWM_PULSECOUNT
|
||||
bool "PWM Pulse Count Support"
|
||||
default n
|
||||
---help---
|
||||
Some hardware will support generation of a fixed number of pulses. This
|
||||
might be used, for example to support a stepper motor. If the hardware
|
||||
will support a fixed pulse count, then this configuration should be set to
|
||||
enable the capability.
|
||||
Some hardware will support generation of a fixed number of pulses.
|
||||
This might be used, for example to support a stepper motor. If the
|
||||
hardware will support a fixed pulse count, then this configuration
|
||||
should be set to enable the capability.
|
||||
|
||||
endif
|
||||
|
||||
@@ -147,23 +148,25 @@ config SPI_OWNBUS
|
||||
bool "SPI single device"
|
||||
default n
|
||||
---help---
|
||||
Set if there is only one active device on the SPI bus. No locking or SPI
|
||||
configuration will be performed. It is not necessary for clients to lock,
|
||||
re-configure, etc..
|
||||
Set if there is only one active device on the SPI bus. No locking or
|
||||
SPI configuration will be performed. It is not necessary for clients to
|
||||
lock, re-configure, etc..
|
||||
|
||||
config SPI_EXCHANGE
|
||||
bool "SPI exchange"
|
||||
default y
|
||||
---help---
|
||||
Driver supports a single exchange method (vs a recvblock() and sndblock ()methods).
|
||||
Driver supports a single exchange method (vs a recvblock() and
|
||||
sndblock() methods).
|
||||
|
||||
config SPI_CMDDATA
|
||||
bool "SPI CMD/DATA"
|
||||
default n
|
||||
---help---
|
||||
Devices on the SPI bus require out-of-band support to distinguish command
|
||||
transfers from data transfers. Such devices will often support either 9-bit
|
||||
SPI (yech) or 8-bit SPI and a GPIO output that selects between command and data.
|
||||
Devices on the SPI bus require out-of-band support to distinguish
|
||||
command transfers from data transfers. Such devices will often support
|
||||
either 9-bit SPI (yech) or 8-bit SPI and a GPIO output that selects
|
||||
between command and data.
|
||||
|
||||
endif
|
||||
|
||||
@@ -173,35 +176,36 @@ menuconfig RTC
|
||||
---help---
|
||||
This selection enables configuration of a real time clock (RTCdriver.
|
||||
See include/nuttx/rtc.h for further watchdog timer driver information.
|
||||
Most RTC drivers are MCU specific and may require other specific settings.
|
||||
Most RTC drivers are MCU specific and may require other specific
|
||||
settings.
|
||||
|
||||
config RTC_DATETIME
|
||||
bool "Date/Time RTC Support"
|
||||
default n
|
||||
depends on RTC
|
||||
---help---
|
||||
There are two general types of RTC: (1) A simple battery backed counter
|
||||
that keeps the time when power is down, and (2) a full date / time RTC the
|
||||
provides the date and time information, often in BCD format. If
|
||||
RTC_DATETIME is selected, it specifies this second kind of RTC. In this
|
||||
case, the RTC is used to "seed" the normal NuttX timer and the NuttX system
|
||||
timer provides for higher resolution time.
|
||||
There are two general types of RTC: (1) A simple battery backed
|
||||
counter that keeps the time when power is down, and (2) a full
|
||||
date / time RTC the provides the date and time information, often in
|
||||
BCD format. If RTC_DATETIME is selected, it specifies this second kind
|
||||
of RTC. In this case, the RTC is used to "seed" the normal NuttX timer
|
||||
and the NuttX system timer provides for higher resolution time.
|
||||
|
||||
config RTC_HIRES
|
||||
bool "Hi-Res RTC Support"
|
||||
default n
|
||||
depends on RTC && !RTC_DATETIME
|
||||
---help---
|
||||
If RTC_DATETIME not selected, then the simple, battery backed counter is
|
||||
used. There are two different implementations of such simple counters
|
||||
based on the time resolution of the counter: The typical RTC keeps time
|
||||
to resolution of 1 second, usually supporting a 32-bit time_t value. In
|
||||
this case, the RTC is used to "seed" the normal NuttX timer and the NuttX
|
||||
timer provides for higherresoution time.
|
||||
If RTC_DATETIME not selected, then the simple, battery backed counter
|
||||
is used. There are two different implementations of such simple
|
||||
counters based on the time resolution of the counter: The typical RTC
|
||||
keeps time to resolution of 1 second, usually supporting a 32-bit
|
||||
time_t value. In this case, the RTC is used to "seed" the normal NuttX
|
||||
timer and the NuttX timer provides for higherresoution time.
|
||||
|
||||
If RTC_HIRES is enabled in the NuttX configuration, then the RTC provides
|
||||
higher resolution time and completely replaces the system timer for purpose
|
||||
of date and time.
|
||||
If RTC_HIRES is enabled in the NuttX configuration, then the RTC
|
||||
provides higher resolution time and completely replaces the system
|
||||
timer for purpose of date and time.
|
||||
|
||||
config RTC_FREQUENCY
|
||||
int "Hi-Res RTC frequency"
|
||||
@@ -209,8 +213,8 @@ config RTC_FREQUENCY
|
||||
depends on RTC && !RTC_DATETIME && RTC_HIRES
|
||||
---help---
|
||||
If RTC_HIRES is defined, then the frequency of the high resolution RTC
|
||||
must be provided. If RTC_HIRES is not defined, RTC_FREQUENCY is assumed
|
||||
to be one Hz.
|
||||
must be provided. If RTC_HIRES is not defined, RTC_FREQUENCY is
|
||||
assumed to be one Hz.
|
||||
|
||||
config RTC_ALARM
|
||||
bool "RTC Alarm Support"
|
||||
@@ -224,8 +228,9 @@ menuconfig WATCHDOG
|
||||
bool "Watchdog Timer Support"
|
||||
default n
|
||||
---help---
|
||||
This selection enables building of the "upper-half" watchdog timer driver.
|
||||
See include/nuttx/watchdog.h for further watchdog timer driver information.
|
||||
This selection enables building of the "upper-half" watchdog timer
|
||||
driver. See include/nuttx/watchdog.h for further watchdog timer driver
|
||||
information.
|
||||
|
||||
if WATCHDOG
|
||||
endif
|
||||
@@ -348,7 +353,8 @@ menuconfig POWER
|
||||
bool "Power Management Support"
|
||||
default n
|
||||
---help---
|
||||
Enable building of power-related devices (battery monitors, chargers, etc).
|
||||
Enable building of power-related devices (battery monitors, chargers,
|
||||
etc).
|
||||
|
||||
if POWER
|
||||
source drivers/power/Kconfig
|
||||
@@ -386,8 +392,8 @@ menuconfig SERIAL
|
||||
default y
|
||||
---help---
|
||||
Front-end character drivers for chip-specific UARTs. This provide
|
||||
some TTY-like functionality and are commonly used (but not required for)
|
||||
the NuttX system console. See also include/nuttx/serial/serial.h
|
||||
some TTY-like functionality and are commonly used (but not required
|
||||
for) the NuttX system console. See also include/nuttx/serial/serial.h
|
||||
|
||||
if SERIAL
|
||||
source drivers/serial/Kconfig
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user