Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 11 additions & 26 deletions Documentation/applications/examples/elf/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,26 @@ Configuration options:

**Notes**:

1. ``CFLAGS`` should be provided in ``CELFFLAGS``. RAM and FLASH memory regions may
require long allcs. For ARM, this might be::

CELFFLAGS = $(CFLAGS) -mlong-calls

Similarly for C++ flags which must be provided in ``CXXELFFLAGS``.

2. Your top-level ``nuttx/Make.defs`` file must also include an appropriate
definition, ``LDELFFLAGS``, to generate a relocatable ELF object. With GNU LD,
this should include ``-r`` and ``-e main`` (or ``_main`` on some platforms).::

LDELFFLAGS = -r -e main

If you use GCC to link, you make also need to include ``-nostdlib``.

3. ELF size: The ELF files in this example are, be default, quite large because
1. The arch ``Toolchain.defs`` sets ``CELFFLAGS``, ``CXXELFFLAGS`` and
``LDELFFLAGS``. For example, on ARM they contain ``-mlong-calls``, the entry
point ``_start`` and the linker script ``libs/libc/elf/gnu-elf.ld``. A board
``scripts/Make.defs`` can add an option with ``+=``, for example
``LDELFFLAGS += -melf32lriscv``. Do not set these variables again with
``=``: the board then loses the options that the arch adds for the
configuration, for example ``crt0.o`` and the PIC and FDPIC options.

2. ELF size: The ELF files in this example are, be default, quite large because
they include a lot of build garbage. You can greatly reduce the size of the
ELF binaries are using the ``objcopy --strip-unneeded`` command to remove
un-necessary information from the ELF files.

4. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
3. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
That is because the Cygwin GCC does not generate ELF file but rather some
Windows-native binary format.

If you really want to do this, you can create a NuttX x86 buildroot toolchain
and use that be build the ELF executables for the ROMFS file system.

5. Linker scripts. You might also want to use a linker scripts to combine
sections better. An example linker script is at
``nuttx/binfmt/elf/gnu-elf.ld``. That example might have to be tuned for
your particular linker output to position additional sections correctly. The
GNU LD ``LDELFFLAGS`` then might be::

LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/elf/gnu-elf.ld

6. When generating the ``romfs.img`` for external filesystem the image (``romfs.img``)
4. When generating the ``romfs.img`` for external filesystem the image (``romfs.img``)
needs to be manually copied to the start of the configured ``CONFIG_EXAMPLES_ELF_DEVPATH``
using ``openocd`` or your preferred programmer.
36 changes: 10 additions & 26 deletions Documentation/applications/examples/module/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,27 @@ configuration options:

**Notes**:

1. ``CFLAGS`` should be provided in ``CMODULEFLAGS``. RAM and FLASH memory regions
may require long allcs. For ARM, this might be::

CMODULEFLAGS = $(CFLAGS) -mlong-calls

Similarly for C++ flags which must be provided in ``CXXMODULEFLAGS``.

2. Your top-level ``nuttx/Make.defs`` file must also include an appropriate
definition, LDMODULEFLAGS, to generate a relocatable ELF object. With GNU LD,
this should include ``-r`` and ``-e <entry point>``.::

LDMODULEFLAGS = -r -e module_initialize

If you use GCC to link, you make also need to include ``-nostdlib``.

3. This example also requires ``genromfs``. ``genromfs`` can be build as part of the
1. The arch ``Toolchain.defs`` sets ``CMODULEFLAGS`` and ``LDMODULEFLAGS``. For
example, on ARM they contain ``-mlong-calls``, ``-r`` and the linker script
``libs/libc/elf/gnu-elf.ld``. A board ``scripts/Make.defs`` can add an option
with ``+=``, for example ``LDMODULEFLAGS += -melf32lriscv``. Do not set these
variables again with ``=``: the board then loses the options that the arch
adds for the configuration, for example the FDPIC options.

