Archive for category Uncategorized

CyanogenMod 11 Nightly on a GSM Galaxy Nexus

I have a Galaxy Nexus, and have been pretty happy with it.  Then Google said it wouldn’t update the Galaxy Nexus to 4.4, and 4.4 is all swanky and new and most importantly, supports low memory devices better. So I want it. And guess what? CyanogenMod is pushing out 4.4 in CM11.

The real push for me to flash it is the fact that it has started dying on me – most annoyingly, the screen lit up to maximum brightness (while I was using it), then turned off. I suspect the screen just went dead, because I mashed the power button and tapped the blank screen and it vibrated at my touch, but the screen would only come back on after I pulled the battery and replaced it. Happening once is OK, I’ll chalk it up to cosmic ray events/random glitches. Having it happen 3 times in a single night is a bit much.

So it’s off to CyanogenMod!

First off, backups: I found a full backup method in an XDA thread. Reading through the thread pointed out that SMSes weren’t backed up, so first SMS Backups were handled by SMS Backup+.

Then I tried to get ADB setup. First roadblock: The Google USB Driver wasn’t in the SDK that I downloaded – had to use the SDK Manager to download it. Unfortunately, that still didn’t work, so I had to install the Samsung driver instead. I ended up with a “Samsung Android ADB Interface” entry in the Device Manager, so that was good.

However, adb seemed to have completely crashed, and it was weirdly even resistant to ending the process through Task Manager. adb.exe, java.exe and powershell.exe are all stubbornly refusing to close. This, however, was because Avast was restricting access to it, annoyingly enough. I disabled the Avast shields, and added the SDK folder as exempt from scanning.

One adb pull /sdcard/ and I had a backup of the contents of the internal SD card.  Because I had the shared stuff (I’m assuming that’s what the SD card stuff is), the next thing is adb backup -all -apk backup.ab. However, Google Music threw this for a loop here because the backup includes the cached music, so the final size of the backup was 5.11GB… which is excessively large.

Next step was actually unlocking the bootloader. fastboot required a different driver, so I ended up using the “Universal Driver” from XDA. After running fastboot oem unlock. I booted back into stock 4.2 (hadn’t flashed CM11 yet), and tried to restore my data using adb restore. It worked through ~half the apps, then died on restoring the google play store. Instead of retrying the restore, I forged ahead and flashed CM11.

I ended up using the instructions in CM’s HowTo install CM on maguro. I flashed the recovery with ClockWorkMod (discovering later that I could have actually used ClockWorkMod Touch instead), and then flashed PlayfulGod’s fork of CM11 for the Galaxy Nexus followed by flashing GApps Standard. (I specifically chose GApps standard because I wanted to get the camera APK integrated by default)

Now that I had CM11 installed, I then tried to restore my data. Which is where the weird part hit – The restore ran for a second or two, and then said “Restore completed”. After retrying a few times and getting the exact same thing, I hooked up adb logcat to monitor the restore and see what was happening.

Now I’m not too sure what was wrong, but BackupManagerService was consistently reporting “Incorrect password”. I tracked down the source, which I eventually decided that either it meant I was truly using the wrong password (I deemed this unlikely because the failed restore partially worked) or comparing the calculated key checksum with the stored key checksum failed. I heard stuff about Android’s encryption being weak, so they might have changed something, but a quick glance over the 4.2.1 and 4.4.2 BackupServiceManager files showed no obvious difference.

Whatever the case, my full adb backup was well and truly dead. So I just reverted to reloading my apps from the Play Store (ran through the list in My Apps) and waiting for the backup manager to restore whatever data Google had backed up. After installing everything, I restored Whatsapp from the database I backed up, and ran SMS Backup+ to restore all my SMS messages/call log from the backup.

So I had pretty much everything back where I wanted it, so the next thing in the list was to install a new kernel that would give me more RAM (since apparently TI ION maps a whole bunch of stuff into the RAM range, so the full 1GB wasn’t usable). That was a download and reboot into recovery mode to flash it, but straight forward since I’d already been poking around CWM.

And that was pretty much that. A shiny new (clean) install of Android 4.4.2 on an older phone, that actually revitalized it.

Future stuff:

  1. Use ClockWorkMod Touch instead of the standard ClockWorkMod (since my volume up button is broken, and scrolling through the list is tedious)
  2. Install the Genie widget to get the stock weather/news widget back
  3. In case I ever need it, recovering data from the internal memory
  4. List of potentially useful GNex resources

, ,

No Comments

Getting Django running on CentOS 6

Trying to follow this guide:

epel6 rpms only seem to install 8.4 at this time, not 9.3 (strangely, since 8.4 isn’t supported anymore, so… I have many questions)

