a question about memory dump of kernel code
I am working on memory dump feature. Now I can dump all memory out to a file by using a tool (0xc0000000 to 0xcfffffff, 256M bytes data),. However, I need to verify what I dump is exactly the same in flash memory.
One solution is to disable interrupt and do checkum when system is on, i.e. capture a snapshot. And printk it. Then reboot the system directly to make it go into hardware boot processing part, then use my tool to dump data to a file. And do the same checksum operation to the file, to compare whether they are bitmatch.
However, I encountered a problem here.
Since my checkum function also need to declare several parameters to implement functionality, it means the value will be changed definitely. But these parameters will also be part of checkum... So when I read it, it maybe 1, however, after checksum finished, the vlaue will be changed to xxx. It will be different with the one in file for sure!
unsigned int flags,result,i;
unsigned char sum;
sum+=(((result >> 24) & 0xff) + ((result >> 16) & 0xff) + ((result>> & 0xff) + (result & 0xff));
My question is how can I do checksum? i.e. do whole memory checkum, and everything is frozen there? Maybe I should put my code in memory directly somehow?