Altera_Forum
Honored Contributor
15 years agoNios MPU. Problems after disabling Memory Protection Unit
Hello,
I took the MPU usage example from the Nios Wiki as the starting point for using the MPU. I adapted it to my hardware (DE1 board), using the 512K off chip SRAM and a 16K onchip ram in place of the instr_ram and stack_ram used in the original example, and modified addresses and sizes accordingly. I ran the test program and obtained the PASSED messages, everything fine till now. After running this test I tried some modifications to the example code and problems started. I modified the program in the following way: after the original tests I disable the MPU (calling nios2_mpu_disable) and after this I repeat the tests (I enclose the modified code below). When running this code the first test after disabling the MPU fails as expected, but after this the program seems to restart, entering in an endless loop (a transcription of the nios console output is enclosed below). What's wrong? jpa########## code modifications
// ... original test_null_data and test_wild_pointer calls
// inserted code begin
nios2_mpu_disable();
test_null_data( exc_info );
test_wild_pointer( exc_info );
// end of inserted code
alt_putstr( "=====\n" );
alt_putstr( "\tException Tests ended.\n" );
alt_printf( "Now exiting program.\n%c", EOT );
# ######### nios console output
Hello from a simple MPU-Enabled Nios II System!.
Starting some exceptions tests.
=====
MPU NULL data pointer test.
...PASSED!
MPU wild pointer test.
...PASSED! <<<<- MPU disabled after this line
MPU NULL data pointer test.
FAIL
Hello from a simple MPU-Enabled Nios II System!. <<<<- UNEXPECTED RESTART, ENDLESS LOOP
Starting some exceptions tests.
=====
MPU NULL data pointer test.
...PASSED!
........