| Libin's profile绿色家园PhotosBlogLists | Help |
绿色家园Green World(本空间文章,未经原作者同意,请勿做商业用途。未注明的文章均为转载。) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
November 19 pldatabase -- Objective-C SQL Database Access LibraryDescriptionA SQL database access library for Objective-C, initially focused on SQLite as an application database. The library supports both Mac OS X and iPhone development. Plausible Database is provided free of charge under the BSD license, and may be freely integrated with any application. Download1.2.1 Stable Release1.1.1 Previous ReleaseDocumentation1.2.1 Stable Release1.1.1 Previous ReleaseBuildingTo build your own release binary, build the 'Disk Image' target: user@max:~/pldatabase-1.2> xcodebuild -configuration Release -target 'Disk Image' This will output a new release disk image containing an embeddable Mac OS X framework and a static iPhone framework in build/Release/Plausible Database-{version}.dmg SQLite Resources for iPhone DevelopersSQLite is a public domain database library that offers file and memory based relational database functionality from a single C library. The iPhone / iPod Touch has the SQLite library included and ready to roll and Apple expects the SQLite library to form the backbone of most applications’ data storage requirements. We’ve collected together some of the best SQLite related tutorials, and libraries in order to help you on your way with this essential iPhone programming technology: Tutorials
Reading data from a SQLite Database by Dean Collins is a wonderful “start to finish” tutorial that covers creating an SQLite database, creating an XCode project, and then all the code necessary to use that database within an iPhone app. There’s even a link to an archive of the code used in the tutorial so you can more quickly try it out for yourself. SQLite Tutorial 1: Selecting Data by Jai Kirdatt is the first in five SQLite focused tutorials from the aforementioned author. This one covers creating an SQLite database and, like Dean’s tutorial above, using that database from Objective C. There’s more code and less screenshots than in the aforementioned tutorials, so this tutorial is worth coming to once you’re totally confident with the basics. Source code is available to download at the bottom of the post. SQLite Tutorial 2: Deleting Data by Jai Kirdatt follows on nicely from the previous tutorial and quickly demonstrates how to delete rows of data from an SQLite database.
SQLite Tutorial 4: Loading Data As Required by Jai Kirdatt shows how to select rows in a database to then display in a detail view. Data is only loaded when it is required. SQLite Tutorial 5: Updating Data by Jai Kirdatt shows you how to update the database when fields on a form are edited and the application is then terminated. LibrariesEntropyDB is an embedded object database for OS X 10.5 and iPhone OS written in Objective C that’s built on top of SQLite. It provides a nicer API than that offered by SQLite directly. You don’t need to use SQL at all, but instead just work with Objective C objects! SQLitePersistentObjects allows you to call “save” on your objects and trust that they will be saved properly and can be easily reloaded in future. No SQL required. FMDB is a library that acts as a wrapper around SQLite - inspired by JDBC. fmdb-migration-manager(originally by last week’s podcast interviewee - Dr Nic Williams) allows you to easily roll out database migrations using fmdb. iPhone SQLite Persistence for Objects is an open source project that lets you add “object persistence” to your applications. The object persistence uses SQLite, and the library works on both the iPhone and iPod Touch. Suggestions?Know of any others? Leave a comment and we’ll do our best to include them! SQLite + UITableView for iPhoneI see many people asking for SQLite tutorials around, and since I am using SQLite for the next part in the Advanced RSS Reader Tutorial, I thought I would write up a quick tutorial on using SQLite with the iPhone SDK. 1. Project Requirements I suggest that you have at least a basic understanding of SQLite,writing SQL statements, the XCode interface and using the terminal inOSX. If you don’t know anything about any of these topics then thistutorial probably isn’t for you. 2. Creating our SQLite database for our tutorial We first need to create a database for use with our application. Forthe purposes of this tutorial we will be building a database of animalsalong with a little information on them and a picture. Fire up a new Terminal window and make a new folder to store the database in, here are the commands I ran [pre]cd /Users/lookaflyingdonkey/Documents mkdir SQLiteTutorial cd SQLiteTutorial sqlite3 AnimalDatabase.sql[/pre]You should now be at a “sqlite” command prompt, this is where wewill be building our database structure and entering some test data. For our example we need the name of the animal, a short descriptionand a link to an image. Follow the commands below to create the tableand to enter some sample data. [pre]CREATE TABLE animals ( id INTEGER PRIMARY KEY, name VARCHAR(50), description TEXT, image VARCHAR(255) ); INSERT INTO animals (name, description, image) VALUES ('Elephant', 'The elephant is a very large animal that lives in Africa and Asia', 'http://dblog.com.au/wp-content/elephant.jpg'); INSERT INTO animals (name, description, image) VALUES ('Monkey', 'Monkies can be VERY naughty and often steal clothing from unsuspecting tourists', 'http://dblog.com.au/wp-content/monkey.jpg'); INSERT INTO animals (name, description, image) VALUES ('Galah', 'Galahs are a wonderful bird and they make a great pet (I should know, I have one)', 'http://dblog.com.au/wp-content/galah.jpg'); INSERT INTO animals (name, description, image) VALUES ('Kangaroo', 'Well I had to add the Kangaroo as they are the essence of the Australian image', 'http://dblog.com.au/wp-content/kangaroo.jpg');[/pre]The first command will create the table with the required structureand the next four will insert some test data for us to work with. Toensure that you have entered the data correctly you can execute “SELECT* FROM animals;” and see if it returns the items above. Once you areconfident that everything had been created successfully you can leavethe sqlite command line by typing “.quit”. 3. Creating our Project Now that our database is all ready to go we need to setup our X-Code project. Start off by creating a new “Navigation-Based Application”. ![]() Give your Project a name, I called mine “SQLiteTutorial”. Now set your screen layout to how you prefer it, I suggest makingthe window as large as possible, and making the code view as tall aspossible by dragging the horizontal slider to the top. This will allowyou the most room to move when building your application. Now its time to create the required classes and views for our application, we will start off by making our views. Right Click on the “Resources” folder in the left hand pane andclick “Add File”, we want to create a new “View XIB” under the “UserInterfaces” group. ![]() We now need to give it a name, to stick the Apple’s naming conventions we are going to call it “AnimalViewController.xib”, Now Click “Finish”. Now we need to create two classes, the first one will represent ananimal, right click on the “Classes” folder in the left hand pane,click “Add > New File…”, choose the “NSObject subclass” templateunder the “Cocoa Touch Classes” group and name it “Animal”. The second class will be for our AnimalsViewController, right clickon the “Classes” folder in the left hand pane, click “Add > NewFile…”, choose the “UIViewController subclass” under the “Cocoa TouchClasses” group and name it “AnimalViewController”. 4. Adding SQLite Framework and our Animal Database Now that we have created all of our views and classes it is time to start the real grunt work. First off we need to include the SQLite libraries so our applicationcan utilise them. To do this you will need to right click on the“Frameworks” folder in the left hand pane, then click on “Add >Existing Frameworks…”, then navigate to“/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/”and double click the “libsqlite3.0.dylib” file. A popup will appear,just click “Add” and the library will be added to your project. We also need to add our database we created earlier to the Resourcesfolder, to do this simply right click on the “Resources” folder, click“Add > Existing Files…”, navigate to the location you created thedatabase in then double click on the AnimalDatabase.sql file. Anotherpopup will appear, just click add. All done with the importing, time to code! 5. The Coding begins! We are going to start the coding by building our “Animal” object,every animal will have 3 properties, a name, a description and an imageURL. Open up the “Animal.h” file from the “Classes” folder and edit its contents to look like below, [pre]#import <UIKit/UIKit.h> @interface Animal : NSObject { NSString *name; NSString *description; NSString *imageURL; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *description; @property (nonatomic, retain) NSString *imageURL; -(id)initWithName:(NSString *)n description:(NSString *)d url:(NSString *)u; @end [/pre]Most of the above code should be pretty familiar to you, the only thing that may not be is the initWithName line, this line will allow us to create a new object with the required data, we could have used the default init function, but it will be easier for us to define our own. Now we will actually have to implement the Animal Object, open up the “Animal.m” file and edit its contents to look like below: [pre]#import "Animal.h" @implementation Animal @synthesize name, description, imageURL; -(id)initWithName:(NSString *)n description:(NSString *)d url:(NSString *)u { self.name = n; self.description = d; self.imageURL = u; return self; } @end [/pre]The above code should be pretty easy to read as well, it basicallystores the supplied data from the initWithName function and return theobject (self). Now its time to setup the Application delegate to access the database. Open up the “SQLiteTutorialAppDelegate.h” and edit its contents to look like below: [pre]#import <UIKit/UIKit.h> #import <sqlite3.h> // Import the SQLite database framework @interface SQLiteTutorialAppDelegate : NSObject { UIWindow *window; UINavigationController *navigationController; // Database variables NSString *databaseName; NSString *databasePath; // Array to store the animal objects NSMutableArray *animals; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @property (nonatomic, retain) NSMutableArray *animals; @end [/pre]What we are doing here is importing the SQLite database frameworkand creating some variables for storing the database details and anarray of animal objects. Now open up the “SQLiteTutorialAppDelegate.m” file and edit its contents to look like below: [pre]#import "SQLiteTutorialAppDelegate.h" #import "RootViewController.h" #import "Animal.h" // Import the animal object header @implementation SQLiteTutorialAppDelegate @synthesize window; @synthesize navigationController; @synthesize animals; // Synthesize the aminals array - (void)applicationDidFinishLaunching:(UIApplication *)application { // Setup some globals databaseName = @"AnimalDatabase.sql"; // Get the path to the documents directory and append the databaseName NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; // Execute the "checkAndCreateDatabase" function [self checkAndCreateDatabase]; // Query the database for all animal records and construct the "animals" array [self readAnimalsFromDatabase]; // Configure and show the window [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } - (void)applicationWillTerminate:(UIApplication *)application { // Save data if appropriate } - (void)dealloc { [animals release]; [navigationController release]; [window release]; [super dealloc]; } -(void) checkAndCreateDatabase{ // Check if the SQL database has already been saved to the users phone, if not then copy it over BOOL success; // Create a FileManager object, we will use this to check the status // of the database and to copy it over if required NSFileManager *fileManager = [NSFileManager defaultManager]; // Check if the database has already been created in the users filesystem success = [fileManager fileExistsAtPath:databasePath]; // If the database already exists then return without doing anything if(success) return; // If not then proceed to copy the database from the application to the users filesystem // Get the path to the database in the application package NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; // Copy the database from the package to the users filesystem [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; [fileManager release]; } -(void) readAnimalsFromDatabase { // Setup the database object sqlite3 *database; // Init the animals Array animals = [[NSMutableArray alloc] init]; // Open the database from the users filessytem if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { // Setup the SQL Statement and compile it for faster access const char *sqlStatement = "select * from animals"; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { // Loop through the results and add them to the feeds array while(sqlite3_step(compiledStatement) == SQLITE_ROW) { // Read the data from the result row NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)]; NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)]; // Create a new animal object with the data from the database Animal *animal = [[Animal alloc] initWithName:aName description:aDescription url:aImageUrl]; // Add the animal object to the animals Array [animals addObject:animal]; [animal release]; } } // Release the compiled statement from memory sqlite3_finalize(compiledStatement); } sqlite3_close(database); } @end [/pre]Now I know that may look like a fair bit of code and it probablyalso looks quite scary! But really it is quite simple and I have triedto comment nearly every line to describe to you what the line does andwhy it is there. The checkAndCreateDatabase function checks to seeif we have already copied our database from the application bundle tothe users filesystem (in their documents folder), if the databasehasn’t already been created or it has been removed for some reason itwill be recreated from the default database. Next the readAnimalsFromDatabase function will makea connection to the database that is stored in the users documentsfolder, and then executes the SQL statement “SELECT * FROM animals”. Itwill then go through each row that is returned and it will extract thename, description and imageURL from the result and build an Animal object for each. You will see the “sqlite3_column_text” function used here, there are many more of these for returning other field types such as “sqlite3_column_int” for integers, “sqlite3_column_blob” for blobs or “sqlite3_column_value” to get an unknown value. Now that we have the data in our array and we have it in our known format we are ready to start displaying it. Open up the “RootViewController.m” file and edit the numberOfRowsInSection to look like the following: [pre]SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate]; return appDelegate.animals.count; [/pre]What this does is it creates a link to the application delegate, andthen the second line returns the size f the animals array in outApplication delegate, this array was filled previously from the SQLitedatabase. Now in the cellForRowAtIndexPath function you will need at change it to look like the following: [pre]- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate]; Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row]; [cell setText:animal.name]; return cell; } [/pre]We pretty much just added 3 lines under the “// Set up the cell” line, the first one is the same as we added previously to access the application delegate. The second line creates a new Animalobject based on the array from the application delegate, it will beused to create a row for each individual record in the database. On thefinal line we are just setting the text of the cell to the name fieldfrom the Animal object. You can now run the program and you should see a table view with the4 animals we added to the database, if you added more than my defaultanimals you should see them in here as well. We will now setup the AnimalViewController, open up the “AnimalViewController.h” file and edit its contents to below: [pre]#import <UIKit/UIKit.h> @interface AnimalViewController : UIViewController { IBOutlet UITextView *animalDesciption; IBOutlet UIImageView *animalImage; } @property (nonatomic, retain) IBOutlet UITextView *animalDesciption; @property (nonatomic, retain) IBOutlet UIImageView *animalImage; @end [/pre]What we are doing above is adding an outlet for the description and image for the Animal, we will use these later on when we link the view up. Now open up the “AnimalViewController.m” file and add a synthesize call for for the description and image, this will go under the “@implementation AnimalViewController” line, like so: [pre]#import "AnimalViewController.h" @implementation AnimalViewController @synthesize animalDesciption, animalImage; [/pre]Now it is time to make the detailed view page appear when you selecta record. Open up the “AnimalViewController.xib” file from theresources folder and the interface builder should appear. The first thing we need to do is to set the File’s Owner Class to AnimalViewController, this is done by selecting the “File’s Owner” item in the main window and then clicking Tools > Identity Inspector in the top menu, and then selecting AnimalViewController from the class dropdown. Your inspector window should now look like this: ![]() We are going to be using a UITextView for the description (as it will allow for word wrapping and scrolling in the case that the description is quite large) and a UIImageView to display the image. I have laid mine out like below: ![]() Now that we have everything laid out it is time to link them all up, start by holding control and click+drag from the “File’s Owner” to the “View” objects, a little gray menu will appear and you will need to select view. Now hold control and click+drag from the “File’s Owner” to the UITextView in the layout window, you should see “animalDescription” in the popup list, select it. Repeat this process for the UIImageView and you should see animalImage appear, select it also. Now save the interface and close the interface builder. Nearly done! All we have to do now is to setup the code for when a user presses on a record in the table view. Open up the “RootViewController.h” file and edit its contents to below: [pre]#import <UIKit/UIKit.h> #import "AnimalViewController.h" @interface RootViewController : UITableViewController { AnimalViewController *animalView; } @property(nonatomic, retain) AnimalViewController *animalView; @end [/pre]We are creating an instance of the AnimalViewController to be used bu the RootViewController when a user presses on an item. Now open up the “RootViewController.m” file and edit the top part of the file to look like below: [pre]#import "RootViewController.h" #import "SQLiteTutorialAppDelegate.h" #import "Animal.h" @implementation RootViewController @synthesize animalView; [/pre]This will just synthesize the animalView that we just added. First up lets set the default title of our view, to do this you needto uncomment the viewDidLoad function, and edit it to below: [pre]- (void)viewDidLoad { [super viewDidLoad]; // Uncomment the following line to add the Edit button to the navigation bar. // self.navigationItem.rightBarButtonItem = self.editButtonItem; self.title = @"My Zoo"; } [/pre]We also need to edit the didSelectRowAtIndexPath function in this file, edit it to look like below: [pre]- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic -- create and push a new view controller SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate]; Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row]; if(self.animalView == nil) { AnimalViewController *viewController = [[AnimalViewController alloc] initWithNibName:@"AnimalViewController" bundle:nil]; self.animalView = viewController; [viewController release]; } // Setup the animation [self.navigationController pushViewController:self.animalView animated:YES]; // Set the title of the view to the animal's name self.animalView.title = [animal name]; // Set the description field to the animals description [self.animalView.animalDesciption setText:[animal description]]; // Load the animals image into a NSData boject and then assign it to the UIImageView NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[animal imageURL]]]; UIImage *animalImage = [[UIImage alloc] initWithData:imageData cache:YES]; self.animalView.animalImage.image = animalImage; } [/pre]What we are doing here is checking to see if the animalView object has already been created, if not then create it. The next few lines are used to setup the animation (slide from rightto left) and to set the actual data fields to those of the selectedanimal. Now you should be ready to fire up the application and see it in all its glory. You should see your windows looking like below.
November 17 Useful open source libraries for IPhone DevelopmentIt’s been almost 3 months since the IPhone SDK’s infamous NDA restrictions were lifted, and there are now a good set of open source libraries available for the IPhone. In this post I will go through the ones that I know of one way or another. If you are aware of more high quality open source projects, please let me know in the comments so that I can update this post.
JSON LibraryCurrently, there are 3 choices that I know of: JSON Framework: I used this one in one of my projects, and did not run into problems. Recently after the update to the new SDK 2.2, you may need to make a quick change to your project as outlined at the end of this discussion. Touch JSON: This one is from the same project owners as the TouchXML. Blake Seely’s BSJSONAdditions: This one is little older and intended for the Mac originally. According to the author of the JSON Framework a little slower as per his performance benchmarks DOM XML LibraryIPhone SDK includes an event driven (SAX based) XML parser called NSXMLParser. But if you need DOM style parser, you are out of luck unless you use the libxml2 library directly. There is no MacOS X equivalent of NSXML on the IPhone. However luckily there are at least 2 options that I know of that you might use if you really need the DOM tree: TouchXML: Open source lightweight replacement for Cocoa’s NSXML cluster of classes based onlibxml2. Matt Gallagher: Wrote a lightweight wrapper on top of libxml2 and describes this in his blog entry. However note that in a memory and CPU constrained environment like IPhone, it does make more sense to use an event driven parser (probably why Apple decided not to include NSXML in the first place). There is a recent SDK sample called XMLPerformance that shows parsing large number of items in an efficient way using both the NSXMLParser and the lower level SAX parser provided in libxml2. Google Data APIsSo you would like to access Picasa, Google Calendar, Google Contacts and more… Well there is a very comprehensive ObjectiveC Client Library that you can include as a static library in your applications. Craig Hockenberry of the awesome Twitterific fame, made the source code of the Mobile Twitterific available to serve as a “Best Practices” document. There you can find how to connect to Twitter, get and post tweets etc. FlickrUnfortunately the well-known Cocoa API for Flickr is still not ported to the IPhone. However it looks like they are working on porting it to IPhone as of November 2008. Game EnginesThere are at least 3 game engines that I know of: 2D Gaming – Cocos 2D: This one is intended for 2D games, demos and other graphical/interactive applications. It is a port from the Python based cocos2d design. It uses Open ES 1.1, instead of the Quartz 2D and integrates the Chipmunk 2d physics engine. 3D Gaming – SIO2 Interactive: A 3D engine written in C using OpenGL ES. 3D Gaming – Oolong Engine: Mainly written in C++ with some ObjectiveC. Based on OpenGL ES 1.1 and includes the Bullet 3D physics engine. You can also take a look at some IPhone game source code: Tris: The source code for the Tetris clone that was pulled out of the Appstore earlier. Molecules: This is not a game, but serves as a good tutorial for OpenGL ES development. Unit Testing and Mock FrameworksAs of IPhone SDK 2.2, Apple now includes the OCUnit. This was discussed in the Stanford IPhone Application Programming course and you can download the presentation and the sample. So right of the bat you are now set up for unit testing, no more excuses. Google actually has a more comprehensive framework in their Google Toolbox for Mac that even includes support for UI testing. There is also a mock object framework called OCMock that is designed for MacOS X Cocoa, but witha little bit of work you can get that to work for your IPhone projects. September 23 Chromium 快捷键列表窗口和标签页快捷键
地址栏快捷键在地址栏,进行下列操作之一:
打开谷歌浏览器各功能的快捷键
网页快捷键
文字快捷键
查看更多快捷键
July 17 将linux-2.6.4内核移植到S3C2410摘自:http://www.cublog.cn/u2/70445/showart_1721091.html
1. 构建起环境 要使用内核,首先要编译内核。如果不选择合适的内核和编译器,就会出现错误。典型的就是如下的错误: EG: CC arch/arm/kernel/asm-offsets.s cc1: error : invalid option 'apcs' cc1: error : invalid option 'no-sched-prolog' cc1: error : invalid option 'little-endian' cc1: error : invalid option 'abi=apcs-gnu' arch/arm/kernel/asm-offsets.c:1: error: bad value (armv4) for -march=switch arch/arm/kernel/asm-offsets.c:1: error: bad value (armv4) for -mtune=switch make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1 make: *** [arch/arm/kernel/asm-offsets.s] Error 2 re:asm-offsets.s 这个文件编译出错一般是编译器问题,不要用2.95.3,用3.4.1 这里主要是编译器版本的问题,2.6内核不能使用以往的2.95.3版本的gcc,需改用3.4.1版本。关于编译器,最好不要自己做,下载网上现成的就可以了。http://www.gnuarm.com/这里有arm的编译器下载。 内核的版本对于编译倒关系不大,一般都能编译成功,而关键还在于配置。为了对s3c2410有更好的支持,建议使用2.6.10以后的版本。网上2.6.11版本用的人也挺多的,相关资料也挺多的,但是新版本对硬件的支持更好更稳定。比如在2.6.11中没有DM9000和CS8900的网卡驱动,在2.6.14版本中就已经对其支持。我选用的是2.6.14版本,现使用三星默认的配置文件arch/arm/configs/s3c2410_defconfig,顺利编译通过。 kernel: http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.11.7.tar.bz2 compiler: ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
2. 运行内核,显示调试信息 运行内核肯定没问题,但是搞不好你就出现了一下问题: Uncompressing Linux................................................................ done, booting the kernel. 就不动了,以前用2.4.18内核是可以启动的。 re:命令行的console参数错了,应该为console=ttySAC0,不是console=ttyS0。 因为2.6对2410的串口支持已经很好了,使用默认配置的话就不要去怀疑串口驱动了。问题出在命令行上,有人说我将默认的命令行改成了console=ttySAC0也还是不行。这只能说明改动了默认的命令行,只有在bootloader没有传递命令行参数给内核的时候才起作用。如果你的bootloader启动过2.4的内核,命令行参数肯定是不对的,在bootloader中将命令行改了就行了。例如:“console=ttySAC0,115200 root=/dev/ram init=/linuxrc rw initrd=0x30008000,0x320000 ”。 因为烧写bootlader麻烦,时间长,调试阶段不建议修改bootloader。我将内核中的arch/arm/kernel/setup.c文件中的parse_tag_cmdline()函数中的内容注释掉,并且配置正确的CONFIG_CMDLINE参数,即可运行。以后每当改变内核参数只要改变CONFIG_CMDLINE就可以了。(CONFIG_CMDLINE这个值可以在make menuconfig中配置,2.6.11版本和2.6.14版本配置位置有所不同,请注意)。
3. 激动的看到shell 当做完以上工作时看到内核信息哗哗哗的出来已经很兴奋了吧,我也是,但是很快你会看到下面有如下错误: Please append a correct "root=" boot option Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) re:传递一个合理的root参数,如果已经传递了,请确认内核是否支持 如果使用“console=ttySAC0,115200 root=/dev/ram init=/linuxrc rw initrd=0x30008000,0x320000”这个命令行参数,需要使用ramdisk和initrd。所以确保CONFIG_RAMDISK=y和CONFIG_INITRD=y。在“device driver”=》“Block device”下面可以配置。 这里的ramdisk是把内存块当做一个块设备来使用,相当于一个位于内存中的“磁盘分区”;而initrd就是用于初始化系统的ramdisk,用来mount真正的root。 这里使用initrd是为了调试方便,不需要使用flash和网络。一般使用是多数会用到mtd,调试时使用nfsroot,在移植完相关硬件后再来讨论。 当内核支持了以后还需要有initrd。使用网上下载的现成的,如何制作等会介绍。例如:我有一个initrd为ramdisk.image.gz,在bootloader下加载到指定的0x30800000处,然后启动内核即可。一般出现如下信息表示ramdisk加载成功了。 RAMDISK: Compressed image found at block 0 VFS: Mounted root (ext2 filesystem) readonly. Freeing init memory: 96K Warning: unable to open an initial console. re:unable to open an initial console是因为没有支持devfs。 但是又出现了“Warning: unable to open an initial console.”这个错误。难道是console的问题?no。有些initrd是用于又devfs支持的内核,所以在/dev/目录下没有设备文件。两种办法解决这个问题:1.copy设备节点;2.让内核支持devfs。两个方法没有什么好与差,只是在2.6.14版本中devfs的配置选项在make menuconfig的时候会看不到。linux除去了devfs的配置,提供了替代品udev,但是对这个不熟悉,而且听说也不稳定,所以还是打算用devfs。可以在.config文件中直接添加CONFIG_DEVFS_FS,但由于每次make menuconfig之后会重新写.config文件,每次编译要添加一次,很麻烦,所以不建议。我是把2.6.11版本中的/fs/Kconfig复制过来替换掉。这样配置的时候就能看到devfs的选项了。配置时注意还要选中“Automatical mount at boot”选项。 Freeing init memory: 80K Warning: unable to open an initial console. Kernel panic - not syncing: No init found. Try passing init= option to kernel. re:init参数没有传递,或者制作的ramdisk有问题。 XXX:目前这个地方我也没弄好。正疑惑。用别人的initrd可以,自己用busybox做的就不行。而且用别人的也不是很稳定。有可能时busybox在编译完了后没有copy相关库,需要静态编译。
当解决了以上问题之后,多数能兴奋的看到shell了。
4. 制作自己的initrd 这个initrd的制作可以参考网上一些制作floppy disk的文章。 4.1 制作一个ext2的文件系统映象 ~# dd if=/dev/zero of=ramdisk.image bs=1M count=2 ~# echo y | mke2fs -i 2000 -m 0 ramdisk.image ~# mkdir mnt ~# mount -o loop ramdisk.image mnt 这样,ramdisk.image这个ext2文件系统映象就做完了,他相当于一个磁盘分区。
5.显示自定义logo 在配置内核的时候选中了启动Logo的支持。 使用下面的方法可以将企鹅的Logo换成自己喜欢的任意图片。 首先准备一幅自己喜欢的图片,然后将背景涂成黑色。然后将该图片保存成png格式,例如linuxlogo.png。在Linux下使用下面的命令:
# pngtopnm linuxlogo.png > linuxlogo.pnm # pnmquant 224 linuxlogo.pnm > linuxlogo224.pnm # pnmtoplainpnm linuxlogo224.pnm > linuxlogo224.ppm
然后.ppm替换/usr/src/linux-2.6.8.1/drivers/后用生成的linuxlogo224video/logo/logo_linux_clut224.ppm(最好先做好备份),然后删除同一目录下的logo_linux_clut224.c文件,重新编译内核,启动之后就可以在屏幕左上方看到自己的Logo了。 May 30 介绍qmakeqmake是用来为不同的平台的开发项目创建makefile的Trolltech开发一个易于使用的工具。qmake简化了makefile的生成,所以为了创建一个makefile只需要一个只有几行信息的文件。qmake可以供任何一个软件项目使用,而不用管它是不是用Qt写的,尽管它包含了为支持Qt开发所拥有的额外的特征。 qmake基于一个项目文件这样的信息来生成makefile。项目文件可以由开发者生成。项目文件通常很简单,但是如果需要它是非常完善的。不用修改项目文件,qmake也可以为为Microsoft Visual Studio生成项目。 qmake的概念QMAKESPEC环境变量举例来说,如果你在Windows下使用Microsoft Visual Studio,然后你需要把QMAKESPEC环境变量设置为win32-msvc。如果你在Solaris上使用gcc,你需要把QMAKESPEC环境变量设置为solaris-g++。 在qt/mkspecs中的每一个目录里面,都有一个包含了平台和编译器特定信息的qmake.conf文件。这些设置适用于你要使用qmake的任何项目,请不要修改它,除非你是一个专家。例如,假如你所有的应用程序都必须和一个特定的库连接,你可以把这个信息添加到相应的qmake.conf文件中。 项目(.pro)文件一个项目文件是用来告诉qmake关于为这个应用程序创建makefile所需要的细节。例如,一个源文件和头文件的列表、任何应用程序特定配置、例如一个必需要连接的额外库、或者一个额外的包含路径,都应该放到项目文件中。 “#”注释你可以为项目文件添加注释。注释由“#”符号开始,一直到这一行的结束。 模板模板变量告诉qmake为这个应用程序生成哪种makefile。下面是可供使用的选择:
“app”模板“app”模板告诉qmake为建立一个应用程序生成一个makefile。当使用这个模板时,下面这些qmake系统变量是被承认的。你应该在你的.pro文件中使用它们来为你的应用程序指定特定信息。
你只需要使用那些你已经有值的系统变量,例如,如果你不需要任何额外的INCLUDEPATH,那么你就不需要指定它,qmake会为所需的提供默认值。例如,一个实例项目文件也许就像这样: TEMPLATE = app 如果条目是单值的,比如template或者目的目录,我们是用“=”,但如果是多值条目,我们使用“+=”来为这个类型添加现有的条目。使用“=”会用新值替换原有的值,例如,如果我们写了DEFINES=QT_DLL,其它所有的定义都将被删除。 “lib”模板“lib”模板告诉qmake为建立一个库而生成makefile。当使用这个模板时,除了“app”模板中提到系统变量,还有一个VERSION是被支持的。你需要在为库指定特定信息的.pro文件中使用它们。
“subdirs”模板“subdirs”模板告诉qmake生成一个makefile,它可以进入到特定子目录并为这个目录中的项目文件生成makefile并且为它调用make。 在这个模板中只有一个系统变量SUBDIRS可以被识别。这个变量中包含了所要处理的含有项目文件的子目录的列表。这个项目文件的名称是和子目录同名的,这样qmake就可以发现它。例如,如果子目里是“myapp”,那么在这个目录中的项目文件应该被叫做myapp.pro。 CONFIG变量配置变量指定了编译器所要使用的选项和所需要被连接的库。配置变量中可以添加任何东西,但只有下面这些选项可以被qmake识别。 下面这些选项控制着使用哪些编译器标志:
下面这些选项定义了所要连编的库/应用程序的类型:
例如,如果你的应用程序使用Qt库,并且你想把它连编为一个可调试的多线程的应用程序,你的项目文件应该会有下面这行: CONFIG += qt thread debug 注意,你必须使用“+=”,不要使用“=”,否则qmake就不能正确使用连编Qt的设置了,比如没法获得所编译的Qt库的类型了。 May 29 编译meshlab 1.21全接触1. 编译环境: a. visual studio 2008 perfessional edition,因为已经安装了sp1,所以不确定它会对编译有何影响。 b. QT opensource v4.5。0,只编译了其动态库文件(静态库无法编译完全)。 执行“Visual Studio 2008 命令提示 ”控制台工具后,在QT根目录执行QT编译环境设置脚本,该脚本同时为meshlab生成vc 项目工程的环境。一下为该脚本原文: @echo off set cur_dir=%cd%\ set QTDIR=%cur_dir% set QMAKESPEC=win32-msvc2008 set ConfPara=-debug-and-release -opensource -fast -no-dbus -no-webkit
set PATH=%QTDIR%/bin;%PATH% set INCLUDE=%MINGWDIR%/include;%QTDIR%/include;%QWTDIR%/src;%LOG4QTDIR%/src;%INCLUDE% set LIB=%MINGWDIR%/lib;%QTDIR%/lib;%QWTDIR%/lib;%LIB%
echo *********************************************************************** echo Created By gmail:bygreencn.gmail.com echo Includes : QT 4.5.0、Visual Studio 2008 echo QT : %QTDIR% echo QMAKESPEC: %QMAKESPEC% echo ConfPara: %ConfPara% echo *********************************************************************** @REM pause @REM nmake clean @REM nmake confclean @REM configure.exe %ConfPara%
@REM pause @REM echo build it now? @REM nmake clean cmd /k
c.下载MeshLab's source code version 1.2.1,我下载的是All Inclusive package 2. 生成所需的VC项目工程文件 a. 上一步的控制台,进入.\ meshlab\src\external,执行qmake -tp vc -recursive external.pro b. 上一步的控制台,进入.\ meshlab\src,执行qmake -tp vc -recursive meshlabv12.pro 3. 编译meshlab a. 首先编译external library。用vc打开.\ meshlab\src\external\external.sln,进入配置管理器,选择编译debug或release版本,在选择生成解决方案,等待编译全部通过,它会生成三个库文件。bz.lib,3ds.lib和muparser.lib,我发现3ds.lib的生成有些问题,会使得meshlab在LINK时无法正确连接函数,我在lib3ds\type.h做了一下修改: //#ifdef _MSC_VER //#ifdef LIB3DS_EXPORTS //#define LIB3DSAPI __declspec(dllexport) //#else //#define LIB3DSAPI __declspec(dllimport) //#endif //#else #define LIB3DSAPI //#endif b.编译meshlab:meshlab所有的plugin工程的设置有些问题,这些工程都制定输出为动态库,但是输出文件却指定为输出为*****.lib,这导致所有的plugins的工程都失败。我的做法是把指定输出为*****.dll,这里应该必须为dll,因为New的对话框中会根据plugins文件夹下的内容动态生成,因为这些应该也是动态加载的,因为静态库是不行的了。 1). 需要为io_lib指定其需要的lib3ds.lib(external library) 2). 需要为io_epoch指定其需要的bz2.lib和头文件的位置(external library) 如果哪个plugin工程出现类似这个错误: 1>Project : error PRJ0019: 某个工具从以下位置返回了错误代码: "MOC v3dImportDialog.h" 1>项目: warning PRJ0018 : 未找到下列环境变量: 1>$(QTDIR) 只需要用生成VC项目的那个控制台环境进入相应的plugin目录,执行qmake -tp vc -recursive xxxxxx.pro来重新生成该工程即可。
编译整个项目,大概需要十多分钟。然后就可以进入.\meshlab\src\meshlab\debug或者.\meshlab\src\meshlab\release执行meshlab.exe;记得要把QT的DLL库文件拷贝到这个目录或者将QT的DLL库所在目录加入到系统PATH中啊。
May 13 破解无线路由器密码Posted by chinahang 2009年5月13日
随着社会的进步!WIFI上网日益普及,特别是大城市中随便在一个小区搜索一下就能找到好多热点,搜索到热点然后链接上去那么我们就可以尽情的享受免费上网服务了。 破解静态WEP KEY全过程
发现 首先通过NetStumbler确认客户端已在某AP的覆盖区内,并通过AP信号的参数进行‘踩点’(数据搜集)。 通 过上图的红色框框部分内容确定该SSID名为demonalex的AP为802.11b类型设 备,Encryption属性为‘已加密’,根据802.11b所支持的算法标准,该算法确定为WEP。有一点需要注意:NetStumbler对任何有 使用加密算法的STA[802.11无线站点]都会在Encryption属性上标识为WEP算法,如上图中SSID为gzpia的AP使用的加密算法是 WPA2-AES。 破解下载Win32版AirCrack程序集---WinAirCrackPack工具包(下载地址:http://www.demonalex.net/download/wireless/aircrack/WinAircrackPack.zip)。解压缩后得到一个大概4MB的目录,其中包括六个EXE文件: aircrack.exe 原WIN32版aircrack程序 airdecap.exe WEP/WPA解码程序 airodump.exe 数据帧捕捉程序 Updater.exe WIN32版aircrack的升级程序 WinAircrack.exe WIN32版aircrack图形前端 wzcook.exe 本地无线网卡缓存中的WEPKEY记录程序
我们本次实验的目的是通过捕捉适当的数据帧进行IV(初始化向量)暴力破解得到WEP KEY,因此只需要使用airodump.exe(捕捉数据帧用)与WinAircrack.exe(破解WEP KEY用)两个程序就可以了。 首先打开ariodump.exe程序,按照下述操作:
选
择‘Key size’为64(目前大多数用户都是使用这个长度的WEP
KEY,因此这一步骤完全是靠猜测选定该值),最后单击主界面右下方的‘Aircrack the
key…’按钮,此时将弹出一个内嵌在cmd.exe下运行的进程对话框,并在提示得出WEP KEY: 利用打开无线网卡的连接参数设置窗口,设置参数为: SSID:demonalex 频道:6 WEP KEY:1111122222(64位) OK,现在可以享受连入别人WLAN的乐趣了。 April 28 让VS 2008支持Subversion插件AnkhsvnVisual
Studio 2005 有一个开源的Subversion插件,Ankhsvn
(http://ankhsvn.tigris.org/),安装后,VS
2005中将内置Subversion的支持,可以直接在VS里面提交修改。我经常用它和TortoiseSVN
配合来使用Subversion,十分方便。
再次打开Visual Studio 2008后,就会发现Ankhsvn已经集成进系统了。 Dim shell, filename, fso, file, content Set shell = CreateObject("wscript.shell") Set fso = CreateObject("Scripting.FileSystemObject") filename = "ankh.reg"![]() shell.run "reg export HKLMSOFTWAREMicrosoftVisualStudio8.0AddinsAnkh " & filename, 1, True![]() Set file = fso.OpenTextFile(filename, 1, False, True) content = file.ReadAll content = Replace(content, "VisualStudio8.0", "VisualStudio9.0") content = Replace(content, ".NET 2005", ".NET 2008") file.Close()![]() Set file = fso.OpenTextFile(filename, 2, True) file.Write content file.Close()![]() shell.run "reg import " & filename, 1, true![]() fso.DeleteFile filename |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|