AURIX TriCore学习笔记五:LwIP基于FreeRTOS系统移植

一目了然

1 准备工作

在查看此博客之前,建议读者先阅读:AURIX TriCore学习笔记四:LwIP裸机移植,文章链接如下所示:https://blog.csdn.net/weixin_43986229/article/details/105651842,此博客是在其基础上进行扩展和完善,增加基于FreeRTOS移植LwIP协议时应当注意的事项。

2 移植LwIP

2.1 文件移植

基于AURIX TriCore学习笔记四:LwIP裸机移植中介绍创建工程路径后,注意“port”目录,这是基于FreeRTOS移植LwIP的关键,主要工作便是对此目录下文件的修改以及文件的添加。首先完善工程文件,在“port\include\arch”目录下添加“sys_arch.h”文件,在“port”目录下添加“sys_arch.c”文件。通常称“sys_arch.h”和“sys_arch.c”为系统模拟接口层文件,其内容定义如下所示。
sys_arch.h文件内容:

/**
 * @file
 *
 * lwIP sys arch configuration.  This file is part of the lwIP TCP/IP stack.
 */

/*
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved. 
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 * OF SUCH DAMAGE.
 */
 
#ifndef LWIP_SYS_ARCH_H
#define LWIP_SYS_ARCH_H

/*
 * The stack be used either in a bare metal environment (NO_SYS=1) or in an OS environment (NO_SYS=0).
 * This implementation supports FreeRTOS as operating system (USING_OS_FREERTOS)
*/
#include "lwip/opt.h"

/* Sanity checks */
#if NO_SYS
#if defined(USING_OS_FREERTOS)
#error NO_SYS cannot be used with USING_OS_FREERTOS
#endif /* defined(USING_OS_FREERTOS) */
#else /* NO_SYS */
#if defined(USING_OS_FREERTOS)
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#else /* defined(USING_OS_FREERTOS) */
#error USING_OS_FREERTOS needs to be enabled when NO_SYS=0
#endif /* defined(USING_OS_FREERTOS) */
#endif /* NO_SYS */


#if defined(USING_OS_FREERTOS)

typedef QueueHandle_t               sys_mbox_t;
typedef SemaphoreHandle_t           sys_sem_t;
typedef SemaphoreHandle_t           sys_mutex_t;
typedef TaskHandle_t                sys_thread_t;

#define SYS_MBOX_NULL               (QueueHandle_t)0
#define SYS_SEM_NULL                (SemaphoreHandle_t)0
#define SYS_MUTEX_NULL              SYS_SEM_NULL

#define sys_mbox_valid(mbox)        (((uintptr_t)(mbox) != (uintptr_t)NULL) && (*(mbox) != SYS_SEM_NULL))
#define sys_mbox_set_invalid(mbox)  do { if ((mbox) != NULL) { *(mbox) = SYS_SEM_NULL; }} while(0)

#define sys_sem_valid(sem)          (((sem) != NULL) && (*(sem) != SYS_SEM_NULL))
#define sys_sem_set_invalid(sem)    do {if ((sem) != NULL) { *(sem) = SYS_SEM_NULL; }} while(0)

#define sys_mutex_valid(sem)        sys_sem_valid(sem)
#define sys_mutex_set_invalid(sem)  sys_sem_set_invalid(sem)

/* These functions are not part of the lwIP sys_arch API
   But since the functionality is support by underlying FreeRTOS, they may be useful for implementing netifs */
void sys_mbox_post_to_front(sys_mbox_t *mbox, void *data);
void sys_thread_delete(sys_thread_t thread);

#if LWIP_SOCKET_SET_ERRNO
#define set_errno(err) do { if (err) { vTaskSetThreadLocalStoragePointer(NULL, 0, (void *)(err)); } } while(0)
#define errno ((int)pvTaskGetThreadLocalStoragePointer(NULL, 0))
#endif /* LWIP_SOCKET_SET_ERRNO */


#if LWIP_NETCONN_SEM_PER_THREAD
#define LWIP_NETCONN_THREAD_SEM_GET() ((sys_sem_t*)pvTaskGetThreadLocalStoragePointer(NULL, 1))
#define LWIP_NETCONN_THREAD_SEM_ALLOC() do {                                                                    \
                                                sys_sem_t* pSem = (sys_sem_t*)pvPortMalloc(sizeof(sys_sem_t));  \
                                                if (ERR_OK == sys_sem_new(pSem, 0)) {                           \
                                                    vTaskSetThreadLocalStoragePointer(NULL, 1, (void*)pSem);    \
                                                }                                                               \
                                           } while(0)
#define LWIP_NETCONN_THREAD_SEM_FREE()  do {                                                                    \
                                                sys_sem_t* pSem = LWIP_NETCONN_THREAD_SEM_GET();                \
                                                sys_sem_free(pSem);                                             \
                                                vPortFree(pSem);                                                \
                                                vTaskSetThreadLocalStoragePointer(NULL, 1, NULL);               \
                                           } while(0)
