--- Quote Start ---
You have remembered to allow access to the JTAG area?
--- Quote End ---
I've tried to reply in my sopcinfo project (see below) the same regions of the Altera project example (also the JTAG area).
https://www.alteraforum.com/forum/attachment.php?attachmentid=7050 All my software project (.text, .bss, .heap, .stack, .rodata, .rwdata, .exception) is stored in sdram. Only .entry is in ext-flash.
I've set the following limits for the MPU regions:
void nios2_mpu_data_init()
{
Nios2MPURegion region[NIOS2_MPU_NUM_DATA_REGIONS];
unsigned int num_of_region = NIOS2_MPU_NUM_DATA_REGIONS;
/* JTAG UART */
region[0].index = 0;
region[0].base = 0x84822; // Byte Address 0x021208B0 (64bytes)
region[0].mask = 0x84823; // Byte Address 0x021208B8 (64bytes)
region[0].c = 0;
region[0].perm = MPU_DATA_PERM_SUPER_RW_USER_RW;
/* JTAG debug module */
region[1].index = 1;
region[1].base = 0x84800; // Byte Address 0x02120000 (64bytes)
region[1].mask = 0x84820; // Byte Address 0x02120800 (64bytes)
region[1].c = 0;
region[1].perm = MPU_DATA_PERM_SUPER_RW_USER_RW;
/* SDRAM */
region[2].index = 2;
region[2].base = 0x40000; // Byte Address 0x01000000 (64bytes)
region[2].mask = 0x80000; // Byte Address 0x02000000 (64bytes)
region[2].c = 0;
region[2].perm = MPU_DATA_PERM_SUPER_RW_USER_RW;
/* Entire address range */
region[3].index = 3;
region[3].base = 0x0; // Byte Address 0x00000000 (64bytes)
region[3].mask = 0x2000000; // Byte Address 0x80000000 (64bytes)
region[3].c = 0;
region[3].perm = MPU_DATA_PERM_SUPER_RW_USER_RW;
nios2_mpu_load_region(region, num_of_region, 1);
}
void nios2_mpu_inst_init()
{
Nios2MPURegion region[NIOS2_MPU_NUM_INST_REGIONS];
unsigned int num_of_region = NIOS2_MPU_NUM_INST_REGIONS;
/* JTAG debug module */
region[0].index = 0;
region[0].base = 0x84800; // Byte Address 0x02120000 (64bytes)
region[0].mask = 0x84820; // Byte Address 0x02120800 (64bytes)
region[0].c = 0;
region[0].perm = MPU_INST_PERM_SUPER_EXEC_USER_EXEC;
/* SDRAM */
region[1].index = 1;
region[1].base = 0x40000; // Byte Address 0x01000000 (64bytes)
region[1].mask = 0x80000; // Byte Address 0x02000000 (64bytes)
region[1].c = 0;
region[1].perm = MPU_INST_PERM_SUPER_EXEC_USER_EXEC;
/* Entire address range */
region[2].index = 2;
region[2].base = 0x0; // Byte Address 0x00000000 (64bytes)
region[2].mask = 0x2000000; // Byte Address 0x80000000 (64bytes)
region[2].c = 0;
region[2].perm = MPU_INST_PERM_SUPER_EXEC_USER_EXEC;
nios2_mpu_load_region(region, num_of_region, 0);
}
When I run the code the exception handler executes and shows the Cause Symbol = 17 (NIOS_EXCEPTION_DATA_REGION_VIOLATION).
Thanks a lot