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.

AWR1843: How to CCS debug When configure MPU(write-protect of TCMA)

Part Number: AWR1843
Other Parts Discussed in Thread: UNIFLASH

Hi,

SDK version: mmwave_sdk_03_02_00_04

CCS: 8.3.1

 

I want to CCS debug MPU functions(I config the TCMA with read only access and execute), I expect to get a data abort exception when I write to address 0 for test purpose.

But the the codes after configure TCMA MPU  write protect will enter prefetch abnormal CPU mode when CCS debug.

Original codes as blow( compile SOC lib with definition of DOWNLOAD_FROM_CCS):

#if ((SOC_XWR18XX_MSS_TCMA_BASE_ADDRESS & (512U * ONE_KB - 1)) != 0)
#error SOC_XWR18XX_MSS_TCMA_BASE_ADDRESS not aligned to 512 KB
#endif
   SOC_MPUSetRegion(SOC_MPU_REGION2);
   SOC_MPUSetRegionBaseAddress(SOC_XWR18XX_MSS_TCMA_BASE_ADDRESS);
#ifdef DOWNLOAD_FROM_CCS
   SOC_MPUSetRegionTypeAndPermission(SOC_MPU_NORMAL_OINC_NONSHARED, SOC_MPU_PRIV_RW_USER_RW_EXEC);
#else
   SOC_MPUSetRegionTypeAndPermission(SOC_MPU_NORMAL_OINC_NONSHARED, SOC_MPU_PRIV_RO_USER_RO_EXEC);
#endif
   SOC_MPUSetRegionSizeRegister(SOC_MPU_REGION_ENABLE | SOC_MPU_512_KB);
   
   

I remove DOWNLOAD_FROM_CCS judge, then use write protect function directly for TCMA memory. as below:

SOC_MPUSetRegion(SOC_MPU_REGION2);
SOC_MPUSetRegionBaseAddress(SOC_XWR18XX_MSS_TCMA_BASE_ADDRESS);
SOC_MPUSetRegionTypeAndPermission(SOC_MPU_NORMAL_OINC_NONSHARED, SOC_MPU_PRIV_RO_USER_RO_EXEC);
SOC_MPUSetRegionSizeRegister(SOC_MPU_REGION_ENABLE | SOC_MPU_512_KB);

Then CCS debugging the edited codes will enter exception after execute up codes after  SOC_MPUEnable();

What can I do to support ccs debug test for the MPU write-protect with codes memory area. Why the second configuration parameter from SOC_MPU_PRIV_RW_USER_RW_EXEC to SOC_MPU_PRIV_RO_USER_RO_EXEC ( no write permission) will cause the exception which I cannot debug anymore. All code load to TCMA already  ok when execute mpu config( called by SOC_init codes in main funciton)

Thanks.

Jeff

  • Hello Jeff,

    As you have mentioned

    I want to CCS debug MPU functions(I config the TCMA with read only access and execute), I expect to get a data abort exception when I write to address 0 for test purpose.

    By looking at your flow as you have only read write access when the macro is defined. In your case you might be getting the prefetch abort handler as the contents of the TCMA has been overwritten and the CPU is trying to execute from that memory, which has invalid code.

    Could you try the same with a TCMA region where there is no code, using the map file/ linker file to allocate the section for testing.

    Regards,
    Saswat Kumar

  • Hello Saswat,

      Thank you for your reply.

       It has read write and execute access when DOWNLOAD_FROM_CCS is yes,

       It has only read and execute access with defining the DOWNLOAD_FROM_CCS  is no.

       They have execute permission in both condition.

     1、 test codes

     I add a mpu  config funciton to config TCMA with no write access after SOC_init, don't edit the code in soc lib anymore.

    main()
    {
       ...
       socHandle = SOC_init (&socCfg, &errCode);
       ...
       MpuApp_config();
       ...
    }
    
    
    #define   MPU_PRIV_RW_USER_RW_EXEC  (0x3)
    #define   MPU_PRIV_RO_USER_RO_EXEC  (0x6)
    
    void MpuApp_config(void)
    {
        MPU_disable();
        regionId = 1;
        regionBaseAddr = 0;
        regionSize = MPU_RegionSize_512K;//MPU_RegionSize_512K;
    
        regionAttrs.enable = true;
        regionAttrs.bufferable = 0;
        regionAttrs.cacheable = 0;
        regionAttrs.shareable = 0;
        regionAttrs.noExecute = 0;
    #ifdef  MPU_CSS_DEBUG
        regionAttrs.accPerm = MPU_PRIV_RW_USER_RW_EXEC;
    #else
        regionAttrs.accPerm = MPU_PRIV_RO_USER_RO_EXEC;
    #endif
        regionAttrs.tex = 1;
        regionAttrs.subregionDisableMask = 0x0;
        MPU_setRegion(regionId, regionBaseAddr, regionSize, &regionAttrs);
        
        MPU_enable();
        
        g_mcuconfig.mpuIsEnable = MPU_isEnabled();
        g_mcuconfig.enableBackgroundRegion = MPU_enableBackgroundRegion;
    }

    2、ccs debug

    CCS debug worked normal when I define MPU_CSS_DEBUG macro, TCMA has read ,write and execute access.

    But it will enter into Undefined instruction or Abort (prefetch) when step debug after mpu_enable with doing reset and load debug test without MPU_CSS_DEBUG  definition (no write access, just read and execute access), it works normal when I burned to flash and do flash boot.

    I continue to step assemble debug after the cpu enter undefined mode, get the PC = 0x3620A

    I reload mss out file to see the codes in address 0x3620A

    There is a different data in the same address between  I step assemble to enter abnormal and to see the ram data and  only reset , load out file with stay in main entry, I continue to debug step by step, it executed normal when it reached the 0x3620A address after the MPU_enable(). Just because the codes I watched the 0x3620A  memory when stay main entry? It work abnormal in the before abnormal address just because without watching the memory?  When does the codes to really load to TCMA memory in CCS debug.

    3、just run

    It will stay in funciton __TI_writemsg like below when I load and run without breakpoint debug.

    After  reconfigure the TCMA memory with no write permission when it reaches to MPU_enable(),  I suggest some codes it don't really exist in TCMA. It will load to memory when it need to run other codes, but at this moment, if the TCMA has no write permission for ccs debug to load codes to. It will fail just display in console window:

    Cortex_R4_0: Trouble Reading Memory Block at 0x40a62 on Page 0 of Length 0xa8: (Error -2043 @ 0x40A66) Unable to clear requested breakpoint from memory. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 8.1.0.00012)

    That's right?

    Thanks.

    Jeff

  • Hi Jeff,

    Could you try same experiment in flash mode not while you debug from CCS?

    i.e. build application with your required change (RO_EXEC) and flash *.bin file using UniFlash to the device.

    Let me know if it goes into exception under this case.

    .

    Regards,

    Jitendra

  • Hi Jitendra,

    Thank you for your reply.

    It can work normally when burned into flash and boot from flash mode.

    It works well as expected to get data abort when any write to tcma memory address.

    Thanks.

    Jeff

  • Hello Jeff,

    I see that its working with the flash mode, so I hope your issue is solved with this fix.

    Regards,

    Saswat Kumar

  • Hello Saswat,

    But I want to know how to CCS debug when configure the TCMA memery without write access. Has any way to do this?

    Now It can't CCS debug when configured the TCMA memery read and execute only.

    Thanks.

    Jeff

  • Hi Saswat,

    Sorry to disturb you again.

    Any updates for this issue?

    Thanks

    Jeff