Skip to content

Commit

Permalink
feat(TM4C123 and Windows): Adding support for GCC on windows
Browse files Browse the repository at this point in the history
Adding support for TM4C123 and VSCode Cortex Debug with OpenOCD and ARM
GDB

Changes to linker script and startup code were needed.

Disabling Middlewares was also required, just keeping TivaWare Drivers
in place for making the current code compatible with TM4C123.

This is a quick and dirty solution, improvements are required.
  • Loading branch information
Josepablo C committed Nov 3, 2024
1 parent 64035a4 commit e321b90
Show file tree
Hide file tree
Showing 23 changed files with 503 additions and 115 deletions.
1 change: 0 additions & 1 deletion .vscode/.cortex-debug.registers.state.json

This file was deleted.

20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/ti/tivaware_c_series_2_1_4_178/",
"C:/ti/ccs1281/ccs/tools/compiler/ti-cgt-arm_20.2.7.LTS/include/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"PART_TM4C123GH6PM",
"TARGET_IS_TM4C123_RB1"
]
}
],
"version": 4
}
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
{
"name": "Cortex Debug",
"cwd": "${workspaceRoot}",
"executable": "./output/output.elf",
"executable": "./build/bin/template.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"searchDir": [
"${workspaceRoot}",
"/usr/share/openocd/scripts/board/",
// "/usr/share/openocd/scripts/board/",
"D:/opt/openocd-v0.12.0-i686-w64-mingw32/share/openocd/scripts/board/",
],
"configFiles": [
"ti_ek-tm4c1294xl.cfg"
"ti_ek-tm4c123gxl.cfg"
]
}
]
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"*.h": "c",
"*.c": "c"
}
}
3 changes: 2 additions & 1 deletion project/BSP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ set(BSP_EXEC_ENTRY_POINT ResetISR PARENT_SCOPE)

add_library(${COMPONENT_NAME} STATIC
${CMAKE_CURRENT_LIST_DIR}/src/Board.c
${CMAKE_CURRENT_LIST_DIR}/src/startup_gcc.c
${CMAKE_CURRENT_LIST_DIR}/src/startup_gcc_tm4c123gh6pm.c
${CMAKE_CURRENT_LIST_DIR}/src/startup_gcc_tm4c1294ncpdt.c
)

target_include_directories(${COMPONENT_NAME} PUBLIC
Expand Down
32 changes: 20 additions & 12 deletions project/BSP/src/Board.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@
#include "FreeRTOSConfig.h"

void Board_init(){
SysCtlClockFreqSet( (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
SYSTEM_CLOCK );
ROM_FPUEnable();
ROM_FPULazyStackingEnable();

#if 0
// Set Clock to 120Mhz on TM4C1294
SysCtlClockFreqSet( (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
SYSTEM_CLOCK );
#else
// Set Clock to 80Mhz using PIOSC (on TM4C123G)
ROM_SysCtlClockSet( SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_INT );

// Set Clock to 80Mhz using MOSC (on TM4C123G)
// ROM_SysCtlClockSet( SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
#endif

//
// Enable the GPIO port that is used for the on-board LED.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// (TM4C123GXL board)
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//
// Check if the peripheral access is enabled.
//
while(
(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION)) ||
(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))
)
// (TM4C123GXL board)
while( (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF)) )
{
}

}

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <stdint.h>

#if PART_TM4C123GH6PM

void ResetISR(void);
static void NmiSR(void);
static void FaultISR(void);
Expand Down Expand Up @@ -232,4 +234,4 @@ static void IntDefaultHandler(void)
}
}


#endif
238 changes: 238 additions & 0 deletions project/BSP/src/startup_gcc_tm4c1294ncpdt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
#include <stdint.h>

#if PART_TM4C129XNCZAD

void ResetISR(void);
static void NmiSR(void);
static void FaultISR(void);
static void IntDefaultHandler(void);

extern int main( int argc, char *argv[] );

extern void xPortPendSVHandler( void );
extern void xPortSysTickHandler( void );
extern void vPortSVCHandler( void );

extern unsigned long _stack_top;

