diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-25 00:05:11 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-25 00:05:11 +0000 |
commit | dfab3df14acb516e4a7e127b4ced4d1d755fcb59 (patch) | |
tree | 7ad2779537de1ab2f84552c6c1580a203c1f80da /nuttx/examples | |
parent | f183944854afe2bd8ccb56ad20f79e3aa371dc02 (diff) | |
download | px4-nuttx-dfab3df14acb516e4a7e127b4ced4d1d755fcb59.tar.gz px4-nuttx-dfab3df14acb516e4a7e127b4ced4d1d755fcb59.tar.bz2 px4-nuttx-dfab3df14acb516e4a7e127b4ced4d1d755fcb59.zip |
Initial NXFLAT debug fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1943 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r-- | nuttx/examples/nxflat/nxflat_main.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/nuttx/examples/nxflat/nxflat_main.c b/nuttx/examples/nxflat/nxflat_main.c index f31c21973..7c03b789d 100644 --- a/nuttx/examples/nxflat/nxflat_main.c +++ b/nuttx/examples/nxflat/nxflat_main.c @@ -51,6 +51,7 @@ #include <nuttx/ramdisk.h> #include <nuttx/binfmt.h> +#include <nuttx/nxflat.h> #include "tests/romfs.h" #include "tests/dirlist.h" @@ -91,6 +92,18 @@ #define ROMFSDEV "/dev/ram0" #define MOUNTPT "/mnt/romfs" +/* If CONFIG_DEBUG is enabled, use dbg instead of printf so that the the + * output will be synchronous with the debug output. + */ + +#ifdef CONFIG_DEBUG +# define message dbg +# define err dbg +#else +# define message printf +# define err fprintf(stderr, +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -114,7 +127,7 @@ static char path[128]; static inline void testheader(FAR const char *progname) { - printf("\n%s\n* Executing %s\n%s\n\n", delimiter, progname, delimiter); + message("\n%s\n* Executing %s\n%s\n\n", delimiter, progname, delimiter); } /**************************************************************************** @@ -139,26 +152,38 @@ int user_start(int argc, char *argv[]) int ret; int i; + /* Initialize the NXFLAT binary loader */ + + message("Initializing the NXFLAT binary loader\n"); + ret = nxflat_initialize(); + if (ret < 0) + { + err("ERROR: Initialization of the NXFLAT loader failed: %d\n", ret); + exit(1); + } + /* Create a ROM disk for the ROMFS filesystem */ - printf("Registering romdisk\n"); + message("Registering romdisk\n"); ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); if (ret < 0) { - fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret); + err("ERROR: romdisk_register failed: %d\n", ret); + nxflat_uninitialize(); exit(1); } /* Mount the file system */ - printf("Mounting ROMFS filesystem at target=%s with source=%s\n", + message("Mounting ROMFS filesystem at target=%s with source=%s\n", MOUNTPT, ROMFSDEV); ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL); if (ret < 0) { - fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n", + err("ERROR: mount(%s,%s,romfs) failed: %s\n", ROMFSDEV, MOUNTPT, errno); + nxflat_uninitialize(); } /* Now excercise every progrm in the ROMFS file system */ @@ -177,16 +202,19 @@ int user_start(int argc, char *argv[]) ret = load_module(&bin); if (ret < 0) { - fprintf(stderr, "ERROR: Failed to load program '%s'\n", dirlist[i]); + err("ERROR: Failed to load program '%s'\n", dirlist[i]); exit(1); } ret = exec_module(&bin, 50); if (ret < 0) { - fprintf(stderr, "ERROR: Failed to execute program '%s'\n", dirlist[i]); + err("ERROR: Failed to execute program '%s'\n", dirlist[i]); unload_module(&bin); } + + message("Wait a bit for test completion\n"); + sleep(2); } return 0; } |