apps/examples/elf: CROMFS and ROMFS configuration currently only usable in FLAT build. Add configuration to use ELF objects on external media like SD card or USB drive instead.
This commit is contained in:
parent
922283ee5d
commit
ba2d9e7c42
@ -7,46 +7,61 @@ config EXAMPLES_ELF
|
||||
bool "ELF Loader Example"
|
||||
default n
|
||||
select LIBC_EXECFUNCS
|
||||
depends on ELF && (FS_ROMFS || FS_CROMFS) && !BUILD_KERNEL
|
||||
depends on ELF
|
||||
---help---
|
||||
Enable the ELF loader example
|
||||
|
||||
if EXAMPLES_ELF
|
||||
|
||||
choice
|
||||
prompt "ROM File System"
|
||||
default EXAMPLES_ELF_ROMFS if FS_ROMFS
|
||||
default EXAMPLES_ELF_CROMFS if !FS_ROMFS && FS_CROMFS
|
||||
prompt "ELF File System"
|
||||
default EXAMPLES_ELF_ROMFS if FS_ROMFS && BUILD_FLAT
|
||||
default EXAMPLES_ELF_CROMFS if !FS_ROMFS && FS_CROMFS && BUILD_FLAT
|
||||
default EXAMPLES_ELF_EXTERN if (!FS_ROMFS && !FS_CROMFS) || !BUILD_FLAT
|
||||
|
||||
config EXAMPLES_ELF_ROMFS
|
||||
bool "ROMFS"
|
||||
depends on FS_ROMFS
|
||||
depends on FS_ROMFS && BUILD_FLAT
|
||||
|
||||
config EXAMPLES_ELF_CROMFS
|
||||
bool "CROMFS"
|
||||
depends on FS_CROMFS
|
||||
depends on FS_CROMFS && BUILD_FLAT
|
||||
|
||||
config EXAMPLES_ELF_EXTERN
|
||||
bool "External File system"
|
||||
|
||||
endchoice # ROM File System
|
||||
|
||||
if EXAMPLES_ELF_ROMFS
|
||||
|
||||
config EXAMPLES_ELF_DEVMINOR
|
||||
int "ROMFS Minor Device Number"
|
||||
default 0
|
||||
depends on EXAMPLES_ELF_ROMFS
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the ELF executables to be tested. Default: 0
|
||||
The minor device number of the ROMFS block. For example, the N in
|
||||
/dev/ramN. Used for registering the RAM block driver that will hold
|
||||
the ROMFS file system containing the ELF executables to be tested.
|
||||
Default: 0
|
||||
|
||||
config EXAMPLES_ELF_FSTYPE
|
||||
string "External file system type"
|
||||
default "vfat"
|
||||
depends on EXAMPLES_ELF_EXTERN
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in
|
||||
/dev/ramN. Used for registering the RAM block driver that will hold
|
||||
the ROMFS file system containing the ELF executables to be tested.
|
||||
Default: 0
|
||||
|
||||
config EXAMPLES_ELF_DEVPATH
|
||||
string "ROMFS Device Path"
|
||||
default "/dev/ram0"
|
||||
string "Block driver device path"
|
||||
default "/dev/ram0" if EXAMPLES_ELF_ROMFS
|
||||
default "/dev/mmcsd0" if EXAMPLES_ELF_EXTERN
|
||||
depends on EXAMPLES_ELF_ROMFS || EXAMPLES_ELF_EXTERN
|
||||
---help---
|
||||
The path to the ROMFS block driver device. This must match EXAMPLES_ELF_DEVMINOR.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the ELF executables to be tested. Default: "/dev/ram0"
|
||||
|
||||
endif # EXAMPLES_ELF_ROMFS
|
||||
The path to the ROMFS/External block driver device. This must match
|
||||
EXAMPLES_ELF_DEVMINOR for the case of ROMFS. Used for mounting the
|
||||
file system containing the ELF executables to be tested. Default:
|
||||
"/dev/ram0" for ROMFS, "/dev/mmcsd0" for the external file system.
|
||||
|
||||
config EXAMPLES_ELF_NOSTRIP
|
||||
bool "Do not strip debug symbols"
|
||||
|
@ -60,7 +60,7 @@
|
||||
# include "tests/romfs.h"
|
||||
#elif defined(CONFIG_EXAMPLES_ELF_CROMFS)
|
||||
# include "tests/cromfs.h"
|
||||
#else
|
||||
#elif !defined(CONFIG_EXAMPLES_ELF_EXTERN)
|
||||
# error "No file system selected"
|
||||
#endif
|
||||
|
||||
@ -86,16 +86,11 @@
|
||||
# error "You must select CONFIG_ELF in your configuration file"
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_FS_ROMFS) && !defined(CONFIG_FS_CROMFS)
|
||||
# error "You must select CONFIG_FS_ROMFS or CONFIG_FS_CROMFS in your configuration file"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file"
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_ELF_ROMFS)
|
||||
|
||||
/* Describe the ROMFS file system */
|
||||
|
||||
# define SECTORSIZE 512
|
||||
@ -110,10 +105,16 @@
|
||||
# define CONFIG_EXAMPLES_ELF_DEVPATH "/dev/ram0"
|
||||
# endif
|
||||
|
||||
#elif defined(CONFIG_EXAMPLES_ELF_CROMFS)
|
||||
/* Describe the CROMFS file system */
|
||||
|
||||
#elif defined(CONFIG_EXAMPLES_ELF_CROMFS)
|
||||
# define MOUNTPT "/mnt/cromfs"
|
||||
|
||||
#elif defined(CONFIG_EXAMPLES_ELF_EXTERN)
|
||||
/* Describe the external file system */
|
||||
|
||||
# define MOUNTPT "/mnt/" CONFIG_EXAMPLES_ELF_FSTYPE
|
||||
|
||||
#else
|
||||
# error "No file system selected"
|
||||
#endif
|
||||
@ -256,6 +257,15 @@ int elf_main(int argc, char *argv[])
|
||||
mm_initmonitor();
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_ELF_ROMFS)
|
||||
#if defined(CONFIG_BUILD_FLAT)
|
||||
/* This example violates the portable POSIX interface by calling the OS
|
||||
* internal function romdisk_register() (aka ramdisk_register()). We can
|
||||
* squeak by in with this violation in the FLAT build mode, but not in
|
||||
* other build modes. In other build modes, the following logic must be
|
||||
* performed in the OS board initialization logic (where it really belongs
|
||||
* anyway).
|
||||
*/
|
||||
|
||||
/* Create a ROM disk for the ROMFS filesystem */
|
||||
|
||||
message("Registering romdisk at /dev/ram%d\n",
|
||||
@ -270,6 +280,7 @@ int elf_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
mm_update(&g_mmstep, "after romdisk_register");
|
||||
#endif
|
||||
|
||||
/* Mount the ROMFS file system */
|
||||
|
||||
@ -291,10 +302,24 @@ int elf_main(int argc, char *argv[])
|
||||
ret = mount(NULL, MOUNTPT, "cromfs", MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
errmsg("ERROR: mount(%s,cromfs) failed: %s\n", MOUNTPT, errno);
|
||||
errmsg("ERROR: mount(%s, cromfs) failed: %d\n", MOUNTPT, errno);
|
||||
}
|
||||
#elif defined(CONFIG_EXAMPLES_ELF_EXTERN)
|
||||
/* 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)
|
||||
{
|
||||
errmsg("ERROR: mount(%s, %s, %s) failed: %d\n",\
|
||||
CONFIG_EXAMPLES_ELF_DEVPATH, CONFIG_EXAMPLES_ELF_FSTYPE,
|
||||
MOUNTPT, errno);
|
||||
}
|
||||
#else
|
||||
# error "No file system selected"
|
||||
# Warning "No file system selected"
|
||||
#endif
|
||||
|
||||
mm_update(&g_mmstep, "after mount");
|
||||
|
Loading…
Reference in New Issue
Block a user