samd: enter_bootldr command, bootldr button
This commit is contained in:
parent
4847e0d1e6
commit
4aee9fe2a3
@ -64,6 +64,9 @@ static bool cmd_debug_bmp(target *t, int argc, const char **argv);
|
||||
#ifdef PLATFORM_HAS_UART_WHEN_SWDP
|
||||
static bool cmd_convert_tdio(target *t, int argc, const char **argv);
|
||||
#endif
|
||||
#ifdef PLATFORM_HAS_BOOTLOADER
|
||||
static bool cmd_enter_bootldr(target *t, int argc, const char **argv);
|
||||
#endif
|
||||
|
||||
const struct command_s cmd_list[] = {
|
||||
{"version", (cmd_handler)cmd_version, "Display firmware version info"},
|
||||
@ -85,6 +88,9 @@ const struct command_s cmd_list[] = {
|
||||
#endif
|
||||
#ifdef PLATFORM_HAS_UART_WHEN_SWDP
|
||||
{"convert_tdio", (cmd_handler)cmd_convert_tdio,"Switch TDI/O pins to UART TX/RX functions"},
|
||||
#endif
|
||||
#ifdef PLATFORM_HAS_BOOTLOADER
|
||||
{"enter_bootldr", (cmd_handler)cmd_enter_bootldr,"Force BMP into bootloader mode"},
|
||||
#endif
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
@ -322,3 +328,16 @@ static bool cmd_convert_tdio(target *t, int argc, const char **argv)
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_HAS_BOOTLOADER
|
||||
static bool cmd_enter_bootldr(target *t, int argc, const char **argv)
|
||||
{
|
||||
(void) t;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
scb_reset_system();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -94,23 +94,45 @@ static uint32_t timing_init(void)
|
||||
static void adc_init(void)
|
||||
{
|
||||
gpio_config_special(ADC_PORT, ADC_POS_PIN, SOC_GPIO_PERIPH_B); /* +input */
|
||||
gpio_config_special(ADC_PORT, ADC_REF_PIN, SOC_GPIO_PERIPH_B); /* reference */
|
||||
gpio_config_special(ADC_PORT, ADC_REF_PIN, SOC_GPIO_PERIPH_B); /* reference */
|
||||
|
||||
set_periph_clk(GCLK1, GCLK_ID_ADC);
|
||||
periph_clk_en(GCLK_ID_ADC, 1);
|
||||
periph_clk_en(GCLK_ID_ADC, 1);
|
||||
|
||||
adc_enable(ADC_REFCTRL_VREFA,0,ADC_INPUTCTRL_GND,ADC_MUXPOS);
|
||||
}
|
||||
|
||||
#define EIC 0x40001800
|
||||
#define EIC_CONFIG1 0x4000181C
|
||||
#define EIC_INTENSET 0x4000180C
|
||||
|
||||
static void button_init(void)
|
||||
{
|
||||
gpio_config_special(BUTTON_PORT, BUTTON_PIN, SOC_GPIO_PERIPH_A);
|
||||
|
||||
INSERTBF(PM_APBAMASK_EIC, 1, PM->apbamask);
|
||||
|
||||
set_periph_clk(GCLK0, GCLK_ID_EIC);
|
||||
periph_clk_en(GCLK_ID_EIC, 1);
|
||||
|
||||
/* configure falling edge */
|
||||
//EIC->evctrl = (1<<15);
|
||||
*((uint32_t*)EIC_CONFIG1) = (2<<28);
|
||||
|
||||
/* enable the IEC */
|
||||
*((uint8_t*)EIC) = (1<<1);
|
||||
|
||||
/* enable interrupts */
|
||||
*((uint32_t*)EIC_INTENSET) = (1<<15);
|
||||
nvic_enable_irq(NVIC_EIC_IRQ);
|
||||
}
|
||||
|
||||
void platform_init(void)
|
||||
{
|
||||
gclk_init(&clock);
|
||||
|
||||
usb_setup();
|
||||
|
||||
//gpio_config_special(TCK_PORT, TCK_PIN, SOC_GPIO_NONE);
|
||||
//gpio_config_special(TMS_PORT, TMS_PIN, SOC_GPIO_NONE);
|
||||
|
||||
gpio_config_output(LED_PORT, LED_IDLE_RUN, 0);
|
||||
gpio_config_output(TMS_PORT, TMS_PIN, 0);
|
||||
gpio_config_output(TCK_PORT, TCK_PIN, 0);
|
||||
@ -136,23 +158,11 @@ void platform_init(void)
|
||||
gpio_clear(LED_PORT_UART, LED_UART);
|
||||
|
||||
|
||||
/* NOT SURE IF NEED THIS */
|
||||
/* Enable internal pull-up on PWR_BR so that we don't drive
|
||||
TPWR locally or inadvertently supply power to the target. */
|
||||
/*
|
||||
if (1) {
|
||||
gpio_set(PWR_BR_PORT, PWR_BR_PIN);
|
||||
gpio_config_input(PWR_BR_PORT, PWR_BR_PIN, GPIO_IN_FLAG_PULLUP);
|
||||
} else {
|
||||
gpio_set(PWR_BR_PORT, PWR_BR_PIN);
|
||||
gpio_set_mode(PWR_BR_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_OPENDRAIN, PWR_BR_PIN);
|
||||
}*/
|
||||
|
||||
timing_init();
|
||||
usbuart_init();
|
||||
cdcacm_init();
|
||||
adc_init();
|
||||
button_init();
|
||||
}
|
||||
|
||||
void platform_srst_set_val(bool assert)
|
||||
@ -192,7 +202,6 @@ const char *platform_target_voltage(void)
|
||||
out[2] = '0' + (char)((voltage/10) % 10);
|
||||
|
||||
return out;
|
||||
//return "not supported";
|
||||
}
|
||||
|
||||
char *serialno_read(char *s)
|
||||
@ -219,3 +228,9 @@ char *serialno_read(char *s)
|
||||
void platform_request_boot(void)
|
||||
{
|
||||
}
|
||||
|
||||
void eic_isr(void)
|
||||
{
|
||||
|
||||
scb_reset_system();
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include <libopencm3/sam/d/port.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
#include <libopencm3/sam/d/nvmctrl.h>
|
||||
|
||||
#include "timing.h"
|
||||
#include "version.h"
|
||||
@ -30,12 +32,17 @@
|
||||
//#define PLATFORM_HAS_DEBUG
|
||||
//#define USBUART_DEBUG
|
||||
#define PLATFORM_HAS_UART_WHEN_SWDP
|
||||
#define PLATFORM_HAS_BOOTLOADER
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe (SAMD), (Firmware " FIRMWARE_VERSION ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for Launchpad, (Firmware " FIRMWARE_VERSION ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (SAMD)"
|
||||
#define DFU_IFACE_STRING "hid"
|
||||
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), SAMD21, (Firmware " FIRMWARE_VERSION ")"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x00000000/1*008Ka,15*8Kg"
|
||||
|
||||
|
||||
extern uint8_t running_status;
|
||||
|
||||
#ifdef DEBUG_ME
|
||||
@ -83,6 +90,9 @@ extern uint8_t running_status;
|
||||
#define ADC_POS_PIN GPIO4
|
||||
#define ADC_MUXPOS 4
|
||||
|
||||
#define BUTTON_PORT PORTA
|
||||
#define BUTTON_PIN GPIO27
|
||||
|
||||
#else
|
||||
|
||||
/* Hardware definitions... */
|
||||
@ -139,6 +149,9 @@ extern uint8_t running_status;
|
||||
#define ADC_POS_PIN GPIO2
|
||||
#define ADC_MUXPOS 0
|
||||
|
||||
#define BUTTON_PORT PORTA
|
||||
#define BUTTON_PIN GPIO27
|
||||
|
||||
#endif
|
||||
|
||||
#define TMS_SET_MODE() { \
|
||||
|
@ -20,9 +20,7 @@
|
||||
/* Define memory regions. */
|
||||
MEMORY
|
||||
{
|
||||
/* rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K */
|
||||
/* ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K */
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
|
||||
rom (rx) : ORIGIN = 0x00002000, LENGTH = 120K /* 128k - 8k for bootloader */
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,9 @@ void usbuart_init(void)
|
||||
|
||||
//usart_enable(USART_NUM, current_baud);
|
||||
usart_setup(USART_NUM, current_baud);
|
||||
#ifndef DEBUG_ME
|
||||
usart_set_pads(USART_NUM, 3, 0); /* uses different pads than the default */
|
||||
#endif
|
||||
usart_enable(USART_NUM, 0); /* baud==0 so setup is skipped */
|
||||
|
||||
usart_enable_rx_interrupt(USART_NUM);
|
||||
|
Loading…
x
Reference in New Issue
Block a user