Ali, you've changed ram setup code. Ram setup is probably the single hardest thing to get right. It can take a year. You need to let people see your code before any one can help you.
It's very common for a new port to pass a ram test and fail in actual use. Just about everyone who has done a port has been in this situation.
But, all that said, you need to let people see your ram code or we can not help you.
ron