Skip to content

Commit

Permalink
cpu: Moved stdio_init() into cpu_init()
Browse files Browse the repository at this point in the history
- Removed stdio_init() from newlib's _init(), as this is too late in the boot
  process to allow DEBUG()ing during periph_init()
- Added stdio_init() to the various cpu_init() routines of the ARM CPUs just
  before periph_init()
  • Loading branch information
maribu committed Sep 6, 2019
1 parent 999fffd commit df27dbe
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cpu/cc2538/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "cpu.h"
#include "periph/init.h"
#include "stdio_base.h"

#define BIT(n) ( 1UL << (n) )

Expand Down Expand Up @@ -48,6 +49,8 @@ void cpu_init(void)
SYS_CTRL->I_MAP = 1;
/* initialize the clock system */
cpu_clock_init();
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();
/* trigger static peripheral initialization */
periph_init();
}
Expand Down
4 changes: 4 additions & 0 deletions cpu/cc26x0/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cpu.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

#ifndef HF_CLOCK_SOURCE
#define HF_CLOCK_SOURCE DDI_0_OSC_CTL0_SCLK_HF_SRC_SEL_RCOSC /* set 48MHz RCOSC */
Expand All @@ -44,6 +45,9 @@ void cpu_init(void)
/* initialize the system clock */
cpu_clock_init();

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
Expand Down
4 changes: 4 additions & 0 deletions cpu/efm32/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cpu.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

#include "em_chip.h"
#include "em_cmu.h"
Expand Down Expand Up @@ -172,6 +173,9 @@ void cpu_init(void)
/* initialize power management interface */
pm_init();

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
3 changes: 3 additions & 0 deletions cpu/ezr32wg/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cpu.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

/**
* @brief Configure clock sources and the CPU frequency
Expand Down Expand Up @@ -60,6 +61,8 @@ void cpu_init(void)
cortexm_init();
/* Initialise clock sources and generic clocks */
clk_init();
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();
/* trigger static peripheral initialization */
periph_init();
}
5 changes: 5 additions & 0 deletions cpu/kinetis/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "cpu.h"
#include "periph/init.h"
#include "stdio_base.h"
#ifdef MODULE_PERIPH_MCG
#include "mcg.h"
#endif
Expand All @@ -41,6 +42,10 @@ void cpu_init(void)
/* initialize the CPU clocking provided by the MCG module */
kinetis_mcg_init();
#endif

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
4 changes: 4 additions & 0 deletions cpu/lm4f120/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "irq.h"
#include "periph/init.h"
#include "periph_conf.h"
#include "stdio_base.h"

/**
* @brief Initialize the CPU, set IRQ priorities
Expand All @@ -36,6 +37,9 @@ void cpu_init(void)
/* initialize the clock system */
cpu_clock_init(CLOCK_SOURCE);

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
Expand Down
3 changes: 3 additions & 0 deletions cpu/lpc1768/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "cpu.h"
#include "periph/init.h"
#include "stdio_base.h"

/**
* @brief Initialize the CPU, set IRQ priorities
Expand All @@ -27,6 +28,8 @@ void cpu_init(void)
{
/* initialize the Cortex-M core */
cortexm_init();
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();
/* trigger static peripheral initialization */
periph_init();
}
3 changes: 3 additions & 0 deletions cpu/nrf51/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "nrf_clock.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

/**
* @brief Initialize the CPU, set IRQ priorities
Expand All @@ -31,6 +32,8 @@ void cpu_init(void)
cortexm_init();
/* setup the HF clock */
clock_init_hf();
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();
/* trigger static peripheral initialization */
periph_init();
}
4 changes: 4 additions & 0 deletions cpu/nrf52/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "nrf_clock.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

/* FTPAN helper functions */
static bool ftpan_32(void);
Expand Down Expand Up @@ -83,6 +84,9 @@ void cpu_init(void)
/* enable wake up on events for __WFE CPU sleep */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
Expand Down
4 changes: 4 additions & 0 deletions cpu/sam3/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cpu.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

/**
* @brief Keys needed for editing certain PMC registers
Expand Down Expand Up @@ -90,6 +91,9 @@ void cpu_init(void)
/* wait for master clock to be ready */
while (!(PMC->PMC_SR & PMC_SR_MCKRDY));

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
3 changes: 3 additions & 0 deletions cpu/samd21/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cpu.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

#ifndef CLOCK_8MHZ
#define CLOCK_8MHZ 1
Expand Down Expand Up @@ -218,6 +219,8 @@ void cpu_init(void)
cortexm_init();
/* Initialise clock sources and generic clocks */
clk_init();
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();
/* trigger static peripheral initialization */
periph_init();
}
4 changes: 4 additions & 0 deletions cpu/samd5x/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cpu.h"
#include "periph_conf.h"
#include "periph/init.h"
#include "stdio_base.h"

static void xosc32k_init(void)
{
Expand Down Expand Up @@ -137,6 +138,9 @@ void cpu_init(void)
gclk_connect(6, GCLK_SOURCE_DFLL, 0);
#endif

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
4 changes: 4 additions & 0 deletions cpu/saml1x/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "periph/init.h"
#include "periph_conf.h"
#include "board.h"
#include "stdio_base.h"

#ifdef CPU_FAM_SAML11
#define _NVMCTRL NVMCTRL_SEC
Expand Down Expand Up @@ -115,6 +116,9 @@ void cpu_init(void)
/* Setup GCLK generators */
_gclk_setup(0, GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSC16M);

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
4 changes: 4 additions & 0 deletions cpu/saml21/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cpu.h"
#include "periph/init.h"
#include "periph_conf.h"
#include "stdio_base.h"

static void _gclk_setup(int gclk, uint32_t reg)
{
Expand Down Expand Up @@ -118,6 +119,9 @@ void cpu_init(void)
SUPC->BOD33.bit.ENABLE=0;
#endif

/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();

/* trigger static peripheral initialization */
periph_init();
}
3 changes: 3 additions & 0 deletions cpu/stm32_common/cpu_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/

#include "cpu.h"
#include "stdio_base.h"
#include "stmclk.h"
#include "periph_cpu.h"
#include "periph/init.h"
Expand Down Expand Up @@ -160,6 +161,8 @@ void cpu_init(void)
/* initialize DMA streams */
dma_init();
#endif
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
stdio_init();
/* trigger static peripheral initialization */
periph_init();
}
2 changes: 1 addition & 1 deletion sys/newlib_syscalls_default/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ char *heap_top = &_sheap + 4;
*/
void _init(void)
{
stdio_init();
/* nothing to do here */
}

/**
Expand Down

0 comments on commit df27dbe

Please sign in to comment.