LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-09-2011, 09:27 PM   #1
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Rep: Reputation: 30
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.
 
Old 03-10-2011, 02:34 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 03-10-2011, 03:39 PM   #3
jrtayloriv
Member
 
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 365
Blog Entries: 1

Rep: Reputation: 44
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?

Last edited by jrtayloriv; 03-10-2011 at 03:40 PM.
 
Old 03-10-2011, 08:30 PM   #4
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by theNbomr View Post
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?
 
Old 03-10-2011, 08:48 PM   #5
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by jrtayloriv View Post
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
 
Old 03-11-2011, 08:10 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
1 members found this post helpful.
Old 03-15-2011, 12:28 AM   #7
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by theNbomr View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shared memory address area in process address space nagaraju1024 Programming 3 02-22-2011 04:49 AM
Calculate total memory consumed by user emymcse Linux - General 12 09-23-2010 05:26 AM
how to calculate memory available if needed on a linux system? icekiss Linux - Server 1 07-16-2010 06:52 AM
Trying to calculate Network Address with shell script Adanos Programming 5 11-09-2008 10:37 AM
How to calculate cpu and memory usage of a process narendra1310 Ubuntu 1 08-30-2008 02:39 AM


All times are GMT -5. The time now is 05:07 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration