Skip to content

Commit 0fe13b1

Browse files
committed
!apps: Simplify NuttX initialization
BREAKING: In an effort to simplify board initialization logic for NuttX, NSH will no longer support architecture initialization. This will happen during boot via the BOARD_LATE_INITIALIZE option. The boardctl command BOARDIOC_INIT is also no longer available from user-space. Quick fix: Any application relying on BOARDIOC_INIT should now enable BOARD_LATE_INITIALIZE to have initialization performed by the kernel in advance of the application running. If control over initialization is still necessary, BOARDIOC_FINALINIT should be implemented and used. Boards relying on NSH for initialization should also enable BOARD_LATE_INITIALIZE instead. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
1 parent 7289c27 commit 0fe13b1

22 files changed

Lines changed: 19 additions & 215 deletions

File tree

boot/miniboot/miniboot_main.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Name: miniboot_main
4040
*
4141
* Description:
42-
* Minimal bootlaoder entry point.
42+
* Minimal bootloader entry point.
4343
*
4444
****************************************************************************/
4545

@@ -49,10 +49,6 @@ int main(int argc, FAR char *argv[])
4949

5050
syslog(LOG_INFO, "*** miniboot ***\n");
5151

52-
/* Perform architecture-specific initialization (if configured) */
53-
54-
boardctl(BOARDIOC_INIT, 0);
55-
5652
#ifdef CONFIG_BOARDCTL_FINALINIT
5753
/* Perform architecture-specific final-initialization (if configured) */
5854

boot/nxboot/nxboot_main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,10 @@ int main(int argc, FAR char *argv[])
264264
FAR struct boardioc_reset_cause_s cause;
265265
#endif
266266

267-
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
268-
/* Perform architecture-specific initialization (if configured) */
269-
270-
boardctl(BOARDIOC_INIT, 0);
271-
272-
#ifdef CONFIG_BOARDCTL_FINALINIT
267+
#if defined(CONFIG_BOARDCTL_FINALINIT) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
273268
/* Perform architecture-specific final-initialization (if configured) */
274269

275270
boardctl(BOARDIOC_FINALINIT, 0);
276-
#endif
277271
#endif
278272

279273
syslog(LOG_INFO, "*** nxboot ***\n");

examples/foc/foc_main.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct args_s g_args =
142142
}
143143
};
144144

145-
/* Start allowed at defaule */
145+
/* Start allowed at default */
146146

147147
static bool g_start_allowed = true;
148148
static pthread_mutex_t g_start_allowed_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -294,16 +294,10 @@ int main(int argc, char *argv[])
294294
goto errout_no_nxscope;
295295
}
296296

297-
#ifndef CONFIG_NSH_ARCHINIT
298-
/* Perform architecture-specific initialization (if configured) */
299-
300-
boardctl(BOARDIOC_INIT, 0);
301-
302-
# ifdef CONFIG_BOARDCTL_FINALINIT
297+
#if defined(CONFIG_BOARDCTL_FINALINIT) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
303298
/* Perform architecture-specific final-initialization (if configured) */
304299

305300
boardctl(BOARDIOC_FINALINIT, 0);
306-
# endif
307301
#endif
308302

309303
PRINTF("\nStart foc_main application!\n\n");

examples/lvgldemo/lvgldemo.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,6 @@
3838
* Pre-processor Definitions
3939
****************************************************************************/
4040

41-
/* Should we perform board-specific driver initialization? There are two
42-
* ways that board initialization can occur: 1) automatically via
43-
* board_late_initialize() during bootupif CONFIG_BOARD_LATE_INITIALIZE
44-
* or 2).
45-
* via a call to boardctl() if the interface is enabled
46-
* (CONFIG_BOARDCTL=y).
47-
* If this task is running as an NSH built-in application, then that
48-
* initialization has probably already been performed otherwise we do it
49-
* here.
50-
*/
51-
52-
#undef NEED_BOARDINIT
53-
54-
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
55-
# define NEED_BOARDINIT 1
56-
#endif
57-
5841
/****************************************************************************
5942
* Private Types
6043
****************************************************************************/
@@ -122,13 +105,6 @@ int main(int argc, FAR char *argv[])
122105
return -1;
123106
}
124107

125-
#ifdef NEED_BOARDINIT
126-
/* Perform board-specific driver initialization */
127-
128-
boardctl(BOARDIOC_INIT, 0);
129-
130-
#endif
131-
132108
lv_init();
133109

134110
lv_nuttx_dsc_init(&info);

examples/lvglterm/lvglterm.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,6 @@
6363
* Pre-processor Definitions
6464
****************************************************************************/
6565

