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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-09-2011, 09:27 PM
|
#1
|
|
Member
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Rep:
|
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. 
|
|
|
|
03-10-2011, 02:34 PM
|
#2
|
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,259
|
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.
|
|
|
|
03-10-2011, 03:39 PM
|
#3
|
|
Member
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 362
Rep:
|
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.
|
|
|
|
03-10-2011, 08:30 PM
|
#4
|
|
Member
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Original Poster
Rep:
|
Quote:
Originally Posted by theNbomr
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?
|
|
|
|
03-10-2011, 08:48 PM
|
#5
|
|
Member
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Original Poster
Rep:
|
Quote:
Originally Posted by jrtayloriv
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 
|
|
|
|
03-11-2011, 08:10 AM
|
#6
|
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,259
|
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.
|
03-15-2011, 12:28 AM
|
#7
|
|
Member
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Original Poster
Rep:
|
Quote:
Originally Posted by theNbomr
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:20 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|