#endif /* LWIP_NETCONN_SEM_PER_THREAD */

#endif /* defined(USING_OS_FREERTOS) */

#endif /* LWIP_FREERTOS_ARCH_SYS_ARCH_H */


sys_arch.c文件内容:

/**
 * @file
 *
 * lwIP sys arch configuration.  This file is part of the lwIP TCP/IP stack.
 */

/*
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved. 
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 * OF SUCH DAMAGE.
 */
 
/* lwIP includes. */
#include "Global.h"
#include "lwip/opt.h"
#include "lwip/arch.h"
#include "lwip/stats.h"
#include "lwip/debug.h"
#include "lwip/sys.h"
#include "lwip/api.h"
#include "arch/sys_arch.h"

#if defined(USING_OS_FREERTOS)
/*
 * Checks validity of a mutex/semaphore, based on pointer value
 */
static err_t check_synchronization_value(const sys_sem_t *synchronization_value)
{
    err_t xResult = ERR_OK;

    if (NULL == *synchronization_value)
    {
        xResult = ERR_MEM;
    }

    return xResult;
}

/*
 * Returns the time elapsed (in milliseconds) since a given time
 * param: startTime - the time since we want to calculate how much time has passed
 */
static u32_t get_elapsed_time(u32_t startTime)
{
    u32_t elapsed;

    elapsed = sys_now() - startTime;
    if (0U == elapsed)
    {
      elapsed = 1U;
    }

    return elapsed;
}

/*
 * Creates an empty mailbox for maximum "size" elements.
 */
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
{
    LWIP_ASSERT("mbox != NULL", mbox != NULL);

    *mbox = xQueueCreate(size, sizeof(void*));

    return ERR_OK;
}

/*
 * Deallocates a mailbox. If there are messages still present in the
 * mailbox when the mailbox is deallocated, it is an indication of a
 * programming error in lwIP and the developer should be notified.
 */
void sys_mbox_free(sys_mbox_t *mbox)
{
    LWIP_ASSERT("mbox != NULL", mbox != NULL);
    LWIP_ASSERT("mbox not empty", !uxQueueMessagesWaiting(*mbox));

    vQueueDelete(*mbox);
}

/*
 * Posts the "msg" to the mailbox. This function have to block until
 * the "msg" is really posted.
 */
void sys_mbox_post(sys_mbox_t *mbox, void *data)
{
    LWIP_ASSERT("mbox != NULL", mbox != NULL);

    while (pdTRUE != xQueueSend(*mbox, &data, 10000)) /* time is arbitrary */
    {}
}

/*
 * Posts the "msg" to the front of the mailbox. This function have to block until
 * the "msg" is really posted.
 */
void sys_mbox_post_to_front(sys_mbox_t *mbox, void *data)
{
    LWIP_ASSERT("mbox != NULL", mbox != NULL);

    while (pdTRUE != xQueueSendToFront(*mbox, &data, 10000)) /* time is arbitrary */
    {}
}

/*
 * Try to post the "msg" to the mailbox. Returns ERR_MEM if this one
 * is full, else, ERR_OK if the "msg" is posted.
 */
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *data)
{
    LWIP_ASSERT("mbox != NULL", mbox != NULL);

    (void)xQueueSend(*mbox, &data, (TickType_t)0);

    return ERR_OK;
}

/*
 * Blocks the thread until a message arrives in the mailbox, but does
 * not block the thread longer than "timeout" milliseconds (similar to
 * the sys_arch_sem_wait() function). The "msg" argument is a result
 * parameter that is set by the function (i.e., by doing "*msg =
 * ptr"). The "msg" parameter maybe NULL to indicate that the message
 * should be dropped.
 *
 * The return values are the same as for the sys_arch_sem_wait() function:
 * Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
 * timeout.
 *
 * Note that a function with a similar name, sys_mbox_fetch(), is
 * implemented by lwIP.
 */
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
{
    void** msgptr = msg;
    u32_t startTime;

    LWIP_ASSERT("mbox != NULL", mbox != NULL);

    startTime = sys_now();

    if (timeout != 0U)
    {
        if (pdTRUE == xQueueReceive(*mbox, msgptr, pdMS_TO_TICKS(timeout)))
        {
            return get_elapsed_time(startTime);
        }
        else /* timed out blocking for message */
        {
            *msgptr = NULL;
            return SYS_ARCH_TIMEOUT;
        }
    }
    else /* block forever for a message. */
    {
        while (pdTRUE != xQueueReceive(*mbox, msgptr, 10000)) /* time is arbitrary */
        {}
        return get_elapsed_time(startTime);
    }
}

/*
 * This is similar to sys_arch_mbox_fetch, however if a message is not
 * present in the mailbox, it immediately returns with the code
 * SYS_MBOX_EMPTY. On success 0 is returned.
 */
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
{
    void** msgptr = msg;

    LWIP_ASSERT("mbox != NULL", mbox != NULL);

    if (pdTRUE == xQueueReceive(*mbox, msgptr, 0))
    {
        return 0U;
    }
    else /* no message */
    {
        *msgptr = NULL;
        return SYS_MBOX_EMPTY;
    }
}

/*
 * Creates and returns a new semaphore. The "count" argument specifies
 * the initial state of the semaphore. TBD finish and test
 */
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
{
    err_t xResult = ERR_OK;

    LWIP_UNUSED_ARG(count);
    LWIP_ASSERT("sem != NULL", sem != NULL);

    portENTER_CRITICAL();
    *sem = xSemaphoreCreateBinary();
    xResult = check_synchronization_value(sem);
    portEXIT_CRITICAL();

    return xResult;
}

/*
 * Blocks the thread while waiting for the semaphore to be
 * signaled. If the "timeout" argument is non-zero, the thread should
 * only be blocked for the specified time (measured in
 * milliseconds).
 *
 * If the timeout argument is non-zero, the return value is the number of
 * milliseconds spent waiting for the semaphore to be signaled. If the
 * semaphore wasn't signaled within the specified time, the return value is
 * SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
 * (i.e., it was already signaled), the function may return zero.
 *
 * Notice that lwIP implements a function with a similar name,
 * sys_sem_wait(), that uses the sys_arch_sem_wait() function.
 */
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
    u32_t startTime;

    LWIP_ASSERT("sem != NULL", sem != NULL);

    startTime = sys_now();
    if (timeout != 0U)
    {
        if (pdTRUE == xSemaphoreTake(*sem, pdMS_TO_TICKS(timeout)))
        {
            return get_elapsed_time(startTime);
        }
        else
        {
            return SYS_ARCH_TIMEOUT;
        }
    }
    else /* must block without a timeout */
    {
        while (xSemaphoreTake(*sem, 10000) != pdTRUE)
        {}
        return get_elapsed_time(startTime);
    }
}

/*
 * Signals a semaphore
 */
void sys_sem_signal(sys_sem_t *sem)
{
    LWIP_ASSERT("sem != NULL", sem != NULL);
    (void)xSemaphoreGive(*sem);
}

/*
 * Deallocates a semaphore
 */
void sys_sem_free(sys_sem_t *sem)
{
    LWIP_ASSERT("sem != NULL", sem != NULL);
    vSemaphoreDelete(*sem);
}

/*
 * Creates a new mutex. The mutex is allocated to the memory that 'mutex'
 * points to (which can be both a pointer or the actual OS structure).
 * If the mutex has been created, ERR_OK should be returned. Returning any
 * other error will provide a hint what went wrong, but except for assertions,
 * no real error handling is implemented.
 */
err_t sys_mutex_new(sys_mutex_t *mutex)
{
    LWIP_ASSERT("mutex != NULL", mutex != NULL);

    portENTER_CRITICAL();
    *mutex = xSemaphoreCreateMutex();
    portEXIT_CRITICAL();

    return check_synchronization_value(mutex);
}

/*
 * Blocks the thread until the mutex can be grabbed.
 */
void sys_mutex_lock(sys_mutex_t *mutex)
{
    LWIP_ASSERT("mutex != NULL", mutex != NULL);
    while (xSemaphoreTake(*mutex, portMAX_DELAY) == pdFALSE)
    {}
}

/*
 * Releases the mutex previously locked through 'sys_mutex_lock()'
 */
void sys_mutex_unlock(sys_mutex_t *mutex)
{
    LWIP_ASSERT("mutex != NULL", mutex != NULL);
    (void)xSemaphoreGive(*mutex);
}

/*
 * Deallocates a mutex
 */
void sys_mutex_free(sys_mutex_t *mutex)
{
    LWIP_ASSERT("mutex != NULL", mutex != NULL);
    vQueueDelete(*mutex);
}

/* Wrap a thread method and its argument for being passed to sys_thread_function */
struct threadfunc
{
    lwip_thread_fn function;
    void *arg;
};

/*
 * Utility method that wraps a thread function call and provides a way to add
 * initialization - eg per-thread semaphores
 */
static void sys_thread_function(void* arg)
{
    struct threadfunc* t = (struct threadfunc*)arg;

    #if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
    netconn_thread_init();
    #endif

    (void)t->function(t->arg);

    /* Regular FreeRTOS tasks don't return. But in case they do, make them exit cleanly. */
    #if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
    netconn_thread_cleanup();
    #endif

    mem_free(t);
    sys_thread_delete(NULL);
}