66-
/* Should we perform board-specific driver initialization? There are two
67-
* ways that board initialization can occur: 1) automatically via
68-
* board_late_initialize() during bootupif CONFIG_BOARD_LATE_INITIALIZE
69-
* or 2).
70-
* via a call to boardctl() if the interface is enabled
71-
* (CONFIG_BOARDCTL=y).
72-
* If this task is running as an NSH built-in application, then that
73-
* initialization has probably already been performed otherwise we do it
74-
* here.
75-
*/
76-
77-
#undef NEED_BOARDINIT
78-
79-
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
80-
# define NEED_BOARDINIT 1
81-
#endif
82-
8366
/* How often to poll for output from NSH Shell (milliseconds) */
8467

8568
#define TIMER_PERIOD_MS 100
@@ -550,16 +533,10 @@ int main(int argc, FAR char *argv[])
550533
uv_loop_t ui_loop;
551534
#endif
552535

553-
#ifdef NEED_BOARDINIT
554-
/* Perform board-specific driver initialization */
555-
556-
boardctl(BOARDIOC_INIT, 0);
557-
558-
#ifdef CONFIG_BOARDCTL_FINALINIT
536+
#if defined(CONFIG_BOARDCTL_FINALINIT) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
559537
/* Perform architecture-specific final-initialization (if configured) */
560538

561539
boardctl(BOARDIOC_FINALINIT, 0);
562-
#endif
563540
#endif
564541

565542
/* LVGL initialization */

examples/nimble/nimble_main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,6 @@ int main(int argc, FAR char *argv[])
255255
ble_hci_sock_set_device(atoi(argv[1]));
256256
}
257257

258-
#ifndef CONFIG_NSH_ARCHINIT
259-
/* Perform architecture-specific initialization */
260-
261-
boardctl(BOARDIOC_INIT, 0);
262-
#endif
263-
264258
#ifndef CONFIG_NSH_NETINIT
265259
/* Bring up the network */
266260

examples/nimble_blecent/nimble_blecent_main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static int blecent_gap_event(FAR struct ble_gap_event *event, FAR void *arg)
412412
return 0;
413413
}
414414

415-
/* An advertisment report was received during GAP discovery. */
415+
/* An advertisement report was received during GAP discovery. */
416416

417417
print_adv_fields(&fields);
418418

@@ -632,12 +632,6 @@ int main(int argc, FAR char **argv)
632632
ble_hci_sock_set_device(atoi(argv[1]));
633633
}
634634

635-
#ifndef CONFIG_NSH_ARCHINIT
636-
/* Perform architecture-specific initialization */
637-
638-
boardctl(BOARDIOC_INIT, 0);
639-
#endif
640-
641635
#ifndef CONFIG_NSH_NETINIT
642636
/* Bring up the network */
643637

examples/nimble_bleprph/nimble_bleprph_main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void bleprph_advertise(void)
140140
BLE_HS_ADV_F_BREDR_UNSUP;
141141

142142
/* Indicate that the TX power level field should be included; have the
143-
* stack fill this value automatically. This is done by assiging the
143+
* stack fill this value automatically. This is done by assigning the
144144
* special value BLE_HS_ADV_TX_PWR_LVL_AUTO.
145145
*/
146146

@@ -372,12 +372,6 @@ int main(int argc, FAR char *argv[])
372372
ble_hci_sock_set_device(atoi(argv[1]));
373373
}
374374

375-
#ifndef CONFIG_NSH_ARCHINIT
376-
/* Perform architecture-specific initialization */
377-
378-
boardctl(BOARDIOC_INIT, 0);
379-
#endif
380-
381375
#ifndef CONFIG_NSH_NETINIT
382376
/* Bring up the network */
383377

examples/nxscope/nxscope_main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,10 @@ int main(int argc, FAR char *argv[])
435435
struct nxscope_dummy_cfg_s nxs_dummy_cfg;
436436
#endif
437437

438-
#ifndef CONFIG_NSH_ARCHINIT
439-
/* Perform architecture-specific initialization (if configured) */
440-
441-
boardctl(BOARDIOC_INIT, 0);
442-
443-
# ifdef CONFIG_BOARDCTL_FINALINIT
438+
#if defined(CONFIG_BOARDCTL_FINALINIT) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
444439
/* Perform architecture-specific final-initialization (if configured) */
445440

446441
boardctl(BOARDIOC_FINALINIT, 0);
447-
# endif
448442
#endif
449443

450444
#ifdef CONFIG_EXAMPLES_NXSCOPE_CDCACM

examples/powerled/powerled_main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,10 @@ int main(int argc, char *argv[])
435435
goto errout;
436436
}
437437

438-
#ifndef CONFIG_NSH_ARCHINIT
439-
/* Perform architecture-specific initialization (if configured) */
440-
441-
boardctl(BOARDIOC_INIT, 0);
442-
443-
#ifdef CONFIG_BOARDCTL_FINALINIT
438+
#if defined(CONFIG_BOARDCTL_FINALINIT) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
444439
/* Perform architecture-specific final-initialization (if configured) */
445440

446441
boardctl(BOARDIOC_FINALINIT, 0);
447-
#endif
448442
#endif
449443

450444
/* Set LED current limit */

0 commit comments

Comments
 (0)