Official 9.3 installation go!

But WTF1: It was installed to /usr/pqsql-9.3, which wasn’t in the search path, so all the createdb and etc commands didn’t work.

Had to su postgres, cd /usr/pgsql-9.3/bin, ./createdb trailstest, ./createuser -P -s trails

And I only discovered it was in /usr/pqsql-9.3 because I did rpm -ql postresql93-server

yum install virtualenv step went fine

yum install libpq-dev python-dev was wrong, yum install postgresql93-devel python-devel was the correct command

pip install psycopg2 failed because pg_config wasn’t in $PATH – surprise surprise. export PATH=$Path:/usr/pgsql-9.3/bin fixed that… (Also, I discovered that there’s no spacing for a reason! Bash syntax!)

And then I got a gcc not found message. My bad, though it’s not a dependency of python-devel? a yum install gcc later, and we’re good…

And now it’s password authentication. I created a user, but it’s not working… even root is failing…

>Pizza Interlude<

So, had “Peer authentication failed” messages, and “Ident authentication failed” messages. I fixed the issue – remove everything from the config file, it defaults to connecting over the local UNIX socket, and using the username which it is running as, so the user has to exist in postgres. If I want it to work with a specific username/password combination, I’d have to edit the hba.conf file to get any other authentication scheme running.

Trying to get DNS working… new domain isn’t resolving on the UWaterloo DNS servers, but it’s showing up on other servers. Trying to get dig installed, but I’m getting yum timeout errors. Realised belatedly that I blocked outgoing HTTP connections. Rerun iptables rule adding with dport and sport swapped for input and output. Now everything is working, dig is showing the domain is resolving, so I’m just going to wait a while for UW to realise that a new subdomain exists…

Gunicorn is complaining about missing django project files when I try to run it and bind to port 8001. Mkay, noted. The Django dev server (python runserver gives me a
working page, and I can get to it, so Django is set up! Wohoo! Time to get some GPS encoded in EXIF images up…

No Comments

On LED driver chips

I have found the TLC5940 chip, which I thought would solve my problems. It didn’t, not all of them, or at least there are a few downsides to it.

The main one being the timing requirements.

The 5940 kind of does PWM. It doesn’t have an internal clock, so it relies on an external clock signal. Generating that signal is tricky in my case, because I was planning to do Pi -> TLC chips -> LED, with the added complexity of multiplexing being thrown into the mix. These chips are designed for stuff like driving LED displays – single layer stuff, not 8 layers deep. And I’m switching between layers, not doing one layer completely then moving on. So the benefit of the chip doing PWM is lost, because I need to update the information in the chip each time I move to the next layer.

In terms of timing, the Pi can only do a max of 2Mhz, and that was measured in a infinite loop that just switched a single signal on and off. To get smooth motion, I’d need to do at least 24Hz refresh rate (guesstimate, based on movies). Because I have 8 layers, that becomes 192Hz. The chips take a 12 bit brightness value for each LED, and it’s serial in, so I’d need at least 192 clock cycles to get all the information in, not counting blanking/starting signals. So that gets us to ~37kHz.

My worry is that the Pi’s setting of pin output levels is synchronous, so I have to wait for 1 pin to go high/low before moving on. If the Pi can endlessly do one complete cycle at 2Mhz, I now have 16 outputs I need to cycle. Which isn’t too bad, that gets me ~167kHz cycles, not counting the clock signal generation. To make the math nice, I shall assume I have a round 20 outputs each cycle (I’ll have at least 1 – the clock signal for the chips), so it becomes 2000kHz/20 = 100kHz. However, a quick bit of calculation shows that I could do 60Hz refresh rate, and that’d need a ~92kHz data transfer rate, so I’m still within boundaries. It would just take an extra bit of complexity in the code.

But why is this a concern? The timing requirements are a lot tighter than if I was using a basic shift register. That generally takes in 8 bits at a time (serially), and outputs in parallel – so the requirements of 192 clock cycles to put in all the information would drop to 1/24th. While it’s only 8 bits/chip, chips can be chained to get the 16 bits. But the timing requirements would still be only 1/12th of what using the 5940 needs. And there’s known to be kernel glitches that affect the output – where the pins lock for ~500 microseconds periodically, presumably because of background processing. I’d be nice-ing the program running on the Pi, clearly.

Also, the fast timing requirements may give me the chance to implement 192 level fading – or 7.5 bits of brightness control, because I could hook up the PWM counter/clock to the same line that drives the input clock, so every input cycle is one PWM cycle, which would get me the 192 levels of brightness. Bitmasking and other bit-level screwery would be required though – though that’s more experimenting than anything else.

However, the pros of the 5940:

  1. Built in current limiter – no need for an extra resistor
  2. Single chip gives you 16 outputs
  3. Free from TI’s lovely wonderful sample program, thanks to the fact that I’m in uni.

Possible explorations once I finish the cube include looking at driving the cube standalone with an Arduino clone, and other stuff as I think of it…

No Comments

Django development on Heroku

Because the setup doesn’t match the ‘quick start’ guides…

First, get the dev environment up. I’m using Fedora 17.

  1. The toolbelt install didn’t get properly setup – bash couldn’t find heroku. It was putting it into the $PATH in .profile, but I’m not sure if Bash on Fedora sources that file. Ended up adding an alias to .bashrc: “alias heroku=/usr/local/heroku/bin/heroku”
  2. Installing psycopg2 from pip failed. First it wanted gcc, then postgresql-devel to be installed. (Hat tip to Stack Overflow for the solution.)
  3. PostgreSQL on Fedora didn’t want to start/appear in systemctl until I ran postgresql-setup initdb. This was possibly because I was typoing it, but I’m not sure…
  4. I had to activate PostgreSQL through the addons panel in Heroku, it wasn’t automatically activated. Then again, apparently once a Django application is detected, a database is automatically setup.
  5. Because I used Heroku on another system, ssh keys were setup. Added the dev one with heroku keys:add.
  6. Despite adding the PostreSQL addon, I had to ‘promote it’ to the primary database; it wasn’t done automatically.

The rest of my problems were django based. (Also, unexpectedly long commitments. Oh well.)


No Comments

Nginx & php-fpm configuration

Edit: Everything below is pretty much superseded by a new post.

php-fpm: /var/lib/php/session was owned by root:apache, so php-fpm couldn’t create session files. Fix was chgrp nginx /var/lib/php/session. For some reason, after doing  yum update, /var/lib/php/session was changed back to root:apache, but that was only noticed on one system so far, haven’t observed it on others, but also haven’t looked for it.

nginx: By default, index.php files aren’t though of as index files. Fix is to add ‘index.php’ to the ‘index index.html’ line.

Alternatively, autoindex.


No Comments

Review of the Manfrotto 055CXPro3

I picked up a Manfrotto 055CXPro3 tripod for Christmas 2011. At that time, I started off writing a short review of it, comparing it with my then-current 055XProB.

Amazon shipping

  • no problem, earlier than expected
  • price went up after I put it in the cart though
  • center column was damaged in transit, cosmetic marks made by the 3 legs

Tripod itself – compared to 2007era 055XProB

  • 1st impression: Locking different – not really good or bad
  • Good:
    • Covering of screws on latch is gone, washer integrated into screw itself
    • Less parts to loose is always good
  • Bad:
    • Screws to secure latch are now hex head instead of phillips head. Why? I now need a semi-specialized screwdriver to take it apart.
  • Indifferent:
    • Latch and screws on upper & lower leg segments are subtly different. Need to keep track or compare all visually before reinstallation
    • Leg segment tops aren’t molded – additional plastic part used as stoppers. This is probably a direct result of using carbon fiber instead of aluminium.
    • No hand warmers. Using it in winter… is going to be fun.

I’ve also completely dismantled it, cleaned it and rebuilt it. There weren’t any manuals, but I found a part diagram/listing on Manfrotto’s site that helped show how the part fit together. (If that link breaks, I found it under the spare parts section here.)

Took some practice, and a few missteps (particularly with the tension(?) spring securing the center column), but it ended up working fine after clearing the sand out of it. (Where I got sand on it from, I have no clue.)

Once again though, I was disappointed in the need of specialized tools. In this case, a 3/8 (I think) hex key.

, ,

No Comments

A grab bag of half-finished posts

Because I’ve started a bunch of posts, haven’t finished them, don’t really want to delete them but stuff looks potentially useful, and I’m clearing stuff out.

Read the rest of this entry »


1 Comment

Fixing the RPC: S-5:AEC-0 error in Google Play

Fix in short: switch Google Play to a different Google Account, and switch back to the original account. It can be a new Google account, or one that already exists on your phone.
I hope that helps, and if you want screenshots & more details, read on. 🙂

(Short version because, apparently, this post is #3 on Google for “Google Play RPC:S-5”, and variations thereof, and putting the fix in the description that Google will show seems like a Good Thing to Do.)
If you’re unlucky, like me, you’re getting an error like this when you try to update stuff on your shiny Android 4.1(.1) device: (Edit: Apparently, not just Android 4.1.1, I’ve seen reports of 4.2 breaking too.)

The most common ‘solution’ I’ve seen is to completely remove your Google account, and re-add it.

Which seemed a bit extreme, given that it’d (supposedly) wipe all your stuff off the phone. A solution that I stumbled upon is to simply switch to a different Google account in Google Play (Tap the options button at the top right), install an update, then switch back to your original account, and install the rest of the updates.

Yes, the third option on the list that appears. (I’m not showing my accounts screen because that has my email addresses.)

That got it working for me. It’s possible that you don’t even need to install an app in the other account – just switching back and forth might be enough to get Google Play to update whatever cached file is breaking. (I’m assuming it’s a cached file, that is.)

Apparently, this is an unexpected result of flushing and restarting the Google Services Framework in an attempt to force Android to detect/receive the update to Android 4.2. (Which, sadly, didn’t work for me, possibly because I’m on Wind in Canada. Oh well.)



The wonders of the internet

The co-op program here at UW is probably the biggest reason I chose to come here – I much prefer applying stuff I’ve learnt instead of learning all theory (why I’m in Software Engineering rather than plain CS). So as part of that, I’m brushing up my resume (and over the holidays, my personal site, and possibly this blog template, finally fix the annoying picture div problems). And as part of brushing up, I (re-)found an old thing that got published about me. Read the rest of this entry »

, ,

No Comments

Midterm week – A retrospect of my first 6 weeks of uni

So… I’m at university. University of Waterloo to be exact. It’s been almost a whirlwind – it’s both more and less hectic than IB, if that makes sense. There’s more to do – activities, events and maintenance things (laundry, grocery shopping and so on.) And the same time, there’s less – schoolwork isn’t as demanding as I found IB – fewer projects meaning less homework, minimal travel time to class. So I’ve got more free time now that mandatory stuff is reduced – but also more things to fill that free time with.

In terms of classes… well, they’re are pretty enjoyable. I’m finding CS137 the easiest coming from IB CS, followed by surprise, Math 117, aka Calculus. I’m enjoying Physics, again, thanks to groundwork in IB. Linear circuits is ok, but I’m finding the work, with all the sign changes tedious and annoying, because if you just make one mistake… yeah, you’re gone. SE 101 is the boring class – half lectures, half project. Lectures turn into what’s been termed Facebook parties, and projects are where we split off into a group and 3 people discuss stuff to do, and the other 3… well, we don’t do much. I’m hoping after midterms that’ll change though.

And the last class… Linear algebra. It’s probably my horror class – so much new stuff, and I’m not finding the textbook too helpful. I can get it in class, I understand what the prof is doing… and then when I get home and try it I’m an utter blank.

Profs are hit and miss too. though I’m not sure if that’s a result of my liking the subject or not. ECE105 & Math 117 are awesome, profs are good at making things easy. Math 115 and CS 137 are ok – profs are ok. They aren’t as interesting though. SE 101 and ECE 140 are not as great – they tend to read directly off their notes.

As for midterms, since I’m in the middle of them… So far, not as bad as I expected, but not as great as I hoped, especially Physics today. They’re sneaky and include a fifth option on their MCQ – “None of the above”. And the marking is purely correct/wrong, no partial marks due to its MCQ basis. I’ve got 2 more exams to go – linear algebra and CS. Worried about lin. alg., not too worried about CS.


And on a more personal note…

I signed up for the Made with Marmalade/Blackberry promotion to see what the Blackberry Playbook is like – they’ll ship a Playbook for free to me for 6 months, and if I publish an app on the Blackberry App World I get to keep it. Making an app is something that’d be good for a resume, so it’s win-win. (I’ve thinking of making a sudoku game, and writing it in Java so I can port it to Android because I don’t like any of the sudoku games that I’ve tried on their.)

I’m also ramping up my VPS plans and (re)creating a personal site. Most stumbling block – nginx isn’t playing well with php-fpm. I’m hoping to follow a LEB script to get it up and running. Random trivia: I’m liking Cloudflare’s Mirage and the SSL support that comes with Cloudflare Plus – at the $9.95/month it costs is more than the $9/month I’m paying for a VPS.

I’m also planning to get back into photography – time lapse astrophotography right now. I’m hoping for a clear Saturday night so I can set up my tripod and camera and let it run for a few hours. Problem of course is that I have no area to leave it overnight, so I’ll need to stick with the camera, and in the cool weather… yeah, it’s not going to be too fun. Also, something to do during that time. Staying out for 2 hours is one thing. Staying out for two hours with nothing to do… that’s another story. Thinking about it, there’s a picnic table outside my dorm, and a fairly empty patch of land with a clear view of the sky.

So, yeah… dinner time now, so I’m off. Meeting with my friends for dinner, chat for a bit, and then come back and continue linear algebra revising.

Because I’ve been using the writing of this post to distract myself from revising for it.



No Comments