AM5729: We have some errors in MMU configuration in SYSBIOS .cfg file

Part Number: AM5729
Other Parts Discussed in Thread: SYSBIOS

Tool/software:

1. we have hug issue with pipeline stall, on review TI suggested to few changes in  MMU table  as highlighted in image , please help us in changing MMU configurations in SYSBIOS .cfg and help in understanding attr0 .. and MARI0 etc.

system details

we are using only one core A15_0  

We have only 512MB DDR

we have Shared GPMC SRAM with FPGA.

we are PCIe RC with inbound configuration.

 .cfg for MMU configuration.


/***********************************************
* MMU Configuration *
***********************************************/
var Mmu = xdc.useModule('ti.sysbios.family.arm.a15.Mmu');
Mmu.enableMMU = true;

/******************************************************************************
*
* SYS/BIOS assigns the following defaults to MAIR0 ATTR0, ATTR1 and ATTR2:
*
* ATTR0 -> 0x44 (mark memory region as non-cacheable normal memory)
* ATTR1 -> 0x04 (mark memory region as device memory, i.e. strongly
* ordered and non-cacheable)
* ATTR2 -> 0xFF (mark memory region as normal memory, RW cacheable and
* RW allocate)
******************************************************************************
*/


// descriptor attribute structure
var attrs0 = new Mmu.DescriptorAttrs();

Mmu.initDescAttrsMeta(attrs0);
attrs0.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
attrs0.shareable = 2; // sharerable
attrs0.attrIndx = 1; // Non-cache, device memory

// Set the descriptor for each entry in the address range
for (var i=0x40600000; i < 0x60000000; i = i + 0x00200000) {
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setSecondLevelDescMeta(i, i, attrs0);
}

// descriptor attribute structure
var attrs1 = new Mmu.DescriptorAttrs();

Mmu.initDescAttrsMeta(attrs1);
attrs1.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
attrs1.shareable = 2; // sharerable
attrs1.attrIndx = 2; // Cached, normal memory

// Set the descriptor for each entry in the address range
for (var i=0x80000000; i < 0xA0000000; i = i + 0x00200000) {
// Each 'BLOCK' descriptor entry spans a 2MB address range
Mmu.setSecondLevelDescMeta(i, i, attrs1);
}

// descriptor attribute structure
var peripheralAttrs = new Mmu.DescriptorAttrs();

Mmu.initDescAttrsMeta(peripheralAttrs);

peripheralAttrs.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
peripheralAttrs.noExecute = true; // not executable
peripheralAttrs.accPerm = 0; // read/write at PL1
peripheralAttrs.attrIndx = 1; // MAIR0 Byte1 describes
// memory attributes for
// each BLOCK MMU entry

// Define the base address of the 2 MB page
// the peripheral resides in.
var peripheralBaseAddrs = [
{ base: 0x4ae00000, size: 0x00100000 }, // PRM
{ base: 0x51000000, size: 0x00800000 }, // pcie_ss1 regs
{ base: 0x51800000, size: 0x01000000 }, // pcie_ss2 regs
{ base: 0x20000000, size: 0x10000000 }, // pcie_ss1 data
{ base: 0x30000000, size: 0x10000000 }, // pcie_ss2 data
/* Following registers for IODELAY/PINMUX */
{ base: 0x4844a000, size: 0x00001000 },
{ base: 0x48447000, size: 0x00001000 },
{ base: 0x4a002000, size: 0x00001000 },
{ base: 0x43300000, size: 0x00300000 }
];

// Configure the corresponding MMU page descriptor accordingly
for (var i =0; i < peripheralBaseAddrs.length; i++)
{
for (var j = 0; j < peripheralBaseAddrs[i].size; j += 0x200000)
{
var addr = peripheralBaseAddrs[i].base + j;
Mmu.setSecondLevelDescMeta(addr, addr, peripheralAttrs);
}
}

//GPMC
var attrs = new Mmu.DescriptorAttrs();
Mmu.initDescAttrsMeta(attrs);
attrs.type = Mmu.DescriptorType_BLOCK;
attrs.noExecute = true;
attrs.accPerm = 0; // R/W at PL1
attrs.attrIndx = 4; // Use MAIR0 Byte2
Mmu.setMAIRMeta(4, 0x04);
Mmu.setSecondLevelDescMeta(0x43200000, 0x43200000, attrs);

/* Set IO Delay configuration areas as non-cache */
attrs.attrIndx = 1;
Mmu.setSecondLevelDescMeta(0x4844a000, 0x4844a000, attrs);
Mmu.setSecondLevelDescMeta(0x4ae07d00, 0x4ae07d00, attrs);

