This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3358: Memory Mapping

Part Number: AM3358
Other Parts Discussed in Thread: SYSBIOS

I am using sitara AM3358 processor in custom board with processor_sdk_rtos_am335x_6_01_00_08.  I am facing some issue in memory allocation. I used .cmd file and some MMU configuration as per following.


#pragma DATA_ALIGN(pageTable, MMU_PAGETABLE_ALIGN_SIZE);
static volatile unsigned int pageTable[MMU_PAGETABLE_NUM_ENTRY];


/******************************************************************************
** FUNCTION DEFINITIONS
******************************************************************************/

/*
** This function will setup the MMU. The function maps three regions -
** 1. DDR
** 2. OCMC RAM
** 3. Device memory
** The function also enables the MMU.
*/
void MMUConfigAndEnable(void)
{
/*
** Define DDR memory region of AM335x. DDR can be configured as Normal
** memory with R/W access in user/privileged modes. The cache attributes
** specified here are,
** Inner - Write through, No Write Allocate
** Outer - Write Back, Write Allocate
*/
REGION regionDdr = {
MMU_PGTYPE_SECTION, START_ADDR_DDR, NUM_SECTIONS_DDR,
MMU_MEMTYPE_NORMAL_NON_SHAREABLE(MMU_CACHE_WT_NOWA,
MMU_CACHE_WB_WA),
MMU_REGION_NON_SECURE, MMU_AP_PRV_RW_USR_RW,
(unsigned int*)pageTable
};
/*
** Define OCMC RAM region of AM335x. Same Attributes of DDR region given.
*/
REGION regionOcmc = {
MMU_PGTYPE_SECTION, START_ADDR_OCMC, NUM_SECTIONS_OCMC,
MMU_MEMTYPE_NORMAL_NON_SHAREABLE(MMU_CACHE_WT_NOWA,
MMU_CACHE_WB_WA),
MMU_REGION_NON_SECURE, MMU_AP_PRV_RW_USR_RW,
(unsigned int*)pageTable
};

/*
** Define Device Memory Region. The region between OCMC and DDR is
** configured as device memory, with R/W access in user/privileged modes.
** Also, the region is marked 'Execute Never'.
*/
REGION regionDev = {
MMU_PGTYPE_SECTION, START_ADDR_DEV, NUM_SECTIONS_DEV,
MMU_MEMTYPE_DEVICE_SHAREABLE,
MMU_REGION_NON_SECURE,
MMU_AP_PRV_RW_USR_RW | MMU_SECTION_EXEC_NEVER,
(unsigned int*)pageTable
};

/* Initialize the page table and MMU */
MMUInit((unsigned int*)pageTable);

/* Map the defined regions */
MMUMemRegionMap(&regionDdr);
MMUMemRegionMap(&regionOcmc);
MMUMemRegionMap(&regionDev);

/* Now Safe to enable MMU */
MMUEnable((unsigned int*)pageTable);
}

If I call this  MMUConfigAndEnable() in main function then it is allocated memory properly for ethernet tcp/ip stack but my graphics get distorted on LCD. However, if I don't call this  MMUConfigAndEnable(); function then my graphics on LCD are displayed properly but ethernet tcp/ip stack doesn't work and it is going to exception handler loop B0 infinite loop. 

If I am using .cmd file then all memory mapping should be done according to .cmd file then MMUConfigAndEnable is not required, right? 

I am attaching main.c , .cmd file and mmu.h file for your reference.

mmu.h

37741.main.c

/*
* Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
*/
/*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*    Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
*    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.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "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 COPYRIGHT
*  OWNER OR CONTRIBUTORS 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.
*
*/

