Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

echoplayer: disable parts of system_init() for application

Most of system_init() should only be performed once after
reset, and is not safe to re-run when the bootloader jumps
to the application.

Change-Id: I4d2e804ce4884da13b9167ddcda860ef3b5ba7d0

authored by

Aidan MacDonald and committed by
Solomon Peachy
21ba79d4 f642d19c

+47 -32
+47 -32
firmware/target/arm/stm32/echoplayer/system-echoplayer.c
··· 29 29 #include "regs/stm32h743/rtc.h" 30 30 #include "regs/cortex-m/cm_scb.h" 31 31 32 + #ifdef BOOTLOADER 33 + # define BOOTLOADER_INIT 1 34 + #else 35 + # define BOOTLOADER_INIT 0 36 + #endif 37 + 32 38 #define F_INPUT GPIOF_INPUT(GPIO_PULL_DISABLED) 33 39 #define F_INPUT_PU GPIOF_INPUT(GPIO_PULL_UP) 34 40 #define F_INPUT_PD GPIOF_INPUT(GPIO_PULL_DOWN) ··· 173 179 174 180 void system_init(void) 175 181 { 176 - /* Enable clocks for all used GPIO banks */ 177 - reg_writef(RCC_AHB4ENR, 178 - GPIOAEN(1), GPIOBEN(1), GPIOCEN(1), GPIODEN(1), 179 - GPIOEEN(1), GPIOFEN(1), GPIOGEN(1), GPIOHEN(1), GPIOIEN(1)); 182 + if (BOOTLOADER_INIT) 183 + { 184 + /* Enable clocks for all used GPIO banks */ 185 + reg_writef(RCC_AHB4ENR, 186 + GPIOAEN(1), GPIOBEN(1), GPIOCEN(1), GPIODEN(1), 187 + GPIOEEN(1), GPIOFEN(1), GPIOGEN(1), GPIOHEN(1), GPIOIEN(1)); 180 188 181 - /* 182 - * NOTE: I think it's possible to disable clocks for the banks which 183 - * we don't need to access at runtime because these are only clocking 184 - * register access. Probably a micro-optimization but it supposedly 185 - * does save a few uA/MHz. 186 - */ 189 + /* 190 + * NOTE: I think it's possible to disable clocks for the banks which 191 + * we don't need to access at runtime because these are only clocking 192 + * register access. Probably a micro-optimization but it supposedly 193 + * does save a few uA/MHz. 194 + */ 195 + } 187 196 188 197 /* 189 198 * Set cpu_power_on high as early as possible to ··· 200 209 system_debug_enable(true); 201 210 #endif 202 211 203 - /* Enable CPU cache */ 204 - stm32_enable_caches(); 212 + if (BOOTLOADER_INIT) 213 + { 214 + /* Enable CPU cache */ 215 + stm32_enable_caches(); 205 216 206 - /* Initialize system clocks */ 207 - echoplayer_clock_init(); 217 + /* Initialize system clocks */ 218 + echoplayer_clock_init(); 219 + } 208 220 209 221 /* Enable systick early due to udelay() needed for FMC init */ 210 222 stm32_systick_enable(); 211 223 212 - /* Configure GPIOs and start FMC */ 213 - gpio_configure_all(gpios, ARRAYLEN(gpios), 214 - pingroups, ARRAYLEN(pingroups)); 215 - fmc_init(); 224 + if (BOOTLOADER_INIT) 225 + { 226 + /* Configure GPIOs and start FMC */ 227 + gpio_configure_all(gpios, ARRAYLEN(gpios), 228 + pingroups, ARRAYLEN(pingroups)); 229 + fmc_init(); 216 230 217 - /* Read & clear reset source */ 218 - uint32_t rsr = reg_var(RCC_RSR); 219 - reg_assignf(RCC_RSR, RMVF(1)); 231 + /* Read & clear reset source */ 232 + uint32_t rsr = reg_var(RCC_RSR); 233 + reg_assignf(RCC_RSR, RMVF(1)); 220 234 221 - /* 222 - * Determine boot reason -- SFTRST means a software reset 223 - * occurred, which may be a reboot or a power off 224 - */ 225 - if (reg_vreadf(rsr, RCC_RSR, SFTRSTF)) 226 - { 227 - reg_writef(RCC_APB4ENR, RTCAPBEN(1)); 235 + /* 236 + * Determine boot reason -- SFTRST means a software reset 237 + * occurred, which may be a reboot or a power off 238 + */ 239 + if (reg_vreadf(rsr, RCC_RSR, SFTRSTF)) 240 + { 241 + reg_writef(RCC_APB4ENR, RTCAPBEN(1)); 228 242 229 - if (reg_readf(RTC_CR, WUTE)) 230 - echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_SW_REBOOT; 231 - else 232 - echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_SW_POWEROFF; 243 + if (reg_readf(RTC_CR, WUTE)) 244 + echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_SW_REBOOT; 245 + else 246 + echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_SW_POWEROFF; 247 + } 233 248 } 234 249 235 250 /* Disable RTC_OUT pin */