LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to calculate flash memory end address of a certain file? (http://www.linuxquestions.org/questions/programming-9/how-to-calculate-flash-memory-end-address-of-a-certain-file-867594/)

jaepi 03-09-2011 10:27 PM

How to calculate flash memory end address of a certain file?
 
Hi, do you have any idea how to calculate (if possible) the end address of an image file in a flash memory. I'm trying to create a checksum and checkheader function and the info that I got is the file's offset, how many sector it consumes and its size. I kinda need the end address, sad thing is, I don't know how to calculate it. Let's say test.img's start address is 0, the size is 0x20000 and consumes 3 sectors. Hoping for a kind reply. Thanks. :)

theNbomr 03-10-2011 03:34 PM

I don't think you can do what you seem to want. If you are talking about a flash memory like a USB thumb drive, then the filesytem will look after the arrangement of the data on the memory device, and it probably won't be contiguous (fragmentation). You simply don't have access to the device at the byte/block level.

Perhaps you have left out some details of your objective.

--- rod.

jrtayloriv 03-10-2011 04:39 PM

I don't know why you'd need access to memory addresses to do a checksum, or to check the file headers. Could you explain why you need to access this information?

Also, why are you writing checksum/image-header functions yourself? There are already plenty of available libraries that will do checksums and image file metadata manipulation for you (if you say which language/platform you're using, I'm sure someone can make a recommendation to you). Are you just doing this for fun/learning/etc., or are you just trying to get it done?

jaepi 03-10-2011 09:30 PM

Quote:

Originally Posted by theNbomr (Post 4285949)
I don't think you can do what you seem to want. If you are talking about a flash memory like a USB thumb drive, then the filesytem will look after the arrangement of the data on the memory device, and it probably won't be contiguous (fragmentation). You simply don't have access to the device at the byte/block level.

Perhaps you have left out some details of your objective.

--- rod.

I see, I thought it is possible to calculate the end address. Correct me if I'm wrong. Start and end address are already fixed data?

jaepi 03-10-2011 09:48 PM

Quote:

Originally Posted by jrtayloriv (Post 4286043)
I don't know why you'd need access to memory addresses to do a checksum, or to check the file headers. Could you explain why you need to access this information?

Also, why are you writing checksum/image-header functions yourself? There are already plenty of available libraries that will do checksums and image file metadata manipulation for you (if you say which language/platform you're using, I'm sure someone can make a recommendation to you). Are you just doing this for fun/learning/etc., or are you just trying to get it done?

I'm actually trying to learn how these thing works and where did these data (start and end address) came from. I guess these are fixed data, based on the layout of the flash. The image files I think were meant to be placed in a specific address. I'm actually trying to understand both functions I found and hopefully I could recreate one. Oh, btw, I'm using C. :)

---------- Post added 03-11-11 at 10:49 AM ----------

BTW, forgot to thank you for your kind replies. Thanks guys :)

theNbomr 03-11-2011 09:10 AM

It seems you may be confused about the difference between memory and storage, perhaps because of the nature of the storage device, which is fundamentally a memory technology device. While at its heart it is a non-volatile memory device, it is under the control of a filesystem, and as such, the details of how it is accessed, partitioned, and generally organized are hidden from userspace applications. By nature, flash memory is actually not a fully linear address space, and access to the memory is controlled by an even lower level of driver which further conceals the details of access to the device. If you really want to learn the details of how memory technology devices work, then you should study the appropriate kernel mode drivers. Start by looking in the 'drivers/mtd/...' section of the linux kernel sources.

--- rod.

jaepi 03-15-2011 01:28 AM

Quote:

Originally Posted by theNbomr (Post 4286927)
It seems you may be confused about the difference between memory and storage, perhaps because of the nature of the storage device, which is fundamentally a memory technology device. While at its heart it is a non-volatile memory device, it is under the control of a filesystem, and as such, the details of how it is accessed, partitioned, and generally organized are hidden from userspace applications. By nature, flash memory is actually not a fully linear address space, and access to the memory is controlled by an even lower level of driver which further conceals the details of access to the device. If you really want to learn the details of how memory technology devices work, then you should study the appropriate kernel mode drivers. Start by looking in the 'drivers/mtd/...' section of the linux kernel sources.

--- rod.

Thanks Rod, I was actually jumping to things immediately without understanding the concept (I was really2x confused). I will look up the drivers/mtd section of the kernel source.


All times are GMT -5. The time now is 10:02 AM.