This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is it possible Netx Duo HTTP Server Packet Pools on SDRAM?

Hei Guys, 

i am working currently on a REST-communication for our custom board.
Our RAM is accutly pretty full. Is it possible to genarted the Packet Pool for the IP instance and the HTTP server on SDRAM?
I tried following steps and run into a ERROR:-

Genarted HTTP server with a IP instance and two packet pools, one for IP instance and one for the server.
Deactivated the auto Initialization for all four drivers.
Initialize two new arrays for the packet pools which located on the sdram and generated the two pools on my own and call the funktion for the ip ini and server ini.

#############################################################################################################
uint8_t g_packet_pool0_pool_memory_ext[(16 * (2048 + sizeof(NX_PACKET)))] __attribute__((section(".sdram")));
uint8_t g_packet_pool1_pool_memory_ext[(16 * (2048 + sizeof(NX_PACKET)))] __attribute__((section(".sdram")));



/* HTTP Server Thread entry function */
void http_server_thread_entry(void)
{
UINT status;

status = nx_packet_pool_create (&g_packet_pool0, "g_packet_pool0 Packet Pool", 2048,
&g_packet_pool0_pool_memory_ext[0], (16 * (2048 + sizeof(NX_PACKET))));
status = nx_packet_pool_create (&g_packet_pool1, "g_packet_pool1 Packet Pool", 2048,
&g_packet_pool1_pool_memory_ext[0], (16 * (2048 + sizeof(NX_PACKET))));

ip_init0();
http_server_init0();

#############################################################################################################

I will run into ERROR at _nxe_http_server_create funktion:-

  

Both values are at 0. Is there a way to fix the problem? Thank you for every solution.

If i initialize the arrays not on the sdram, everything is working.

Chris

 

Parents
  • Update:

    I downloaded the NETX Duo to look at the nx_packet_pool_create.c which Synergy not allowed.
    There ist only one point where the pool_ptr -> nx_packet_pool_available_list written.

    UINT _nx_packet_pool_create(NX_PACKET_POOL *pool_ptr, CHAR *name_ptr, ULONG payload_size,
    VOID *pool_start, ULONG pool_size)

    {
    .
    .
    .
    .
    .

    /* Set the packet pool available list. */
    pool_ptr -> nx_packet_pool_available_list = (NX_PACKET *)pool_start;

    .
    .
    .

    }

    Its looks like there is a difference between the initialize from the array at sdram and ram.
    Maybe i have to change sth. at the Linker Script, but im not sure about this.
    I never worked with the Linker Script so have anyone some Turtorials or Informations about it ?

    Chris 

    ##########################################################################################################

    UINT _nx_packet_pool_create(NX_PACKET_POOL *pool_ptr, CHAR *name_ptr, ULONG payload_size,
    VOID *pool_start, ULONG pool_size)
    {

    TX_INTERRUPT_SAVE_AREA

    NX_PACKET_POOL *tail_ptr; /* Working packet pool pointer */
    ULONG packets; /* Number of packets in pool */
    ULONG original_payload_size; /* Original payload size */
    ULONG header_size; /* Rounded header size */
    CHAR *packet_ptr; /* Working packet pointer */
    CHAR *next_packet_ptr; /* Next packet pointer */
    CHAR *end_of_pool; /* End of pool area */
    CHAR *payload_address; /* Address of the first payload*/
    VOID *rounded_pool_start; /* Rounded stating address */


    /* Save the original payload size. */
    original_payload_size = payload_size;

    /* Align the starting address to four bytes. */
    /*lint -e{923} suppress cast between ULONG and pointer. */
    rounded_pool_start = (VOID *)((((ALIGN_TYPE)pool_start + NX_PACKET_ALIGNMENT - 1) / NX_PACKET_ALIGNMENT) * NX_PACKET_ALIGNMENT);

    /* Round the pool size down to something that is evenly divisible by alignment. */
    /*lint -e{923} suppress cast between ULONG and pointer. */
    pool_size = (ULONG)(((pool_size - ((ALIGN_TYPE)rounded_pool_start - (ALIGN_TYPE)pool_start)) / NX_PACKET_ALIGNMENT) * NX_PACKET_ALIGNMENT);

    /* Set the pool starting address. */
    pool_start = rounded_pool_start;

    /* Calculate the address of payload. */
    /*lint -e{923} suppress cast between ULONG and pointer. */
    payload_address = (CHAR *)((ALIGN_TYPE)rounded_pool_start + sizeof(NX_PACKET));

    /* Align the address of payload. */
    /*lint -e{923} suppress cast between ULONG and pointer. */
    payload_address = (CHAR *)((((ALIGN_TYPE)payload_address + NX_PACKET_ALIGNMENT - 1) / NX_PACKET_ALIGNMENT) * NX_PACKET_ALIGNMENT);

    /* Calculate the header size. */
    /*lint -e{923} suppress cast between ULONG and pointer. */
    header_size = (ULONG)((ALIGN_TYPE)payload_address - (ALIGN_TYPE)rounded_pool_start);

    /* Round the packet size up to something that helps guarantee proper alignment for header and payload. */
    payload_size = (ULONG)(((header_size + payload_size + NX_PACKET_ALIGNMENT - 1) / NX_PACKET_ALIGNMENT) * NX_PACKET_ALIGNMENT - header_size);

    /* Clear pool fields. */
    memset(pool_ptr, 0, sizeof(NX_PACKET_POOL));

    /* Setup the basic packet pool fields. */
    pool_ptr -> nx_packet_pool_name = name_ptr;
    pool_ptr -> nx_packet_pool_suspension_list = TX_NULL;
    pool_ptr -> nx_packet_pool_suspended_count = 0;
    pool_ptr -> nx_packet_pool_start = (CHAR *)pool_start;
    pool_ptr -> nx_packet_pool_size = pool_size;
    pool_ptr -> nx_packet_pool_payload_size = original_payload_size;

    /* Calculate the end of the pool's memory area. */
    end_of_pool = ((CHAR *)pool_start) + pool_size;

    /* Walk through the pool area, setting up the available packet list. */
    packets = 0;
    packet_ptr = (CHAR *)rounded_pool_start;
    next_packet_ptr = packet_ptr + (payload_size + header_size);

    /*lint -e{946} suppress pointer subtraction, since it is necessary. */
    while (next_packet_ptr <= end_of_pool)
    {

    /* Yes, we have another packet. Increment the packet count. */
    packets++;

    /* Setup the link to the next packet. */
    /*lint -e{929} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_queue_next = (NX_PACKET *)next_packet_ptr;

    /* Remember that this packet pool is the owner. */
    /*lint -e{929} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_pool_owner = pool_ptr;

    #ifndef NX_DISABLE_PACKET_CHAIN
    /* Clear the next packet pointer. */
    /*lint -e{929} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_next = (NX_PACKET *)NX_NULL;
    #endif /* NX_DISABLE_PACKET_CHAIN */

    /* Mark the packet as free. */
    /*lint -e{929} -e{923} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_union_next.nx_packet_tcp_queue_next = (NX_PACKET *)NX_PACKET_FREE;

    /* Setup the packet data pointers. */
    /*lint -e{929} -e{928} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_data_start = (UCHAR *)(packet_ptr + header_size);

    /*lint -e{929} -e{928} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_data_end = (UCHAR *)(packet_ptr + header_size + original_payload_size);

    /* Add debug information. */
    NX_PACKET_DEBUG(__FILE__, __LINE__, (NX_PACKET *)packet_ptr);

    /* Advance to the next packet. */
    packet_ptr = next_packet_ptr;

    /* Update the next packet pointer. */
    next_packet_ptr = packet_ptr + (payload_size + header_size);
    }

    /* Backup to the last packet in the pool. */
    packet_ptr = packet_ptr - (payload_size + header_size);

    /* Set the last packet's forward pointer to NULL. */
    /*lint -e{929} -e{740} -e{826} suppress cast of pointer to pointer, since it is necessary */
    ((NX_PACKET *)packet_ptr) -> nx_packet_queue_next = NX_NULL;

    /* Save the remaining information in the pool control packet. */
    pool_ptr -> nx_packet_pool_available = packets;
    pool_ptr -> nx_packet_pool_total = packets;

    /* Set the packet pool available list. */
    pool_ptr -> nx_packet_pool_available_list = (NX_PACKET *)pool_start;

    /* If trace is enabled, register this object. */
    NX_TRACE_OBJECT_REGISTER(NX_TRACE_OBJECT_TYPE_PACKET_POOL, pool_ptr, name_ptr, payload_size, packets);

    /* If trace is enabled, insert this event into the trace buffer. */
    NX_TRACE_IN_LINE_INSERT(NX_TRACE_PACKET_POOL_CREATE, pool_ptr, payload_size, pool_start, pool_size, NX_TRACE_PACKET_EVENTS, 0, 0);

    /* Disable interrupts to place the packet pool on the created list. */
    TX_DISABLE

    /* Setup the packet pool ID to make it valid. */
    pool_ptr -> nx_packet_pool_id = NX_PACKET_POOL_ID;

    /* Place the packet pool on the list of created packet pools. First,
    check for an empty list. */
    if (_nx_packet_pool_created_ptr)
    {

    /* Pickup tail pointer. */
    tail_ptr = _nx_packet_pool_created_ptr -> nx_packet_pool_created_previous;

    /* Place the new packet pool in the list. */
    _nx_packet_pool_created_ptr -> nx_packet_pool_created_previous = pool_ptr;
    tail_ptr -> nx_packet_pool_created_next = pool_ptr;

    /* Setup this packet pool's created links. */
    pool_ptr -> nx_packet_pool_created_previous = tail_ptr;
    pool_ptr -> nx_packet_pool_created_next = _nx_packet_pool_created_ptr;
    }
    else
    {

    /* The created packet pool list is empty. Add packet pool to empty list. */
    _nx_packet_pool_created_ptr = pool_ptr;
    pool_ptr -> nx_packet_pool_created_next = pool_ptr;
    pool_ptr -> nx_packet_pool_created_previous = pool_ptr;
    }

    /* Increment the number of packet pools created. */
    _nx_packet_pool_created_count++;

    /* Restore interrupts. */
    TX_RESTORE

    /* Return NX_SUCCESS. */
    return(NX_SUCCESS);
    }

    ##############################################################################################################

  • Did you confirm the addresses of your packet pools are in the address range you setup up for external DRAM, via the debuuger or printf?

    If the addresses are not correct, then post your link script from the gcc or IAR linker, whatever you're using.

    Thanks

    LArry

  • sdram is only initialized after clearing variable/setting initial value to variables. Besides, SSP doesnt handle initialization of variables from two region. (sram and sdram address are not contigous) I tried your approach. I could see the new packet pool being initialized and added to available list. No issue with http server create. Could your problem be your sdram isnt initialized? bsp_sdram_init() done?

  • Ohh god, i had some problems with my custom board and switch back to the S7G2 SK board to make some test with the HTTP- Webserver example... unfortunately have the S7G2 SK Board no SDRAM(at the linker file is configured).... i did  try on my custum board again and everything is working as i tried on my first post.

Reply
  • Ohh god, i had some problems with my custom board and switch back to the S7G2 SK board to make some test with the HTTP- Webserver example... unfortunately have the S7G2 SK Board no SDRAM(at the linker file is configured).... i did  try on my custum board again and everything is working as i tried on my first post.

Children
No Data