/*
 * Starts a new thread named "name" with priority "prio" that will begin its
 * execution in the function "thread()". The "arg" argument will be passed as an
 * argument to the thread() function. The stack size to used for this thread is
 * the "stacksize" parameter. The id of the new thread is returned. Both the id
 * and the priority are system dependent.
 */
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
{
    TaskHandle_t CreatedTask = NULL;
    uint16_t stackDepth = ((uint16_t)stacksize != 0U) ? (uint16_t)stacksize : (uint16_t)configMINIMAL_STACK_SIZE;
    struct threadfunc* tf = (struct threadfunc*)mem_malloc(sizeof (struct threadfunc));

    LWIP_ASSERT("tf != NULL", tf != NULL);

    tf->function = thread;
    tf->arg = arg;
    xTaskCreate(sys_thread_function, name, stackDepth, tf, prio, &CreatedTask);

    return CreatedTask;
}

/*
 * Deletes a thread
 */
void sys_thread_delete(sys_thread_t thread)
{
    vTaskDelete(thread);
}

/*
 * This optional function does a "fast" critical region protection and returns
 * the previous protection level. This function is only called during very short
 * critical regions. An embedded system which supports ISR-based drivers might
 * want to implement this function by disabling interrupts. Task-based systems
 * might want to implement this by using a mutex or disabling tasking. This
 * function should support recursive calls from the same task or interrupt. In
 * other words, sys_arch_protect() could be called while already protected. In
 * that case the return value indicates that it is already protected.
 *
 * sys_arch_protect() is only required if your port is supporting an operating
 * system.
 */
sys_prot_t sys_arch_protect(void)
{
    portENTER_CRITICAL();
    return 0;
}

/*
 * This optional function does a "fast" set of critical region protection to the
 * value specified by pval. See the documentation for sys_arch_protect() for
 * more information. This function is only required if your port is supporting
 * an operating system.
 */
void sys_arch_unprotect(sys_prot_t pval)
{
    (void) pval;
    portEXIT_CRITICAL();
}
#endif /* defined(USING_OS_FREERTOS) */

/*
 * Initialize sys arch layer
 */
void sys_init(void)
{
#if NO_SYS
    /* One dependency for FreeRTOS config file */
    vTaskDelay(pdMS_TO_TICKS(delay));
#endif
}

/*
 * Ticks/jiffies since power up
 */
u32_t sys_jiffies(void)
{
    return (uint32_t)((((uint64_t) xTaskGetTickCount()) * 1000u) / configTICK_RATE_HZ);
}

/*
 * Returns the current time in milliseconds.
 */
u32_t sys_now(void)
{
    return (uint32_t)((((uint64_t) xTaskGetTickCount()) * 1000u) / configTICK_RATE_HZ);
}

2.2 文件修改

perf.h文件保持不动,对cc.h文件修改如下:

/*
 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
 * All rights reserved. 
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 * 
 * Author: Adam Dunkels <adam@sics.se>
 *
 */
#ifndef LWIP_ARCH_CC_H
#define LWIP_ARCH_CC_H

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

#define LWIP_PROVIDE_ERRNO              1

/* Define generic types used in lwIP. */
typedef uint8_t   u8_t;
typedef int8_t    s8_t;
typedef uint16_t  u16_t;
typedef int16_t   s16_t;
typedef uint32_t  u32_t;
typedef int32_t   s32_t;
typedef uintptr_t mem_ptr_t;
typedef int sys_prot_t;

/* Define (sn)printf formatters for these lwIP types. */
#define X8_F  "02x"
#define U16_F "hu"
#define S16_F "hd"
#define X16_F "hx"
#define U32_F "lu"
#define S32_F "ld"
#define X32_F "lx"
#define SZT_F "lu"

/* Little endian mode. */
#define BYTE_ORDER              LITTLE_ENDIAN

/* define compiler specific symbols */
#if defined (__ICCARM__)

#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_END
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_USE_INCLUDES

#elif defined (__CC_ARM)

#define PACK_STRUCT_BEGIN __packed
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_END
#define PACK_STRUCT_FIELD(x) x

#elif defined (__GNUC__)
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
#define PACK_STRUCT_END
#define PACK_STRUCT_FIELD(x) x

#elif defined (__TASKING__)

#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_END
#define PACK_STRUCT_FIELD(x) x

#endif

#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
                                                      handler;} } while(0)

#ifndef LWIP_PLATFORM_DIAG
#define LWIP_PLATFORM_DIAG(x) do {} while(0)
#endif

#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion failed: ");\
                                    printf("Assertion failed: ");}while(0)

/* C runtime functions redefined */
#include <stdlib.h>
#define LWIP_RAND() ((u32_t)rand())

#define PPP_INCLUDE_SETTINGS_HEADER

#endif /* LWIP_ARCH_CC_H */


对lwipopts.h文件修改如下:

/**
 * @file
 *
 * lwIP Options Configuration
 */

/*
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved. 
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 * 
 * Author: Adam Dunkels <adam@sics.se>
 *
 */
#ifndef LWIP_LWIPOPTS_H
#define LWIP_LWIPOPTS_H

/*
   -----------------------------------------------
   ---------- Platform specific locking ----------
   -----------------------------------------------
*/

/** 
 * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
 * use lwIP facilities.
 */
#define NO_SYS                          0
#define USING_OS_FREERTOS

/**
 * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
 * critical regions during buffer allocation, deallocation and memory
 * allocation and deallocation.
 */
#define SYS_LIGHTWEIGHT_PROT            (NO_SYS == 0)

/*
   ------------------------------------
   ---------- Memory options ----------
   ------------------------------------
*/
/**
 * MEM_ALIGNMENT: should be set to the alignment of the CPU
 *    4 byte alignment -> #define MEM_ALIGNMENT 4
 *    2 byte alignment -> #define MEM_ALIGNMENT 2
 */
#define MEM_ALIGNMENT                   4
/**
 * MEM_SIZE: the size of the heap memory. If the application will send
 * a lot of data that needs to be copied, this should be set high.
 */
#define MEM_SIZE                        (30 * 1024)

/*
   ------------------------------------------------
   ---------- Internal Memory Pool Sizes ----------
   ------------------------------------------------
*/
/**
 * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
 * If the application sends a lot of data out of ROM (or other static memory),
 * this should be set high.
 */
#define MEMP_NUM_PBUF                   30

/**
 * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
 * (requires the LWIP_RAW option)
 */
#define MEMP_NUM_RAW_PCB                4

/**
 * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
 * per active UDP "connection".
 * (requires the LWIP_UDP option)
 */
#define MEMP_NUM_UDP_PCB                4

/**
 * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
 * (requires the LWIP_TCP option)
 */
#define MEMP_NUM_TCP_PCB                8

/**
 * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
 * (requires the LWIP_TCP option)
 */
#define MEMP_NUM_TCP_PCB_LISTEN         8

/**
 * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
 * (requires the LWIP_TCP option)
 */
#define MEMP_NUM_TCP_SEG                16

/**
 * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing
 * packets (pbufs) that are waiting for an ARP request (to resolve
 * their destination address) to finish.
 * (requires the ARP_QUEUEING option)
 */
#define MEMP_NUM_ARP_QUEUE              2

/**
 * MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts.
 * The default number of timeouts is calculated here for all enabled modules.
 * The formula expects settings to be either '0' or '1'.
 *
 * To this default value, 1 was added for the snmp_increment timer.
 */
#define MEMP_NUM_SYS_TIMEOUT            (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) + 1

/**
 * MEMP_NUM_NETBUF: the number of struct netbufs.
 * (only needed if you use the sequential API, like api_lib.c)
 */
#define MEMP_NUM_NETBUF                 16

/**
 * MEMP_NUM_NETCONN: the number of struct netconns.
 * (only needed if you use the sequential API, like api_lib.c)
 */
#define MEMP_NUM_NETCONN                32

/**
 * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
 * for callback/timeout API communication. 
 * (only needed if you use tcpip.c)
 */
#define MEMP_NUM_TCPIP_MSG_API          8

/**
 * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
 * for incoming packets. 
 * (only needed if you use tcpip.c)
 */
#define MEMP_NUM_TCPIP_MSG_INPKT        8

/**
 * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. 
 */
#define PBUF_POOL_SIZE                  32

/**
 * MEMP_OVERFLOW_CHECK: Memory pool overflow check switch.
 */
#define MEMP_OVERFLOW_CHECK             0

/*
   ---------------------------------
   ---------- ARP options ----------
   ---------------------------------
*/
/**
 * LWIP_ARP==1: Enable ARP functionality.
 */
#define LWIP_ARP                        1
#define ARP_TABLE_SIZE                  10    /* ARP Table size */
#define ARP_QUEUEING                    1     /* ARP Queueing */

/*
   --------------------------------
   ---------- IP options ----------
   --------------------------------
*/
/**
 * IP_FORWARD==1: Enables the ability to forward IP packets across network
 * interfaces. If you are going to run lwIP on a device with only one network
 * interface, define this to 0.
 */
#define IP_FORWARD                      0

/**
 * IP_OPTIONS: Defines the behavior for IP options.
 *      IP_OPTIONS==0_ALLOWED: All packets with IP options are dropped.
 *      IP_OPTIONS==1_ALLOWED: IP options are allowed (but not parsed).
 */
#define IP_OPTIONS_ALLOWED              1

/**
 * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that
 * this option does not affect outgoing packet sizes, which can be controlled
 * via IP_FRAG.
 */
