From e3ba485a852fc10a85533d0c5a28c6e01d66a0d4 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 22 Jul 2011 20:12:50 +0000 Subject: apps/examples/usbstorage can now be built as NSH built-in commands; configs/stm3210e-eval/nsh2 now uses these usb storage commands git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3812 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 4 + apps/examples/Makefile | 20 ++- apps/examples/README.txt | 4 + apps/examples/nx/nx_main.c | 112 ++++++++-------- apps/examples/nxhello/nxhello_bkgd.c | 2 +- apps/examples/nxhello/nxhello_main.c | 4 +- apps/examples/nxtext/nxtext_main.c | 36 +++--- apps/examples/usbstorage/Makefile | 21 ++- apps/examples/usbstorage/usbstrg_main.c | 156 ++++++++++++++++++----- nuttx/ChangeLog | 3 + nuttx/Documentation/NuttXCommercial.html | 3 +- nuttx/Documentation/NuttXDocumentation.html | 2 +- nuttx/Documentation/NuttXLinks.html | 4 +- nuttx/Documentation/NuttXRelated.html | 4 +- nuttx/arch/arm/src/stm32/stm32_usbdev.c | 139 ++++++++++++-------- nuttx/configs/stm3210e-eval/README.txt | 1 + nuttx/configs/stm3210e-eval/nsh2/appconfig | 1 + nuttx/configs/stm3210e-eval/nsh2/defconfig | 60 ++++++++- nuttx/configs/stm3210e-eval/src/up_nsh.c | 4 +- nuttx/configs/stm3210e-eval/src/up_usbstrg.c | 15 ++- nuttx/configs/stm3210e-eval/usbstorage/defconfig | 33 ++++- 21 files changed, 451 insertions(+), 177 deletions(-) diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 712e1e4f7..f771b97fa 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -82,3 +82,7 @@ * apps/examples/nximage: Another super simple graphics example: It just puts the NuttX logo in the center of the display. This example can also be built as an NSH "built-in" command. + * apps/examples/usbstorage: Can now be built as two NSH "built-in" commands: + 'msconn' will connect the USB mass storage device; 'msdis' will disconnect + the USB storage device. + diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 45f05d8db..f5ab34a1c 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -38,13 +38,29 @@ # Sub-directories SUBDIRS = buttons dhcpd ftpc hello helloxx hidkbd igmp mm mount nettest \ - nsh null nx nxffs nxflat nxhello nximage nxtext stest pashello pipe \ + nsh null nx nxffs nxflat nxhello nximage nxtext ostest pashello pipe \ poll rgmp romfs sendmail serloop thttpd udp uip usbserial usbstorage \ wget wlan # Sub-directories that might need context setup -CNTXTDIRS = nx nxhello nximage nxtext +CNTXTDIRS = + +ifeq ($(CONFIG_EXAMPLES_NX_BUILTIN),y) +CNTXTDIRS += nx +endif +ifeq ($(CONFIG_EXAMPLES_NXHELLO_BUILTIN),y) +CNTXTDIRS += nxhello +endif +ifeq ($(CONFIG_EXAMPLES_NXIMAGE_BUILTIN),y) +CNTXTDIRS += nximage +endif +ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y) +CNTXTDIRS += nxtext +endif +ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y) +CNTXTDIRS += usbstorage +endif all: nothing .PHONY: nothing context depend clean distclean diff --git a/apps/examples/README.txt b/apps/examples/README.txt index d234a5549..bef78528e 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -800,6 +800,10 @@ examples/usbstorage Configuration options: + CONFIG_EXAMPLES_USBSTRG_BUILTIN + This example can be built as two NSH "built-in" commands if this option + is selection: 'msconn' will connect the USB mass storage device; 'msdis' + will disconnect the USB storage device. CONFIG_EXAMPLES_USBSTRG_NLUNS Defines the number of logical units (LUNs) exported by the USB storage driver. Each LUN corresponds to one exported block driver (or partition diff --git a/apps/examples/nx/nx_main.c b/apps/examples/nx/nx_main.c index 6d85d0fb7..366ec80a4 100644 --- a/apps/examples/nx/nx_main.c +++ b/apps/examples/nx/nx_main.c @@ -231,7 +231,7 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb, hwnd = nx_openwindow(g_hnx, cb, (FAR void *)state); if (!hwnd) { - message("user_start: nx_openwindow failed: %d\n", errno); + message("nxeg_openwindow: nx_openwindow failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENWINDOW; } return hwnd; @@ -245,7 +245,7 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb, hwnd = nxtk_openwindow(g_hnx, cb, (FAR void *)state); if (!hwnd) { - message("user_start: nxtk_openwindow failed: %d\n", errno); + message("nxeg_openwindow: nxtk_openwindow failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENWINDOW; } return hwnd; @@ -262,7 +262,7 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta int ret = nx_closewindow(hwnd); if (ret < 0) { - message("user_start: nx_closewindow failed: %d\n", errno); + message("nxeg_closewindow: nx_closewindow failed: %d\n", errno); g_exitcode = NXEXIT_NXCLOSEWINDOW; } return ret; @@ -273,7 +273,7 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta int ret = nxtk_closewindow(hwnd); if (ret < 0) { - message("user_start: nxtk_closewindow failed: %d\n", errno); + message("nxeg_closewindow: nxtk_closewindow failed: %d\n", errno); g_exitcode = NXEXIT_NXCLOSEWINDOW; } nxeg_freestate(state); @@ -291,7 +291,7 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size) int ret = nx_setsize(hwnd, size); if (ret < 0) { - message("user_start: nx_setsize failed: %d\n", errno); + message("nxeg_setsize: nx_setsize failed: %d\n", errno); g_exitcode = NXEXIT_NXSETSIZE; } return ret; @@ -302,7 +302,7 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size) int ret = nxtk_setsize(hwnd, size); if (ret < 0) { - message("user_start: nxtk_setsize failed: %d\n", errno); + message("nxeg_setsize: nxtk_setsize failed: %d\n", errno); g_exitcode = NXEXIT_NXSETSIZE; } return ret; @@ -319,7 +319,7 @@ static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos int ret = nx_setposition(hwnd, pos); if (ret < 0) { - message("user_start: nx_setposition failed: %d\n", errno); + message("nxeg_setposition: nx_setposition failed: %d\n", errno); g_exitcode = NXEXIT_NXSETPOSITION; } return ret; @@ -330,7 +330,7 @@ static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos int ret = nxtk_setposition(hwnd, pos); if (ret < 0) { - message("user_start: nxtk_setposition failed: %d\n", errno); + message("nxeg_setposition: nxtk_setposition failed: %d\n", errno); g_exitcode = NXEXIT_NXSETPOSITION; } return ret; @@ -350,7 +350,7 @@ static inline int nxeq_opentoolbar(NXEGWINDOW hwnd, nxgl_coord_t height, ret = nxtk_opentoolbar(hwnd, height, cb, (FAR void *)state); if (ret < 0) { - message("user_start: nxtk_opentoolbar failed: %d\n", errno); + message("nxeq_opentoolbar: nxtk_opentoolbar failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENTOOLBAR; } return ret; @@ -367,7 +367,7 @@ static inline int nxeg_lower(NXEGWINDOW hwnd) int ret = nx_lower(hwnd); if (ret < 0) { - message("user_start: nx_lower failed: %d\n", errno); + message("nxeg_lower: nx_lower failed: %d\n", errno); g_exitcode = NXEXIT_NXLOWER; } return ret; @@ -378,7 +378,7 @@ static inline int nxeg_lower(NXEGWINDOW hwnd) int ret = nxtk_lower(hwnd); if (ret < 0) { - message("user_start: nxtk_lower failed: %d\n", errno); + message("nxeg_lower: nxtk_lower failed: %d\n", errno); g_exitcode = NXEXIT_NXLOWER; } return ret; @@ -395,7 +395,7 @@ static inline int nxeg_raise(NXEGWINDOW hwnd) int ret = nx_raise(hwnd); if (ret < 0) { - message("user_start: nx_raise failed: %d\n", errno); + message("nxeg_raise: nx_raise failed: %d\n", errno); g_exitcode = NXEXIT_NXRAISE; } return ret; @@ -406,7 +406,7 @@ static inline int nxeg_raise(NXEGWINDOW hwnd) int ret = nxtk_raise(hwnd); if (ret < 0) { - message("user_start: nxtk_raise failed: %d\n", errno); + message("nxeg_raise: nxtk_raise failed: %d\n", errno); g_exitcode = NXEXIT_NXRAISE; } return ret; @@ -490,7 +490,7 @@ static inline int nxeg_suinitialize(void) g_hnx = nx_open(dev); if (!g_hnx) { - message("user_start: nx_open failed: %d\n", errno); + message("nxeg_suinitialize: nx_open failed: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; return ERROR; } @@ -618,10 +618,14 @@ static int nxeg_initialize(void) ****************************************************************************/ #ifdef CONFIG_EXAMPLES_NX_BUILTIN -int nx_main(int argc, char **argv) +# define MAIN_NAME nx_main +# define MAIN_NAME_STRING "nx_main" #else -int user_start(int argc, char *argv[]) +# define MAIN_NAME user_start +# define MAIN_NAME_STRING "user_start" #endif + +int MAIN_NAME(int argc, char *argv[]) { NXEGWINDOW hwnd1; NXEGWINDOW hwnd2; @@ -633,10 +637,10 @@ int user_start(int argc, char *argv[]) /* Initialize */ ret = nxeg_initialize(); - message("user_start: NX handle=%p\n", g_hnx); + message(MAIN_NAME_STRING ": NX handle=%p\n", g_hnx); if (!g_hnx || ret < 0) { - message("user_start: Failed to get NX handle: %d\n", errno); + message(MAIN_NAME_STRING ": Failed to get NX handle: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; goto errout; } @@ -646,29 +650,29 @@ int user_start(int argc, char *argv[]) g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT); if (!g_fonthandle) { - message("user_start: Failed to get font handle: %d\n", errno); + message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno); g_exitcode = NXEXIT_FONTOPEN; goto errout; } /* Set the background to the configured background color */ - message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR); + message(MAIN_NAME_STRING ": Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR); color = CONFIG_EXAMPLES_NX_BGCOLOR; ret = nx_setbgcolor(g_hnx, &color); if (ret < 0) { - message("user_start: nx_setbgcolor failed: %d\n", errno); + message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno); g_exitcode = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } /* Create window #1 */ - message("user_start: Create window #1\n"); + message(MAIN_NAME_STRING ": Create window #1\n"); nxeg_initstate(&g_wstate[0], 1, CONFIG_EXAMPLES_NX_COLOR1); hwnd1 = nxeg_openwindow(&g_nxcb, &g_wstate[0]); - message("user_start: hwnd1=%p\n", hwnd1); + message(MAIN_NAME_STRING ": hwnd1=%p\n", hwnd1); if (!hwnd1) { goto errout_with_nx; @@ -680,14 +684,14 @@ int user_start(int argc, char *argv[]) { (void)sem_wait(&g_semevent); } - message("user_start: Screen resolution (%d,%d)\n", g_xres, g_yres); + message(MAIN_NAME_STRING ": Screen resolution (%d,%d)\n", g_xres, g_yres); /* Set the size of the window 1 */ size.w = g_xres / 2; size.h = g_yres / 2; - message("user_start: Set window #1 size to (%d,%d)\n", size.w, size.h); + message(MAIN_NAME_STRING ": Set window #1 size to (%d,%d)\n", size.w, size.h); ret = nxeg_setsize(hwnd1, &size); if (ret < 0) { @@ -699,7 +703,7 @@ int user_start(int argc, char *argv[]) * actually do them! */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); /* Set the position of window #1 */ @@ -707,7 +711,7 @@ int user_start(int argc, char *argv[]) pt.x = g_xres / 8; pt.y = g_yres / 8; - message("user_start: Set window #1 postion to (%d,%d)\n", pt.x, pt.y); + message(MAIN_NAME_STRING ": Set window #1 postion to (%d,%d)\n", pt.x, pt.y); ret = nxeg_setposition(hwnd1, &pt); if (ret < 0) { @@ -716,13 +720,13 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); /* Open the toolbar */ #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS - message("user_start: Add toolbar to window #1\n"); + message(MAIN_NAME_STRING ": Add toolbar to window #1\n"); ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]); if (ret < 0) { @@ -731,16 +735,16 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); #endif /* Create window #2 */ - message("user_start: Create window #2\n"); + message(MAIN_NAME_STRING ": Create window #2\n"); nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2); hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]); - message("user_start: hwnd2=%p\n", hwnd2); + message(MAIN_NAME_STRING ": hwnd2=%p\n", hwnd2); if (!hwnd2) { goto errout_with_hwnd1; @@ -748,12 +752,12 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); /* Set the size of the window 2 == size of window 1*/ - message("user_start: Set hwnd2 size to (%d,%d)\n", size.w, size.h); + message(MAIN_NAME_STRING ": Set hwnd2 size to (%d,%d)\n", size.w, size.h); ret = nxeg_setsize(hwnd2, &size); if (ret < 0) { @@ -762,7 +766,7 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); /* Set the position of window #2 */ @@ -770,7 +774,7 @@ int user_start(int argc, char *argv[]) pt.x = g_xres - size.w - pt.x; pt.y = g_yres - size.h - pt.y; - message("user_start: Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y); + message(MAIN_NAME_STRING ": Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y); ret = nxeg_setposition(hwnd2, &pt); if (ret < 0) { @@ -779,11 +783,11 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS - message("user_start: Add toolbar to window #2\n"); + message(MAIN_NAME_STRING ": Add toolbar to window #2\n"); ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]); if (ret < 0) { @@ -792,30 +796,30 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); #endif /* Give keyboard input to the top window -- should be window #2 */ #ifdef CONFIG_NX_KBD - message("user_start: Send keyboard input: %s\n", g_kbdmsg1); + message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_kbdmsg1); ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1); if (ret < 0) { - message("user_start: nx_kbdin failed: %d\n", errno); + message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno); goto errout_with_hwnd2; } /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); #endif /* Lower window 2 */ - message("user_start: Lower window #2\n"); + message(MAIN_NAME_STRING ": Lower window #2\n"); ret = nxeg_lower(hwnd2); if (ret < 0) { @@ -824,7 +828,7 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); /* Put mouse left-button clicks all over the screen and see who responds */ @@ -834,30 +838,30 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); #endif /* Give keyboard input to the top window -- should be window #1 */ #ifdef CONFIG_NX_KBD - message("user_start: Send keyboard input: %s\n", g_kbdmsg2); + message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_kbdmsg2); ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2); if (ret < 0) { - message("user_start: nx_kbdin failed: %d\n", errno); + message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno); goto errout_with_hwnd2; } /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(1); #endif /* Raise window 2 */ - message("user_start: Raise window #2\n"); + message(MAIN_NAME_STRING ": Raise window #2\n"); ret = nxeg_raise(hwnd2); if (ret < 0) { @@ -872,31 +876,31 @@ int user_start(int argc, char *argv[]) /* Sleep a bit */ - message("user_start: Sleeping\n\n"); + message(MAIN_NAME_STRING ": Sleeping\n\n"); sleep(2); /* Close the window 2 */ errout_with_hwnd2: - message("user_start: Close window #2\n"); + message(MAIN_NAME_STRING ": Close window #2\n"); (void)nxeg_closewindow(hwnd2, &g_wstate[1]); /* Close the window1 */ errout_with_hwnd1: - message("user_start: Close window #1\n"); + message(MAIN_NAME_STRING ": Close window #1\n"); (void)nxeg_closewindow(hwnd1, &g_wstate[0]); errout_with_nx: #ifdef CONFIG_NX_MULTIUSER /* Disconnect from the server */ - message("user_start: Disconnect from the server\n"); + message(MAIN_NAME_STRING ": Disconnect from the server\n"); nx_disconnect(g_hnx); #else /* Close the server */ - message("user_start: Close NX\n"); + message(MAIN_NAME_STRING ": Close NX\n"); nx_close(g_hnx); #endif errout: diff --git a/apps/examples/nxhello/nxhello_bkgd.c b/apps/examples/nxhello/nxhello_bkgd.c index 3b609d1f6..09beac952 100644 --- a/apps/examples/nxhello/nxhello_bkgd.c +++ b/apps/examples/nxhello/nxhello_bkgd.c @@ -248,7 +248,7 @@ static void nxhello_center(FAR struct nxgl_point_s *pos, */ pos->x = (g_nxhello.xres - width) / 2; - pos->y = (g_nxhello.yres - fbm->metric.height) / 2; + pos->y = (g_nxhello.yres - fontset->mxheight) / 2; } /**************************************************************************** diff --git a/apps/examples/nxhello/nxhello_main.c b/apps/examples/nxhello/nxhello_main.c index 4f6701aa5..38c2e52c2 100644 --- a/apps/examples/nxhello/nxhello_main.c +++ b/apps/examples/nxhello/nxhello_main.c @@ -211,7 +211,7 @@ static inline int nxhello_initialize(void) # define MAIN_NAME_STRING "nxhello_main" #else # define MAIN_NAME user_start -# define MAIN_NAME_STRING "user_start" +# define MAIN_NAME_STRING MAIN_NAME_STRING "" #endif int MAIN_NAME(int argc, char *argv[]) @@ -235,7 +235,7 @@ int MAIN_NAME(int argc, char *argv[]) g_nxhello.hfont = nxf_getfonthandle(NXFONT_DEFAULT); if (!g_nxhello.hfont) { - message("user_start: Failed to get font handle: %d\n", errno); + message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno); g_nxhello.code = NXEXIT_FONTOPEN; goto errout; } diff --git a/apps/examples/nxtext/nxtext_main.c b/apps/examples/nxtext/nxtext_main.c index a9d9207e6..58d29d33c 100644 --- a/apps/examples/nxtext/nxtext_main.c +++ b/apps/examples/nxtext/nxtext_main.c @@ -233,7 +233,7 @@ static inline int nxtext_suinitialize(void) g_hnx = nx_open(dev); if (!g_hnx) { - message("user_start: nx_open failed: %d\n", errno); + message("nxtext_initialize: nx_open failed: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; return ERROR; } @@ -348,10 +348,14 @@ static int nxtext_initialize(void) ****************************************************************************/ #ifdef CONFIG_EXAMPLES_NXTEXT_BUILTIN -int nxtext_main(int argc, char **argv) +# define MAIN_NAME nxtext_main +# define MAIN_NAME_STRING "nxtext_main" #else -int user_start(int argc, char *argv[]) +# define MAIN_NAME user_start +# define MAIN_NAME_STRING "user_start" #endif + +int MAIN_NAME(int argc, char **argv) { FAR struct nxtext_state_s *bgstate; NXWINDOW hwnd = NULL; @@ -363,10 +367,10 @@ int user_start(int argc, char *argv[]) /* Initialize NX */ ret = nxtext_initialize(); - message("user_start: NX handle=%p\n", g_hnx); + message(MAIN_NAME_STRING ": NX handle=%p\n", g_hnx); if (!g_hnx || ret < 0) { - message("user_start: Failed to get NX handle: %d\n", errno); + message(MAIN_NAME_STRING ": Failed to get NX handle: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; goto errout; } @@ -376,19 +380,19 @@ int user_start(int argc, char *argv[]) g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT); if (!g_fonthandle) { - message("user_start: Failed to get font handle: %d\n", errno); + message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno); g_exitcode = NXEXIT_FONTOPEN; goto errout; } /* Set the background to the configured background color */ - message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR); + message(MAIN_NAME_STRING ": Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR); color = CONFIG_EXAMPLES_NXTEXT_BGCOLOR; ret = nx_setbgcolor(g_hnx, &color); if (ret < 0) { - message("user_start: nx_setbgcolor failed: %d\n", errno); + message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno); g_exitcode = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } @@ -399,7 +403,7 @@ int user_start(int argc, char *argv[]) ret = nx_requestbkgd(g_hnx, &g_bgcb, bgstate); if (ret < 0) { - message("user_start: nx_setbgcolor failed: %d\n", errno); + message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno); g_exitcode = NXEXIT_NXREQUESTBKGD; goto errout_with_nx; } @@ -412,7 +416,7 @@ int user_start(int argc, char *argv[]) { (void)sem_wait(&g_semevent); } - message("user_start: Screen resolution (%d,%d)\n", g_xres, g_yres); + message(MAIN_NAME_STRING ": Screen resolution (%d,%d)\n", g_xres, g_yres); /* Now loop, adding text to the background and periodically presenting * a pop-up window. @@ -440,11 +444,11 @@ int user_start(int argc, char *argv[]) /* Give keyboard input to the top window (which should be the pop-up) */ #ifdef CONFIG_NX_KBD - message("user_start: Send keyboard input: %s\n", g_pumsg); + message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_pumsg); ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg), g_pumsg); if (ret < 0) { - message("user_start: nx_kbdin failed: %d\n", errno); + message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno); goto errout_with_hwnd; } #endif @@ -453,7 +457,7 @@ int user_start(int argc, char *argv[]) { /* Destroy the pop-up window and restart the sequence */ - message("user_start: Close pop-up\n"); + message(MAIN_NAME_STRING ": Close pop-up\n"); (void)nxpu_close(hwnd); popcnt = 0; } @@ -475,7 +479,7 @@ int user_start(int argc, char *argv[]) errout_with_hwnd: if (popcnt >= 3) { - message("user_start: Close pop-up\n"); + message(MAIN_NAME_STRING ": Close pop-up\n"); (void)nxpu_close(hwnd); } @@ -486,12 +490,12 @@ errout_with_nx: #ifdef CONFIG_NX_MULTIUSER /* Disconnect from the server */ - message("user_start: Disconnect from the server\n"); + message(MAIN_NAME_STRING ": Disconnect from the server\n"); nx_disconnect(g_hnx); #else /* Close the server */ - message("user_start: Close NX\n"); + message(MAIN_NAME_STRING ": Close NX\n"); nx_close(g_hnx); #endif errout: diff --git a/apps/examples/usbstorage/Makefile b/apps/examples/usbstorage/Makefile index 39957f141..e821468be 100644 --- a/apps/examples/usbstorage/Makefile +++ b/apps/examples/usbstorage/Makefile @@ -56,12 +56,22 @@ endif ROOTDEPPATH = --dep-path . +# NXTEXT built-in application info + +APPNAME1 = msconn +PRIORITY1 = SCHED_PRIORITY_DEFAULT +STACKSIZE1 = 2048 + +APPNAME2 = msdis +PRIORITY2 = SCHED_PRIORITY_DEFAULT +STACKSIZE2 = 2048 + # Common build VPATH = all: .built -.PHONY: clean depend distclean +.PHONY: context clean depend distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -75,7 +85,14 @@ $(COBJS): %$(OBJEXT): %.c done ; ) @touch .built -context: +.context: +ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y) + $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) + $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main) + @touch $@ +endif + +context: .context .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/usbstorage/usbstrg_main.c b/apps/examples/usbstorage/usbstrg_main.c index 3f0cf57e5..76e864fee 100644 --- a/apps/examples/usbstorage/usbstrg_main.c +++ b/apps/examples/usbstorage/usbstrg_main.c @@ -93,6 +93,17 @@ * Private Data ****************************************************************************/ +/* This is the handle that references to this particular USB storage driver + * instance. It is only needed if the USB mass storage device example is + * built using CONFIG_EXAMPLES_USBSTRG_BUILTIN. In this case, the value + * of the driver handle must be remembered between the 'msconn' and 'msdis' + * commands. + */ + +#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN +static FAR void *g_mshandle; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -284,72 +295,104 @@ static int usbstrg_enumerate(struct usbtrace_s *trace, void *arg) ****************************************************************************/ /**************************************************************************** - * user_start + * user_start/msconn_main + * + * Description: + * This is the main program that configures the USB mass storage device + * and exports the LUN(s). If CONFIG_EXAMPLES_USBSTRG_BUILTIN is defined + * in the NuttX configuration, then this program can be executed by + * entering the "msconn" command at the NSH console. + * ****************************************************************************/ -int user_start(int argc, char *argv[]) +#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN +# define MAIN_NAME msconn_main +# define MAIN_NAME_STRING "msconn" +#else +# define MAIN_NAME user_start +# define MAIN_NAME_STRING "user_start" +#endif + +int MAIN_NAME(int argc, char *argv[]) { - void *handle; + FAR void *handle; int ret; + /* If this program is implemented as the NSH 'msconn' command, then we need to + * do a little error checking to assure that we are not being called re-entrantly. + */ + +#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN + + /* Check if there is a non-NULL USB mass storage device handle (meaning that the + * USB mass storage device is already configured). + */ + + if (g_mshandle) + { + message(MAIN_NAME_STRING ": ERROR: Already connected\n"); + return 1; + } +#endif + /* Initialize USB trace output IDs */ usbtrace_enable(TRACE_BITSET); /* Register block drivers (architecture-specific) */ - message("user_start: Creating block drivers\n"); + message(MAIN_NAME_STRING ": Creating block drivers\n"); ret = usbstrg_archinitialize(); if (ret < 0) { - message("user_start: usbstrg_archinitialize failed: %d\n", -ret); - return 1; + message(MAIN_NAME_STRING ": usbstrg_archinitialize failed: %d\n", -ret); + return 2; } /* Then exports the LUN(s) */ - message("user_start: Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS); + message(MAIN_NAME_STRING ": Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS); ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle); if (ret < 0) { - message("user_start: usbstrg_configure failed: %d\n", -ret); + message(MAIN_NAME_STRING ": usbstrg_configure failed: %d\n", -ret); usbstrg_uninitialize(handle); - return 2; + return 3; } - message("user_start: handle=%p\n", handle); + message(MAIN_NAME_STRING ": handle=%p\n", handle); - message("user_start: Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1); + message(MAIN_NAME_STRING ": Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1); ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false); if (ret < 0) { - message("user_start: usbstrg_bindlun failed for LUN 1 using %s: %d\n", + message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 1 using %s: %d\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret); usbstrg_uninitialize(handle); - return 2; + return 4; } #if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1 - message("user_start: Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2); + message(MAIN_NAME_STRING ": Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2); ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false); if (ret < 0) { - message("user_start: usbstrg_bindlun failed for LUN 2 using %s: %d\n", + message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 2 using %s: %d\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret); usbstrg_uninitialize(handle); - return 3; + return 5; } #if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2 - message("user_start: Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3); + message(MAIN_NAME_STRING ": Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3); ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false); if (ret < 0) { - message("user_start: usbstrg_bindlun failed for LUN 3 using %s: %d\n", + message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 3 using %s: %d\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret); usbstrg_uninitialize(handle); - return 4; + return 6; } #endif @@ -358,34 +401,83 @@ int user_start(int argc, char *argv[]) ret = usbstrg_exportluns(handle); if (ret < 0) { - message("user_start: usbstrg_exportluns failed: %d\n", -ret); + message(MAIN_NAME_STRING ": usbstrg_exportluns failed: %d\n", -ret); usbstrg_uninitialize(handle); - return 5; + return 7; } - /* Now just hang around and monitor the USB storage activity */ + /* It this program was configued as an NSH command, then just exit now. + * Also, if signals are not enabled (and, hence, sleep() is not supported. + * then we have not real option but to exit now. + */ + +#if !defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) && !defined(CONFIG_DISABLE_SIGNALS) + + /* Otherwise, this thread will hang around and monitor the USB storage activity */ -#ifndef CONFIG_DISABLE_SIGNALS for (;;) { msgflush(); sleep(5); -#ifdef CONFIG_USBDEV_TRACE +# ifdef CONFIG_USBDEV_TRACE message("\nuser_start: USB TRACE DATA:\n"); ret = usbtrace_enumerate(usbstrg_enumerate, NULL); if (ret < 0) { - message("user_start: usbtrace_enumerate failed: %d\n", -ret); + message(MAIN_NAME_STRING ": usbtrace_enumerate failed: %d\n", -ret); usbstrg_uninitialize(handle); - return 6; + return 8; } -#else - message("user_start: Still alive\n"); -#endif +# else + message(MAIN_NAME_STRING ": Still alive\n"); +# endif } -#else - message("user_start: Exiting\n"); - #endif +#elif defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) + + /* Return the USB mass storage device handle so it can be used by the 'misconn' + * command. + */ + + message(MAIN_NAME_STRING ": Connected\n"); + g_mshandle = handle; + +#else /* defined(CONFIG_DISABLE_SIGNALS) */ + + /* Just exit */ + + message(MAIN_NAME_STRING ": Exiting\n"); + +#endif + return 0; } +/**************************************************************************** + * msdis_main + * + * Description: + * This is a program entry point that will disconnet the USB mass storage + * device. This program is only available if CONFIG_EXAMPLES_USBSTRG_BUILTIN + * is defined in the NuttX configuration. In that case, this program can + * be executed by entering the "msdis" command at the NSH console. + * + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN +int msdis_main(int argc, char *argv[]) +{ + /* First check if the USB mass storage device is already connected */ + + if (!g_mshandle) + { + message("msdis: ERROR: Not connected\n"); + return 1; + } + + /* Then disconnect the device and uninitialize the USB mass storage driver */ + + usbstrg_uninitialize(g_mshandle); + g_mshandle = NULL; + message("msdis: Disconnected\n"); +} +#endif diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index d588f7bb3..67809e58d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1936,4 +1936,7 @@ ID and returns a handle that is now used at all other font interfaces to specify which of the multiple fonts to use. * arch/arm/src/lpc17xx/lpc17_syscon.h: Fix typo (reported by Li Zhuoyi). + * configs/stm3210e-eval/nsh2: Extended to support two new commands: + 'msconn' will connect the USB mass storage device; 'msdis' will + disconnect the USB storage device. diff --git a/nuttx/Documentation/NuttXCommercial.html b/nuttx/Documentation/NuttXCommercial.html index a4d4de1b9..e35a48e38 100755 --- a/nuttx/Documentation/NuttXCommercial.html +++ b/nuttx/Documentation/NuttXCommercial.html @@ -19,7 +19,7 @@ - + @@ -52,6 +52,7 @@
  • Raztek Solutions
  • 2G Engineering
  • ISOTEL Research
  • +
  • DSPWorks
  • diff --git a/nuttx/Documentation/NuttXDocumentation.html b/nuttx/Documentation/NuttXDocumentation.html index bc8842dd1..80401a078 100755 --- a/nuttx/Documentation/NuttXDocumentation.html +++ b/nuttx/Documentation/NuttXDocumentation.html @@ -50,7 +50,7 @@ - + diff --git a/nuttx/Documentation/NuttXLinks.html b/nuttx/Documentation/NuttXLinks.html index 394ee3c5a..745e12b7e 100755 --- a/nuttx/Documentation/NuttXLinks.html +++ b/nuttx/Documentation/NuttXLinks.html @@ -31,7 +31,7 @@ - + @@ -51,7 +51,7 @@ - + diff --git a/nuttx/Documentation/NuttXRelated.html b/nuttx/Documentation/NuttXRelated.html index 37b0fae7c..fac7c5745 100755 --- a/nuttx/Documentation/NuttXRelated.html +++ b/nuttx/Documentation/NuttXRelated.html @@ -19,7 +19,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/nuttx/arch/arm/src/stm32/stm32_usbdev.c b/nuttx/arch/arm/src/stm32/stm32_usbdev.c index 1a696628c..3fe54ea17 100644 --- a/nuttx/arch/arm/src/stm32/stm32_usbdev.c +++ b/nuttx/arch/arm/src/stm32/stm32_usbdev.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32/stm32_usbdev.c * - * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -479,6 +479,8 @@ static int stm32_selfpowered(struct usbdev_s *dev, bool selfpowered); static void stm32_reset(struct stm32_usbdev_s *priv); static void stm32_hwreset(struct stm32_usbdev_s *priv); +static void stm32_hwsetup(struct stm32_usbdev_s *priv); +static void stm32_hwshutdown(struct stm32_usbdev_s *priv); /**************************************************************************** * Private Data @@ -3310,33 +3312,13 @@ static void stm32_hwreset(struct stm32_usbdev_s *priv) } /**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: up_usbinitialize - * Description: - * Initialize the USB driver - * Input Parameters: - * None - * - * Returned Value: - * None - * + * Name: stm32_hwsetup ****************************************************************************/ -void up_usbinitialize(void) +static void stm32_hwsetup(struct stm32_usbdev_s *priv) { - /* For now there is only one USB controller, but we will always refer to - * it using a pointer to make any future ports to multiple USB controllers - * easier. - */ - - struct stm32_usbdev_s *priv = &g_usbdev; int epno; - usbtrace(TRACE_DEVINIT, 0); - stm32_checksetup(); - /* Power the USB controller, put the USB controller into reset, disable * all USB interrupts */ @@ -3408,6 +3390,63 @@ void up_usbinitialize(void) stm32_putreg(USB_CNTR_FRES, STM32_USB_CNTR); up_mdelay(5); +} + +/**************************************************************************** + * Name: stm32_hwshutdown + ****************************************************************************/ + +static void stm32_hwshutdown(struct stm32_usbdev_s *priv) +{ + priv->usbdev.speed = USB_SPEED_UNKNOWN; + + /* Disable all interrupts and force the USB controller into reset */ + + stm32_putreg(USB_CNTR_FRES, STM32_USB_CNTR); + + /* Clear any pending interrupts */ + + stm32_putreg(0, STM32_USB_ISTR); + + /* Disconnect the device / disable the pull-up */ + + stm32_usbpullup(&priv->usbdev, false); + + /* Power down the USB controller */ + + stm32_putreg(USB_CNTR_FRES|USB_CNTR_PDWN, STM32_USB_CNTR); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ +/**************************************************************************** + * Name: up_usbinitialize + * Description: + * Initialize the USB driver + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void up_usbinitialize(void) +{ + /* For now there is only one USB controller, but we will always refer to + * it using a pointer to make any future ports to multiple USB controllers + * easier. + */ + + struct stm32_usbdev_s *priv = &g_usbdev; + + usbtrace(TRACE_DEVINIT, 0); + stm32_checksetup(); + + /* Power up the USB controller, but leave it in the reset state */ + + stm32_hwsetup(priv); /* Attach USB controller interrupt handlers. The hardware will not be * initialized and interrupts will not be enabled until the class device @@ -3456,39 +3495,25 @@ void up_usbuninitialize(void) struct stm32_usbdev_s *priv = &g_usbdev; irqstate_t flags; - usbtrace(TRACE_DEVUNINIT, 0); - - if (priv->driver) - { - usbtrace(TRACE_DEVERROR(STM32_TRACEERR_DRIVERREGISTERED), 0); - usbdev_unregister(priv->driver); - } - flags = irqsave(); - priv->usbdev.speed = USB_SPEED_UNKNOWN; + usbtrace(TRACE_DEVUNINIT, 0); - /* Disable and detach IRQs */ + /* Disable and detach the USB IRQs */ up_disable_irq(STM32_IRQ_USBHPCANTX); up_disable_irq(STM32_IRQ_USBLPCANRX0); irq_detach(STM32_IRQ_USBHPCANTX); irq_detach(STM32_IRQ_USBLPCANRX0); - /* Disable all interrupts and force the USB controller into reset */ - - stm32_putreg(USB_CNTR_FRES, STM32_USB_CNTR); - - /* Clear any pending interrupts */ - - stm32_putreg(0, STM32_USB_ISTR); - - /* Disconnect the device / disable the pull-up */ + if (priv->driver) + { + usbtrace(TRACE_DEVERROR(STM32_TRACEERR_DRIVERREGISTERED), 0); + usbdev_unregister(priv->driver); + } - stm32_usbpullup(&priv->usbdev, false); - - /* Power down the USB controller */ + /* Put the hardware in an inactive state */ - stm32_putreg(USB_CNTR_FRES|USB_CNTR_PDWN, STM32_USB_CNTR); + stm32_hwshutdown(priv); irqrestore(flags); } @@ -3530,7 +3555,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver) /* First hook up the driver */ - priv->driver = driver; + priv->driver = driver; /* Then bind the class driver */ @@ -3570,9 +3595,10 @@ int usbdev_register(struct usbdevclass_driver_s *driver) * Name: usbdev_unregister * * Description: - * Un-register usbdev class driver.If the USB device is connected to a USB host, - * it will first disconnect(). The driver is also requested to unbind() and clean - * up any device state, before this procedure finally returns. + * Un-register usbdev class driver. If the USB device is connected to a + * USB host, it will first disconnect(). The driver is also requested to + * unbind() and clean up any device state, before this procedure finally + * returns. * ****************************************************************************/ @@ -3584,6 +3610,8 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver) */ struct stm32_usbdev_s *priv = &g_usbdev; + irqstate_t flags; + usbtrace(TRACE_DEVUNREGISTER, 0); #ifdef CONFIG_DEBUG @@ -3596,16 +3624,25 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver) /* Unbind the class driver */ + flags = irqsave(); CLASS_UNBIND(driver, &priv->usbdev); - /* Disable USB controller interrupts */ + /* Disable USB controller interrupts (but keep them attached) */ up_disable_irq(STM32_IRQ_USBHPCANTX); up_disable_irq(STM32_IRQ_USBLPCANRX0); + /* Put the hardware in an inactive state. Then bring the hardware back up + * in the reset state. + */ + + stm32_hwshutdown(priv); + stm32_hwsetup(priv); + /* Unhook the driver */ priv->driver = NULL; + irqrestore(flags); return OK; } diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt index f01d3987d..bf35141c9 100755 --- a/nuttx/configs/stm3210e-eval/README.txt +++ b/nuttx/configs/stm3210e-eval/README.txt @@ -477,6 +477,7 @@ Where is one of the following: ----------- ----------------------- -------------------------------- Built-in None apps/examples/nx Apps apps/examples/nxhello + apps/examples/usbstorage =========== ======================= ================================ * You will probably need to modify nsh/setenv.sh or nsh2/setenv.sh diff --git a/nuttx/configs/stm3210e-eval/nsh2/appconfig b/nuttx/configs/stm3210e-eval/nsh2/appconfig index d3fe4cc28..22b63c04a 100644 --- a/nuttx/configs/stm3210e-eval/nsh2/appconfig +++ b/nuttx/configs/stm3210e-eval/nsh2/appconfig @@ -45,5 +45,6 @@ CONFIGURED_APPS += nshlib CONFIGURED_APPS += examples/nx CONFIGURED_APPS += examples/nxhello +CONFIGURED_APPS += examples/usbstorage diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig index 694bdd1c0..7d0ae8eb3 100644 --- a/nuttx/configs/stm3210e-eval/nsh2/defconfig +++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig @@ -321,12 +321,15 @@ CONFIG_HAVE_LIBM=n # thread. Default: CONFIG_IDLETHREAD_STACKSIZE. # CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up # the worker thread. Default: 4 +# CONFIG_SCHED_WAITPID - Enable the waitpid() API +# CONFIG_SCHED_ATEXIT - Enabled the atexit() API # #CONFIG_APPS_DIR= CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_GRAPHICS=n CONFIG_DEBUG_LCD=n +CONFIG_DEBUG_USB=n CONFIG_DEBUG_SYMBOLS=n CONFIG_MM_REGIONS=1 CONFIG_ARCH_LOWPUTC=y @@ -352,6 +355,8 @@ CONFIG_SCHED_WORKPRIORITY=50 CONFIG_SCHED_WORKPERIOD=(50*1000) CONFIG_SCHED_WORKSTACKSIZE=1024 CONFIG_SIG_SIGWORK=4 +CONFIG_SCHED_WAITPID=y +CONFIG_SCHED_ATEXIT=n # # Settings for NXFLAT @@ -647,7 +652,7 @@ CONFIG_NET_RESOLV_ENTRIES=4 # CONFIG_USBDEV_TRACE_NRECORDS # Number of trace entries to remember # -CONFIG_USBDEV=n +CONFIG_USBDEV=y CONFIG_USBDEV_ISOCHRONOUS=n CONFIG_USBDEV_DUALSPEED=n CONFIG_USBDEV_SELFPOWERED=y @@ -715,7 +720,7 @@ CONFIG_USBSER_TXBUFSIZE=512 # CONFIG_USBSTRG_REMOVABLE # Select if the media is removable # -CONFIG_USBSTRG=n +CONFIG_USBSTRG=y CONFIG_USBSTRG_EP0MAXPACKET=64 CONFIG_USBSTRG_EPBULKOUT=2 CONFIG_USBSTRG_EPBULKIN=5 @@ -1009,7 +1014,7 @@ CONFIG_EXAMPLES_NX_NOTIFYSIGNO=4 CONFIG_EXAMPLES_NX_EXTERNINIT=n # -# Settings for examples/nx +# Settings for examples/nxhello # # CONFIG_EXAMPLES_NXHELLO_BUILTIN -- Build the NXHELLO example as a "built-in" # that can be executed from the NSH command line @@ -1074,6 +1079,55 @@ CONFIG_EXAMPLES_NXIMAGE_YSCALE1p5=y CONFIG_EXAMPLES_NXIMAGE_YSCALE2p0=n CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT=n +# +# Settings for examples/usbstorage +# +# CONFIG_EXAMPLES_USBSTRG_BUILTIN +# This example can be built as two NSH "built-in" commands if this option +# is selection: 'msconn' will connect the USB mass storage device; 'msdis' +# will disconnect the USB storage device. +# CONFIG_EXAMPLES_USBSTRG_NLUNS +# Defines the number of logical units (LUNs) exported by the USB storage +# driver. Each LUN corresponds to one exported block driver (or partition +# of a block driver). May be 1, 2, or 3. Default is 1. +# CONFIG_EXAMPLES_USBSTRG_DEVMINOR1 +# The minor device number of the block driver for the first LUN. For +# example, N in /dev/mmcsdN. Used for registering the block driver. Default +# is zero. +# CONFIG_EXAMPLES_USBSTRG_DEVPATH1 +# The full path to the registered block driver. Default is "/dev/mmcsd0" +# CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 and CONFIG_EXAMPLES_USBSTRG_DEVPATH2 +# Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS +# is 2 or 3. No defaults. +# CONFIG_EXAMPLES_USBSTRG_DEVMINOR3 and CONFIG_EXAMPLES_USBSTRG_DEVPATH3 +# Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS +# is 3. No defaults. +# +# If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then +# the example code will also manage the USB trace output. The amount of trace output +# can be controlled using: +# +# CONFIG_EXAMPLES_USBSTRG_TRACEINIT +# Show initialization events +# CONFIG_EXAMPLES_USBSTRG_TRACECLASS +# Show class driver events +# CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS +# Show data transfer events +# CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER +# Show controller events +# CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS +# Show interrupt-related events. +# +CONFIG_EXAMPLES_USBSTRG_BUILTIN=y +CONFIG_EXAMPLES_USBSTRG_NLUNS=1 +CONFIG_EXAMPLES_USBSTRG_DEVMINOR1=0 +CONFIG_EXAMPLES_USBSTRG_DEVPATH1="/dev/mmcsd0" +CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n +CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n +CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n +CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n +CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n + # # Stack and heap information # diff --git a/nuttx/configs/stm3210e-eval/src/up_nsh.c b/nuttx/configs/stm3210e-eval/src/up_nsh.c index ab4b625f0..36430a52a 100755 --- a/nuttx/configs/stm3210e-eval/src/up_nsh.c +++ b/nuttx/configs/stm3210e-eval/src/up_nsh.c @@ -2,7 +2,7 @@ * config/stm3210e_eval/src/up_nsh.c * arch/arm/src/board/up_nsh.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -190,7 +190,7 @@ int nsh_archinitialize(void) return -ENODEV; } - /* Now bind the SPI interface to the MMC/SD driver */ + /* Now bind the SDIO interface to the MMC/SD driver */ message("nsh_archinitialize: Bind SDIO to the MMC/SD driver, minor=%d\n", CONFIG_NSH_MMCSDMINOR); diff --git a/nuttx/configs/stm3210e-eval/src/up_usbstrg.c b/nuttx/configs/stm3210e-eval/src/up_usbstrg.c index add9a7ed9..f7ba205cc 100755 --- a/nuttx/configs/stm3210e-eval/src/up_usbstrg.c +++ b/nuttx/configs/stm3210e-eval/src/up_usbstrg.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/stm3210e-eval/src/up_usbstrg.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Configure and register the STM32 MMC/SD SDIO block driver. @@ -50,6 +50,8 @@ #include "stm32_internal.h" +/* There is nothing to do here if SDIO support is not selected. */ + #ifdef CONFIG_STM32_SDIO /**************************************************************************** @@ -107,6 +109,12 @@ int usbstrg_archinitialize(void) { + /* If examples/usbstrg is built as an NSH command, then SD slot should + * already have been initized in nsh_archinitialize() (see up_nsh.c). In + * this case, there is nothing further to be done here. + */ + +#ifndef CONFIG_EXAMPLES_USBSTRG_BUILTIN FAR struct sdio_dev_s *sdio; int ret; @@ -124,7 +132,7 @@ int usbstrg_archinitialize(void) return -ENODEV; } - /* Now bind the SPI interface to the MMC/SD driver */ + /* Now bind the SDIO interface to the MMC/SD driver */ message("usbstrg_archinitialize: " "Bind SDIO to the MMC/SD driver, minor=%d\n", @@ -147,6 +155,9 @@ int usbstrg_archinitialize(void) */ sdio_mediachange(sdio, true); + +#endif /* CONFIG_EXAMPLES_USBSTRG_BUILTIN */ + return OK; } diff --git a/nuttx/configs/stm3210e-eval/usbstorage/defconfig b/nuttx/configs/stm3210e-eval/usbstorage/defconfig index 3eaaa800a..a560b9a7b 100755 --- a/nuttx/configs/stm3210e-eval/usbstorage/defconfig +++ b/nuttx/configs/stm3210e-eval/usbstorage/defconfig @@ -303,9 +303,6 @@ CONFIG_HAVE_LIBM=n # 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, @@ -350,13 +347,29 @@ CONFIG_SEM_NNESTPRIO=0 CONFIG_FDCLONE_DISABLE=n CONFIG_FDCLONE_STDIO=n CONFIG_SDCLONE_DISABLE=y -CONFIG_NXFLAT=n CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=50 CONFIG_SCHED_WORKPERIOD=(50*1000) CONFIG_SCHED_WORKSTACKSIZE=1024 CONFIG_SIG_SIGWORK=4 +# +# Settings for NXFLAT +# +# 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_NXFLAT_DUMPBUFFER. Dump a most buffers that NXFFLAT deals +# with. CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and +# CONFIG_DEBUG_BINFMT have to be defined or +# CONFIG_NXFLAT_DUMPBUFFER does nothing. +# CONFIG_SYMTAB_ORDEREDBYNAME. Select if the system symbol table +# is ordered by symbol name +# +CONFIG_NXFLAT=n +CONFIG_NXFLAT_DUMPBUFFER=n +CONFIG_SYMTAB_ORDEREDBYNAME=y + # # The following can be used to disable categories of # APIs supported by the OS. If the compiler supports @@ -728,6 +741,9 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # # 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 @@ -737,6 +753,8 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # CONFIG_NSH_DISABLEBG - Disable background commands # CONFIG_NSH_ROMFSETC - Use startup script in /etc # CONFIG_NSH_CONSOLE - Use serial console front end +# CONFIG_NSH_CONDEV - Select the serial device used to support +# the NSH console. Default: stdin and stdout # CONFIG_NSH_TELNET - Use telnetd console front end # CONFIG_NSH_ARCHINIT - Platform provides architecture # specific initialization (nsh_archinitialize()). @@ -759,6 +777,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # CONFIG_NSH_FATNSECTORS - FAT FS number of sectors # CONFIG_NSH_FATMOUNTPT - FAT FS mountpoint # +CONFIG_NSH_BUILTIN_APPS=n CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_STRERROR=n CONFIG_NSH_LINELEN=64 @@ -768,6 +787,7 @@ CONFIG_NSH_DISABLESCRIPT=n CONFIG_NSH_DISABLEBG=n CONFIG_NSH_ROMFSETC=n CONFIG_NSH_CONSOLE=y +#CONFIG_NSH_CONDEV="/dev/ttyS1" CONFIG_NSH_TELNET=n CONFIG_NSH_ARCHINIT=y CONFIG_NSH_IOBUFFER_SIZE=512 @@ -818,6 +838,10 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n # # Settings for examples/usbstorage # +# CONFIG_EXAMPLES_USBSTRG_BUILTIN +# This example can be built as two NSH "built-in" commands if this option +# is selection: 'msconn' will connect the USB mass storage device; 'msdis' +# will disconnect the USB storage device. # CONFIG_EXAMPLES_USBSTRG_NLUNS # Defines the number of logical units (LUNs) exported by the USB storage # driver. Each LUN corresponds to one exported block driver (or partition @@ -850,6 +874,7 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n # CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS # Show interrupt-related events. # +CONFIG_EXAMPLES_USBSTRG_BUILTIN=n CONFIG_EXAMPLES_USBSTRG_NLUNS=1 CONFIG_EXAMPLES_USBSTRG_DEVMINOR1=0 CONFIG_EXAMPLES_USBSTRG_DEVPATH1="/dev/mmcsd0" -- cgit v1.2.3