__attribute__ ((section(".isr_vector")))
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((unsigned long)&_stack_top),
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
IntDefaultHandler, // The MPU fault handler
IntDefaultHandler, // The bus fault handler
IntDefaultHandler, // The usage fault handler
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
vPortSVCHandler, // SVCall handler
IntDefaultHandler, // Debug monitor handler
0, // Reserved
xPortPendSVHandler, // The PendSV handler
xPortSysTickHandler, // The SysTick handler
IntDefaultHandler, // GPIO Port A
IntDefaultHandler, // GPIO Port B
IntDefaultHandler, // GPIO Port C
IntDefaultHandler, // GPIO Port D
IntDefaultHandler, // GPIO Port E
IntDefaultHandler, // UART0 Rx and Tx
IntDefaultHandler, // UART1 Rx and Tx
IntDefaultHandler, // SSI0 Rx and Tx
IntDefaultHandler, // I2C0 Master and Slave
IntDefaultHandler, // PWM Fault
IntDefaultHandler, // PWM Generator 0
IntDefaultHandler, // PWM Generator 1
IntDefaultHandler, // PWM Generator 2
IntDefaultHandler, // Quadrature Encoder 0
IntDefaultHandler, // ADC Sequence 0
IntDefaultHandler, // ADC Sequence 1
IntDefaultHandler, // ADC Sequence 2
IntDefaultHandler, // ADC Sequence 3
IntDefaultHandler, // Watchdog timer
IntDefaultHandler, // Timer 0 subtimer A
IntDefaultHandler, // Timer 0 subtimer B
IntDefaultHandler, // Timer 1 subtimer A
IntDefaultHandler, // Timer 1 subtimer B
IntDefaultHandler, // Timer 2 subtimer A
IntDefaultHandler, // Timer 2 subtimer B
IntDefaultHandler, // Analog Comparator 0
IntDefaultHandler, // Analog Comparator 1
IntDefaultHandler, // Analog Comparator 2
IntDefaultHandler, // System Control (PLL, OSC, BO)
IntDefaultHandler, // FLASH Control
IntDefaultHandler, // GPIO Port F
IntDefaultHandler, // GPIO Port G
IntDefaultHandler, // GPIO Port H
IntDefaultHandler, // UART2 Rx and Tx
IntDefaultHandler, // SSI1 Rx and Tx
IntDefaultHandler, // Timer 3 subtimer A
IntDefaultHandler, // Timer 3 subtimer B
IntDefaultHandler, // I2C1 Master and Slave
IntDefaultHandler, // CAN0
IntDefaultHandler, // CAN1
IntDefaultHandler, // Ethernet
IntDefaultHandler, // Hibernate
IntDefaultHandler, // USB0
IntDefaultHandler, // PWM Generator 3
IntDefaultHandler, // uDMA Software Transfer
IntDefaultHandler, // uDMA Error
IntDefaultHandler, // ADC1 Sequence 0
IntDefaultHandler, // ADC1 Sequence 1
IntDefaultHandler, // ADC1 Sequence 2
IntDefaultHandler, // ADC1 Sequence 3
IntDefaultHandler, // External Bus Interface 0
IntDefaultHandler, // GPIO Port J
IntDefaultHandler, // GPIO Port K
IntDefaultHandler, // GPIO Port L
IntDefaultHandler, // SSI2 Rx and Tx
IntDefaultHandler, // SSI3 Rx and Tx
IntDefaultHandler, // UART3 Rx and Tx
IntDefaultHandler, // UART4 Rx and Tx
IntDefaultHandler, // UART5 Rx and Tx
IntDefaultHandler, // UART6 Rx and Tx
IntDefaultHandler, // UART7 Rx and Tx
IntDefaultHandler, // I2C2 Master and Slave
IntDefaultHandler, // I2C3 Master and Slave
IntDefaultHandler, // Timer 4 subtimer A
IntDefaultHandler, // Timer 4 subtimer B
IntDefaultHandler, // Timer 5 subtimer A
IntDefaultHandler, // Timer 5 subtimer B
IntDefaultHandler, // FPU
0, // Reserved
0, // Reserved
IntDefaultHandler, // I2C4 Master and Slave
IntDefaultHandler, // I2C5 Master and Slave
IntDefaultHandler, // GPIO Port M
IntDefaultHandler, // GPIO Port N
0, // Reserved
IntDefaultHandler, // Tamper
IntDefaultHandler, // GPIO Port P (Summary or P0)
IntDefaultHandler, // GPIO Port P1
IntDefaultHandler, // GPIO Port P2
IntDefaultHandler, // GPIO Port P3
IntDefaultHandler, // GPIO Port P4
IntDefaultHandler, // GPIO Port P5
IntDefaultHandler, // GPIO Port P6
IntDefaultHandler, // GPIO Port P7
IntDefaultHandler, // GPIO Port Q (Summary or Q0)
IntDefaultHandler, // GPIO Port Q1
IntDefaultHandler, // GPIO Port Q2
IntDefaultHandler, // GPIO Port Q3
IntDefaultHandler, // GPIO Port Q4
IntDefaultHandler, // GPIO Port Q5
IntDefaultHandler, // GPIO Port Q6
IntDefaultHandler, // GPIO Port Q7
IntDefaultHandler, // GPIO Port R
IntDefaultHandler, // GPIO Port S
IntDefaultHandler, // SHA/MD5 0
IntDefaultHandler, // AES 0
IntDefaultHandler, // DES3DES 0
IntDefaultHandler, // LCD Controller 0
IntDefaultHandler, // Timer 6 subtimer A
IntDefaultHandler, // Timer 6 subtimer B
IntDefaultHandler, // Timer 7 subtimer A
IntDefaultHandler, // Timer 7 subtimer B
IntDefaultHandler, // I2C6 Master and Slave
IntDefaultHandler, // I2C7 Master and Slave
IntDefaultHandler, // HIM Scan Matrix Keyboard 0
IntDefaultHandler, // One Wire 0
IntDefaultHandler, // HIM PS/2 0
IntDefaultHandler, // HIM LED Sequencer 0
IntDefaultHandler, // HIM Consumer IR 0
IntDefaultHandler, // I2C8 Master and Slave
IntDefaultHandler, // I2C9 Master and Slave
IntDefaultHandler // GPIO Port T
};