/****************************************************************************/
/* LNK32.CMD - v4.5.0 COMMAND FILE FOR LINKING TMS470 32BIS C/C++ PROGRAMS  */
/*                                                                          */
/*   Usage:  lnk470 <obj files...>    -o <out file> -m <map file> lnk32.cmd */
/*           cl470 <src files...> -z -o <out file> -m <map file> lnk32.cmd  */
/*                                                                          */
/*   Description: This file is a sample command file that can be used       */
/*                for linking programs built with the TMS470 C/C++          */
/*                Compiler.   Use it as a guideline; you may want to change */
/*                the allocation scheme according to the size of your       */
/*                program and the memory layout of your target system.      */
/*                                                                          */
/*   Notes: (1)   You must specify the directory in which run-time support  */
/*                library is located.  Either add a "-i<directory>" line to */
/*                this file, or use the system environment variable C_DIR   */
/*                to specify a search path for libraries.                   */
/*                                                                          */
/*          (2)   If the run-time support library you are using is not      */
/*                named below, be sure to use the correct name here.        */
/*                                                                          */
/****************************************************************************/
-stack  0x0008                             /* SOFTWARE STACK SIZE           */
-heap   0xFFFF                             /* HEAP AREA SIZE                */
-e Entry
/*  Since we used 'Entry' as the entry-point symbol the compiler issues a   */
/*  warning (#10063-D: entry-point symbol other than "_c_int00" specified:  */
/*  "Entry"). The CCS Version (5.1.0.08000) stops building from command     */
/*  line when there is a warning. So this warning is suppressed with the    */
/*  below flag. */

--diag_suppress=10063

/* SPECIFY THE SYSTEM MEMORY MAP */

MEMORY
{
	SRAM:     o = 0x402F0400  l = 0x0000FC00  /* 64kB internal SRAM */
    L3OCMC0:  o = 0x40300000  l = 0x00010000  /* 64kB L3 OCMC SRAM */
    M3SHUMEM: o = 0x44D00000  l = 0x00004000  /* 16kB M3 Shared Unified Code Space */
    M3SHDMEM: o = 0x44D80000  l = 0x00002000  /* 8kB M3 Shared Data Memory */
    DDR_MEM     : org = 0x80000000  len = 0x1FFFFFFF /* RAM */ //256 MB
}

/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */

SECTIONS
{
    .text:Entry : load > 0x80000000

    .text    : load > DDR_MEM              /* CODE                          */
    .data    : load > DDR_MEM              /* INITIALIZED GLOBAL AND STATIC VARIABLES */
    //.bss     : load > DDR_MEM              /* UNINITIALIZED OR ZERO INITIALIZED */
                                           /* GLOBAL & STATIC VARIABLES */

    .bss     : load > 0x80100000
                    RUN_START(bss_start)
                    RUN_END(bss_end)
    .const   : load > DDR_MEM              /* GLOBAL CONSTANTS              */
    .stack   : load > 0x87FFFFF0           /* SOFTWARE SYSTEM STACK         */
    .cinit         >  DDR_MEM



}

If any other information required then please let me know.

Regards,

Gaurav

  • Hi Gaurav,

    The linker command file (.cmd) and MMU serve different purposes. The linker command file defines memory regions and the placement rules of code and data sections of your program. The MMU translates virtual addresses to physical addresses. 

    You may want to look at the MMU Manager in TI-RTOS regarding MMU configuration:  <BIOS installation folder>/docs/cdoc/ti/sysbios/family/arm/a8/Mmu.html. 

    Also, there is another similar thread which may have helpful information for you: https://e2e.ti.com/support/processors/f/791/t/908657. Please take a look.

    Regards,

    Jianzhong

  • Jianzhong,

    Is MMUConfigAndEnable  really required for the application?

    What could be the reason for distorting the graphics on LCD after enable the MMU?

    Regards,

    Gaurav

  • Hi Gaurav,

    MMU configuration is required for any application because MMU sets permissions, cacheability, etc. 

    The graphics distortion might be caused by incorrect MMU configuration. In your source code, you used MMUInit(), MMUMemRegionMap(), and MMUEnable(). Where did these functions come from? Were they from the PDK?

    You can use Sysbio config file to configure MMU. Please refer to C:\ti\pdk_am335x_1_0_16\packages\ti\drv\uart\example\sample\am335x\armv7\bios\am335x_app_evmam335x.cfg for reference code.

    Regards,

    Jianzhong

  • Jianzhong,

    I have configured MMU for DDR3 shareable and it is working. Earlier it was Non shareable. 

    Thanks for your support.

    Regards,

    Gaurav