#define IP_REASSEMBLY                   1
#define MEMP_NUM_REASSDATA              10

/**
 * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
 * that this option does not affect incoming packet sizes, which can be
 * controlled via IP_REASSEMBLY.
 */
#define IP_FRAG                         1

/**
 * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
 * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
 * in this time, the whole packet is discarded.
 */
#define IP_REASS_MAXAGE                 3

/**
 * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
 * Since the received pbufs are enqueued, be sure to configure
 * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
 * packets even if the maximum amount of fragments is enqueued for reassembly!
 */
#define IP_REASS_MAX_PBUFS              10

/**
 * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP
 * fragmentation. Otherwise pbufs are allocated and reference the original
 * packet data to be fragmented.
 */
#define IP_FRAG_USES_STATIC_BUF         0

/**
 * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers.
 */
#define IP_DEFAULT_TTL                  255

/*
   ----------------------------------
   ---------- ICMP options ----------
   ----------------------------------
*/
/**
 * LWIP_ICMP==1: Enable ICMP module inside the IP stack.
 * Be careful, disable that make your product non-compliant to RFC1122
 */
#define LWIP_ICMP                       1

/**
 * ICMP_TTL: Default value for Time-To-Live used by ICMP packets.
 */
#define ICMP_TTL                       (IP_DEFAULT_TTL)

/*
   ----------------------------------
   ---------- DHCP options ----------
   ----------------------------------
*/
/**
 * LWIP_DHCP==1: Enable DHCP module.
 */
#define LWIP_DHCP                       0

/*
   ------------------------------------
   ---------- AUTOIP options ----------
   ------------------------------------
*/
/**
 * LWIP_AUTOIP==1: Enable AUTOIP module.
 */
#define LWIP_AUTOIP                     0

/*
   ----------------------------------
   ---------- SNMP options ----------
   ----------------------------------
*/
/**
 * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP
 * transport.
 */
#define LWIP_SNMP                       (LWIP_UDP)
#define MIB2_STATS                      (LWIP_SNMP)

/*
   ----------------------------------
   ---------- IGMP options ----------
   ----------------------------------
*/
/**
 * LWIP_IGMP==1: Turn on IGMP module. 
 */
#define LWIP_IGMP                       1

/*
   ----------------------------------
   ---------- DNS options -----------
   ----------------------------------
*/
/**
 * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
 * transport.
 */
#define LWIP_DNS                        (LWIP_UDP)

/*
   ---------------------------------
   ---------- UDP options ----------
   ---------------------------------
*/
/**
 * LWIP_UDP==1: Turn on UDP.
 */
#define LWIP_UDP                        1

/**
 * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP)
 */
#define LWIP_UDPLITE                    (LWIP_UDP)

/**
 * UDP_TTL: Default Time-To-Live value.
 */
#define UDP_TTL                         (IP_DEFAULT_TTL)

/*
   ---------------------------------
   ---------- TCP options ----------
   ---------------------------------
*/
/**
 * LWIP_TCP==1: Turn on TCP.
 */
#define LWIP_TCP                        1
#define TCP_TTL                         255

/* Controls if TCP should queue segments that arrive out of
 order. Define to 0 if your device is low on memory. */
#define TCP_QUEUE_OOSEQ                 0

/* TCP Maximum segment size. */
#define TCP_MSS                         (1500 - 40)

/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF                     (4 * TCP_MSS)

/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at
   least as much as (4 * TCP_SND_BUF/TCP_MSS) for things to work. */
#define TCP_SND_QUEUELEN                (4 * TCP_SND_BUF / TCP_MSS)

/* TCP receive window. */
#define TCP_WND                         (4 * TCP_MSS)

/* TCP writable space (bytes). This must be less than or equal
   to TCP_SND_BUF. It is the amount of space which must be
   available in the tcp snd_buf for select to return writable */
#define TCP_SNDLOWAT                    (TCP_SND_BUF / 2)

#define TCP_MAXRTX                      12    /* Maximum number of retransmissions of data segments. */
#define TCP_SYNMAXRTX                   4     /* Maximum number of retransmissions of SYN segments. */

/*
   ----------------------------------
   ---------- Pbuf options ----------
   ----------------------------------
*/
/**
 * PBUF_LINK_HLEN: the number of bytes that should be allocated for a
 * link level header. The default is 14, the standard value for
 * Ethernet.
 */
#define PBUF_LINK_HLEN                  16

/*
   ------------------------------------
   ---------- LOOPIF options ----------
   ------------------------------------
*/
/**
 * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
 */
#define LWIP_HAVE_LOOPIF                0

/*
   ---------------------------------
   ---------- RAW options ----------
   ---------------------------------
*/
/**
 * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
 */
#define LWIP_RAW                        1

/*
   ------------------------------------
   ---------- Socket options ----------
   ------------------------------------
*/
/**
 * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
 */
