sifive / freedom-e-sdk

Open Source Software for Developing on the Freedom E Platform - Deprecated
Other
579 stars 209 forks source link

Question on example-pmp demo #455

Open yuhui-zheng opened 4 years ago

yuhui-zheng commented 4 years ago

I'm experimenting with the example-pmp demo https://github.com/sifive/example-pmp/blob/master/example-pmp.c. At line 100, it seems mcause register is not set for me and program doesn't enter store_access_fault_handler(), which is incorrect. I'm also observing protected_global[0] is not updated by executing line 100, which is the correct behavior. Could you confirm this is the intended behavior on SiFive HiFive1 revb? Thank you.

I'm using

SiFive Eclipse IDE for C/C++ Development
Version: 4.12.0.2019-08-2

More steps taken to identify the issue scope: I also modified the demo -- have a load_access_fault_handler() and register the exception with error code = 5. (Per RISC-V privileged spec v1.10 section 3.1.20, load access fault has error code 0x05.) This time I set the same region to be R=0 (cannot read). Now if I read protected_global[0], the program enters load_access_fault_handler(), which is as expected. So, questioning the write access exception part...

taovcu commented 3 years ago

I repeat the above tests on SiFive HiFive1 revb with same observations.

taovcu commented 3 years ago

After I reset the board and run the original code again, I see the "store_access_fault_handler" is triggered. I add a printf("Entered store_access_fault_handler !\n") tag statement at the beginning of the handler function, I see the log is printed.

Virtual-Machine commented 3 years ago

I also have an hifive1 revb and am having the same issue. In fact it wasn't mentioned above but after loading this program, I am forced to use safe mode to recover to a new program. Just mentioning this in case someone else gets stuck after trying to run this.

To get into safe mode press 'reset' and when the green led flashes immediately press it again. If you time it right then it should start flashing red. This will now allow you to overwrite with a new program while led is flashing red.