Skip to content

Commit 1136795

Browse files
1ridicmysterywolf
authored andcommitted
[bsp][pico] Add msh cmd to reset pico to BOOTSEL mode
1 parent 87ee720 commit 1136795

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

bsp/raspberry-pico/board/board.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "board.h"
1818
#include "hardware/structs/systick.h"
19+
#include "pico/bootrom.h"
1920

2021
#define PLL_SYS_KHZ (133 * 1000)
2122

@@ -36,16 +37,16 @@ void isr_systick(void)
3637

3738
uint32_t systick_config(uint32_t ticks)
3839
{
39-
if ((ticks - 1UL) > M0PLUS_SYST_RVR_RELOAD_BITS)
40-
{
41-
return (1UL); /* Reload value impossible */
42-
}
40+
if ((ticks - 1UL) > M0PLUS_SYST_RVR_RELOAD_BITS)
41+
{
42+
return (1UL); /* Reload value impossible */
43+
}
4344

44-
mpu_hw->rvr = (uint32_t)(ticks - 1UL); /* set reload register */
45-
mpu_hw->csr = M0PLUS_SYST_CSR_CLKSOURCE_BITS |
45+
mpu_hw->rvr = (uint32_t)(ticks - 1UL); /* set reload register */
46+
mpu_hw->csr = M0PLUS_SYST_CSR_CLKSOURCE_BITS |
4647
M0PLUS_SYST_CSR_TICKINT_BITS |
4748
M0PLUS_SYST_CSR_ENABLE_BITS; /* Enable SysTick IRQ and SysTick Timer */
48-
return (0UL); /* Function successful */
49+
return (0UL); /* Function successful */
4950
}
5051

5152
void rt_hw_board_init()
@@ -71,12 +72,13 @@ void rt_hw_board_init()
7172
// Call each function in the list.
7273
// We have to take the address of the symbols, as __init_array_start *is*
7374
// the first function pointer, not the address of it.
74-
for (void (**p)() = &__init_array_start; p < &__init_array_end; ++p) {
75+
for (void (**p)() = &__init_array_start; p < &__init_array_end; ++p)
76+
{
7577
(*p)();
7678
}
7779

7880
/* Configure the SysTick */
79-
systick_config(clock_get_hz(clk_sys)/RT_TICK_PER_SECOND);
81+
systick_config(clock_get_hz(clk_sys) / RT_TICK_PER_SECOND);
8082

8183
#ifdef RT_USING_COMPONENTS_INIT
8284
rt_components_board_init();
@@ -88,6 +90,15 @@ void rt_hw_board_init()
8890
#endif
8991

9092
#ifdef RT_USING_CONSOLE
91-
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
93+
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
9294
#endif
9395
}
96+
97+
#ifdef RT_USING_MSH
98+
static int pico_reboot(int argc, char *argv[])
99+
{
100+
reset_usb_boot(0, 0);
101+
return 0;
102+
}
103+
MSH_CMD_EXPORT_ALIAS(pico_reboot, reboot, reset Pico to BOOTSEL mode);
104+
#endif

0 commit comments

Comments
 (0)