#define LWIP_SOCKET                     1
#define LWIP_SOCKET_SET_ERRNO           (LWIP_SOCKET)

/*
   ------------------------------------
   ---------- Netconn options ----------
   ------------------------------------
*/
/**
 * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
 */
#define LWIP_NETCONN                    1
#define LWIP_NETCONN_SEM_PER_THREAD     (LWIP_NETCONN || LWIP_SOCKET)

/*
   ----------------------------------------
   ---------- Statistics options ----------
   ----------------------------------------
*/
#define TCPIP_MBOX_SIZE                 10

#define DEFAULT_UDP_RECVMBOX_SIZE       10
#define DEFAULT_TCP_RECVMBOX_SIZE       10
#define DEFAULT_RAW_RECVMBOX_SIZE       10
#define DEFAULT_ACCEPTMBOX_SIZE         10

#define LWIP_NETIF_TX_SINGLE_PBUF       1
#define LWIP_SUPPORT_CUSTOM_PBUF        1
#define MEMP_USE_CUSTOM_POOLS           0
#define MEM_USE_POOLS                   0

/* Self-define data. */
/* LWIP MAC address define. */
#define LWIP_MAC_ADDR                   0x11, 0x22, 0x33, 0x44, 0x55, 0x66
/* LWIP net host name define. */
#define LWIP_NETIF_HOSTNAME             1
#define LWIP_NETIF_HOSTNAME_TEXT        "TriCore"
/* LWIP use IPV4 address. */
#define LWIP_IPV4                       1
/* Ethernet link speed define. */
#define LWIP_LINK_SPEED_IN_BPS          100000000
/* LWIP gateway, IP address and netmask define. */
#define LWIP_INIT_IPADDR(addr)          IP4_ADDR((addr), 192,168,1,20)
#define LWIP_INIT_NETMASK(addr)         IP4_ADDR((addr), 255,255,255,0)
#define LWIP_INIT_GW(addr)              IP4_ADDR((addr), 192,168,1,1)

/*
   ---------------------------------------
   ---------- Debugging options ----------
   ---------------------------------------
*/
#define TAPIF_DEBUG                     LWIP_DBG_OFF
#define TUNIF_DEBUG                     LWIP_DBG_OFF
#define UNIXIF_DEBUG                    LWIP_DBG_OFF
#define DELIF_DEBUG                     LWIP_DBG_OFF
#define SIO_FIFO_DEBUG                  LWIP_DBG_OFF
#define TCPDUMP_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 DEMO_DEBUG                      LWIP_DBG_OFF
#define IP_DEBUG                        LWIP_DBG_OFF
#define IP_REASS_DEBUG                  LWIP_DBG_OFF
#define RAW_DEBUG                       LWIP_DBG_OFF
#define ICMP_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


#define LWIP_DBG_TYPES_ON               (LWIP_DBG_ON | LWIP_DBG_TRACE | \
                                         LWIP_DBG_STATE | LWIP_DBG_FRESH \
                                         |LWIP_DBG_HALT)


#endif /* LWIP_LWIPOPTS_H */


2.3 函数修改

自定义LwIP初始化函数,此函数需在FreeRTOS任务调度器运行起来之后调用:

在这里插入代码片

low_level_init函数:

static void low_level_init(struct netif *netif)
{
  struct ethernetif *ethernetif = netif->state;
  uint8_t aMacAddr[NETIF_MAX_HWADDR_LEN] = {LWIP_MAC_ADDR};

  /* set MAC hardware address length */
  netif->hwaddr_len = ETHARP_HWADDR_LEN;

  /* set MAC hardware address */
  netif->hwaddr[0] = aMacAddr[0];
  netif->hwaddr[1] = aMacAddr[1];
  netif->hwaddr[2] = aMacAddr[2];
  netif->hwaddr[3] = aMacAddr[3];
  netif->hwaddr[4] = aMacAddr[4];
  netif->hwaddr[5] = aMacAddr[5];

  /* maximum transfer unit */
  netif->mtu = 1500;

  /* Device ethernet port set. */
  netif->num = ETHERNET_PORT0;

  /* device capabilities */
  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
  netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;

#if LWIP_IPV6 && LWIP_IPV6_MLD
  /*
   * For hardware/netifs that implement MAC filtering.
   * All-nodes link-local is handled by default, so we must let the hardware know
   * to allow multicast packets in.
   * Should set mld_mac_filter previously. */
  if (netif->mld_mac_filter != NULL) {
    ip6_addr_t ip6_allnodes_ll;
    ip6_addr_set_allnodes_linklocal(&ip6_allnodes_ll);
    netif->mld_mac_filter(netif, &ip6_allnodes_ll, NETIF_ADD_MAC_FILTER);
  }
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
  /* Do whatever else is needed to initialize interface. */
  /* Create a semaphore. */
  s_xSemaphore = xSemaphoreCreateCounting(40, 0);
  /* Create the task that handles the Ethernet module. */
  sys_thread_new("LwIPRun", ethernetif_input, netif, 1024, 1);
  /* Ethernet module init. */
  DevEthInit(netif->num);
}