2. This example also requires ``genromfs``. ``genromfs`` can be build as part of the
nuttx toolchain. Or can built from the ``genromfs`` sources that can be found
in the NuttX tools repository (``genromfs-0.5.2.tar.gz``). In any event, the
PATH variable must include the path to the ``genromfs`` executable.

4. ELF size: The ELF files in this example are, be default, quite large because
3. ELF size: The ELF files in this example are, be default, quite large because
they include a lot of build garbage. You can greatly reduce the size of the
ELF binaries are using the ``objcopy --strip-unneeded`` command to remove
un-necessary information from the ELF files.

5. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
4. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
That is because the Cygwin GCC does not generate ELF file but rather some
Windows-native binary format.

If you really want to do this, you can create a NuttX x86 ``buildroot``
toolchain and use that be build the ELF executables for the ROMFS file
system.

6. Linker scripts. You might also want to use a linker scripts to combine
sections better. An example linker script is at
``nuttx/libc/elf/gnu-elf.ld``. That example might have to be tuned for your
particular linker output to position additional sections correctly. The GNU
LD ``LDMODULEFLAGS`` then might be::

LDMODULEFLAGS = -r -e module_initialize -T$(TOPDIR)/libc/elf/gnu-elf.ld
37 changes: 11 additions & 26 deletions Documentation/applications/examples/posix_spawn/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,27 @@ Test-specific configuration options:

**Notes**:

1. ``CFLAGS`` should be provided in ``CELFFLAGS``. RAM and FLASH memory regions may
require long allcs. For ARM, this might be::

CELFFLAGS = $(CFLAGS) -mlong-calls

Similarly for C++ flags which must be provided in ``CXXELFFLAGS``.

2. Your top-level ``nuttx/Make.defs`` file must also include an appropriate
definition, ``LDELFFLAGS``, to generate a relocatable ELF object. With GNU LD,
this should include ``-r`` and ``-e main`` (or ``_main`` on some platforms).::

LDELFFLAGS = -r -e main

If you use GCC to link, you make also need to include ``-nostdlib``.

3. This example also requires ``genromfs``. ``genromfs`` can be build as part of the
1. The arch ``Toolchain.defs`` sets ``CELFFLAGS``, ``CXXELFFLAGS`` and
``LDELFFLAGS``. For example, on ARM they contain ``-mlong-calls``, the entry
point ``_start`` and the linker script ``libs/libc/elf/gnu-elf.ld``. A board
``scripts/Make.defs`` can add an option with ``+=``, for example
``LDELFFLAGS += -melf32lriscv``. Do not set these variables again with
``=``: the board then loses the options that the arch adds for the
configuration, for example ``crt0.o`` and the PIC and FDPIC options.

2. This example also requires ``genromfs``. ``genromfs`` can be build as part of the
nuttx toolchain. Or can built from the ``genromfs`` sources that can be found
in the NuttX tools repository (``genromfs-0.5.2.tar.gz``). In any event, the
``PATH`` variable must include the path to the ``genromfs`` executable.

4. ELF size: The ELF files in this example are, be default, quite large because
3. ELF size: The ELF files in this example are, be default, quite large because
they include a lot of build garbage. You can greatly reduce the size of the
ELF binaries are using the ``objcopy --strip-unneeded`` command to remove
un-necessary information from the ELF files.

5. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
4. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
That is because the Cygwin GCC does not generate ELF file but rather some
Windows-native binary format.

If you really want to do this, you can create a NuttX x86 buildroot toolchain
and use that be build the ELF executables for the ROMFS file system.

6. Linker scripts. You might also want to use a linker scripts to combine
sections better. An example linker script is at
``nuttx/binfmt/elf/gnu-elf.ld``. That example might have to be tuned for
your particular linker output to position additional sections correctly. The
GNU LD ``LDELFFLAGS`` then might be::

LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/elf/gnu-elf.ld
36 changes: 10 additions & 26 deletions Documentation/applications/examples/sotest/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,26 @@ system. At run time, the shared library is installed and exercised. Requires

**Notes**:

