Skip to content

Commit

Permalink
cpu/esp32: fix of ctor and newlib initialization
Browse files Browse the repository at this point in the history
Module `newlib` is now used by default. Therefore, the separation of initialization of ctors and the newlibc is not needed any longer. Instead of calling `do_global_ctors` and `_init` separately, `__libc_init_array` is called. Explicit function `do_global_ctors` is removed.
  • Loading branch information
gschorcht committed Aug 21, 2019
1 parent d297033 commit 328813c
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions cpu/esp32/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ extern void bootloader_clock_configure(void);

/* forward declarations */
static void system_init(void);
static void do_global_ctors(void);
static void intr_matrix_clear(void);

typedef int32_t esp_err_t;
Expand Down Expand Up @@ -279,22 +278,19 @@ static NORETURN void IRAM system_init (void)
/* Disable the hold flag of all RTC GPIO pins */
RTCCNTL.hold_force.val = 0;

/* execute constructors */
do_global_ctors();
/*
* initialization of newlib, includes the ctors initialization and
* and the execution of stdio_init in _init of newlib_syscalls_default
*/
extern void __libc_init_array(void);
__libc_init_array();

/* init watchdogs */
system_wdt_init();

/* init random number generator */
srand(hwrand());

/*
* initialization as it should be called from newlibc (includes the
* execution of stdio_init)
*/
extern void _init(void);
_init();

/* add SPI RAM to heap if enabled */
#if CONFIG_SPIRAM_SUPPORT && CONFIG_SPIRAM_BOOT_INIT
spi_ram_heap_init();
Expand Down Expand Up @@ -345,18 +341,6 @@ static NORETURN void IRAM system_init (void)
UNREACHABLE();
}

static void do_global_ctors(void)
{
#if 0 /* TODO when real ctors are used exist */
extern uint32_t* __init_array_start;
extern uint32_t* __init_array_end;
for (uint32_t* up = __init_array_end - 1; up >= __init_array_start; --up) {
void (*fp)(void) = (void (*)(void))up;
fp();
}
#endif
}

static void intr_matrix_clear(void)
{
/* attach all peripheral interrupt sources (Technical Reference, Table 7) */
Expand Down

0 comments on commit 328813c

Please sign in to comment.