建议网络数据接收采用中断方式,这样可借助于FreeRTOS提供的信号机制,实时通知和读取网络数据。如下所示:
网络端口中断处理函数:

/**
 * Abstract:
 *   Ethernet module interrupt handler function.
 *
 * Parameters:
 *   i32Arg: Arguments passing into the function.
 *
 * Return:
 *   None.
 */
 static void IsrEthHandler(int i32Arg)
{
    uint32_t u32Ret = 0;
    portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

    /* Just to avoid compiler warnings about unused parameters. */
    (void) i32Arg;
    u32Ret = taskENTER_CRITICAL_FROM_ISR();

    /* Check for ethernet RX interrupt. */
    if (TRUE == IfxEth_isRxInterrupt(&sEth))
    {
        xSemaphoreGiveFromISR(s_xSemaphore, &xHigherPriorityTaskWoken);
        portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
        /* Clear Rx interrupt status bit. */
        IfxEth_clearRxInterrupt(&sEth);
    }
    /* Check for ethernet TX interrupt. */
    if (TRUE == IfxEth_isTxInterrupt(&sEth))
    {
        /* Clear Tx interrupt status bit. */
        IfxEth_clearTxInterrupt(&sEth);
    }

    taskEXIT_CRITICAL_FROM_ISR(u32Ret);
}

LwIP链路层数据接收函数:

static void ethernetif_input(struct netif *netif)
{
    struct eth_hdr *ethhdr = NULL;
    struct pbuf *p = NULL;

    while (1)
        {
        //vTaskDelay(pdMS_TO_TICKS(15));
        if (pdTRUE == xSemaphoreTake(s_xSemaphore, portMAX_DELAY))
        {
            /* Move received packet into a new buf. */
            taskENTER_CRITICAL();
            p = low_level_input(netif);
            taskEXIT_CRITICAL();
            /* if no packet could be read, silently ignore this */
            if (p != NULL)
            {
                taskENTER_CRITICAL();
                /* pass all packets to ethernet_input, which decides what packets it supports */
                if (netif->input(p, netif) != ERR_OK)
                {
                    LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
                    pbuf_free(p);
                    p = NULL;
                }
                taskEXIT_CRITICAL();
            }
        }
    }
}

至此,基于FreeRTOS移植LwIP的工作已完成,在项目工程中可以利用socket接口或者netconn接口进行网口编程了。若要进行测试,可添加LwIP源码包提供的“contrib-2.0.1\apps\”目录下的例程进行测试,可根据需要选择要进行测试的app,将选择的app文件夹添加到工程目录中,在low_level_init函数中“sys_thread_new(“LwIPRun”, ethernetif_input, netif, 1024, 1);”后调用app提供的初始化函数,便可进行相应测试。

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Autosar是针对汽车电子领域开发的标准化解决方案,旨在为汽车电子软件和硬件提供单一的标准化平台,以加强不同系统之间的集成。Tricore是一种基于32位处理器架构的芯片,常用于汽车电子领域。在汽车电子系统中,Tricore架构处理器经常作为主控制设备来控制各种从设备,完成车辆的各种功能。Autosar的标准化解决方案与Tricore架构处理器的结合,为汽车电子领域提供了更可靠、更高效、更安全的解决方案。 针对基于Tricore架构处理器的Autosar标准操作系统移植与改进,需要进行以下工作: 1. 完善基本的Autosar软件模块。包括通信模块、诊断模块、存储模块等。这些软件模块将为汽车电子系统提供可靠的基础服务。 2. 优化操作系统性能。Tricore架构处理器的性能要求非常高,因此需要对Autosar操作系统进行优化,以最大化其性能和效率。 3. 添加多任务支持。基于Tricore架构处理器的汽车电子系统需要支持多任务操作,因此需要在Autosar操作系统中添加多任务支持。 4. 强化安全性。在汽车电子系统中,安全至关重要。因此,在Autosar操作系统中需要加强安全性措施,以确保系统的安全性。 5. 实现模块化开发。Tricore架构处理器适用于开发模块化的软件系统。因此,需要在Autosar操作系统中实现类似的模块化开发模式,以方便软件的开发与维护。 综上所述,基于Tricore架构处理器的Autosar标准操作系统移植与改进的实现,需要对基本的Autosar软件模块进行完善并实现多任务支持,同时优化操作系统性能,并加强安全性措施。此外,还需要实现模块化开发模式,以充分发挥Tricore架构处理器的性能优势。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值