//*****************************************************************************
//
// The following are constructs created by the linker, indicating where the
// the "data" and "bss" segments reside in memory. The initializers for the
// for the "data" segment resides immediately following the "text" segment.
//
//*****************************************************************************
extern unsigned long _text;
extern unsigned long _etext;
extern unsigned long _data;
extern unsigned long _edata;
extern unsigned long _bss;
extern unsigned long _ebss;

//*****************************************************************************
//
// This is the code that gets called when the processor first starts execution
// following a reset event. Only the absolutely necessary set is performed,
// after which the application supplied entry() routine is called. Any fancy
// actions (such as making decisions based on the reset cause register, and
// resetting the bits in that register) are left solely in the hands of the
// application.
//
//*****************************************************************************

void ResetISR(void)
{

unsigned long *pulSrc, *pulDest;
pulSrc = &_etext;
for(pulDest = &_data; pulDest < &_edata; )
{
*pulDest++ = *pulSrc++;
}

for(pulDest = &_bss; pulDest < &_ebss; )
{
*pulDest++ = 0;
}

main( 0x00U , 0x00U );
}

//*****************************************************************************
//
// This is the code that gets called when the processor receives a NMI. This
// simply enters an infinite loop, preserving the system state for examination
// by a debugger.
//
//*****************************************************************************
static void NmiSR(void)
{
while(1)
{
}
}

//*****************************************************************************
//
// This is the code that gets called when the processor receives a fault
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void FaultISR(void)
{
while(1)
{
}
}

//*****************************************************************************
//
// This is the code that gets called when the processor receives an unexpected
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void IntDefaultHandler(void)
{
while(1)
{
}
}


#endif
2 changes: 2 additions & 0 deletions project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ project( TivaCTemplate
LANGUAGES C ASM
)

include(cmake/toolchain-epilog.cmake)

# ===================================================================
# Project Set-Up
# ===================================================================
Expand Down
7 changes: 0 additions & 7 deletions project/Tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,5 @@ target_link_libraries( ${COMPONENT_NAME}
TivaWare
Misc
System
I2C::TivaCTM4C1294
SPI::TivaCTM4C1294
BUS8080::TivaCTM4C1294
ILI9341::TivaCTM4C1294
SSD1306::TivaCTM4C1294
MCP2515::TivaCTM4C1294
simpleGFX::TivaCTM4C1294
)

Loading

0 comments on commit e321b90

Please sign in to comment.