Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stm32 support #134

Open
wants to merge 4 commits into
base: stm32-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ message( STATUS "Build type: ${CMAKE_BUILD_TYPE}" )
set(CMAKE_ERROR_FLAGS "-Wall -Wextra -Wpointer-arith -Wno-packed-bitfield-compat -Wno-unused-parameter -Wno-missing-field-initializers")

# Build specific flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ERROR_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ERROR_FLAGS} -fcommon")
set(CMAKE_C_FLAGS_DEBUG "-Og -g3 -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-Os")

Expand Down Expand Up @@ -86,10 +86,10 @@ link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
add_executable(${CMAKE_PROJECT_NAME} ${UCONTROLLER_SRCS} ${PROJ_SRCS})
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${MODULES_FLAGS})

if(${BOARD} MATCHES "^(afc)")
if(${TARGET_CONTROLLER} MATCHES "^(LPC)")
set(PROJ_LIBS lpcopen)
else()
message(FATAL_ERROR "${BOARD} not supported!")
elseif(${TARGET_CONTROLLER} MATCHES "^(STM32)")
set(PROJ_LIBS libstm)
endif()


Expand Down Expand Up @@ -132,4 +132,11 @@ if(${BOARD} MATCHES "^(afc)")
)
endif()

include( ${CMAKE_SOURCE_DIR}/probe/lpclink.cmake )
if(${TARGET_CONTROLLER} MATCHES "^(LPC)")
include( ${CMAKE_SOURCE_DIR}/probe/lpclink.cmake )
elseif(${TARGET_CONTROLLER} MATCHES "^(STM32)")
include( ${CMAKE_SOURCE_DIR}/probe/openocd.cmake )
else()
message(WARNING "No probe support for ${TARGET_CONTROLLER}!")
endif()

9 changes: 9 additions & 0 deletions FreeRTOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ if(${TARGET_CONTROLLER} MATCHES "^(lpc|LPC)17")
set(FREERTOS_FLAGS ${FREERTOS_FLAGS} -mcpu=${TARGET_CPU} -mtune=${TARGET_CPU})
set(FREERTOS_FLAGS ${FREERTOS_FLAGS} -march=${TARGET_ARCH})
set(FREERTOS_FLAGS ${FREERTOS_FLAGS} -mthumb -mthumb-interwork -mno-sched-prolog -mapcs-frame)
elseif(${TARGET_CONTROLLER} MATCHES "^(stm|STM)32(f|F)3")
set(FREERTOS_INC ${FREERTOS_INC} ${CMAKE_CURRENT_SOURCE_DIR}/portable/GCC/ARM_CM3)
set(LIBFREERTOS_SRCS ${LIBFREERTOS_SRCS}
portable/GCC/ARM_CM3/port.c
portable/MemMang/heap_4.c
)
set(TARGET_CPU "cortex-m3")
set(FREERTOS_FLAGS ${FREERTOS_FLAGS} -mcpu=${TARGET_CPU} -mtune=${TARGET_CPU})
set(FREERTOS_FLAGS ${FREERTOS_FLAGS} -mthumb -mthumb-interwork -mno-sched-prolog -mapcs-frame)
else()
message(FATAL_ERROR "${BoldRed}The specified controller doesn't have a supported FreeRTOS port!${ColourReset}")
endif()
Expand Down
192 changes: 192 additions & 0 deletions linker/STM32F30X_app.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/*
******************************************************************************
**
** @file : LinkerScript.ld
**
** @author : Auto-generated by STM32CubeIDE
**
** Abstract : Linker script for STM32F303ER Device with
** 512KByte FLASH,
** 64KByte RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed as is, without any warranty
** of any kind.
**
******************************************************************************
** @attention
**
** Copyright (c) 2022 STMicroelectronics.
** All rights reserved.
**
** This software is licensed under terms that can be found in the LICENSE file
** in the root directory of this software component.
** If no LICENSE file comes with this software, it is provided AS-IS.
**
******************************************************************************
*/

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */

_Min_Heap_Size = 0x200 ; /* required amount of heap */
_Min_Stack_Size = 0x400 ; /* required amount of stack */

/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
}

/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH

/* The program code and other data into "FLASH" Rom type memory */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)

KEEP (*(.init))
KEEP (*(.fini))

. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH

.ipmi_handlers : ALIGN(32)
{
_ipmi_handlers = .;
KEEP(*(.ipmi_handlers))
_eipmi_handlers = .;
} > FLASH

/* Constant data into "FLASH" Rom type memory */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH

.ARM.extab : {
. = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} >FLASH

.ARM : {
. = ALIGN(4);
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
. = ALIGN(4);
} >FLASH

.preinit_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
} >FLASH

