This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cyg_user_start fails to start


In the attached C Code file I am creating two threads one that 
reads a chunk of serial data from port serial B.
The other thread writes a part of the received data
back to serial B.
The board is based on at91eb40a and has 1MegaByte of external SRAM.
Weve changed our memory layout files to accomodate. 
also i have increased the buffer size for port B in the
configtool in the serial driver section to 32KBytes
Read buffer is allocated thus in C code:
char readBuffer[1600]={'c'}; 
Code works perfectly in RAM startup mode, for both small and
large readBuffer allocation
Code works perfectly in RAMROM startup mode also ONLY IF
readBuffer is given a small enough size eg.
char readBuffer[1600]={'c'}; 

Problem1: Code *fails* in ROMRAM startup mode if you assign
a large readBuffer eg. :
char readBuffer[8192]={'c'}; 

Problem/Symptom2: The cyg_user_start is supposed to blink 
the LEDs twice when it is entered. It does not blink if i
increase the readBuffer size from 1600 to 8192.
This leads me to believe that when the readBuffer size is large ecos
does not even initialize correctly. Im *guessing* that its
happening during hal or kernel initializations when memory is 
being allocated for the line of code
char readBuffer[8192]={'c'}; 
Kindly advise.
Thanks
#include <cyg/kernel/kapi.h>
#include <cyg/io/io.h> 
#include <stdlib.h> 
#include <cyg/hal/var_io.h> 
#include <cyg/hal/plf_io.h>             
#include <cyg/hal/hal_io.h>             
#define THREAD_STACK_SIZE 4096



int threadStack[2][THREAD_STACK_SIZE]; 
cyg_handle_t threadWriteHandle,threadReadHandle; 
cyg_thread threadWriteObj,threadReadObj; 
cyg_io_handle_t ttyHdl;
int err=0;
char outputString[] = "0xAA\n\r";
cyg_uint32 outputLen = sizeof(outputString);
cyg_mutex_t printfSerialIoMutex; 


void threadWriteRoutine(cyg_addrword_t);
void threadreadRoutine(cyg_addrword_t);
cyg_uint32 validDataLen = 8190; 
cyg_uint32 readLen = 8192;
char readBuffer[8192]={'c'}; 


void threadWriteRoutine(cyg_addrword_t data)
{
	while(1)
	{
		cyg_mutex_lock(&printfSerialIoMutex); 
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); 
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_CODR,0x00000078); //LEDs on
		err = cyg_io_write (ttyHdl,&readBuffer[2],&validDataLen); 
		cyg_thread_delay(40); 
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); //LEDs off
		cyg_mutex_unlock(&printfSerialIoMutex); 
		cyg_thread_yield(); 
	}
}
	
void threadReadRoutine(cyg_addrword_t data)
{
	while(1)
	{
		cyg_mutex_lock(&printfSerialIoMutex);
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); 
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_CODR,0x000f0000);//LEDs on 
		err = cyg_io_read(ttyHdl,readBuffer,&readLen);
		cyg_thread_delay(40); 
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); //LEDs off
		char lengthString[2];
		lengthString[0]=readBuffer[0];
		lengthString[1]=readBuffer[1];
		validDataLen =atoi(lengthString); 
		cyg_mutex_unlock(&printfSerialIoMutex);
		cyg_thread_yield(); 
	}
}
	
void cyg_user_start(void)
{
	//blink LEDs to indicate cyg_user_start entered
		long blah=0;
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); 
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_CODR,0x000f0078); 
		for (blah=0;blah < 2000000 ; blah++);
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); 
		for (blah=0;blah < 2000000 ; blah++);
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_CODR,0x000f0078); 
		for (blah=0;blah < 2000000 ; blah++);
		HAL_WRITE_UINT32(AT91_PIO+AT91_PIO_SODR,0xffffffff); 
		for (blah=0;blah < 4000000 ; blah++);
	cyg_mutex_init(&printfSerialIoMutex);
	err = cyg_io_lookup("/dev/tty1", &ttyHdl); 
	cyg_thread_create(
			0, 	 	         
			threadWriteRoutine,        
			(cyg_addrword_t)0,       
			"threadWrite",             
			(void *)threadStack[0],  
			THREAD_STACK_SIZE,    
			&threadWriteHandle,        
			&threadWriteObj	         
			); 
	
	cyg_thread_resume(threadWriteHandle);
	cyg_thread_create(
			0, 	 	         
			threadReadRoutine,        
			(cyg_addrword_t)0,       
			"threadRead",             
			(void *)threadStack[1],  
			THREAD_STACK_SIZE,    
			&threadReadHandle,        
			&threadReadObj	         
			); 
	
	cyg_thread_resume(threadReadHandle);
}





-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]