Part Number:TMS320C6748
I am attempting to test memory protection on the C6748. I have been following this thread (https://e2e.ti.com/support/processors/f/791/t/158135#pi317270=2) and the mpuTest example provided, and I am able to run a test on my LCDK dev board with the debugger. However, it isn't working as expected.
When I first ran the MPU test, it did not work as expected (same output as below). I looked at the registers and saw that there were overlapping ranges configured, so I made some modifications to define them differently in case that was an issue. Right now I am only focusing my efforts on MPU1.
Here's the MPU1 configuration I'm doing at the start, then you can see in the output below how I change the MPPA register during the test:
#define MPU1_REGION_START_ADDR (0x80000000) #define MPU1_REGION_SIZE (0x00010000) #define MPU1_TEST_ADDR (MPU1_REGION_START_ADDR + 0x20) // Setup the range we will be working with MPU1->PROG_RANGE[0].MPSAR = MPU1_REGION_START_ADDR; MPU1->PROG_RANGE[0].MPEAR = MPU1_REGION_START_ADDR + 0x400 - 1; MPU1->PROG_RANGE[0].MPPA = 0x03FFFEFF; // full access to start // Clear the other ranges MPU1->PROG_RANGE[1].MPSAR = MPU1_REGION_START_ADDR + 0x400; MPU1->PROG_RANGE[1].MPEAR = MPU1_REGION_START_ADDR + 0x800 - 1; MPU1->PROG_RANGE[1].MPPA = 0x03FFFEC0; // no access MPU1->PROG_RANGE[2].MPSAR = MPU1_REGION_START_ADDR + 0x800; MPU1->PROG_RANGE[2].MPEAR = MPU1_REGION_START_ADDR + 0xc00 - 1; MPU1->PROG_RANGE[2].MPPA = 0x03FFFEC0; // no access MPU1->PROG_RANGE[3].MPSAR = MPU1_REGION_START_ADDR + 0xc00; MPU1->PROG_RANGE[3].MPEAR = MPU1_REGION_START_ADDR + 0x1000 - 1; MPU1->PROG_RANGE[3].MPPA = 0x03FFFEC0; // no access MPU1->PROG_RANGE[4].MPSAR = MPU1_REGION_START_ADDR + 0x1000; MPU1->PROG_RANGE[4].MPEAR = MPU1_REGION_START_ADDR + 0x1400 - 1; MPU1->PROG_RANGE[4].MPPA = 0x03FFFEC0; // no access MPU1->PROG_RANGE[5].MPSAR = MPU1_REGION_START_ADDR + 0x1400; MPU1->PROG_RANGE[5].MPEAR = MPU1_REGION_START_ADDR + 0x1800 - 1; MPU1->PROG_RANGE[5].MPPA = 0x03FFFEC0; // no access
Here is the output I get, which clearly shows that no protection is occurring:
[C674X_0] MPU1 Testing Begins
------------------------------------------------------------------
FULL ACCESS: Memory protection set to = 0x03FFFEFF
FULL ACCESS: Value wrote to memory = 0x0BADBEEF
FULL ACCESS: Value read from memory = 0x0BADBEEF
NO ACCESS: Memory protection set to = 0x03FFFEC0
NO ACCESS: Value wrote to memory = 0x76543210
NO ACCESS: Value read from memory = 0x76543210
READ-ONLY ACCESS: Memory protection set to = 0x03FFFEE4
READ-ONLY ACCESS: Value wrote to memory = 0x01234567
READ-ONLY ACCESS: Value read from memory = 0x01234567
WRITE-ONLY ACCESS: Memory protection set to = 0x03FFFED2
WRITE-ONLY ACCESS: Value wrote to memory = 0xA5A50F0F
WRITE-ONLY ACCESS: Value read from memory = 0xA5A50F0F
READ/WRITE ACCESS: Memory protection set to = 0x03FFFEF6
READ/WRITE ACCESS: Value read from memory = 0xA5A50F0F
------------------------------------------------------------------
The register values also corroborate that what I'm writing to the registers looks correct (as far as I can tell):
0x01E14200 - 80000000 800003FF 03FFFEF6 00000000 80000400
0x01E14214 - 800007FF 03FFFEC0 00000000 80000800 80000BFF
0x01E14228 - 03FFFEC0 00000000 80000C00 80000FFF 03FFFEC0
0x01E1423C - 00000000 80001000 800013FF 03FFFEC0 00000000
0x01E14250 - 80001400 800017FF 03FFFEC0 00000000 00000000
The value of 0x80000020 also matches up with the end of the test:
0x80000020 - A5A50F0F
Any suggestions as to what I might be doing wrong or what might be going on? Is there something I'm missing about how the MPUs work?