diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h index 371b5f8dc1..c30c781ffd 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h @@ -57,11 +57,8 @@ extern void vAssertCalled( void ); #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 0 #define configMAX_PRIORITIES ( 10 ) -#define configTIMER_QUEUE_LENGTH 20 -#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 3 ) #define configUSE_COUNTING_SEMAPHORES 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configNUM_TX_DESCRIPTORS 15 /* Set the following definitions to 1 to include the API function, or zero * to exclude the API function. */ @@ -74,7 +71,7 @@ extern void vAssertCalled( void ); #define INCLUDE_vTaskDelete 0 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 0 -#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelayUntil 0 #define INCLUDE_vTaskDelay 1 @@ -89,7 +86,6 @@ extern void vAssertCalled( void ); /* networking definitions */ #define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 2 ) #define ipconfigUSE_NETWORK_EVENT_HOOK 1 -/*#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME pdMS_TO_TICKS(5000) */ #define configNETWORK_INTERFACE_TO_USE 1L /* The address of an echo server that will be used by the two demo echo client @@ -115,16 +111,16 @@ extern void vAssertCalled( void ); #define configMAC_ADDR4 0x34 #define configMAC_ADDR5 0xAD -/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or - * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ +/* Default IP address configuration. Used if ipconfigUSE_DHCP is set to 0, or + * ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ #define configIP_ADDR0 10 #define configIP_ADDR1 211 #define configIP_ADDR2 55 #define configIP_ADDR3 5 -/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to - * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ +/* Default gateway IP address configuration. Used if ipconfigUSE_DHCP is set to + * 0, or ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ #define configGATEWAY_ADDR0 10 #define configGATEWAY_ADDR1 211 @@ -132,16 +128,16 @@ extern void vAssertCalled( void ); #define configGATEWAY_ADDR3 1 /* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and - * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set - * to 1 but a DNS server cannot be contacted.*/ + * 208.67.220.220. Used if ipconfigUSE_DHCP is set to 0, or ipconfigUSE_DHCP is set + * to 1 but a DHCP server cannot be contacted.*/ #define configDNS_SERVER_ADDR0 127 #define configDNS_SERVER_ADDR1 0 #define configDNS_SERVER_ADDR2 0 #define configDNS_SERVER_ADDR3 53 -/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or - * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ +/* Default netmask configuration. Used if ipconfigUSE_DHCP is set to 0, or + * ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ #define configNET_MASK0 255 #define configNET_MASK1 255 #define configNET_MASK2 255 diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile index fdfe7c7410..eb248d9a51 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile @@ -1,4 +1,5 @@ CC = arm-none-eabi-gcc +SIZE = arm-none-eabi-size BIN := freertos_tcp_mps2_demo.axf BUILD_DIR := build @@ -29,7 +30,6 @@ INCLUDE_DIRS += -I$(KERNEL_DIR)/include SOURCE_FILES += $(KERNEL_DIR)/tasks.c SOURCE_FILES += $(KERNEL_DIR)/list.c SOURCE_FILES += $(KERNEL_DIR)/queue.c -SOURCE_FILES += $(KERNEL_DIR)/timers.c SOURCE_FILES += $(KERNEL_DIR)/event_groups.c # FreeRTOS Kernel ARM Cortex-M3 Port @@ -51,30 +51,33 @@ SOURCE_FILES += ${FREERTOS_TCP}/source/portable/BufferManagement/BufferAllocatio SOURCE_FILES += ${FREERTOS_TCP}/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c SOURCE_FILES += ${FREERTOS_TCP}/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c -DEFINES := -DQEMU_SOC_MPS2 -DHEAP3 - -LDFLAGS = -T mps2_m3.ld -specs=nano.specs --specs=rdimon.specs -lc -lrdimon -LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map - -CFLAGS += -nostartfiles -mthumb -mcpu=cortex-m3 -Wno-error=implicit-function-declaration -CFLAGS += -Wno-builtin-declaration-mismatch -Werror +DEFINES := -DHEAP3 +CPPFLAGS += $(DEFINES) +CFLAGS += -mthumb -mcpu=cortex-m3 ifeq ($(DEBUG), 1) - CFLAGS += -ggdb3 -Og + CFLAGS += -g3 -Og -ffunction-sections -fdata-sections else - CFLAGS += -O3 + CFLAGS += -Os -ffunction-sections -fdata-sections endif - CFLAGS += -fstrict-aliasing -Wstrict-aliasing -Wno-error=address-of-packed-member +CFLAGS += -MMD +CFLAGS += -Wall -Wextra -Wshadow +#CFLAGS += -Wpedantic -fanalyzer +#CFLAGS += -flto +CFLAGS += $(INCLUDE_DIRS) -OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) +LDFLAGS = -T mps2_m3.ld +LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map +LDFLAGS += -Xlinker --gc-sections +LDFLAGS += -nostartfiles -specs=nano.specs -specs=nosys.specs -specs=rdimon.specs -CPPFLAGS += $(DEFINES) -CFLAGS += $(INCLUDE_DIRS) +OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) .PHONY: clean $(BUILD_DIR)/$(BIN) : $(OBJ_FILES) - $(CC) -ffunction-sections -fdata-sections $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(CC) $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(SIZE) $(@) %.d: %.c @set -e; rm -f $@; \ @@ -87,7 +90,7 @@ INCLUDES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.d) ${BUILD_DIR}/%.o : %.c Makefile -mkdir -p $(@D) - $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ clean: -rm -rf build diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c index 41b9ed0933..477ba4c1c0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c @@ -206,10 +206,10 @@ lStringLength = prvCreateTxData( pcTransmittedString, echoBUFFER_SIZES ); /* Add in some unique text at the front of the string. */ - sprintf( pcTransmittedString, "TxRx message number %u", ulTxCount ); + sprintf( pcTransmittedString, "TxRx message number %lu", ulTxCount ); ulTxCount++; - printf( "sending data to the echo server size %d original %d\n", + printf( "sending data to the echo server size %ld original %d\n", lStringLength, echoBUFFER_SIZES ); /* Send the string to the socket. */ @@ -217,7 +217,7 @@ ( void * ) pcTransmittedString, /* The data being sent. */ lStringLength, /* The length of the data being sent. */ 0 ); /* No flags. */ - printf( "FreeRTOS_send returned...transmitted %d\n", + printf( "FreeRTOS_send returned...transmitted %ld\n", lTransmitted ); if( lTransmitted < 0 ) @@ -398,15 +398,24 @@ #if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress ) + { + ( void ) eDHCPPhase; + ( void ) ulIPAddress; + + return eDHCPContinue; + } #else /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */ eDHCPCallbackAnswer_t xApplicationDHCPHook_Multi( eDHCPCallbackPhase_t eDHCPPhase, struct xNetworkEndPoint * pxEndPoint, IP_Address_t * pxIPAddress ) + { + ( void ) eDHCPPhase; + ( void ) pxEndPoint; + ( void ) pxIPAddress; + + return eDHCPContinue; + } #endif /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */ - { - /* Provide a stub for this function. */ - return eDHCPContinue; - } #endif /* if ( ipconfigUSE_DHCP_HOOK != 0 )*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c index cb17a6bf47..ec5f5650c8 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c @@ -40,9 +40,7 @@ void main_tcp_echo_client_tasks( void ); void vApplicationIdleHook( void ); void vApplicationTickHook( void ); -extern void initialise_monitor_handles( void ); - -int main() +int main( void ) { main_tcp_echo_client_tasks(); return 0; @@ -84,8 +82,6 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, void vApplicationIdleHook( void ) { - volatile size_t xFreeHeapSpace; - /* This is just a trivial example of an idle hook. It is called on each * cycle of the idle task. It must *NOT* attempt to block. In this case the * idle task just queries the amount of FreeRTOS heap that remains. See the diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c index 5af2c81b20..60e5ca3640 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c @@ -180,8 +180,6 @@ void main_tcp_echo_client_tasks( void ) } #endif /* ( ipconfigUSE_DHCP != 0 ) */ - memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) ); - FreeRTOS_IPInit_Multi(); #else /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ /* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */ @@ -224,6 +222,10 @@ BaseType_t xTasksAlreadyCreated = pdFALSE; uint32_t ulDNSServerAddress; char cBuffer[ 16 ]; + #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) + ( void ) pxEndPoint; + #endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ + /* If the network has just come up...*/ if( eNetworkEvent == eNetworkUp ) { @@ -335,6 +337,10 @@ static void prvMiscInitialisation( void ) { BaseType_t xReturn; + #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) + ( void ) pxEndPoint; + #endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ + /* Determine if a name lookup is for this node. Two names are given * to this node: that returned by pcApplicationHostnameHook() and that set * by mainDEVICE_NICK_NAME. */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld index 13b1a3d79f..97089f3c4a 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld @@ -128,7 +128,7 @@ SECTIONS _heap_top = .; . = . + _Min_Stack_Size; . = ALIGN(8); - } >RAM + } >RAM /* Set stack top to end of RAM, and stack limit move down by * size of stack_dummy section */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c index 3dcec37f44..72a269c07e 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c @@ -28,15 +28,14 @@ #include #include #include -#include "CMSIS/CMSDK_CM3.h" -#include "CMSIS/core_cm3.h" extern void vPortSVCHandler( void ); extern void xPortPendSVHandler( void ); extern void xPortSysTickHandler( void ); -extern void uart_init(); -extern int main(); +extern void uart_init( void ); +extern int main( void ); +void _start( void ); void __attribute__( ( weak ) ) EthernetISR( void ); extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss; @@ -63,7 +62,6 @@ void Reset_Handler( void ) } /* jump to board initialisation */ - void _start( void ); _start(); } @@ -96,6 +94,16 @@ void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress ) for( ; ; ) { } + + /* Remove the warning about unused variables. */ + ( void ) r0; + ( void ) r1; + ( void ) r2; + ( void ) r3; + ( void ) r12; + ( void ) lr; + ( void ) pc; + ( void ) psr; } static void Default_Handler( void ) __attribute__( ( naked ) ); @@ -114,7 +122,8 @@ void Default_Handler( void ) "NVIC_INT_CTRL_CONST: .word 0xe000ed04\n" ); } -static void HardFault_Handler( void ) __attribute__( ( naked ) ); + +static void Default_Handler2( void ) __attribute__( ( naked ) ); void Default_Handler2( void ) { __asm volatile @@ -158,7 +167,7 @@ void Default_Handler6( void ) } } -const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = +const uint32_t * const isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = { ( uint32_t * ) &_estack, ( uint32_t * ) &Reset_Handler, /* Reset -15 */ @@ -195,7 +204,7 @@ const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = void _start( void ) { uart_init(); - main( 0, 0 ); + main(); exit( 0 ); } @@ -212,4 +221,6 @@ __attribute__( ( naked ) ) void exit( int status ) "bkpt 0xab\n" "end: b end\n" ); + + ( void ) status; } diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c index bfa97f3b8e..6e5425db00 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c @@ -38,24 +38,21 @@ typedef struct UART_t volatile uint32_t BAUDDIV; } UART_t; -#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) ) +#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) ) #define UART_DR( baseaddr ) ( *( unsigned int * ) ( baseaddr ) ) -#define UART_STATE_TXFULL ( 1 << 0 ) -#define UART_CTRL_TX_EN ( 1 << 0 ) -#define UART_CTRL_RX_EN ( 1 << 1 ) +#define UART_CTRL_TX_EN ( 1 << 0 ) extern unsigned long _heap_bottom; extern unsigned long _heap_top; -extern unsigned long g_ulBase; -static void * heap_end = 0; +static char * heap_end = ( char * ) &_heap_bottom; /** * @brief initializes the UART emulated hardware */ -void uart_init() +void uart_init( void ) { UART0_ADDR->BAUDDIV = 16; UART0_ADDR->CTRL = UART_CTRL_TX_EN; @@ -68,6 +65,7 @@ void uart_init() */ int _fstat( int file ) { + ( void ) file; return 0; } @@ -80,6 +78,9 @@ int _read( int file, char * buf, int len ) { + ( void ) file; + ( void ) buf; + ( void ) len; return -1; } @@ -97,6 +98,8 @@ int _write( int file, { int todo; + ( void ) file; + for( todo = 0; todo < len; todo++ ) { UART_DR( UART0_ADDR ) = *buf++; @@ -113,16 +116,9 @@ int _write( int file, */ void * _sbrk( int incr ) { - char * prev_heap_end; - - if( heap_end == 0 ) - { - heap_end = ( void * ) &_heap_bottom; - } - - prev_heap_end = heap_end; + void * prev_heap_end = heap_end; - if( ( heap_end + incr ) > ( void * ) &_heap_top ) + if( ( heap_end + incr ) > ( char * ) &_heap_top ) { return ( void * ) -1; } diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c index 126e747769..3d4e285f1d 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c @@ -145,6 +145,7 @@ static UBaseType_t ulNextRand; int main( void ) { + BaseType_t xResult; const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL ); /* @@ -185,14 +186,14 @@ int main( void ) } #endif /* ( ipconfigUSE_DHCP != 0 ) */ - memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) ); - - FreeRTOS_IPInit_Multi(); + xResult = FreeRTOS_IPInit_Multi(); #else /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ /* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */ - FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); + xResult = FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); #endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ + configASSERT( xResult == pdTRUE ); + /* Start the RTOS scheduler. */ FreeRTOS_debug_printf( ( "vTaskStartScheduler\r\n" ) ); vTaskStartScheduler(); diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile index eec39ba295..f268700e4f 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile @@ -9,13 +9,20 @@ LD = arm-none-eabi-gcc SIZE = arm-none-eabi-size MAKE = make - -CFLAGS += $(INCLUDE_DIRS) -nostartfiles -ffreestanding -mthumb -mcpu=cortex-m3 \ - -Wall -Wextra -g3 -Os -ffunction-sections -fdata-sections \ - -MMD -MP -MF"$(@:%.o=%.d)" -MT $@ - -#CFLAGS += -Wpedantic -Wshadow -fanalyzer +CFLAGS += -ffreestanding -mthumb -mcpu=cortex-m3 +CFLAGS += -Wall -Wextra -Wshadow +CFLAGS += -g3 -Os -ffunction-sections -fdata-sections +CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT $@ +#CFLAGS += -std=c99 +#CFLAGS += -Wpedantic -fanalyzer #CFLAGS += -flto +CFLAGS += $(INCLUDE_DIRS) + +LDFLAGS = -T ./mps2_m3.ld +LDFLAGS += -Xlinker -Map=$(OUTPUT_DIR)/RTOSDemo.map +LDFLAGS += -Xlinker --gc-sections +LDFLAGS += -nostartfiles +LDFLAGS += -specs=nano.specs -specs=nosys.specs # -specs=rdimon.specs # # Kernel build. @@ -106,9 +113,7 @@ $(IMAGE): ./mps2_m3.ld $(OBJS_OUTPUT) Makefile @echo "" @echo "--- Final linking ---" @echo "" - $(LD) $(OBJS_OUTPUT) $(CFLAGS) -Xlinker --gc-sections -Xlinker -T ./mps2_m3.ld \ - -Xlinker -Map=$(OUTPUT_DIR)/RTOSDemo.map -specs=nano.specs \ - -specs=nosys.specs -specs=rdimon.specs -o $(IMAGE) + $(LD) $(CFLAGS) $(LDFLAGS) $(OBJS_OUTPUT) -o $(IMAGE) $(SIZE) $(IMAGE) $(DEP_OUTPUT): diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c index 0b06e65fe2..fe6d2b1e99 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c @@ -27,22 +27,6 @@ #include #include -/* UART peripheral register addresses and bits. */ -#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) ) -#define UART_DR( baseaddr ) ( *( uint32_t * ) ( baseaddr ) ) -#define UART_STATE( baseaddr ) ( *( uint32_t * ) ( baseaddr + 4 ) ) -#define UART_STATE_TXFULL ( 1 << 0 ) - -typedef struct UART_t -{ - volatile uint32_t DATA; - volatile uint32_t STATE; - volatile uint32_t CTRL; - volatile uint32_t INTSTATUS; - volatile uint32_t BAUDDIV; -} UART_t; - - /* FreeRTOS interrupt handlers. */ extern void vPortSVCHandler( void ); extern void xPortPendSVHandler( void ); @@ -99,7 +83,7 @@ void Reset_Handler( void ) } /* Variables used to store the value of registers at the time a hardfault - * occurs. These are volatile to try and prevent the compiler/linker optimising + * occurs. These are volatile to try and prevent the compiler/linker optimizing * them away as the variables never actually get used. */ volatile uint32_t r0; volatile uint32_t r1; diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile index 87fc5f0ac4..82c018698d 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile @@ -1,4 +1,5 @@ CC = arm-none-eabi-gcc +SIZE = arm-none-eabi-size BIN := RTOSDemo.axf BUILD_DIR := build @@ -34,33 +35,23 @@ INCLUDE_DIRS += -I$(FREERTOS_DIR)/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/C INCLUDE_DIRS += -I$(KERNEL_DIR)/include INCLUDE_DIRS += -I$(KERNEL_DIR)/portable/GCC/ARM_CM3_MPU -DEFINES := -DQEMU_SOC_MPS2 DEFINES := -DHEAP4 - CPPFLAGS += $(DEFINES) -CFLAGS += -mcpu=cortex-m3 -CFLAGS += -Wno-error=implicit-function-declaration -CFLAGS += -Wno-builtin-declaration-mismatch -CFLAGS += -Werror -CFLAGS += -Wall -CFLAGS += -Wextra -CFLAGS += -fstrict-aliasing -CFLAGS += -Wstrict-aliasing -CFLAGS += -Wno-error=address-of-packed-member -CFLAGS += -Wno-unused-parameter +CFLAGS += -mthumb -mcpu=cortex-m3 +CFLAGS += -Wall -Wextra -Wshadow -Wno-unused-parameter +#CFLAGS += -Wpedantic -fanalyzer CFLAGS += $(INCLUDE_DIRS) LDFLAGS = -T ./scripts/mps2_m3.ld -LDFLAGS += -mthumb - LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map +LDFLAGS += -Xlinker --gc-sections LDFLAGS += -nostartfiles -nostdlib -nolibc -nodefaultlibs ifeq ($(DEBUG), 1) - CFLAGS += -ggdb3 -Og -save-temps=obj + CFLAGS += -g3 -Og -ffunction-sections -fdata-sections -save-temps=obj else - CFLAGS += -O3 + CFLAGS += -Os -ffunction-sections -fdata-sections endif ifeq ($(PICOLIBC), 1) @@ -73,7 +64,8 @@ OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) .PHONY: clean $(BUILD_DIR)/$(BIN) : $(OBJ_FILES) - $(CC) -ffunction-sections -fdata-sections $(LDFLAGS) $+ -o $(@) + $(CC) $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(SIZE) $(@) %.d: %.c @set -e; rm -f $@; \ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c index 400583c127..4a9752d460 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c @@ -35,7 +35,9 @@ extern void vPortSVCHandler( void ); extern void xPortPendSVHandler( void ); extern void xPortSysTickHandler( void ); extern void uart_init( void ); -extern int main(); +extern int main( void ); + +void _start( void ); extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss; @@ -61,13 +63,12 @@ void Reset_Handler( void ) } /* jump to board initialisation */ - void _start( void ); _start(); } void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress ) { -/* These are volatile to try and prevent the compiler/linker optimising them +/* These are volatile to try and prevent the compiler/linker optimizing them * away as the variables never actually get used. If the debugger won't show the * values of the variables, make them global my moving their declaration outside * of this function. */ @@ -122,6 +123,7 @@ void Default_Handler( void ) "NVIC_INT_CTRL_CONST: .word 0xe000ed04\n" ); } + static void HardFault_Handler( void ) __attribute__( ( naked ) ); void HardFault_Handler( void ) { @@ -232,12 +234,12 @@ const uint32_t * const isr_vector[] __attribute__( ( section( ".isr_vector" ) ) void _start( void ) { uart_init(); - main( 0, 0 ); + main(); exit( 0 ); } __attribute__( ( naked ) ) -void exit( __attribute__( ( unused ) ) int status ) +void exit( int status ) { /* Force qemu to exit using ARM Semihosting */ __asm volatile ( @@ -250,4 +252,6 @@ void exit( __attribute__( ( unused ) ) int status ) "bkpt 0xab\n" "end: b end\n" ); + + ( void ) status; } diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c index d24cfa890e..6481ac4296 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c @@ -37,7 +37,7 @@ void vApplicationIdleHook( void ); void vApplicationTickHook( void ); -int main() +int main( void ) { app_main(); return 0; diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c index 4d0ef93aaa..d8fc48cb9d 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c @@ -69,7 +69,7 @@ void uart_init(void) int _uart_putc(char c, FILE *file) { - (void) file; + ( void ) file; UART_DR( UART0_ADDR ) = c; return (unsigned char) c; } @@ -90,8 +90,9 @@ static char * heap_end = ( char * ) &_heap_bottom; * @todo implement if necessary * */ -int _fstat( __attribute__( ( unused ) ) int file ) +int _fstat( int file ) { + ( void ) file; return 0; } @@ -100,10 +101,13 @@ int _fstat( __attribute__( ( unused ) ) int file ) * @todo implement if necessary * */ -int _read( __attribute__( ( unused ) ) int file, - __attribute__( ( unused ) ) char * buf, - __attribute__( ( unused ) ) int len ) +int _read( int file, + char * buf, + int len ) { + ( void ) file; + ( void ) buf; + ( void ) len; return -1; } @@ -115,12 +119,14 @@ int _read( __attribute__( ( unused ) ) int file, * @param [in] len length of the buffer * @returns the number of bytes written */ -int _write( __attribute__( ( unused ) ) int file, - __attribute__( ( unused ) ) char * buf, +int _write( int file, + char * buf, int len ) { int todo; + ( void ) file; + for( todo = 0; todo < len; todo++ ) { UART_DR( UART0_ADDR ) = *buf++; diff --git a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt index 199de7508b..6131634b6c 100644 --- a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt +++ b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt @@ -4,6 +4,8 @@ project( posix_demo ) add_compile_options( -D_WINDOWS_ ) +add_compile_options( -Wall -Wextra -Wpedantic ) + if( TRACE_ON_ENTER ) add_compile_options( -DTRACE_ON_ENTER=1 ) else() @@ -33,6 +35,9 @@ else() set( CMAKE_BUILD_TYPE "debug" ) endif() +set(CMAKE_CXX_FLAGS_RELEASE "-O3") +set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3") + if( SANITIZE_ADDRESS ) add_compile_options( -fsanitize=address -fsanitize=alignment ) endif() diff --git a/FreeRTOS/Demo/Posix_GCC/main.c b/FreeRTOS/Demo/Posix_GCC/main.c index bf69bf280c..f5773de512 100644 --- a/FreeRTOS/Demo/Posix_GCC/main.c +++ b/FreeRTOS/Demo/Posix_GCC/main.c @@ -455,7 +455,7 @@ void handle_sigint( int signal ) printf( "chdir into %s error is %d\n", BUILD, errno ); } - exit( 2 ); + _exit( 2 ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c b/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c index d5c4260bba..c1ddf191f0 100644 --- a/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c +++ b/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c @@ -622,40 +622,6 @@ void test_vTaskStepTick_assert_scheduler_not_suspended( void ) validate_and_clear_assertions(); } -/** - * @brief prvCheckForRunStateChange - task state not changed. - * - * When the task is able to run after calling portENABLE_INTERRUPTS. The task state - * is supposed to be changed to run state. This test cover the assertion of this scenario. - * - * Coverage - * @code{c} - * configASSERT( pxThisTCB->xTaskRunState != taskTASK_YIELDING ); - * @endcode - */ -void test_prvCheckForRunStateChange_assert_task_state_not_changed( void ) -{ - TCB_t xTaskTCB = { NULL }; - - pxCurrentTCBs[ 0 ] = &xTaskTCB; - xTaskTCB.uxCriticalNesting = 0; - xTaskTCB.xTaskRunState = taskTASK_YIELDING; - uxSchedulerSuspended = 1; - - /* Expection. */ - vFakePortAssertIfISR_Expect(); - vFakePortGetCoreID_ExpectAndReturn( 0 ); - vFakePortGetCoreID_ExpectAndReturn( 0 ); - vFakePortReleaseTaskLock_Expect(); - vFakePortEnableInterrupts_Expect(); - - /* API Call. */ - EXPECT_ASSERT_BREAK( prvCheckForRunStateChange() ); - - /* Test Verifications */ - validate_and_clear_assertions(); -} - /** * @brief vTaskStepTick - assert if scheduler suspended. * diff --git a/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h b/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h index bd7b65c103..64d8304a43 100644 --- a/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h +++ b/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h @@ -565,6 +565,13 @@ #define traceTASK_SWITCHED_IN() #endif +#ifndef traceSTARTING_SCHEDULER + +/* Called after all idle tasks and timer task (if enabled) have been created + * successfully, just before the scheduler is started. */ + #define traceSTARTING_SCHEDULER( xIdleTaskHandles ) +#endif + #ifndef traceINCREASE_TICK_COUNT /* Called before stepping the tick count after waking from tickless idle