2012-10-25 22:06:46 +02:00
|
|
|
/****************************************************************************
|
2021-05-08 20:33:52 +02:00
|
|
|
* apps/examples/elf/elf_main.c
|
2012-10-25 22:06:46 +02:00
|
|
|
*
|
2020-04-11 20:13:56 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2012-10-25 22:06:46 +02:00
|
|
|
*
|
2020-04-11 20:13:56 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-10-25 22:06:46 +02:00
|
|
|
*
|
2020-04-11 20:13:56 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2012-10-25 22:06:46 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <nuttx/compiler.h>
|
2021-05-08 20:33:52 +02:00
|
|
|
#include <sys/boardctl.h>
|
2012-10-25 22:06:46 +02:00
|
|
|
|
|
|
|
#include <sys/mount.h>
|
2018-08-05 00:24:02 +02:00
|
|
|
#include <sys/stat.h>
|
2012-10-29 20:32:05 +01:00
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2020-06-15 08:02:49 +02:00
|
|
|
#include <malloc.h>
|
2012-10-25 22:06:46 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2017-10-02 22:32:17 +02:00
|
|
|
#include <nuttx/symtab.h>
|
2016-07-20 22:02:41 +02:00
|
|
|
#include <nuttx/drivers/ramdisk.h>
|
2012-10-25 22:06:46 +02:00
|
|
|
#include <nuttx/binfmt/binfmt.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-10-02 22:06:11 +02:00
|
|
|
* Pre-processor Definitions
|
2012-10-25 22:06:46 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Check configuration. This is not all of the configuration settings that
|
|
|
|
* are required -- only the more obvious.
|
|
|
|
*/
|
|
|
|
|
2012-12-19 22:16:03 +01:00
|
|
|
#ifdef CONFIG_BINFMT_DISABLE
|
|
|
|
# error "The binary loader is disabled (CONFIG_BINFMT_DISABLE)!"
|
|
|
|
#endif
|
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
#ifndef CONFIG_ELF
|
|
|
|
# error "You must select CONFIG_ELF in your configuration file"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
|
|
|
# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file"
|
|
|
|
#endif
|
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
#if defined(CONFIG_EXAMPLES_ELF_ROMFS)
|
2012-10-25 22:06:46 +02:00
|
|
|
/* Describe the ROMFS file system */
|
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
# define SECTORSIZE 512
|
|
|
|
# define NSECTORS(b) (((b) + SECTORSIZE - 1) / SECTORSIZE)
|
|
|
|
# define MOUNTPT "/mnt/romfs"
|
2012-10-25 22:06:46 +02:00
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
# ifndef CONFIG_EXAMPLES_ELF_DEVMINOR
|
|
|
|
# define CONFIG_EXAMPLES_ELF_DEVMINOR 0
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef CONFIG_EXAMPLES_ELF_DEVPATH
|
|
|
|
# define CONFIG_EXAMPLES_ELF_DEVPATH "/dev/ram0"
|
|
|
|
# endif
|
|
|
|
|
2018-08-04 21:10:40 +02:00
|
|
|
#elif defined(CONFIG_EXAMPLES_ELF_CROMFS)
|
2018-03-24 18:36:20 +01:00
|
|
|
/* Describe the CROMFS file system */
|
2012-10-26 00:10:56 +02:00
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
# define MOUNTPT "/mnt/cromfs"
|
2018-08-04 21:10:40 +02:00
|
|
|
|
apps/examples/elf: Correct mount point configuration error.
If an external file system is used but is not mounted by the the ELF example, then a compilation error will occur. This configuration problem has existed for a long time but was unmasked by a recent PR. In the failure mode, CONFIG_EXAMPLES_ELF_FSTYPE would not be defined because it depends on CONFIG_EXAMPLES_ELF_FSMOUNT which is not defined. The resulting mountpoint, MOUNTPT, would therefore be left in an invalid state. Previous changes to conditional logic now allowed setenv() to run and to attempt to set the PATH variable to MOUNTPT, causing a compile time failure like this:
CC: elf_main.c
elf_main.c: In function 'elf_main':
elf_main.c:113:32: error: expected ')' before 'CONFIG_EXAMPLES_ELF_FSTYPE'
# define MOUNTPT "/mnt/" CONFIG_EXAMPLES_ELF_FSTYPE
^~~~~~~~~~~~~~~~~~~~~~~~~~
elf_main.c:364:18: note: in expansion of macro 'MOUNTPT'
setenv("PATH", MOUNTPT, 1);
^~~~~~~
elf_main.c:364:3: error: too few arguments to function 'setenv'
setenv("PATH", MOUNTPT, 1);
^~~~~~
In file included from elf_main.c:47:
D:\Spuda\Documents\projects\nuttx\master\nuttx-fork\include/stdlib.h:158:11: note: declared here
int setenv(FAR const char *name, FAR const char *value, int overwrite);
^~~~~~
This problem was found during manual build testing using configuration lx_cpu:nsh.
2020-02-15 17:14:03 +01:00
|
|
|
#elif defined(CONFIG_EXAMPLES_ELF_EXTERN) && defined(CONFIG_EXAMPLES_ELF_FSMOUNT)
|
2018-08-04 21:10:40 +02:00
|
|
|
/* Describe the external file system */
|
|
|
|
|
|
|
|
# define MOUNTPT "/mnt/" CONFIG_EXAMPLES_ELF_FSTYPE
|
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
#else
|
apps/examples/elf: Correct mount point configuration error.
If an external file system is used but is not mounted by the the ELF example, then a compilation error will occur. This configuration problem has existed for a long time but was unmasked by a recent PR. In the failure mode, CONFIG_EXAMPLES_ELF_FSTYPE would not be defined because it depends on CONFIG_EXAMPLES_ELF_FSMOUNT which is not defined. The resulting mountpoint, MOUNTPT, would therefore be left in an invalid state. Previous changes to conditional logic now allowed setenv() to run and to attempt to set the PATH variable to MOUNTPT, causing a compile time failure like this:
CC: elf_main.c
elf_main.c: In function 'elf_main':
elf_main.c:113:32: error: expected ')' before 'CONFIG_EXAMPLES_ELF_FSTYPE'
# define MOUNTPT "/mnt/" CONFIG_EXAMPLES_ELF_FSTYPE
^~~~~~~~~~~~~~~~~~~~~~~~~~
elf_main.c:364:18: note: in expansion of macro 'MOUNTPT'
setenv("PATH", MOUNTPT, 1);
^~~~~~~
elf_main.c:364:3: error: too few arguments to function 'setenv'
setenv("PATH", MOUNTPT, 1);
^~~~~~
In file included from elf_main.c:47:
D:\Spuda\Documents\projects\nuttx\master\nuttx-fork\include/stdlib.h:158:11: note: declared here
int setenv(FAR const char *name, FAR const char *value, int overwrite);
^~~~~~
This problem was found during manual build testing using configuration lx_cpu:nsh.
2020-02-15 17:14:03 +01:00
|
|
|
# undef MOUNTPT
|
2012-10-26 00:10:56 +02:00
|
|
|
#endif
|
|
|
|
|
2020-04-11 20:56:24 +02:00
|
|
|
/* If CONFIG_DEBUG_FEATURES is enabled, use info/err instead of printf so
|
|
|
|
* that the output will be synchronous with the debug output.
|
2012-10-25 22:06:46 +02:00
|
|
|
*/
|
|
|
|
|
2020-05-04 12:52:59 +02:00
|
|
|
#ifdef CONFIG_DEBUG_INFO
|
|
|
|
# define message _info
|
2012-10-25 22:06:46 +02:00
|
|
|
#else
|
2020-05-04 12:52:59 +02:00
|
|
|
# define message printf
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_ERROR
|
|
|
|
# define errmsg _err
|
|
|
|
#else
|
|
|
|
# define errmsg printf
|
2012-10-25 22:06:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-10-29 20:32:05 +01:00
|
|
|
static unsigned int g_mminitial; /* Initial memory usage */
|
|
|
|
static unsigned int g_mmstep; /* Memory Usage at beginning of test step */
|
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
static const char delimiter[] =
|
2020-04-11 20:56:24 +02:00
|
|
|
"**************************************"
|
|
|
|
"**************************************";
|
2012-10-25 22:06:46 +02:00
|
|
|
|
2021-08-01 09:28:27 +02:00
|
|
|
#ifndef CONFIG_LIBC_ENVPATH
|
2012-12-19 22:16:03 +01:00
|
|
|
static char fullpath[128];
|
|
|
|
#endif
|
2012-10-25 22:06:46 +02:00
|
|
|
|
2012-10-27 02:04:47 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Symbols from Auto-Generated Code
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-05-14 05:32:35 +02:00
|
|
|
#if defined(CONFIG_EXAMPLES_ELF_ROMFS) || defined(CONFIG_EXAMPLES_ELF_CROMFS)
|
|
|
|
extern const unsigned char romfs_img[];
|
|
|
|
extern const unsigned int romfs_img_len;
|
|
|
|
#elif !defined(CONFIG_EXAMPLES_ELF_EXTERN)
|
|
|
|
# error "No file system selected"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern const char *dirlist[];
|
|
|
|
|
2018-07-15 00:36:25 +02:00
|
|
|
extern const struct symtab_s g_elf_exports[];
|
|
|
|
extern const int g_elf_nexports;
|
2012-10-27 02:04:47 +02:00
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-10-29 20:32:05 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: mm_update
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void mm_update(FAR unsigned int *previous, FAR const char *msg)
|
|
|
|
{
|
|
|
|
struct mallinfo mmcurrent;
|
|
|
|
|
|
|
|
/* Get the current memory usage */
|
|
|
|
|
|
|
|
mmcurrent = mallinfo();
|
|
|
|
|
|
|
|
/* Show the change from the previous time */
|
|
|
|
|
|
|
|
printf("\nMemory Usage %s:\n", msg);
|
|
|
|
printf(" Before: %8u After: %8u Change: %8d\n",
|
2020-04-11 20:56:24 +02:00
|
|
|
*previous, mmcurrent.uordblks,
|
|
|
|
(int)mmcurrent.uordblks - (int)*previous);
|
2012-10-29 20:32:05 +01:00
|
|
|
|
|
|
|
/* Set up for the next test */
|
|
|
|
|
|
|
|
*previous = mmcurrent.uordblks;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mm_initmonitor
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void mm_initmonitor(void)
|
|
|
|
{
|
|
|
|
struct mallinfo mmcurrent;
|
|
|
|
|
|
|
|
mmcurrent = mallinfo();
|
|
|
|
|
|
|
|
g_mminitial = mmcurrent.uordblks;
|
|
|
|
g_mmstep = mmcurrent.uordblks;
|
|
|
|
|
|
|
|
printf("Initial memory usage: %d\n", mmcurrent.uordblks);
|
|
|
|
}
|
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: testheader
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static inline void testheader(FAR const char *progname)
|
|
|
|
{
|
|
|
|
message("\n%s\n* Executing %s\n%s\n\n", delimiter, progname, delimiter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: elf_main
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-09-06 17:23:23 +02:00
|
|
|
int main(int argc, FAR char *argv[])
|
2012-10-25 22:06:46 +02:00
|
|
|
{
|
2018-08-05 00:24:02 +02:00
|
|
|
#ifdef CONFIG_EXAMPLES_ELF_FSREMOVEABLE
|
|
|
|
struct stat buf;
|
2021-05-13 04:16:45 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_EXAMPLES_ELF_ROMFS
|
|
|
|
struct boardioc_romdisk_s desc;
|
2018-08-05 00:24:02 +02:00
|
|
|
#endif
|
2021-06-15 20:55:57 +02:00
|
|
|
FAR char *args[2];
|
2012-10-25 22:06:46 +02:00
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
2012-10-29 20:32:05 +01:00
|
|
|
/* Initialize the memory monitor */
|
|
|
|
|
|
|
|
mm_initmonitor();
|
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
#if defined(CONFIG_EXAMPLES_ELF_ROMFS)
|
2018-08-04 21:10:40 +02:00
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
/* Create a ROM disk for the ROMFS filesystem */
|
|
|
|
|
2017-10-02 22:32:17 +02:00
|
|
|
message("Registering romdisk at /dev/ram%d\n",
|
|
|
|
CONFIG_EXAMPLES_ELF_DEVMINOR);
|
2021-05-08 20:33:52 +02:00
|
|
|
|
|
|
|
desc.minor = CONFIG_EXAMPLES_ELF_DEVMINOR; /* Minor device number of the ROM disk. */
|
|
|
|
desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
|
|
|
|
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
|
|
|
|
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
|
|
|
|
|
|
|
|
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
|
2012-10-25 22:06:46 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2021-05-08 20:33:52 +02:00
|
|
|
errmsg("ERROR: romdisk_register failed: %s\n", strerror(errno));
|
2012-10-25 22:06:46 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-10-29 20:32:05 +01:00
|
|
|
mm_update(&g_mmstep, "after romdisk_register");
|
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
/* Mount the ROMFS file system */
|
2012-10-25 22:06:46 +02:00
|
|
|
|
|
|
|
message("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
2012-10-26 00:10:56 +02:00
|
|
|
MOUNTPT, CONFIG_EXAMPLES_ELF_DEVPATH);
|
2012-10-25 22:06:46 +02:00
|
|
|
|
2020-04-11 20:56:24 +02:00
|
|
|
ret = mount(CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, "romfs",
|
|
|
|
MS_RDONLY, NULL);
|
2012-10-25 22:06:46 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2021-05-08 20:33:52 +02:00
|
|
|
errmsg("ERROR: mount(%s,%s,romfs) failed: %s\n",
|
|
|
|
CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, strerror(errno));
|
2012-10-25 22:06:46 +02:00
|
|
|
}
|
|
|
|
|
2018-03-24 18:36:20 +01:00
|
|
|
#elif defined(CONFIG_EXAMPLES_ELF_CROMFS)
|
|
|
|
/* Mount the CROMFS file system */
|
|
|
|
|
|
|
|
message("Mounting CROMFS filesystem at target=%s\n", MOUNTPT);
|
|
|
|
|
|
|
|
ret = mount(NULL, MOUNTPT, "cromfs", MS_RDONLY, NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2021-05-08 20:33:52 +02:00
|
|
|
errmsg("ERROR: mount(%s, cromfs) failed: %s\n",
|
|
|
|
MOUNTPT, strerror(errno));
|
2018-08-04 21:10:40 +02:00
|
|
|
}
|
|
|
|
#elif defined(CONFIG_EXAMPLES_ELF_EXTERN)
|
2018-08-05 00:24:02 +02:00
|
|
|
/* An external file system is being used */
|
|
|
|
|
|
|
|
#if defined(CONFIG_EXAMPLES_ELF_FSMOUNT)
|
|
|
|
#if defined(CONFIG_EXAMPLES_ELF_FSREMOVEABLE)
|
|
|
|
/* The file system is removable, wait until the block driver is available */
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ret = stat(CONFIG_EXAMPLES_ELF_DEVPATH, &buf);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
int errcode = errno;
|
|
|
|
if (errcode == ENOENT)
|
|
|
|
{
|
|
|
|
printf("%s does not exist. Waiting...\n",
|
|
|
|
CONFIG_EXAMPLES_ELF_DEVPATH);
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-08 20:33:52 +02:00
|
|
|
printf("ERROR: stat(%s) failed: %s Aborting...\n",
|
|
|
|
CONFIG_EXAMPLES_ELF_DEVPATH, strerror(errcode));
|
2018-08-05 00:24:02 +02:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!S_ISBLK(buf.st_mode))
|
|
|
|
{
|
|
|
|
printf("ERROR: stat(%s) exists but is not a block driver: %04x\n",
|
|
|
|
CONFIG_EXAMPLES_ELF_DEVPATH, buf.st_mode);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (ret < 0);
|
|
|
|
#endif
|
|
|
|
|
2018-08-04 21:10:40 +02:00
|
|
|
/* Mount the external file system */
|
|
|
|
|
|
|
|
message("Mounting %s filesystem at target=%s\n",
|
|
|
|
CONFIG_EXAMPLES_ELF_FSTYPE, MOUNTPT);
|
|
|
|
|
|
|
|
ret = mount(CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT,
|
|
|
|
CONFIG_EXAMPLES_ELF_FSTYPE, MS_RDONLY, NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2021-05-08 20:33:52 +02:00
|
|
|
errmsg("ERROR: mount(%s, %s, %s) failed: %s\n",
|
2018-08-04 21:10:40 +02:00
|
|
|
CONFIG_EXAMPLES_ELF_DEVPATH, CONFIG_EXAMPLES_ELF_FSTYPE,
|
2021-05-08 20:33:52 +02:00
|
|
|
MOUNTPT, strerror(errno));
|
2018-03-24 18:36:20 +01:00
|
|
|
}
|
2018-08-05 00:24:02 +02:00
|
|
|
#endif
|
2018-03-24 18:36:20 +01:00
|
|
|
#else
|
2018-08-04 21:10:40 +02:00
|
|
|
# Warning "No file system selected"
|
2018-03-24 18:36:20 +01:00
|
|
|
#endif
|
|
|
|
|
2012-10-29 20:32:05 +01:00
|
|
|
mm_update(&g_mmstep, "after mount");
|
|
|
|
|
2021-08-01 09:28:27 +02:00
|
|
|
#if defined(CONFIG_LIBC_ENVPATH) && defined(MOUNTPT)
|
2020-02-14 10:23:25 +01:00
|
|
|
/* Does the system support the PATH variable?
|
|
|
|
* If YES, then set the PATH variable to the ROMFS mountpoint.
|
2012-12-19 22:16:03 +01:00
|
|
|
*/
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
setenv("PATH", MOUNTPT, 1);
|
2012-12-19 22:16:03 +01:00
|
|
|
#endif
|
|
|
|
|
2018-03-16 15:51:49 +01:00
|
|
|
/* Now exercise every program in the ROMFS file system */
|
2012-10-25 22:06:46 +02:00
|
|
|
|
|
|
|
for (i = 0; dirlist[i]; i++)
|
|
|
|
{
|
2017-10-02 22:32:17 +02:00
|
|
|
FAR const char *filename;
|
|
|
|
|
2018-03-16 15:51:49 +01:00
|
|
|
/* Output a separator so that we can clearly discriminate the output of
|
2012-12-19 22:16:03 +01:00
|
|
|
* this program from the others.
|
|
|
|
*/
|
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
testheader(dirlist[i]);
|
|
|
|
|
2012-12-19 22:16:03 +01:00
|
|
|
/* If the binary loader does not support the PATH variable, then
|
|
|
|
* create the full path to the executable program. Otherwise,
|
|
|
|
* use the relative path so that the binary loader will have to
|
|
|
|
* search the PATH variable to find the executable.
|
|
|
|
*/
|
|
|
|
|
2021-08-01 09:28:27 +02:00
|
|
|
#ifdef CONFIG_LIBC_ENVPATH
|
2017-10-02 22:32:17 +02:00
|
|
|
filename = dirlist[i];
|
2012-12-19 22:16:03 +01:00
|
|
|
#else
|
2023-03-20 09:46:48 +01:00
|
|
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", MOUNTPT, dirlist[i]);
|
2017-10-02 22:32:17 +02:00
|
|
|
filename = fullpath;
|
2012-12-19 22:16:03 +01:00
|
|
|
#endif
|
2012-10-29 20:32:05 +01:00
|
|
|
|
2017-10-06 23:13:00 +02:00
|
|
|
/* Execute the ELF module.
|
|
|
|
*
|
|
|
|
* NOTE: The standard posix_spawn() interface would be more correct.
|
|
|
|
* The non-standard exec() function is used because it provides a
|
|
|
|
* simple way to pass the symbol table information needed to load the
|
|
|
|
* program. posix_spawn(), on the other hand, will assume that symbol
|
|
|
|
* table information is available within the OS.
|
|
|
|
*/
|
2012-12-19 22:16:03 +01:00
|
|
|
|
2021-06-15 20:55:57 +02:00
|
|
|
args[0] = (FAR char *)dirlist[i];
|
|
|
|
args[1] = NULL;
|
2022-04-21 05:55:35 +02:00
|
|
|
ret = exec(filename, args, NULL, g_elf_exports, g_elf_nexports);
|
2012-10-29 20:32:05 +01:00
|
|
|
|
2017-10-02 22:32:17 +02:00
|
|
|
mm_update(&g_mmstep, "after exec");
|
2012-10-29 20:32:05 +01:00
|
|
|
|
2012-10-25 22:06:46 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2021-05-08 20:33:52 +02:00
|
|
|
errmsg("ERROR: exec(%s) failed: %s\n",
|
|
|
|
dirlist[i], strerror(errno));
|
2012-10-29 20:32:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message("Wait a bit for test completion\n");
|
|
|
|
sleep(4);
|
2012-10-25 22:06:46 +02:00
|
|
|
}
|
|
|
|
|
2017-10-02 22:32:17 +02:00
|
|
|
mm_update(&g_mmstep, "after program execution");
|
2012-10-25 22:06:46 +02:00
|
|
|
}
|
|
|
|
|
2012-10-29 20:32:05 +01:00
|
|
|
mm_update(&g_mmstep, "End-of-Test");
|
2012-10-25 22:06:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|