var attrs = new Mmu.DescriptorAttrs();
Mmu.initDescAttrsMeta(attrs);
attrs.type = Mmu.DescriptorType_BLOCK;
attrs.shareable = 2; // sharerable
attrs.attrIndx = 1; // Non-cache, device memory
Mmu.setSecondLevelDescMeta(0x50000000, 0x50000000, attrs); // this covers the first 2MB
Mmu.setSecondLevelDescMeta(0x50200000, 0x50200000, attrs);

// descriptor attribute structure

var peripheralAttrs = new Mmu.DescriptorAttrs();

Mmu.initDescAttrsMeta(peripheralAttrs);

peripheralAttrs.type = Mmu.DescriptorType_TABLE;

Mmu.setFirstLevelDescMeta(0, 0, peripheralAttrs);

peripheralAttrs.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor

peripheralAttrs.noExecute = true; // not executable

peripheralAttrs.accPerm = 0; // read/write at PL1

peripheralAttrs.attrIndx = 4; // Non-cache, device memory

// MAIR0 Byte1 describes
// memory attributes for
// each BLOCK MMU entry
// write memory region attribute in mairRegAttr[2] i.e. MAIR0 Reg Byte2

Mmu.setMAIRMeta(4, 0x00);

var gpmcAttrs = new Mmu.DescriptorAttrs();
Mmu.initDescAttrsMeta(gpmcAttrs);
gpmcAttrs.type = Mmu.DescriptorType_BLOCK;
gpmcAttrs.shareable = 2;
gpmcAttrs.noExecute = 1;
gpmcAttrs.accPerm = 0;
gpmcAttrs.attrIndx = 1; // level2: 2MB area (level1 is 1GB area)