1. ``CFLAGS`` should be provided in ``CMODULEFLAGS``. RAM and FLASH memory regions
may require long allcs. For ARM, this might be::

CMODULEFLAGS = $(CFLAGS) -mlong-calls

Similarly for C++ flags which must be provided in ``CXXMODULEFLAGS``.

2. Your top-level ``nuttx/Make.defs`` file must also include an appropriate
definition, ``LDMODULEFLAGS``, to generate a relocatable ELF object. With GNU
LD, this should include ``-r`` and ``-e <entry point>``.::

LDMODULEFLAGS = -r -e module_initialize

If you use GCC to link, you make also need to include ``-nostdlib``.

3. This example also requires ``genromfs``. ``genromfs`` can be built as part of the
1. The arch ``Toolchain.defs`` sets ``CMODULEFLAGS`` and ``LDMODULEFLAGS``. For
example, on ARM they contain ``-mlong-calls``, ``-r`` and the linker script
``libs/libc/elf/gnu-elf.ld``. A board ``scripts/Make.defs`` can add an option
with ``+=``, for example ``LDMODULEFLAGS += -melf32lriscv``. Do not set these
variables again with ``=``: the board then loses the options that the arch
adds for the configuration, for example the FDPIC options.

2. This example also requires ``genromfs``. ``genromfs`` can be built as part of the
nuttx toolchain. Or can built from the ``genromfs`` sources that can be found
in the NuttX tools repository (``genromfs-0.5.2.tar.gz``). In any event, the
``PATH`` variable must include the path to the ``genromfs`` executable.

4. ELF size: The ELF files in this example are, be default, quite large because
3. ELF size: The ELF files in this example are, be default, quite large because
they include a lot of build garbage. You can greatly reduce the size of the
ELF binaries are using the ``objcopy --strip-unneeded`` command to remove
un-necessary information from the ELF files.

5. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
4. Simulator. You cannot use this example with the NuttX simulator on Cygwin.
That is because the Cygwin GCC does not generate ELF file but rather some
Windows-native binary format.

If you really want to do this, you can create a NuttX x86 buildroot toolchain
and use that to build the ELF executables for the ROMFS file system.

6. Linker scripts. You might also want to use a linker script to combine
sections better. An example linker script is at
``nuttx/libc/elf/gnu-elf.ld``. That example might have to be tuned for your
particular linker output to position additional sections correctly. The GNU
LD ``LDMODULEFLAGS`` then might be::

LDMODULEFLAGS = -r -e module_initialize -T$(TOPDIR)/libc/elf/gnu-elf.ld
7 changes: 0 additions & 7 deletions boards/arm/imx9/imx93-qsb/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
7 changes: 0 additions & 7 deletions boards/arm/imx9/imx95-evk/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
7 changes: 0 additions & 7 deletions boards/arm/imx9/mr-navq95b/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
7 changes: 0 additions & 7 deletions boards/arm/imxrt/fmu-v6xrt/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
7 changes: 0 additions & 7 deletions boards/arm/imxrt/imxrt1170-evk/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
12 changes: 0 additions & 12 deletions boards/arm/sama5/sama5d3-xplained/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
7 changes: 0 additions & 7 deletions boards/arm/samv7/samv71-xult/configs/knsh/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
12 changes: 0 additions & 12 deletions boards/arm/stm32h7/devebox-stm32h743/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
12 changes: 0 additions & 12 deletions boards/arm/stm32h7/linum-stm32h753bi/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
12 changes: 0 additions & 12 deletions boards/arm/stm32h7/openh743i/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
12 changes: 0 additions & 12 deletions boards/arm/stm32h7/weact-stm32h743/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
12 changes: 0 additions & 12 deletions boards/arm/stm32h7/weact-stm32h750/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
7 changes: 0 additions & 7 deletions boards/arm/xmc4/xmc4800-relax/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# Loadable module definitions

CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs

LDMODULEFLAGS = -r -e module_initialize
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
3 changes: 0 additions & 3 deletions boards/arm64/imx9/imx95-a55-evk/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
Loading
Loading