diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/FreeRTOSIPConfig.h index 47c2ee8ae2..de18b8bdea 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/FreeRTOSIPConfig.h +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/FreeRTOSIPConfig.h @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/core_mqtt_config.h b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/core_mqtt_config.h index 18db95f8f8..1c092aa5d5 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/core_mqtt_config.h +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/core_mqtt_config.h @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/demo_config.h b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/demo_config.h index 990c053771..69930fa3dd 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/demo_config.h +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/include/demo_config.h @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/MutualAuthMQTTExample.c b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/MutualAuthMQTTExample.c index f4f12f51d8..3e5eefaeda 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/MutualAuthMQTTExample.c +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/MutualAuthMQTTExample.c @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main.c b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main.c index 52832908bb..1e3ad8f758 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main.c +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main.c @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -31,16 +31,17 @@ #include <stdarg.h> #include <stdio.h> -void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); +void vApplicationStackOverflowHook( TaskHandle_t pxTask, + char * pcTaskName ); void vApplicationMallocFailedHook( void ); void vMainMQTTClientTasks( void ); void vApplicationIdleHook( void ); void vApplicationTickHook( void ); extern void initialise_monitor_handles( void ); -extern void vStartupTask( void* pvParameters ); +extern void vStartupTask( void * pvParameters ); -int main () +int main() { initialise_monitor_handles(); @@ -51,14 +52,16 @@ int main () NULL, 1U, NULL - ); + ); vTaskStartScheduler(); - // The code should never reach here. + /* The code should never reach here. */ configASSERT( 0 ); - for ( ;; ) {} + for( ; ; ) + { + } return 0; } @@ -68,39 +71,46 @@ int main () void vApplicationMallocFailedHook( void ) { /* Called if a call to pvPortMalloc() fails because there is insufficient - free memory available in the FreeRTOS heap. pvPortMalloc() is called - internally by FreeRTOS API functions that create tasks, queues, software - timers, and semaphores. The size of the FreeRTOS heap is set by the - configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ + * free memory available in the FreeRTOS heap. pvPortMalloc() is called + * internally by FreeRTOS API functions that create tasks, queues, software + * timers, and semaphores. The size of the FreeRTOS heap is set by the + * configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ taskDISABLE_INTERRUPTS(); - for( ;; ){}; + + for( ; ; ) + { + } } /*-----------------------------------------------------------*/ -void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) +void vApplicationStackOverflowHook( TaskHandle_t pxTask, + char * pcTaskName ) { ( void ) pcTaskName; ( void ) pxTask; /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook - function is called if a stack overflow is detected. */ + * configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + * function is called if a stack overflow is detected. */ taskDISABLE_INTERRUPTS(); - for( ;; ){}; + + for( ; ; ) + { + } } /*-----------------------------------------------------------*/ void vApplicationIdleHook( void ) { -volatile size_t xFreeHeapSpace; + 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 - memory management section on the https://www.FreeRTOS.org web site for memory - management options. If there is a lot of heap memory free then the - configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up - RAM. */ + * 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 + * memory management section on the https://www.FreeRTOS.org web site for memory + * management options. If there is a lot of heap memory free then the + * configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up + * RAM. */ } /*-----------------------------------------------------------*/ @@ -112,10 +122,11 @@ void vApplicationTickHook( void ) void vAssertCalled( void ) { volatile unsigned long looping = 0; + taskENTER_CRITICAL(); { - /* Use the debugger to set looping to a non-zero value in order to step out - of this function to determine why it was called. */ + /* Use the debugger to set looping to a non-zero value in order to step + * out of this function to determine why it was called. */ while( looping == 0LU ) { portNOP(); @@ -124,13 +135,14 @@ void vAssertCalled( void ) taskEXIT_CRITICAL(); } /*-----------------------------------------------------------*/ -void vLoggingPrintf( const char *pcFormat, ... ) +void vLoggingPrintf( const char * pcFormat, + ... ) { - va_list arg; + va_list arg; - va_start( arg, pcFormat ); - vprintf( pcFormat, arg ); - va_end( arg ); + va_start( arg, pcFormat ); + vprintf( pcFormat, arg ); + va_end( arg ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main_networking.c b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main_networking.c index b3f1819f55..71401afabe 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main_networking.c +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/main_networking.c @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -185,7 +185,6 @@ void vPlatformInitIpStack( void ) { BaseType_t xResult; uint8_t ucIPAddress[ 4 ]; - uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 }; uint8_t ucNullAddress[ 4 ] = { 0, 0, 0, 0 }; uint8_t ucMACAddress[ 6 ]; uint8_t ucDNSServerAddress[ 4 ]; diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/startup.c b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/startup.c index c38a90b56f..2edff09dd4 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/startup.c +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/startup.c @@ -37,48 +37,50 @@ extern void xPortSysTickHandler( void ); extern void uart_init(); extern int main(); -void __attribute__((weak)) EthernetISR (void); +void __attribute__( ( weak ) ) EthernetISR( void ); extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss; /* Prevent optimization so gcc does not replace code with memcpy */ -__attribute__((optimize("O0"))) -__attribute__((naked)) -void Reset_Handler(void) - { - // set stack pointer - __asm volatile ("ldr r0, =_estack"); - __asm volatile ("mov sp, r0"); - // copy .data section from flash to RAM - for (uint32_t *src = &_sidata, *dest = &_sdata; dest < &_edata;) +__attribute__( ( optimize( "O0" ) ) ) +__attribute__( ( naked ) ) +void Reset_Handler( void ) +{ + /* set stack pointer */ + __asm volatile ( "ldr r0, =_estack" ); + __asm volatile ( "mov sp, r0" ); + + /* copy .data section from flash to RAM */ + for( uint32_t * src = &_sidata, * dest = &_sdata; dest < &_edata; ) { *dest++ = *src++; } - // zero out .bss section - for (uint32_t *dest = &_sbss; dest < &_ebss;) + /* zero out .bss section */ + for( uint32_t * dest = &_sbss; dest < &_ebss; ) { *dest++ = 0; } - // jump to board initialisation - void _start(void); + + /* jump to board initialisation */ + void _start( void ); _start(); } -void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress ) +void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress ) { /* These are volatile to try and prevent the compiler/linker optimising 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. */ + * 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. */ volatile uint32_t r0; volatile uint32_t r1; volatile uint32_t r2; volatile uint32_t r3; volatile uint32_t r12; - volatile uint32_t lr; /* Link register. */ - volatile uint32_t pc; /* Program counter. */ - volatile uint32_t psr;/* Program status register. */ + volatile uint32_t lr; /* Link register. */ + volatile uint32_t pc; /* Program counter. */ + volatile uint32_t psr; /* Program status register. */ r0 = pulFaultStackAddress[ 0 ]; r1 = pulFaultStackAddress[ 1 ]; @@ -91,11 +93,13 @@ of this function. */ psr = pulFaultStackAddress[ 7 ]; /* When the following line is hit, the variables contain the register values. */ - for( ;; ); + for( ; ; ) + { + } } static void Default_Handler( void ) __attribute__( ( naked ) ); -void Default_Handler(void) +void Default_Handler( void ) { __asm volatile ( @@ -111,9 +115,8 @@ void Default_Handler(void) ); } static void HardFault_Handler( void ) __attribute__( ( naked ) ); -void Default_Handler2(void) +void Default_Handler2( void ) { - __asm volatile ( " tst lr, #4 \n" @@ -127,79 +130,86 @@ void Default_Handler2(void) ); } -void Default_Handler3(void) +void Default_Handler3( void ) { - for (;;) { } + for( ; ; ) + { + } } -void Default_Handler4(void) +void Default_Handler4( void ) { - for (;;) { } + for( ; ; ) + { + } } -void Default_Handler5(void) +void Default_Handler5( void ) { - for (;;) { } + for( ; ; ) + { + } } -void Default_Handler6(void) +void Default_Handler6( void ) { - for (;;) { } + for( ; ; ) + { + } } -const uint32_t* isr_vector[] __attribute__((section(".isr_vector"))) = +const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = { - (uint32_t*)&_estack, - (uint32_t*)&Reset_Handler, // Reset -15 - (uint32_t*)&Default_Handler, // NMI_Handler -14 - (uint32_t*)&Default_Handler2, // HardFault_Handler -13 - (uint32_t*)&Default_Handler3, // MemManage_Handler -12 - (uint32_t*)&Default_Handler4, // BusFault_Handler -11 - (uint32_t*)&Default_Handler5, // UsageFault_Handler -10 - 0, // reserved - 0, // reserved - 0, // reserved - 0, // reserved -6 - (uint32_t*)&vPortSVCHandler, // SVC_Handler -5 - (uint32_t*)&Default_Handler6, // DebugMon_Handler -4 - 0, // reserved - (uint32_t*)&xPortPendSVHandler, // PendSV handler -2 - (uint32_t*)&xPortSysTickHandler, // SysTick_Handler -1 - 0, // uart0 receive 0 - 0, // uart0 transmit - 0, // uart1 receive - 0, // uart1 transmit - 0, // uart 2 receive - 0, // uart 2 transmit - 0, // GPIO 0 combined interrupt - 0, // GPIO 2 combined interrupt - 0, // Timer 0 - 0, // Timer 1 - 0, // Dial Timer - 0, // SPI0 SPI1 - 0, // uart overflow 1 2,3 12 - (uint32_t*)&EthernetISR, // Ethernet 13 + ( uint32_t * ) &_estack, + ( uint32_t * ) &Reset_Handler, /* Reset -15 */ + ( uint32_t * ) &Default_Handler, /* NMI_Handler -14 */ + ( uint32_t * ) &Default_Handler2, /* HardFault_Handler -13 */ + ( uint32_t * ) &Default_Handler3, /* MemManage_Handler -12 */ + ( uint32_t * ) &Default_Handler4, /* BusFault_Handler -11 */ + ( uint32_t * ) &Default_Handler5, /* UsageFault_Handler -10 */ + 0, /* reserved */ + 0, /* reserved */ + 0, /* reserved */ + 0, /* reserved -6 */ + ( uint32_t * ) &vPortSVCHandler, /* SVC_Handler -5 */ + ( uint32_t * ) &Default_Handler6, /* DebugMon_Handler -4 */ + 0, /* reserved */ + ( uint32_t * ) &xPortPendSVHandler, /* PendSV handler -2 */ + ( uint32_t * ) &xPortSysTickHandler, /* SysTick_Handler -1 */ + 0, /* uart0 receive 0 */ + 0, /* uart0 transmit */ + 0, /* uart1 receive */ + 0, /* uart1 transmit */ + 0, /* uart 2 receive */ + 0, /* uart 2 transmit */ + 0, /* GPIO 0 combined interrupt */ + 0, /* GPIO 2 combined interrupt */ + 0, /* Timer 0 */ + 0, /* Timer 1 */ + 0, /* Dial Timer */ + 0, /* SPI0 SPI1 */ + 0, /* uart overflow 1 2,3 12 */ + ( uint32_t * ) &EthernetISR, /* Ethernet 13 */ }; -void _start(void) +void _start( void ) { uart_init(); - main(0, 0); - exit(0); + main( 0, 0 ); + exit( 0 ); } -__attribute__((naked)) void exit(int status) +__attribute__( ( naked ) ) void exit( int status ) { - // Force qemu to exit using ARM Semihosting + /* Force qemu to exit using ARM Semihosting */ __asm volatile ( "mov r1, r0\n" "cmp r1, #0\n" "bne .notclean\n" - "ldr r1, =0x20026\n" // ADP_Stopped_ApplicationExit, a clean exit + "ldr r1, =0x20026\n" /* ADP_Stopped_ApplicationExit, a clean exit */ ".notclean:\n" - "movs r0, #0x18\n" // SYS_EXIT + "movs r0, #0x18\n" /* SYS_EXIT */ "bkpt 0xab\n" "end: b end\n" ); } - diff --git a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/syscall.c b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/syscall.c index 1c6ffda6bf..52e5e0badf 100644 --- a/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/syscall.c +++ b/FreeRTOS-Plus/Demo/MQTT_Mutual_Auth_Qemu_mps2/source/syscall.c @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -29,7 +29,8 @@ extern "C" { #include <sys/types.h> -typedef struct UART_t { +typedef struct UART_t +{ volatile uint32_t DATA; volatile uint32_t STATE; volatile uint32_t CTRL; @@ -37,19 +38,19 @@ typedef struct UART_t { volatile uint32_t BAUDDIV; } UART_t; -#define UART0_ADDR ((UART_t *)(0x40004000)) -#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) +#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_STATE_TXFULL ( 1 << 0 ) +#define UART_CTRL_TX_EN ( 1 << 0 ) +#define UART_CTRL_RX_EN ( 1 << 1 ) extern unsigned long _heap_bottom; extern unsigned long _heap_top; extern unsigned long g_ulBase; -static void *heap_end = 0; +static void * heap_end = 0; /** * @brief initializes the UART emulated hardware @@ -65,7 +66,7 @@ void uart_init() * @todo implement if necessary * */ -int _fstat(int file) +int _fstat( int file ) { return 0; } @@ -75,9 +76,11 @@ int _fstat(int file) * @todo implement if necessary * */ -int _read(int file, char *buf, int len) +int _read( int file, + char * buf, + int len ) { - return -1; + return -1; } /** @@ -88,13 +91,17 @@ int _read(int file, char *buf, int len) * @param [in] len length of the buffer * @returns the number of bytes written */ -int _write(int file, char *buf, int len) +int _write( int file, + char * buf, + int len ) { int todo; - for (todo = 0; todo < len; todo++){ - UART_DR(UART0_ADDR) = *buf++; + for( todo = 0; todo < len; todo++ ) + { + UART_DR( UART0_ADDR ) = *buf++; } + return len; } @@ -104,20 +111,20 @@ int _write(int file, char *buf, int len) * @returns the previous top of the heap * @note uses a global variable <b>heap_end</b> to keep track of the previous top */ -void* _sbrk(int incr) +void * _sbrk( int incr ) { - char *prev_heap_end; + char * prev_heap_end; - if (heap_end == 0) + if( heap_end == 0 ) { - heap_end = (void*) &_heap_bottom; + heap_end = ( void * ) &_heap_bottom; } prev_heap_end = heap_end; - if ((heap_end + incr) > (void*)&_heap_top) + if( ( heap_end + incr ) > ( void * ) &_heap_top ) { - return (void*)-1; + return ( void * ) -1; } heap_end += incr;