/* Configure the corresponding MMU page descriptor accordingly *//* For AM572x GPMC */
for (var gpmcBaseAddr = 0x00000000; gpmcBaseAddr < 0x20000000; gpmcBaseAddr += 0x200000)
{
Mmu.setSecondLevelDescMeta(gpmcBaseAddr,gpmcBaseAddr,gpmcAttrs);
}

 

  • Hi,

    Our assigned expert is on vacation today, so please expect a delay in response on this ticket.

    regards

    Suman

  • Hi Suman,

             Any update on the ticket. Please help in configuring the MMU.

  • Hello Chittapu,

    Not sure what it is that you need from your image but you can learn more about the MMU APIs in the following Link:

    https://software-dl.ti.com/processor-sdk-rtos/esd/AM65X/07_00_00_05/exports/docs/bios_6_82_01_19/docs/cdoc/index.html#ti/sysbios/family/arm/arm9/Mmu.html

    As well as the TRM:  https://www.ti.com/lit/ug/spruhz6l/spruhz6l.pdf#page=5528

    ARM Documentation: https://developer.arm.com/documentation/ddi0438/i/memory-management-unit/about-the-mmu

    ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition:DDI0406C_d_armv7ar_arm.pdf

    Notes:

    attrs is a pointer to descriptor attribute struct, either 1st or 2nd Level

    and the MAIR0 has to do with the Memory Attribute Indirection Registers (MAIR). 

    Please look at the above documentation for deeper understanding.

    -Josue

  • in MAIR i cant find never execute (xn) bit, I can only find non-execute, please help with bit getting never execute bit (xn) set in for the above mentioned snip locations.

  • Hi Chittapu,

    I will look into this more and get back to you.

    Regards,

    Karthik

  • Hi Chittapu,

    It looks like the following line is missing in your MMU configuration, Please add this line into your configuration. let us know if this helps. 

    attrs0.noExecute = true;

    Regards,
    Karthik

  • we already using that but xn bit is not getting set. above we added the snip of MMU .cfg code at start of ticket.

  • Hi Chittapu,

    I'm working on this issue; I'll get back to you.

    Regards,

    Karthik

  • Hi Chittapu,

     .cfg for MMU configuration.

    Could you please share the complete MMU configuration file and also point me to the exact path in the SDK where you are updating this file?

    Regards,

    Karthik

  • update/override the MMU settings in BIOS configuration using .cfg file  of the project

    .cfg file MMU configuration details

    /***********************************************
    * MMU Configuration *
    ***********************************************/
    var Mmu = xdc.useModule('ti.sysbios.family.arm.a15.Mmu');
    Mmu.enableMMU = true;

    /******************************************************************************
    *
    * SYS/BIOS assigns the following defaults to MAIR0 ATTR0, ATTR1 and ATTR2:
    *
    * ATTR0 -> 0x44 (mark memory region as non-cacheable normal memory)
    * ATTR1 -> 0x04 (mark memory region as device memory, i.e. strongly
    * ordered and non-cacheable)
    * ATTR2 -> 0xFF (mark memory region as normal memory, RW cacheable and
    * RW allocate)
    ******************************************************************************
    */


    // descriptor attribute structure
    var attrs0 = new Mmu.DescriptorAttrs();

    Mmu.initDescAttrsMeta(attrs0);
    attrs0.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
    attrs0.shareable = 2; // sharerable
    attrs0.attrIndx = 1; // Non-cache, device memory

    // Set the descriptor for each entry in the address range
    for (var i=0x40600000; i < 0x60000000; i = i + 0x00200000) {
    // Each 'BLOCK' descriptor entry spans a 2MB address range
    Mmu.setSecondLevelDescMeta(i, i, attrs0);
    }

    // descriptor attribute structure
    var attrs1 = new Mmu.DescriptorAttrs();

    Mmu.initDescAttrsMeta(attrs1);
    attrs1.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
    attrs1.shareable = 2; // sharerable
    attrs1.attrIndx = 2; // Cached, normal memory

    // Set the descriptor for each entry in the address range
    for (var i=0x80000000; i < 0xA0000000; i = i + 0x00200000) {
    // Each 'BLOCK' descriptor entry spans a 2MB address range
    Mmu.setSecondLevelDescMeta(i, i, attrs1);
    }

    // descriptor attribute structure
    var peripheralAttrs = new Mmu.DescriptorAttrs();

    Mmu.initDescAttrsMeta(peripheralAttrs);

    peripheralAttrs.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
    peripheralAttrs.noExecute = true; // not executable
    peripheralAttrs.accPerm = 0; // read/write at PL1
    peripheralAttrs.attrIndx = 1; // MAIR0 Byte1 describes
    // memory attributes for
    // each BLOCK MMU entry

    // Define the base address of the 2 MB page
    // the peripheral resides in.
    var peripheralBaseAddrs = [
    { base: 0x4ae00000, size: 0x00100000 }, // PRM
    { base: 0x51000000, size: 0x00800000 }, // pcie_ss1 regs
    { base: 0x51800000, size: 0x01000000 }, // pcie_ss2 regs
    { base: 0x20000000, size: 0x10000000 }, // pcie_ss1 data
    { base: 0x30000000, size: 0x10000000 }, // pcie_ss2 data
    /* Following registers for IODELAY/PINMUX */
    { base: 0x4844a000, size: 0x00001000 },
    { base: 0x48447000, size: 0x00001000 },
    { base: 0x4a002000, size: 0x00001000 },
    { base: 0x43300000, size: 0x00300000 }
    ];

    // Configure the corresponding MMU page descriptor accordingly
    for (var i =0; i < peripheralBaseAddrs.length; i++)
    {
    for (var j = 0; j < peripheralBaseAddrs[i].size; j += 0x200000)
    {
    var addr = peripheralBaseAddrs[i].base + j;
    Mmu.setSecondLevelDescMeta(addr, addr, peripheralAttrs);
    }
    }

    //GPMC
    var attrs = new Mmu.DescriptorAttrs();
    Mmu.initDescAttrsMeta(attrs);
    attrs.type = Mmu.DescriptorType_BLOCK;
    attrs.noExecute = true;
    attrs.accPerm = 0; // R/W at PL1
    attrs.attrIndx = 4; // Use MAIR0 Byte2
    Mmu.setMAIRMeta(4, 0x04);
    Mmu.setSecondLevelDescMeta(0x43200000, 0x43200000, attrs);

    /* Set IO Delay configuration areas as non-cache */
    attrs.attrIndx = 1;
    Mmu.setSecondLevelDescMeta(0x4844a000, 0x4844a000, attrs);
    Mmu.setSecondLevelDescMeta(0x4ae07d00, 0x4ae07d00, attrs);

    var attrs = new Mmu.DescriptorAttrs();
    Mmu.initDescAttrsMeta(attrs);
    attrs.type = Mmu.DescriptorType_BLOCK;
    attrs.shareable = 2; // sharerable
    attrs.attrIndx = 1; // Non-cache, device memory
    Mmu.setSecondLevelDescMeta(0x50000000, 0x50000000, attrs); // this covers the first 2MB
    Mmu.setSecondLevelDescMeta(0x50200000, 0x50200000, attrs);

    // descriptor attribute structure

    var peripheralAttrs = new Mmu.DescriptorAttrs();

    Mmu.initDescAttrsMeta(peripheralAttrs);

    peripheralAttrs.type = Mmu.DescriptorType_TABLE;

    Mmu.setFirstLevelDescMeta(0, 0, peripheralAttrs);

    peripheralAttrs.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor

    peripheralAttrs.noExecute = true; // not executable

    peripheralAttrs.accPerm = 0; // read/write at PL1

    peripheralAttrs.attrIndx = 4; // Non-cache, device memory

    // MAIR0 Byte1 describes
    // memory attributes for
    // each BLOCK MMU entry
    // write memory region attribute in mairRegAttr[2] i.e. MAIR0 Reg Byte2

    Mmu.setMAIRMeta(4, 0x00);

    var gpmcAttrs = new Mmu.DescriptorAttrs();
    Mmu.initDescAttrsMeta(gpmcAttrs);
    gpmcAttrs.type = Mmu.DescriptorType_BLOCK;
    gpmcAttrs.shareable = 2;
    gpmcAttrs.noExecute = 1;
    gpmcAttrs.accPerm = 0;
    gpmcAttrs.attrIndx = 1; // level2: 2MB area (level1 is 1GB area)

    /* Configure the corresponding MMU page descriptor accordingly *//* For AM572x GPMC */
    for (var gpmcBaseAddr = 0x00000000; gpmcBaseAddr < 0x20000000; gpmcBaseAddr += 0x200000)
    {
    Mmu.setSecondLevelDescMeta(gpmcBaseAddr,gpmcBaseAddr,gpmcAttrs);
    }

  • Hi Vishnu,

    Please check below example snippet for setting no execute bit for the memory area that you mentioned above. I just added entries for first two locations in the memory snapshot you have shared. You can extend the rsvdBaseAddrs array for other addresses. Please add this to you bios config and give a try.


    var rsvdAttrs = new Mmu.DescriptorAttrs();
    Mmu.initDescAttrsMeta(rsvdAttrs);
    rsvdAttrs.noExecute = 1;
    rsvdAttrs.accPerm = 0;
    rsvdAttrs.attrIndx = 1; // level2: 2MB area

    // Define the base address of the 2 MB page for the reserved locations
    var rsvdBaseAddrs = [
    { base: 0x40000000, size: 0x03200000 }, // RSVD1
    { base: 0x43600000, size: 0x04A00000 } // RSVD2
    ];

    // Configure the corresponding MMU page descriptor accordingly
    for (var i =0; i < rsvdBaseAddrs.length; i++)
    {
    for (var j = 0; j < rsvdBaseAddrs[i].size; j += 0x200000)
    {
    var addr = rsvdBaseAddrs[i].base + j;
    Mmu.setSecondLevelDescMeta(addr, addr, rsvdAttrs);
    }
    }

    - Pratap.

  • Hi Team,

    we have updated the code as below snip (highlighted in green color).

    Before updating the MMU configuration,

    After updating the MMU configuration, result is same. still some memory regions showing as "ex".

    Can you please help to all memory regions make as "xn".

  • Hi Vishnu,

    It is not just setting the 'No execute' and 'Access permission' bits. You need to set the attributes for each of the reserved memory locations as I mentioned in my previous thread. Adding the code here below again. 

    var rsvdAttrs = new Mmu.DescriptorAttrs();
    Mmu.initDescAttrsMeta(rsvdAttrs);
    rsvdAttrs.noExecute = 1;
    rsvdAttrs.accPerm = 0;
    rsvdAttrs.attrIndx = 1; // level2: 2MB area

    // Define the base address of the 2 MB page for the reserved locations
    var rsvdBaseAddrs = [
    { base: 0x40000000, size: 0x03200000 }, // RSVD1
    { base: 0x43600000, size: 0x04A00000 } // RSVD2
    ];

    // Configure the corresponding MMU page descriptor accordingly
    for (var i =0; i < rsvdBaseAddrs.length; i++)
    {
    for (var j = 0; j < rsvdBaseAddrs[i].size; j += 0x200000)
    {
    var addr = rsvdBaseAddrs[i].base + j;
    Mmu.setSecondLevelDescMeta(addr, addr, rsvdAttrs);
    }
    }

     - Pratap.

  • Hi Pratap,

    We updated the code as below attached screenshot. After adding the code, My application is not booting. If possible shall we schedule a short session.

    Regards,

    Vishnu

  • Hi Vishnu,

    Looks like reserved memory with base address 0x40200000 is causing some issue for the MMU init which is making the boot failure. Can you please remove this address entry from the array for now and check if you are able to boot your application. If it boots, please confirm if never execute bits are set for other memory locations.

    - Pratap.

  • Hi Pratap,

    Removed 0x40200000 memory location, it is booted but exception occurred. so for this, We tried to enable only one memory region at a time in the same list to check where the exception is happens. But after enabling only 0x40600000 location no exception was observed but it seems, if we configure the MMU configuration second time a BUS error was occurred(as observed in Trace32). 

    If Possible, shall we schedule a quick session for better understanding the issue.

    Regards,

    Vishnu