- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
........
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quite possible the memory cycle you are doing is accessing some other part of the system - due to address aliasing - and that is causing the reset.
The SOPC builder doesn't seem to tell you the actual address decode rules it has put in place.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After making some debug I think I know the reason of the endless loop.
The problem was that in the MPU_usage example, when the first fail condition is detected the program exits with the following code: alt_printf("FAIL\n");
exit(1);
But the library function exit() seems to be implemented as "call 0", even when there is no memory at address 0. Program control is then transferred to address 0, and the processor reads an all ones word (FFFFFFFF) as opcode. The attempt to execute this opcode provokes an exception with cause "Illegal instruction". The same is repeated at address 4, 8, and so on, sweeping unpopulated memory space from address 0 until reaching the reset vector at the start of my RAM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, it's Jay, doing MPU stuff. I met some strange problems. may I ask for a copy of your previous MPU project? Really appreciated if you could help.:)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page