rp2040: support usb_request_bootloader
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
bb2f27f928
commit
0597210cb9
|
@ -15,7 +15,7 @@ $(OUT)klipper.elf: $(OUT)stage2.o $(OUT)src/rp2040/rp2040_link.ld
|
|||
# Add source files
|
||||
src-y += rp2040/main.c rp2040/gpio.c rp2040/adc.c generic/crc16_ccitt.c
|
||||
src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_reset.c
|
||||
src-y += generic/timer_irq.c rp2040/timer.c
|
||||
src-y += generic/timer_irq.c rp2040/timer.c rp2040/bootrom.c
|
||||
src-$(CONFIG_USBSERIAL) += rp2040/usbserial.c generic/usb_cdc.c
|
||||
src-$(CONFIG_SERIAL) += rp2040/serial.c generic/serial_irq.c
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// Hardware interface to bootrom on rp2040
|
||||
//
|
||||
// Copyright (C) 2021 Lasse Dalegaard <dalegaard@gmail.com>
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include <stdint.h> // uint16_t, uint32_t, uintptr_t
|
||||
|
||||
static void *
|
||||
rom_func_lookup(uint32_t code)
|
||||
{
|
||||
// Table and lookup function are provided by the BOOTROM
|
||||
void *(*fn)(uint16_t *, uint32_t) =
|
||||
(void *)(uintptr_t)(*(uint16_t *)0x18);
|
||||
uint16_t *table = (uint16_t *)(uintptr_t)(*(uint16_t *)0x14);
|
||||
return fn(table, code);
|
||||
}
|
||||
|
||||
void
|
||||
reset_to_usb_boot(uint32_t gpio_activity_pin_mask
|
||||
, uint32_t disable_interface_mask)
|
||||
{
|
||||
void (*reset_to_usb_boot)(uint32_t, uint32_t) = rom_func_lookup(0x4255);
|
||||
reset_to_usb_boot(gpio_activity_pin_mask, disable_interface_mask);
|
||||
}
|
|
@ -8,5 +8,7 @@ void enable_pclock(uint32_t reset_bit);
|
|||
int is_enabled_pclock(uint32_t reset_bit);
|
||||
uint32_t get_pclock_frequency(uint32_t reset_bit);
|
||||
void gpio_peripheral(uint32_t gpio, int func, int pull_up);
|
||||
void reset_to_usb_boot(uint32_t gpio_activity_pin_mask
|
||||
, uint32_t disable_interface_mask);
|
||||
|
||||
#endif // internal.h
|
||||
|
|
|
@ -153,7 +153,8 @@ usb_set_configure(void)
|
|||
void
|
||||
usb_request_bootloader(void)
|
||||
{
|
||||
// XXX
|
||||
// Use the bootrom-provided code to reset into BOOTSEL mode
|
||||
reset_to_usb_boot(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue