Wednesday, August 4, 2010

iPhoDroid: My Adventure



A couple weeks ago, I heard about the iPhoDroid project. At the prospect of dual-booting my iPhone with iOS and Android, my palms got sweaty and my knees got weak. It felt like the room was spinning and my tongue got numb.

So I decided to give it a shot.

I read up about the project and the prerequisites, and got everything I needed to get this accomplished. One of the requirements was that the iPhone had to be jailbroken (check!) not by Spirit (DOH!)*. So I went through the process of restoring my iPhone to 3.1.2 and then jailbreaking with Pwnage Tool (my favorite anyway).

 *In a moment of sheer curiosity a while back, I jailbroke with Spirit...it was so easy, it made me wonder why people would go through any OTHER methods of jailbreaking. 

Monday, August 2, 2010

Motorola 68000 Programming

Funny how if you truly have an interest in something, you'll come back to it. In college, I had a terrible experience with assembly programming. My professor, who was probably a skilled engineer at work, regrettably was not a very good teacher. It was obvious that he knew the material, but could not find an efficient way to communicate the concepts to the class. As a result of that, I was kind of turned off by 68k programming.

Recently, the urge to learn assembly has crept back in my mind, and I picked up my book again and downloaded the Easy68k IDE. I'm currently strengthening my foundation of the 68k processor and microprocessors in general. Now that it's not in a forced, stressful environment, it's actually much more enjoyable. I see how this could have been fun in college, under the right circumstances lol.

Here's some progress on the subject.

Monday, July 12, 2010

Eclipse and Java for the Total Beginner

So I decided to get serious about learning Java today. I took a course in college, but it didn't really prepare me as much as I'd like. These tutorials that I found are really helpful. They are not only filling in the gaps I missed in Java and OOP, but teaching me the features and functionality of the Eclipse IDE as well.

I am getting to implement various aspects of Agile/ XP Methodologies. I'd previously read about these, but am now getting a chance to put them into practice. I am learning about Unit Testing and Test-Driven Development, by creating test cases before the classes. I am also building competency using JUnit testing framework, and the Eclipse IDE as a whole.

In addition to these video tutorials, I'm also taking online training on Principles of Object-Oriented Programming
through my job. The goal is to be a more well-rounded programmer with a strong understanding of fundamental primciples. Eventually, this will help me properly dive into Android programming as well.

Check out the Java tutorials out if you're interested!

Tuesday, July 6, 2010

Aahhhh, so THAT'S the big deal about 4G

I decided to do some reading on 4G and see what all the fuss is about.

Now I know.

If my understanding is correct, it just switches all communications to a really fast IP-switched data network. In contrast, 3G used circuit-switched technology for voice and IP for data. 4G implements VOiP for calls, so there's no need for separate networks for voice and data. And looking at the theoretical speeds (100 Mbit - 1Gbit/ sec), I can clearly see what the commotion is about. I would LOVE to work on implementing this network. Can't wait till I can at least access it here lol.

Tuesday, June 29, 2010

My iPhone 4 Story. . .

So, on June 24, the new iPhone 4 was released. I had no intentions of getting one on that day. I just said that I'd upgrade my 3G to iOS 4 and jailbreak it to get multitasking and whatnot. However, after work I decided to head to the mall anyway, just to see what was going on. I fully expected the Apple store to be sold out, and all the lines long gone.

Upon arrival at the mall, I encountered a line of people stretched all the way down the hall from the Apple store (those who had pre-ordered online), as well as another line which stretched the other way down the hall (for walk-ins). . . so I said I'd wait in line.

After waiting for about 2 hours (and getting free food, courtesy of Apple), one of the Apple store employees came out, counted the people in line, stopped at me, looked me directly in the eye with the "damn, homie" look and said "sorry dude, looks like we won't have any phones from you on back." I said ok, but decided to wait until the last one was sold before I left.

About a half hour later, he came back, counting again. This time, he stopped about 10 people ahead of me and told us that there DEFINITELY wouldn't be any phones for us, but that we could put our names on the priority reservation list to be informed as soon as the store gets more. Lots of people left at this point. But once again, I said ok, but decided to wait until the last one was sold before I left.

Ten minutes later, the regional manager, who happened to be in this particular store, comes out and says, "right now there are no more iPhones in stock, however I'm going to call all the other stores in the area an and see if they have extras that they can bring." And they did...1 hour later, I left the Apple store with my new 32 GB iPhone 4.

I wish the people standing with me in line who punked out could see this.

Thursday, June 24, 2010

Research: How to launch iOS app upon device startup

I have long been interested in the deep innerworkings of the iPhone (now iOS). I have gotten into iOS development, and poked into the process of jailbreaking and the filesystem of iDevices.

Today I was given a task to research the possibility of launching an app when the iDevice boots. I know that it is possible, since certain jailbreak apps/ processes are loaded upon startup. My digging led me to learn about daemons and how they work. This is incredibly useful to me in my quest to understand under the hood of iOS. Here are the results from my research.
  • The device will have to be jailbroken in order to have access to the filesystem. I recommend Pwnage. It takes a lot longer than Spirit, but is more secure.
    • With Spirit, you simply plug in your iPhone, open the Spirit app, press a button, and you're jailbroken. Spirit is what's called a "untethered userland jailbreak." Which means it exploits a hack in user (rather than kernel) mode in the UNIX filesystem. It therefore does not require iTunes to reboot the device and perform low-level tasks. Apple usually fills these holes in the minor updates (i.e. 3.1.x).
    • The Pwnage Tool,  builds a custom .ipsw file from an official copy. After that process is complete, you restore it to the device using iTunes. This is my preferred method. It takes about 30 minutes (maybe more), but some Pwnage jailbreaks will persist through software updates.There are Pwnage jailbreaks for 3.2 and 4.0 software already.
  • Here is a list of iOS daemons. Depending on the functionality of the app, we can delete many of these in order to clear up some overhead RAM.
  • We will have to create a daemon to launch our app. This tutorial goes into it as well as this one. The .plist will obviously have to be customized, but these two just prove that it is possible.
  • Overriding the home button is the other issue I'm researching. In addition to SBSSettings, there are other apps which allow you to associate user interactions on the screen (swipe, pinch, touching the volume display, etc) with system actions (e.g opening apps, toggling settings). More research is needed on this, but I do believe it is a feasible task.
This stuff is VERY interesting to me. I'm glad that I'm finally starting to get somewhere in my quest to understand what's happening in the system itself.

Too bad I just decided today that I want an iPhone 4. I'm almost sure they're all gone now.

Sunday, April 25, 2010

Code Specification Development

Recently I was given a unique opportunity. I was charged with the task of creating the code specification document for the official project which resulted from the proof-of-concept I developed. I was eager to take on such an assignment, as it presented a chance to learn a new area of the engineering process.

Since I'd never written one before, it took a bit of explaination from my boss for me to get the picture. Before he explainsed it to me, I had an idea, but was not completely comfortable with what I was doing.

I created an initial revision in Pages, using on a previous document as a template and screen mockups which illustrated the app's intended functionality. I went through each of the screens defined and established global variables, inputs and outputs, and specific functionality and data constructs necessary for the app to operate properly.

Being that it was a small project, the code specification didn't take long to develop. It took about a full work day to complete.

One of my favorite professors, Ben Sweet, preaches about the importance of engineering documentation. The time spent up front on providing detailed specifications saves time down the road on clarification and debugging.

I agree that this process is a necessity, and feel more well-rounded as an engineer because of this experience. It's good to have knowledge in multiple areas of development in order to be a proficient engineer.

- Posted using BlogPress from my iPhone

Monday, April 19, 2010

What is jailbreak?

OK, I obviously know HOW to jailbreak, but I'm interested to know what the actual process does to the phone. I posted on a couple forums to find my answer. Apple Developer Forums was no help (as I suspected). But the folks at Stack Overflow gave a pretty decent explanation/ discussion on the topic. Check it out! Very interesting.

Monday, April 12, 2010

POC proved the concept!

Last week I was given the responsibility of creating a proof-of-concept so that we can present to a company to try to get their business. I was a bit nervous because I had never had this type of pressure put on me. It was up to me to create an application nice enough as to capture the attention of this company and instill in them the necessity to do business with us.


Anyway, sparing you the dramatics (lol), it worked! I got word today that the company wants to move forward with us, and we'll be developing a full app for them. This is exciting for me because I built this app from the ground up. I ran into a couple of snags along the way, and worked through them by finding resources online as well as utilizing my teammates' knowledge.

The POC wasn't perfect, but it was impressive enough to get us the work. Now I'm looking forward to perfecting it for the official builds!

Wednesday, March 3, 2010

Debugging EXC_BAD_ACCESS from a NSString

While writing an iPhone application, I kept getting a mysterious crash during execution. There were no warnings or errors, but when I got to a specific point every time, it would crash. I decided to examine the console for messages. I found the message "EXC_BAD_ACCESS" there.

I Googled this message and found this site on setting the environment variables NSZombieEnabled and MallocStackLoggingNoCompact.

A little background
NSZombieEnabled - If I'm understanding this correctly, when this environment variable is set to YES, when an object is deallocated, instead of releasing it, the compiler will set its type to _NSZombie. Because the memory is never freed, the object remains on the stack, but its type is now _NSZombie. With a little command line usage, you can see where it was attempted to be freed, and whether or not it is intentional.

MallocStackLoggingNoCompact - "causes malloc to remember the caller requesting each allocation, and remembers it after the allocation is freed." (from Mac OSX Reference Library)

To set the environment variables, use this procedure:
  1. Ctrl+Click on the executable in your project
  2. Select "Get Info"
  3. Select "Arguments" tab
  4. Enter the variable information as seen in the screenshot below

Now, when I run the program, at the point of the crash, the console says:
2010-03-01 19:13:46.924 CruzNomad[7952:207] * -[CFString stringByAddingPercentEscapesUsingEncoding:]: message sent to deallocated instance 0x58448e0


At the gdb prompt, I issued the command: info malloc-history 0x58448e0. This gave me the object's allocation/ deallocation history:


Alloc: Block address: 0x058448e0 length: 64
Stack - pthread: 0xa0b33500 number of frames: 25
0: 0x98e089bc in malloc_zone_malloc
1: 0x21516aa in _CFRuntimeCreateInstance
2: 0x2152bf8 in __CFStringCreateImmutableFunnel3
3: 0x21567d9 in CFStringCreateCopy
4: 0x21742fc in _CFStringCreateWithFormatAndArgumentsAux
5: 0xdb546 in -[NSPlaceholderString initWithFormat:locale:arguments:]
6: 0xdb4d8 in +[NSString stringWithFormat:]
7: 0x23aa3 in -[BuisnessCardViewController viewDidLoad] at /Users/.../Classes/BuisnessCardViewController.m:85
8: 0x3d6796 in -[UIViewController view]
9: 0x347b4 in -[gm_menuViewController btn5_Pressed:] at /Users/.../Classes/menuViewController.m:535
10: 0x357459 in -[UIApplication sendAction:to:from:forEvent:]
11: 0x3baba2 in -[UIControl sendAction:to:forEvent:]
12: 0x3bcdc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]
13: 0x3bbb0f in -[UIControl touchesEnded:withEvent:]
14: 0x370e33 in -[UIWindow _sendTouchesForEvent:]
15: 0x35a81c in -[UIApplication sendEvent:]
16: 0x3610b5 in _UIApplicationHandleEvent
17: 0x2984ed1 in PurpleEventCallback
18: 0x2197b80 in CFRunLoopRunSpecific
19: 0x2196c48 in CFRunLoopRunInMode
20: 0x298378d in GSEventRunModal
21: 0x2983852 in GSEventRun
22: 0x362003 in UIApplicationMain
23: 0x2c8c in main at /Users/.../source/main.m:14
24: 0x2bfa in start
 
Line 7 says the problem was in line 85 of BuisnessCardViewController.m. That line is here:
fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString];

I read that the method stringWithFormat: returns an autorelease object. I had to retain the variable right after its first usage, earlier in the method.

fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString];
[fullAddress retain];

I use it a few times in the implementation file. This is the first operation I perform on it, so I decided to retain it here.

I posted this question on StackOverflow and the iPhone Developer Forums (you need a login for the latter).

Such a rewarding feeling to get an issue debugged!

Thursday, February 25, 2010

iPhone Programming Course

A while ago, I stumbled across the Stanford iPhone courses on iTunesU. The courses are videos of the actual iPhone development course at Stanford University. I used these a few months ago to get familiar with the XCode IDE and the iPhone SDK. 

Now that I actually landed a small gig as an iPhone developer, I have been thrown into the belly of the beast. Because I'm in such a fast-paced environment, I'm learning WHAT to do to get things working, but not so much WHY I'm doing it this way. I'd rather not be solely a creature of habit, and would like to understand the inner-workings of the code that I'm....coding.

With that being said, I decided to take some time and revisit the Stanford iPhone course. I believe this will be time well-spent; an investment in my future as a Cocoa/ Objective-C developer. After finishing the first episode, I feel enlightened on a couple of nagging issues I had before. I'm sure this trend will continue as I progress through the course. 

I actually found another iPhone course at RWTH Aachen (a German school). Maybe I'll check this out another time.

Friday, February 19, 2010

Random Thought

I've recently come to the realization that few things are impossible - some things just haven't been done yet. As a software engineer, my job is to figure how to do these things.

Monday, February 8, 2010

My First Deadline

The past two weeks have really introduced me to "The Fire" by which entry-level programmers are often baptized. I have been moving non-stop for 15 days straight now. On day #12 of my never-ending workweek, I was given an assignment: insert a Google Maps View on a pre-existing screen and drop a pin on a given address.....*for delivery to the customer in 2 days.

I found lots of resources online and made a few practice apps. At the end of my research, I made a proof of concept to demonstrate the requested functionality. When the moment of truth came, and I was given access to the repository with the project's source code, I felt an overwhelming sense of...well, honestly, fear. But in addition to that, I felt proud that I had made it to a point where I could be held responsible for such a task.

After I got myself together, I began to focus on the task at hand: integrating my code into the project. This would not be as simple as it seemed. I ran into lots of issues, from breaking the code altogether and having to start over and re-sync, to having it build, compile, and run but seeing no sign of my added functionality.

There was a point where it looked like I might not make it. But I stayed up all night on Saturday, and even worked all day [Superbowl] Sunday (and did not watch the game), until I got the desired results. Of course, that couldn't be the end...although I got it working on my computer, I still had trouble committing the file to the repository. I had to delete the entire project, re-sync, then copy and paste my code into the files I altered to get this resolved.

I managed to get my code checked in and made my deadline!

This is really a big deal to me. This is my first time writing code to be used professionally. It is really a confidence builder to know that the company has enough faith in me to use my code in a release on a major project. I really feel like this was a huge first step on my path to becoming a professional software developer.

Wednesday, January 13, 2010

iPhone dev position

YES! I recently got a part-time contract position as an iPhone developer with a small start-up company in the area. This opportunity is exactly what I've been looking for because I can learn Objective C and the iPhone/ iPod touch SDK. I'm not expected to know it all already, and am learning it with a few others in my shoes. Since it's part time and contract, I can still have a full-time job (which I'm still looking for btw...).

I definitely plan on learning as much as I can from this company!

Thursday, January 7, 2010

SPARKFUN FREE DAY!

I've been trying to keep this to myself, but today is the day the saints at Sparkfun are giving away $100 worth of free merchandise per customer until they reach $100k. All you have to pay is shipping! Currently, the site is down :-( but I'm waiting patiently for my turn. I just hope people are going to be honest and not cheat. I know it's inevitable with this clientele though :-\.



Here's my list:
Since I have a few PSPs, I figure I can experiment with one of them. I want to put a touchscreen on it. Seems like fun.

Anyway, wish me luck!

Update 1: :-(

Update 2: It's over. I didn't get it. Oh well. Gives me more time to plan my project instead of just impulse buying :-). I still plan on having these parts procured within the next 2 weeks.

Thanks anyway Sparkfun!