diff options
author | rtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2> | 2014-06-12 16:27:35 +0000 |
---|---|---|
committer | rtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2> | 2014-06-12 16:27:35 +0000 |
commit | 906b56633071e2806cb6141d47d011d9086aa676 (patch) | |
tree | 02ab4ea8f299f3f83bc5f6c00eb4cd9db2263269 /FreeRTOS/Demo | |
parent | dd3c512d5aec02182e3b59a81188ec3c174b89f7 (diff) | |
download | freertos-906b56633071e2806cb6141d47d011d9086aa676.tar.gz |
Zynq demo: Fix Xilinx network driver by deferring the function that allocated memory from the interrupt into a task. Add DHCP option.
git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2257 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS/Demo')
7 files changed, 78 insertions, 36 deletions
diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h index b61a83bb8..9bcfed81d 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h @@ -117,7 +117,7 @@ #define configUSE_TICK_HOOK 1
#define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 200 )
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 80 * 1024 ) )
+#define configTOTAL_HEAP_SIZE ( 80 * 1024 )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
@@ -165,7 +165,7 @@ extern XScuWdt xWatchDogInstance; extern void vInitialiseTimerForRunTimeStats( void );
#define configGENERATE_RUN_TIME_STATS 1
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vInitialiseTimerForRunTimeStats()
-#define portGET_RUN_TIME_COUNTER_VALUE() ( 0xffffffffUL - XScuWdt_ReadReg( xWatchDogInstance.Config.BaseAddr, XSCUWDT_COUNTER_OFFSET ) )
+#define portGET_RUN_TIME_COUNTER_VALUE() ( ( 0xffffffffUL - XScuWdt_ReadReg( xWatchDogInstance.Config.BaseAddr, XSCUWDT_COUNTER_OFFSET ) ) >> 1 )
/* The size of the global output buffer that is available for use when there
are multiple command interpreters running at once (for example, one on a UART
diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/serial.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/serial.c index 1cf524704..a3440bb0c 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/serial.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/serial.c @@ -140,7 +140,7 @@ XUartPs_Config *pxConfig; the semaphore so it is in the correct state the first time
xSerialSendString() is called. A block time of zero is used when taking
the semaphore as it is guaranteed to be available (it was just created). */
- xTxCompleteSemaphore = xSemaphoreCreateMutex();
+ xTxCompleteSemaphore = xSemaphoreCreateBinary();
configASSERT( xTxCompleteSemaphore );
xSemaphoreTake( xTxCompleteSemaphore, 0 );
@@ -208,7 +208,7 @@ const TickType_t xMaxWait = 200UL / portTICK_PERIOD_MS; otherwise there is a risk the calling function will overwrite the string
pointed to by the pcString parameter while it is still being transmitted.
The calling task will wait in the Blocked state (so not consuming any
- processing time) until the mutex is available. */
+ processing time) until the semaphore is available. */
xSemaphoreTake( xTxCompleteSemaphore, xMaxWait );
}
/*-----------------------------------------------------------*/
@@ -221,7 +221,7 @@ signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar /* Send the character. */
XUartPs_Send( &xUARTInstance, ( void * ) &cOutChar, sizeof( cOutChar ) );
- /* Wait for the transmission to be complete so the mutex is left in the
+ /* Wait for the transmission to be complete so the semaphore is left in the
correct state for the next time vSerialPutString() is called. */
xSemaphoreTake( xTxCompleteSemaphore, xBlockTime );
diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c index bf7d1f0bf..c16580670 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c @@ -67,7 +67,7 @@ #include "FreeRTOS_CLI.h"
/* Dimensions the buffer into which input characters are placed. */
-#define cmdMAX_INPUT_SIZE 20
+#define cmdMAX_INPUT_SIZE 100
/* Dimensions the buffer into which string outputs can be placed. */
#define cmdMAX_OUTPUT_SIZE 1024
diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c index b298b8dd3..737348182 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c @@ -62,6 +62,7 @@ /* lwIP core includes */
#include "lwip/opt.h"
#include "lwip/tcpip.h"
+#include "lwip/inet.h"
/* applications includes */
#include "apps/httpserver_raw_from_lwIP_download/httpd.h"
@@ -121,6 +122,21 @@ static signed char cTxBuffer[ lwipappsTX_BUFFER_SIZE ]; /*-----------------------------------------------------------*/
+void vStatusCallback( struct netif *pxNetIf )
+{
+char pcMessage[20];
+
+ if( netif_is_up( pxNetIf ) != 0 )
+ {
+ strcpy( pcMessage, "IP=" );
+ strcat( pcMessage, inet_ntoa( *( struct in_addr* ) &( pxNetIf->ip_addr ) ) );
+ xil_printf( pcMessage );
+ }
+ else
+ {
+ xil_printf( "Network is down" );
+ }
+}
/* Called from the TCP/IP thread. */
void lwIPAppsInit( void *pvArgument )
@@ -151,7 +167,16 @@ static struct netif xNetIf; xNetIf.hwaddr[ 5 ] = configMAC_ADDR5;
netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway, ( void * ) XPAR_XEMACPS_0_BASEADDR, xemacpsif_init, tcpip_input ) );
- netif_set_up( &xNetIf );
+ netif_set_status_callback( &xNetIf, vStatusCallback );
+ #if LWIP_DHCP
+ {
+ dhcp_start( &xNetIf );
+ }
+ #else
+ {
+ netif_set_up( &xNetIf );
+ }
+ #endif
/* Install the server side include handler. */
http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );
diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xemacpsif_dma.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xemacpsif_dma.c index 6d02020d6..429b51a7e 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xemacpsif_dma.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xemacpsif_dma.c @@ -124,6 +124,12 @@ void process_sent_bds(XEmacPs_BdRing *txring) return; } +void vPendableSendCompleteFunction( void *pvParameter, uint32_t ulParameter ) +{ + ( void ) ulParameter; + process_sent_bds(pvParameter); +} + void emacps_send_handler(void *arg) { struct xemac_s *xemac; @@ -139,11 +145,19 @@ void emacps_send_handler(void *arg) regval = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, XEMACPS_TXSR_OFFSET); XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress,XEMACPS_TXSR_OFFSET, regval); - /* If Transmit done interrupt is asserted, process completed BD's */ - process_sent_bds(TxRingPtr); #ifdef OS_IS_FREERTOS xInsideISR--; #endif + + /* If Transmit done interrupt is asserted, process completed BD's - Replaced + a call to process_sent_bds(TxRingPtr); with a pendable function to prevent + the memory allocation files being accessed from the ISR with not redress if + obtaining the mutex fails. */ + { + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + xTimerPendFunctionCallFromISR( vPendableSendCompleteFunction, TxRingPtr, 0, &xHigherPriorityTaskWoken ); + portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + } } XStatus emacps_sgsend(xemacpsif_s *xemacpsif, struct pbuf *p) diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwipopts.h b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwipopts.h index afc7986b4..30025dc2d 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwipopts.h +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwipopts.h @@ -69,35 +69,36 @@ void vLwipAppsReleaseTxBuffer( void ); #define LWIP_SO_RCVTIMEO 1 #define LWIP_SO_RCVBUF 1 +//#define LWIP_DEBUG #ifdef LWIP_DEBUG -#define LWIP_DBG_MIN_LEVEL 0 -#define PPP_DEBUG LWIP_DBG_ON -#define MEM_DEBUG LWIP_DBG_ON -#define MEMP_DEBUG LWIP_DBG_ON -#define PBUF_DEBUG LWIP_DBG_ON -#define API_LIB_DEBUG LWIP_DBG_ON -#define API_MSG_DEBUG LWIP_DBG_ON -#define TCPIP_DEBUG LWIP_DBG_ON -#define NETIF_DEBUG LWIP_DBG_ON -#define SOCKETS_DEBUG LWIP_DBG_ON -#define DNS_DEBUG LWIP_DBG_ON -#define AUTOIP_DEBUG LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL // LWIP_DBG_LEVEL_SERIOUS +#define PPP_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define NETIF_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF #define DHCP_DEBUG LWIP_DBG_ON -#define IP_DEBUG LWIP_DBG_ON -#define IP_REASS_DEBUG LWIP_DBG_ON -#define ICMP_DEBUG LWIP_DBG_ON -#define IGMP_DEBUG LWIP_DBG_ON -#define UDP_DEBUG LWIP_DBG_ON -#define TCP_DEBUG LWIP_DBG_ON -#define TCP_INPUT_DEBUG LWIP_DBG_ON -#define TCP_OUTPUT_DEBUG LWIP_DBG_ON -#define TCP_RTO_DEBUG LWIP_DBG_ON -#define TCP_CWND_DEBUG LWIP_DBG_ON -#define TCP_WND_DEBUG LWIP_DBG_ON -#define TCP_FR_DEBUG LWIP_DBG_ON -#define TCP_QLEN_DEBUG LWIP_DBG_ON -#define TCP_RST_DEBUG LWIP_DBG_ON +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF #endif #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) @@ -306,4 +307,6 @@ a lot of data that needs to be copied, this should be set high. */ #endif /* PPP_SUPPORT */ +#define LWIP_NETIF_STATUS_CALLBACK 1 + #endif /* __LWIPOPTS_H__ */ diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c index 425c87ac7..5019093db 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c @@ -124,7 +124,7 @@ *
* When mainSELECTED_APPLICATION is set to 2 the lwIP example will be run.
*/
-#define mainSELECTED_APPLICATION 2
+#define mainSELECTED_APPLICATION 1
/*-----------------------------------------------------------*/
|