Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Error using Heap2

Posted by emerico on December 11, 2005
Hello,
On a FreeRTOS port on ADuC7026 in nonpreemtive mode using Heap_2 as Heap,
I can not correctly start a task after have allocated memory to a pointer.

Example:
If a write this:
/**********************************************/
3. xTaskCreate( vAbcsp_aduc_ABCSPLaunch, "ABCSP",
4. 100, NULL, ABCSP_PRIORITY, &xABCSPHANDLE);
/**********************************************/

then a will not have any problem. but if l first allocate memory to a pointer like this:

/***********************************************/
1. uint8* pointer = pvPortMalloc (sizeof(uint8*));
2. pointer[0] = 0x00;
3. xTaskCreate( vAbcsp_aduc_ABCSPLaunch, "ABCSP",
4. 100, NULL, ABCSP_PRIORITY, &xABCSPHANDLE);
/***********************************/

then a have a problem at line 3. (Especially in xTaskCreate where memory is allocated to the Task control block.)
Error:
/***************
Data Abort: Thumb Instruction at 000830F2H, Memory Access at 00C016E8H
****************************************/

Can somebody help me? any idea where the error is comming from?
Best regards
Emeric

RE: Error using Heap2

Posted by Nobody/Anonymous on December 11, 2005
What are you using to debug your system with? Are you able to step through the code? If so can you find the line that is causing the problem?

The ADuC7026 is not a standard port, did you write it yourself? If so, have you checked the startup code to ensure the processor is in the expected mode, and that the stacks are setup correctly?

RE: Error using Heap2

Posted by emerico on December 11, 2005
I am using the Keil debugger.

The error is:
in funktion xTaskCreate in tasks.c at line:
pxNewTCB = prvAllocateTCBAndStack( usStackDepth );

in funktion prvAllocateTCBAndStack in tasks.c at line:
pxNewTCB = ( tskTCB * ) pvPortMalloc( sizeof( tskTCB ) );

in funktion pvPortMalloc in Heap_2.c at line:
Especially at line :
/* Insert the new block into the list of free blocks. */
prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );



Looking in startup.s i found this
/************************************

// <h> Stack Configuration (Stack Sizes in Bytes)
// <o0> Undefined Mode <0x0-0xFFFFFFFF:4>
// <o1> Supervisor Mode <0x0-0xFFFFFFFF:4>
// <o2> Abort Mode <0x0-0xFFFFFFFF:4>
// <o3> Fast Interrupt Mode <0x0-0xFFFFFFFF:4>
// <o4> Interrupt Mode <0x0-0xFFFFFFFF:4>
// <o5> User/System Mode <0x0-0xFFFFFFFF:4>
// </h>
*/
UND_Stack_Size EQU 0x00000004
SVC_Stack_Size EQU 0x00000100
ABT_Stack_Size EQU 0x00000004
FIQ_Stack_Size EQU 0x00000004
IRQ_Stack_Size EQU 0x00000080
USR_Stack_Size EQU 0x00000200

AREA STACK, DATA, READWRITE, ALIGN=2
DS (USR_Stack_Size+3)&~3 ; Stack for User/System Mode
DS (SVC_Stack_Size+3)&~3 ; Stack for Supervisor Mode
DS (IRQ_Stack_Size+3)&~3 ; Stack for Interrupt Mode
DS (FIQ_Stack_Size+3)&~3 ; Stack for Fast Interrupt Mode
DS (ABT_Stack_Size+3)&~3 ; Stack for Abort Mode
DS (UND_Stack_Size+3)&~3 ; Stack for Undefined Mode
Top_Stack:


/**********************************

and this.

/*************************************************


// Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size

// Enter S Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SYS
MOV SP, R0

// Start in supervisor mode
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
// Enter the C code
LDR R0,=?C?INIT
TST R0,#1 ; Bit-0 set: main is Thumb
LDREQ LR,=exit?A ; ARM Mode
LDRNE LR,=exit?T ; Thumb Mode
BX R0
ENDP


/*********************************************/

How to be sure to be sure that the stack is normally setted?
thank you in advance.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists