mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
add flash-uniflash support for ti tm4c
This commit is contained in:
parent
0be427bae9
commit
1402e6ec0d
@ -1,4 +1,4 @@
|
||||
|Build Status| |Documentation Status| |Fuzzing Status| |License|
|
||||
|Build Status| |CircleCI Status| |Documentation Status| |Fuzzing Status| |License|
|
||||
|
||||
Sponsors
|
||||
========
|
||||
@ -197,6 +197,8 @@ Docs
|
||||
|
||||
.. |Build Status| image:: https://github.com/hathach/tinyusb/actions/workflows/cmake_arm.yml/badge.svg
|
||||
:target: https://github.com/hathach/tinyusb/actions
|
||||
.. |CircleCI Status| image:: https://dl.circleci.com/status-badge/img/circleci/4AYHvUhFxdnY4rA7LEsdqW/QmrpoL2AjGqetvFQNqtWyq/tree/master.svg?style=svg
|
||||
:target: https://dl.circleci.com/status-badge/redirect/circleci/4AYHvUhFxdnY4rA7LEsdqW/QmrpoL2AjGqetvFQNqtWyq/tree/master
|
||||
.. |Documentation Status| image:: https://readthedocs.org/projects/tinyusb/badge/?version=latest
|
||||
:target: https://docs.tinyusb.org/en/latest/?badge=latest
|
||||
.. |Fuzzing Status| image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/tinyusb.svg
|
||||
|
@ -166,6 +166,11 @@ flash-bmp: $(BUILD)/$(PROJECT).elf
|
||||
debug-bmp: $(BUILD)/$(PROJECT).elf
|
||||
$(GDB) -ex 'target extended-remote $(BMP)' -ex 'monitor swdp_scan' -ex 'attach 1' $<
|
||||
|
||||
# --------------- TI Uniflash -----------------
|
||||
DSLITE ?= dslite.sh
|
||||
flash-uniflash: $(BUILD)/$(PROJECT).hex
|
||||
${DSLITE} ${UNIFLASH_OPTION} -f $<
|
||||
|
||||
#-------------- Artifacts --------------
|
||||
|
||||
# Create binary directory
|
||||
|
@ -573,6 +573,21 @@ function(family_flash_msp430flasher TARGET)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_flash_uniflash TARGET)
|
||||
if (NOT DEFINED DSLITE)
|
||||
set(DSLITE dslite.sh)
|
||||
endif ()
|
||||
|
||||
separate_arguments(OPTION_LIST UNIX_COMMAND ${UNIFLASH_OPTION})
|
||||
|
||||
add_custom_target(${TARGET}-uniflash
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${DSLITE} ${UNIFLASH_OPTION} -f $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.hex
|
||||
VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# Family specific
|
||||
#----------------------------------
|
||||
|
@ -4,6 +4,7 @@ set(JLINK_DEVICE TM4C123GH6PM)
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/tm4c123.ld)
|
||||
|
||||
set(OPENOCD_OPTION "-f board/ti_ek-tm4c123gxl.cfg")
|
||||
set(UNIFLASH_OPTION "-c ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ccxml -r 1")
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -10,4 +10,6 @@ JLINK_DEVICE = TM4C123GH6PM
|
||||
# flash using openocd
|
||||
OPENOCD_OPTION = -f board/ti_ek-tm4c123gxl.cfg
|
||||
|
||||
UNIFLASH_OPTION = -c ${TOP}/${BOARD_PATH}/${BOARD}.ccxml -r 1
|
||||
|
||||
flash: flash-openocd
|
||||
|
17
hw/bsp/tm4c/boards/ek_tm4c123gxl/ek_tm4c123gxl.ccxml
Normal file
17
hw/bsp/tm4c/boards/ek_tm4c123gxl/ek_tm4c123gxl.ccxml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<configurations XML_version="1.2" id="configurations_0">
|
||||
<configuration XML_version="1.2" id="configuration_0">
|
||||
<instance XML_version="1.2" desc="Stellaris In-Circuit Debug Interface" href="connections/Stellaris_ICDI_Connection.xml" id="Stellaris In-Circuit Debug Interface" xml="Stellaris_ICDI_Connection.xml" xmlpath="connections"/>
|
||||
<connection XML_version="1.2" id="Stellaris In-Circuit Debug Interface">
|
||||
|
||||
<instance XML_version="1.2" href="drivers/stellaris_cs_dap.xml" id="drivers" xml="stellaris_cs_dap.xml" xmlpath="drivers"/>
|
||||
|
||||
<instance XML_version="1.2" href="drivers/stellaris_cortex_m4.xml" id="drivers" xml="stellaris_cortex_m4.xml" xmlpath="drivers"/>
|
||||
|
||||
|
||||
<platform XML_version="1.2" id="platform_0">
|
||||
<instance XML_version="1.2" desc="Tiva TM4C123GH6PM" href="devices/tm4c123gh6pm.xml" id="Tiva TM4C123GH6PM" xml="tm4c123gh6pm.xml" xmlpath="devices"/>
|
||||
</platform>
|
||||
</connection>
|
||||
</configuration>
|
||||
</configurations>
|
@ -5,8 +5,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB0_Handler(void)
|
||||
{
|
||||
void USB0_Handler(void) {
|
||||
#if CFG_TUH_ENABLED
|
||||
tuh_int_handler(0, true);
|
||||
#endif
|
||||
@ -20,8 +19,7 @@ void USB0_Handler(void)
|
||||
// MACRO TYPEDEF CONSTANT ENUM
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static void board_uart_init (void)
|
||||
{
|
||||
static void board_uart_init(void) {
|
||||
SYSCTL->RCGCUART |= (1 << 0); // Enable the clock to UART0
|
||||
SYSCTL->RCGCGPIO |= (1 << 0); // Enable the clock to GPIOA
|
||||
|
||||
@ -42,13 +40,12 @@ static void board_uart_init (void)
|
||||
UART0->CTL = (1 << 0) | (1 << 8) | (1 << 9); // UART0 Enable, Transmit Enable, Receive Enable
|
||||
}
|
||||
|
||||
static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirmsk)
|
||||
{
|
||||
static void initialize_board_led(GPIOA_Type* port, uint8_t PinMsk, uint8_t dirmsk) {
|
||||
/* Enable PortF Clock */
|
||||
SYSCTL->RCGCGPIO |= (1 << 5);
|
||||
|
||||
/* Let the clock stabilize */
|
||||
while ( !((SYSCTL->PRGPIO) & (1 << 5)) ) {}
|
||||
while (!((SYSCTL->PRGPIO) & (1 << 5))) {}
|
||||
|
||||
/* Port Digital Enable */
|
||||
port->DEN |= PinMsk;
|
||||
@ -57,46 +54,33 @@ static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirm
|
||||
port->DIR = dirmsk;
|
||||
}
|
||||
|
||||
static void board_switch_init (void)
|
||||
{
|
||||
GPIOF->DIR &= ~(1 << BOARD_BTN);
|
||||
GPIOF->PUR |= (1 << BOARD_BTN);
|
||||
GPIOF->DEN |= (1 << BOARD_BTN);
|
||||
}
|
||||
|
||||
static void WriteGPIOPin (GPIOA_Type *port, uint8_t PinMsk, bool state)
|
||||
{
|
||||
if ( state )
|
||||
{
|
||||
static void WriteGPIOPin(GPIOA_Type* port, uint8_t PinMsk, bool state) {
|
||||
if (state) {
|
||||
port->DATA |= PinMsk;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
port->DATA &= ~(PinMsk);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t ReadGPIOPin (GPIOA_Type *port, uint8_t pinMsk)
|
||||
{
|
||||
static uint32_t ReadGPIOPin(GPIOA_Type* port, uint8_t pinMsk) {
|
||||
return (port->DATA & pinMsk);
|
||||
}
|
||||
|
||||
void board_init (void)
|
||||
{
|
||||
void board_init(void) {
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
// 1ms tick timer
|
||||
SysTick_Config(SystemCoreClock / 1000);
|
||||
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
||||
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
||||
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||
#endif
|
||||
|
||||
/* Reset USB */
|
||||
SYSCTL->SRCR2 |= (1u << 16);
|
||||
|
||||
for ( volatile uint8_t i = 0; i < 20; i++ ) {}
|
||||
for (volatile uint8_t i = 0; i < 20; i++) {}
|
||||
|
||||
SYSCTL->SRCR2 &= ~(1u << 16);
|
||||
|
||||
@ -110,7 +94,7 @@ void board_init (void)
|
||||
SYSCTL->RCGCGPIO |= (1u << 3);
|
||||
|
||||
/* Let the clock stabilize */
|
||||
while ( !(SYSCTL->PRGPIO & (1u << 3)) ) {}
|
||||
while (!(SYSCTL->PRGPIO & (1u << 3))) {}
|
||||
|
||||
/* USB IOs to Analog Mode */
|
||||
GPIOD->AFSEL &= ~((1u << 4) | (1u << 5));
|
||||
@ -124,7 +108,9 @@ void board_init (void)
|
||||
initialize_board_led(LED_PORT, leds, dirmsk);
|
||||
|
||||
/* Configure GPIO for board switch */
|
||||
board_switch_init();
|
||||
GPIOF->DIR &= ~(1 << BOARD_BTN);
|
||||
GPIOF->PUR |= (1 << BOARD_BTN);
|
||||
GPIOF->DEN |= (1 << BOARD_BTN);
|
||||
|
||||
/* Initialize board UART */
|
||||
board_uart_init();
|
||||
@ -132,32 +118,35 @@ void board_init (void)
|
||||
TU_LOG1_INT(SystemCoreClock);
|
||||
}
|
||||
|
||||
void board_led_write (bool state)
|
||||
{
|
||||
void board_led_write(bool state) {
|
||||
WriteGPIOPin(LED_PORT, (1 << LED_PIN_BLUE), state);
|
||||
}
|
||||
|
||||
uint32_t board_button_read (void)
|
||||
{
|
||||
uint32_t board_button_read(void) {
|
||||
uint32_t gpio_value = ReadGPIOPin(BOARD_BTN_PORT, BOARD_BTN_Msk);
|
||||
return BUTTON_STATE_ACTIVE ? gpio_value : !gpio_value;
|
||||
}
|
||||
|
||||
int board_uart_write (void const *buf, int len)
|
||||
{
|
||||
uint8_t const * data = buf;
|
||||
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
|
||||
(void) max_len;
|
||||
uint8_t const len = 8;
|
||||
// Note: DID0, DID1 are variant ID, they aer used since TM4C123 does not have unique ID
|
||||
memcpy(id, (void*)(uintptr_t) &SYSCTL->DID0, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < len; i++ )
|
||||
{
|
||||
while ( (UART0->FR & (1 << 5)) != 0 ) {} // Poll until previous data was shofted out
|
||||
UART0->DR = data[i]; // Write UART0 DATA REGISTER
|
||||
int board_uart_write(void const* buf, int len) {
|
||||
uint8_t const* data = buf;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
while ((UART0->FR & (1 << 5)) != 0) {} // Poll until previous data was shofted out
|
||||
UART0->DR = data[i]; // Write UART0 DATA REGISTER
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int board_uart_read (uint8_t *buf, int len)
|
||||
{
|
||||
int board_uart_read(uint8_t* buf, int len) {
|
||||
(void) buf;
|
||||
(void) len;
|
||||
return 0;
|
||||
@ -165,13 +154,13 @@ int board_uart_read (uint8_t *buf, int len)
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler (void)
|
||||
{
|
||||
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t board_millis (void)
|
||||
{
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -92,4 +92,5 @@ function(family_configure_example TARGET RTOS)
|
||||
# Flashing
|
||||
family_add_bin_hex(${TARGET})
|
||||
family_flash_openocd(${TARGET})
|
||||
family_flash_uniflash(${TARGET})
|
||||
endfunction()
|
||||
|
@ -196,6 +196,11 @@ def flash_esptool(board, firmware):
|
||||
return ret
|
||||
|
||||
|
||||
def flash_uniflash(board, firmware):
|
||||
ret = run_cmd(f'dslite.sh {board["flasher_args"]} -f {firmware}.hex')
|
||||
return ret
|
||||
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# Tests
|
||||
# -------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user