.init_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
} >FLASH

.fini_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
} >FLASH

/* Used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* Initialized data sections into "RAM" Ram type memory */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */

} >RAM AT> FLASH

/* Uninitialized data section into "RAM" Ram type memory */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM

/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM

/* Remove information from the compiler libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

.ARM.attributes 0 : { *(.ARM.attributes) }
}
16 changes: 14 additions & 2 deletions modules/ipmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
#include "port.h"
#include "task_priorities.h"

#ifndef IPMB_TXTASK_STACK_SIZE
#define IPMB_TXTASK_STACK_SIZE 100
#endif

#ifndef IPMB_RXTASK_STACK_SIZE
#define IPMB_RXTASK_STACK_SIZE 100
#endif

/**
* @brief Encode IPMI msg struct to a byte formatted buffer
*
Expand Down Expand Up @@ -243,8 +251,12 @@ void ipmb_init ( void )
ipmb_txqueue = xQueueCreate( IPMB_TXQUEUE_LEN, sizeof(ipmi_msg_cfg *) );
vQueueAddToRegistry( ipmb_txqueue, "IPMB_TX_QUEUE");

xTaskCreate( IPMB_TXTask, (const char*)"IPMB_TX", 100, ( void * ) NULL, tskIPMB_TX_PRIORITY, ( TaskHandle_t * ) NULL );
xTaskCreate( IPMB_RXTask, (const char*)"IPMB_RX", 100, ( void * ) NULL, tskIPMB_RX_PRIORITY, ( TaskHandle_t * ) NULL );
xTaskCreate(
IPMB_TXTask, (const char*)"IPMB_TX", IPMB_TXTASK_STACK_SIZE,
( void * ) NULL, tskIPMB_TX_PRIORITY, ( TaskHandle_t * ) NULL);
xTaskCreate(
IPMB_RXTask, (const char*)"IPMB_RX", IPMB_RXTASK_STACK_SIZE,
( void * ) NULL, tskIPMB_RX_PRIORITY, ( TaskHandle_t * ) NULL);
}

ipmb_error ipmb_send_request ( ipmi_msg * req )
Expand Down
8 changes: 7 additions & 1 deletion modules/ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "payload.h"
#include "uart_debug.h"

#ifndef IPMITASK_STACK_SIZE
#define IPMITASK_STACK_SIZE 100
#endif

/* Local variables */
/**
* @brief Queue that holds the incoming IPMI messages
Expand Down Expand Up @@ -116,7 +120,9 @@ void ipmi_init ( void )
{
ipmb_init();
ipmb_register_rxqueue( &ipmi_rxqueue );
xTaskCreate( IPMITask, (const char*)"IPMI Dispatcher", 100, ( void * ) NULL, tskIPMI_PRIORITY, &TaskIPMI_Handle );
xTaskCreate(
IPMITask, (const char*)"IPMI Dispatcher", IPMITASK_STACK_SIZE,
( void * ) NULL, tskIPMI_PRIORITY, &TaskIPMI_Handle);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions modules/sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

/* Project Includes */
#include "sdr.h"
#include "port.h"
#include "sensors.h"
#include "ipmi.h"
#include "fpga_spi.h"
Expand Down Expand Up @@ -109,6 +110,10 @@ void sensor_init( void )
#if defined(MODULE_INA220_CURRENT) || defined(MODULE_INA220_VOLTAGE)
ina220_init();
#endif
#ifdef MODULE_STM32F3_ADC
STM32F3_ADC_init();
#endif

}

void sdr_init( void )
Expand Down
5 changes: 5 additions & 0 deletions modules/sensors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ if (";${TARGET_MODULES};" MATCHES ";INA220_CURRENT;")
set(MODULES_FLAGS "${MODULES_FLAGS} -DMODULE_INA220_CURRENT")
endif()

if (";${TARGET_MODULES};" MATCHES ";STM32F3_ADC;")
set(PROJ_SRCS ${PROJ_SRCS} ${SENSOR_PATH}/stm32f3_adc.c)
set(MODULES_FLAGS "${MODULES_FLAGS} -DMODULE_STM32F3_ADC")
endif()

set(PROJ_SRCS ${PROJ_SRCS} ${SENSOR_PATH} PARENT_SCOPE)
set(PROJ_HDRS ${PROJ_HDRS} ${SENSOR_PATH} PARENT_SCOPE)
set(MODULES_FLAGS "${MODULES_FLAGS}" PARENT_SCOPE)
4 changes: 4 additions & 0 deletions modules/sensors/sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@
#include "max6642.h"
#endif

#ifdef MODULE_STM32F3_ADC
#include "stm32f3_adc.h"
#endif

#endif
Loading