mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
OP-900 Updated howto_upgrade.txt doc
+review OPReview-435
This commit is contained in:
parent
81156ad132
commit
f68a038af0
@ -2,6 +2,16 @@ General guidelines for updating FreeRTOS
|
|||||||
|
|
||||||
This file will list the necessary modifications to FreeRTOS package to be used inside PiOS
|
This file will list the necessary modifications to FreeRTOS package to be used inside PiOS
|
||||||
|
|
||||||
|
Brief list of modifications:
|
||||||
|
*Add function to get task run time;
|
||||||
|
*Modified heap_1.c to allow for different alignment for stack and generic malloc;
|
||||||
|
*Allow heap_1.c for modification of max heap size at runtime;
|
||||||
|
*use section ".heap" for heap.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- include/task.h
|
- include/task.h
|
||||||
add the following declaration:
|
add the following declaration:
|
||||||
|
|
||||||
@ -41,16 +51,24 @@ add the following function:
|
|||||||
|
|
||||||
it usually is added after the declaration of vTaskGetRunTimeStats.
|
it usually is added after the declaration of vTaskGetRunTimeStats.
|
||||||
|
|
||||||
|
- STM32F1XX/Libraries/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h
|
||||||
|
add the following define for
|
||||||
|
|
||||||
|
#define portBYTE_HEAP_ALIGNMENT 4 // this value is used to allocate heap
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- portable/MemMang/heap_1.c
|
- portable/MemMang/heap_1.c
|
||||||
following there is the modification done in this revision against the base heap_1.c
|
following there is the modification done in this revision against the base heap_1.c
|
||||||
The modifications add a currentTOTAL_HEAP_SIZE variable that hold the current heap size,
|
The modifications add a currentTOTAL_HEAP_SIZE variable that hold the current heap size,
|
||||||
used instead of the configTOTAL_HEAP_SIZE macro that can be changed by the added
|
used instead of the configTOTAL_HEAP_SIZE macro that can be changed by the added
|
||||||
xPortIncreaseHeapSize function.
|
xPortIncreaseHeapSize function.
|
||||||
|
Also it allows for configurable aligments for Heap and Stack allocations.
|
||||||
|
|
||||||
--- ../op_evo/FreeRTOSV7.4.0/FreeRTOS/Source/portable/MemMang/heap_1.c 2013-04-06 15:04:22.760048534 +0200
|
--- ../op_evo/FreeRTOSV7.4.0/FreeRTOS/Source/portable/MemMang/heap_1.c 2013-04-06 15:04:22.760048534 +0200
|
||||||
+++ ./flight/PiOS/Common/Libraries/FreeRTOS/Source/portable/MemMang/heap_1.c 2013-04-06 14:53:31.828030608 +0200
|
+++ ./flight/PiOS/Common/Libraries/FreeRTOS/Source/portable/MemMang/heap_1.c 2013-04-08 02:23:01.649194752 +0200
|
||||||
@@ -92,13 +92,16 @@
|
@@ -92,26 +92,30 @@
|
||||||
|
|
||||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
||||||
|
|
||||||
@ -63,14 +81,54 @@ xPortIncreaseHeapSize function.
|
|||||||
static size_t xNextFreeByte = ( size_t ) 0;
|
static size_t xNextFreeByte = ( size_t ) 0;
|
||||||
|
|
||||||
+static size_t currentTOTAL_HEAP_SIZE = configTOTAL_HEAP_SIZE;
|
+static size_t currentTOTAL_HEAP_SIZE = configTOTAL_HEAP_SIZE;
|
||||||
|
+void *pvPortMallocGeneric( size_t xWantedSize, size_t alignment);
|
||||||
+
|
+
|
||||||
+/* A few bytes might be lost to byte aligning the heap start address. */
|
+/* A few bytes might be lost to byte aligning the heap start address. */
|
||||||
+#define configADJUSTED_HEAP_SIZE (currentTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT)
|
+#define configADJUSTED_HEAP_SIZE (currentTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT)
|
||||||
+
|
+
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void *pvPortMalloc( size_t xWantedSize )
|
-void *pvPortMalloc( size_t xWantedSize )
|
||||||
@@ -172,6 +175,12 @@
|
+void *pvPortMallocGeneric( size_t xWantedSize, size_t alignment)
|
||||||
|
{
|
||||||
|
void *pvReturn = NULL;
|
||||||
|
static unsigned char *pucAlignedHeap = NULL;
|
||||||
|
-
|
||||||
|
+size_t mask = alignment-1;
|
||||||
|
/* Ensure that blocks are always aligned to the required number of bytes. */
|
||||||
|
#if portBYTE_ALIGNMENT != 1
|
||||||
|
- if( xWantedSize & portBYTE_ALIGNMENT_MASK )
|
||||||
|
+ if( xWantedSize & mask )
|
||||||
|
{
|
||||||
|
- /* Byte alignment required. */
|
||||||
|
- xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
|
||||||
|
+ /* Byte alignment required. */
|
||||||
|
+ xWantedSize += ( alignment - ( xWantedSize & mask ) );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -120,7 +124,7 @@
|
||||||
|
if( pucAlignedHeap == NULL )
|
||||||
|
{
|
||||||
|
/* Ensure the heap starts on a correctly aligned boundary. */
|
||||||
|
- pucAlignedHeap = ( unsigned char * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) );
|
||||||
|
+ pucAlignedHeap = ( unsigned char * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ alignment ] ) & ( ( portPOINTER_SIZE_TYPE ) ~ mask ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check there is enough room left for the allocation. */
|
||||||
|
@@ -147,6 +151,11 @@
|
||||||
|
|
||||||
|
return pvReturn;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void *pvPortMalloc( size_t xWantedSize){
|
||||||
|
+ return pvPortMallocGeneric(xWantedSize, portBYTE_HEAP_ALIGNMENT);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vPortFree( void *pv )
|
||||||
|
@@ -172,6 +181,12 @@
|
||||||
{
|
{
|
||||||
return ( configADJUSTED_HEAP_SIZE - xNextFreeByte );
|
return ( configADJUSTED_HEAP_SIZE - xNextFreeByte );
|
||||||
}
|
}
|
||||||
@ -90,3 +148,5 @@ xPortIncreaseHeapSize function.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user