apps/graphics/twm4nx: Add options to initialize the system via boardctl() and to bring up the network using the new apps/netutils/netinit. This latter is only necessary because VNC is being used to provide graphics.

This commit is contained in:
Gregory Nutt 2019-04-29 11:49:15 -06:00
parent 94a0d92b54
commit ad57b3de4d
4 changed files with 67 additions and 10 deletions

View File

@ -41,4 +41,24 @@ config TWM4NX_REVMINOR
string "Twm4Nx minor version number"
default "0"
config TWM4NX_ARCHINIT
bool "Have architecture-specific initialization"
default n
select LIB_BOARDCTL
depends on !NSH_ARCHINIT
---help---
Set if your board provides architecture specific initialization
via the board-interface function boardctl(). The boardctl()
function will be called early in Twm4Nx initialization to allow
board logic to do such things as configure MMC/SD slots.
config TWM4NX_NETINIT
bool "Network initialization"
default y
depends on NET
select NETUTILS_NETINIT
depends on !NSH_ARCHINIT
---help---
This option enables/disables all network initialization in Twm4Nx.
endif # GRAPHICS_TWM4NX

View File

@ -64,6 +64,7 @@
#include <nuttx/nx/nxglib.h>
#include "platform/cxxinitialize.h"
#include "netutils/netinit.h"
#include "graphics/twm4nx/twm4nx_config.hxx"
#include "graphics/twm4nx/ctwm4nx.hxx"
@ -182,16 +183,6 @@ bool CTwm4Nx::run(void)
up_cxxinitialize();
#endif
#if defined(CONFIG_LIB_BOARDCTL) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
// Should we perform board-specific initialization? There are two ways
// that board initialization can occur: 1) automatically via
// board_late_initialize() during bootup if CONFIG_BOARD_LATE_INITIALIZE, or
// 2) here via a call to boardctl() if the interface is enabled
// (CONFIG_LIB_BOARDCTL=y).
(void)boardctl(BOARDIOC_INIT, 0);
#endif
// Connect to the NX server
if (!connect())
@ -601,6 +592,38 @@ int twm4nx_main(int argc, char *argv[])
return EXIT_FAILURE;
}
int ret;
#if defined(CONFIG_TWM4NX_ARCHINIT) && defined(CONFIG_LIB_BOARDCTL) && \
!defined(CONFIG_BOARD_LATE_INITIALIZE)
// Should we perform board-specific initialization? There are two ways
// that board initialization can occur: 1) automatically via
// board_late_initialize() during bootup if CONFIG_BOARD_LATE_INITIALIZE, or
// 2) here via a call to boardctl() if the interface is enabled
// (CONFIG_LIB_BOARDCTL=y). board_early_initialize() is also possibility,
// although less likely.
ret = boardctl(BOARDIOC_INIT, 0);
if (ret < 0)
{
gerr("ERROR: boardctl(BOARDIOC_INIT) failed: %d\n", errno);
return EXIT_FAILURE;
}
#endif
#ifdef CONFIG_TWM4NX_NETINIT
/* Bring up the network */
ret = netinit_bringup();
if (ret < 0)
{
gerr("ERROR: netinit_bringup() failed: %d\n", ret);
return EXIT_FAILURE;
}
#endif
UNUSED(ret);
/* Create an instance of CTwm4Nx and and run it */
FAR CTwm4Nx *twm4nx = new CTwm4Nx(display);

View File

@ -47,6 +47,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Networking support. Make sure that all non-boolean configuration
@ -99,6 +100,14 @@
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: netinit_bringup
*
@ -117,5 +126,9 @@ int netinit_bringup(void);
int netinit_associate(FAR const char *ifname);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_NETUTILS_NETINIT */
#endif /* __APPS_INCLUDE_NETUTILS_NETINIT_H */

View File

@ -8,6 +8,7 @@ menuconfig NETUTILS_NETINIT
bool "Network initialization"
default n
depends on NET
select NETUTILS_NETLIB
---help---
This option enables/disables all support for common network initialization.