Monthly Archives: January 2014

Re-flashing from custom install of OpenWRT

I have acquired a collection of Linksys WRT54GL routers to use as wireless bridges – with only one seemingly small task to do – reflash them with a firmware of my choice. Easy, I thought!

It turns out that the routers had a custom firmware on, that even after a 30/30/30 reset, they didn’t allow the facility to flash the firmware through the UI.

OpenWRT no support for flash firmware

Most interaction had to be done through the command line – here is the procedure I followed:

  1. 1. Perform 30/30/30 reset as described here.
  2. When the router is booting up after only a second or two, repeatedly press the Cisco Systems button on the front – for several seconds. This will enable Failsafe mode.
  3. Telnet into the router (after having manually set your IP address to 192.168.1.2. (If this doesn’t work you probably aren’t in Failsafe mode).
  4. Run “firstboot”.
  5. Reset the root password with “passwd”.
  6. Reboot “reboot -f”.
  7. When the router reboots, you can connect with ssh with the root user, and the password specified previously. From here you can transfer the bin file and flash (as described here or below).
  8. Use scp to transfer the bin file to the temp file system. “scp ~/Downloads/dd-wrt.v24_mini_generic.bin root@192.168.1.1:/tmp/”.
  9. Log in to router with ssh, and change into the /tmp/ directory.
  10. Rename the file, to make it a trx. “mv dd-wrt.v24_mini_generic.bin dd-wrt.v24_mini_generic.trx”.
  11. Write to linux fs and reboot “mtd write dd-wrt.v24_mini_generic.trx linux && reboot”.
  12. The router will now boot back up in dd-wrt. Yay!

 

Salesforce MIXED_DML_OPERATION error on PostInstall script in Managed Package

We’re having another strange Salesforce.com bug in work today – we distribute our product as a Managed Package, and constantly have problems with this that only show up when we upload the package.

This week’s issue is a MIXED_DML_OPERATION exception that we are getting, due to updating data in two objects, a custom setting and some PermissionSetAssignments.

We have been using the install scripts as a good way of getting around some restrictions in Salesforce (dml operations in constructors, etc.), and when shipping an updated package we need to update some data – easily done in a PostInstall script.

However, despite following the best practice of code separation using the @future annotation on functions, we are still getting a bug.

Here is the code I have built to set up the PermissionSetAssignments in the future context (which should be in a different context to the custom setting updates):

@future
private static void insertPermissionSetAssignments(Map<Id, Id> psaAssignment){
  List permissionSetAssignments = new List();
    for(Id userId: psaAssignment.keySet()){
      PermissionSetAssignment psa = new PermissionSetAssignment(AssigneeId = userId, PermissionSetId = psaAssignment.get(userId));
      permissionSetAssignments.add(psa);
    }
  insert(permissionSetAssignments);
}

As this is a PostInstall script we can’t use some of the usual hacks (system.runas) to avoid this error …

 

UPDATE!

Well, this turned out to be a bit different to what I expected. It was a test class that was causing the error – the postinstall script was fine. So to fix it, we had to write code that would check if you were inside a test or not, and react accordingly…

if(Test.isRunningTest()){
  User adminuser = [select Id from User where Profile.Name = 'System Administrator' and IsActive = true limit 1];
  System.runAs(adminuser){
    insert(permissionSetAssignments);			
  }
}else{
  insert(permissionSetAssignments);			
}

(ewwww)

Getting PS2 EyeToy working on Raspberry Pi

Finally got the EyeToy working on Raspberry Pi
EyeToy

Found the fix here, which disables fiq_split – to allow this USB1.1 device to work correctly.

Next challenge is to get the Logitech QuickCam Pro 4000 – which seems to timeout when accessed – possibly a power supply issue:

pi@raspberrypi ~ $ sudo fswebcam -d /dev/video0 -r 160x120 test3.jpeg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
--- Capturing frame...
Timed out waiting for frame!
No frames captured.

SNES emulators

Firstly, tried installing EmulationStation – got errors when trying to start it.

Then tried making a RetroPie SD card to boot from – worked – but wanted a more elegant solution.

Installed pisnes – a SNES emulator specifically designed for the Raspberry Pi. Installed fine, however when trying to run a few roms it stalled. Mario Kart works ok (but I didn’t remember MK’s graphics being that bad!)