Papillio Pro – Introducing Schematic Capture

(Arrgh them damn bus taps!)

schmatic-intro

After a lengthy break from electronics (blame the wife!) I decided to get back into working with FPGA’s and the world of pain that are their woeful accompanying tools…

You can see from my earlier posts that my introduction to VHDL allowed me to produce (from scratch!) a VGA signal generator, I was left feeling that (for me personally) VHDL was not the most intuitive way of designing a circuit and I promised myself that I would have a good look at using schematic capture (basically its turning a diagram of logic blocks into VHDL).

For my first trial – and that’s what it was! I decided I’d make a simple circuit just to flash the Papilio Pro’s onboard LED a couple of times a second.  I still don’t know what it was that was holding me up for quite some time, but temporarily replacing one of the counters with a larger one fixed the problem.  Once I swapped the counter back it was still working – like it should have been all along! (I’m guessing I might have to get used to the odd bit of random behaviour)

Anyhow the basic design was simple, count the boards 32mhz clock pulses with a large enough counter and use a fairly high bit of the counters output as a driver for the LED.

Take a quick click at the image above it might help follow whats going on. A 32mhz clock has a period of 31.25ns my first guess at how many bits I’d need was spot on, the high bit of an eight bit counter driven by the high bit of a sixteen bit counter…

According to WolframAlpha 31.25ns * (2^24) comes out at just over half a second which puts us in the ballpark of perceivable flashing.

Now you’d have thought that a really very basic circuit like this could have been implemented even by a newbie in what 10 minutes? I wish!  Aside from the circuit behaving badly in real life and simulation then the same circuit partly rebuilt working – there is the little *gem* of bus taps….

Bus taps are should be a simple a way of getting (in this case) just one signal from a bus of say sixteen signals.  The big gottcha is making sure that “automatically add a bus tap between the bus and wire” is set in the add wire options.  It doesn’t actually seem to do anything when you create the bus, but it does mean that it will allow taps to be added to it, if you’ve not selected this option who knows if you can do it without destroying and recreating the bus first!  Actually placing the tap isn’t particularly intuitive either, first you have to click with the centre of the bus tap to select the bus, then you have to move the head of the bus tap exactly onto the bus and click again.  Basically the whole process is a needless ball ache (and I’m being polite here!!!)

But wait there’s more! (pain)

It took me further time and frustration to discover that the bus name and the outgoing wire (net) both have to have the same name ie:

COUNT_2_OUT(7:0) –> (the tap) –> COUNT_2_OUT(7)

It took me a while for this to dawn on me sadly… (the warnings showed a problem but could have been a LOT more useful) this seems to mean that if you want to keep an output named for example LED1 (in your constraints for example) you seem to need to put a buffer between the wire coming out of the tap and into the output marker.

I wish that were all the frustrations with their bad advert, but Xilinx’s tools are far from eXcillent with a wide range of glitches and really awkward interface design choices.

There was some good news mind, after I got my flashing LED, I decided to tie TX and RX of the USB serial channel together, just to see if I’d get anything back over USB.  To be honest between Xilinx tools and potential configuration issues with the laptops ttyUSB I wasn’t over hopeful! but get this – it work first time - no really, I was so shocked I had to throw an inverter into the mix to check I got rubbish back for fear it was just a local echo!

So my conclusions – well I think you know my thoughts on Xilinx’s tools – its a shame they don’t grok the advantages of open source, it would improve their tools and make them a bunch more money, but ah well I digress – I definitely do see the advantage of using schematic capture (for me personally its a lot more intuitive) and my next task I’m going to set myself is converting a VHDL snippet into a working library symbol (I’m thinking UART here) – Wish me luck! :)

 

Posted in Uncategorized | Leave a comment

GreaseMonkey gottcha – script not triggering ?

In the unlikely event you haven’t discovered GreaseMonkey it’s ideal for tweaking the presentation of a website to suit your own taste.

A good example of this would be the ad sponsored block of links typically at the top of the list of search results.  These are often presented in a box with a subtly different background colour, alas this colour is usually so subtle that especially on a laptop screen you can’t see it! (if I was suspicious I’d think it was done that way on purpose!)

Doing a quick hack for this rather than searching for someone else’s script is probably quicker and certainly good practice.

My search engine of choice is startpage and I was scratching my head trying to figure out why the script wasn’t being triggered – then I looked again at the URL (check the page info when right clicking on the page with firefox)

https://startpage.com/do/metasearch.pl

The thing here is the second slash after the domain name I’d assumed that the filter https://startpage.com/* would basically capture everything – turns out this isn’t sufficient and https://startpage.com/*/* is what’s required.

Just one more minor irritation is that ID attributes are *supposed* to be unique within a document, however the div at the bottom of the results also shares the same ID.  While there are facilities to get arrays of all tags with shared class attributes, as far as I’m aware this is not the case with ID’s.  I decided to just brute force through all the div tags in a document searching for the same target ID, there may well be a more elegant way to do this but what the hey it works!

I’ve included the script here for anyone who’s not used GreaseMonkey but fancies a play…

// ==UserScript==
// @name        startpage ad
// @namespace   codifies@bedroomcoders.co.uk
// @description makes the background for the ad links actually visible
// @include     https://startpage.com/*/*
// @version     1
// @grant       none
// ==/UserScript==

//var el = document.getElementById("sponsored_container");
//el.style.backgroundColor = '#8080ff';

// *sigh* all id's *should* be unique

var all = document.getElementsByTagName("div");

for (var i=0, max=all.length; i < max; i++) {
     if (all[i].id=="sponsored_container") {
       all[i].style.backgroundColor = '#a0a0ff';
     }
}

 

 

Posted in Uncategorized | Leave a comment

SpritePlacer get physics

SpritePlacer

While far from complete, SpritePlacer now has physics.  Each sprite can have multiple physics shapes added to it.  This allows you to have sprites that aren’t rectangular.  You can see an example of this on the left (click to enlarge), the dumbbell shapes each have three physics shapes.  Two spheres and a rectangle are sufficient to make the collision shape for the sprite.  In addition to the collision shapes (and properties like restitution friction and density) its also possible to have different body types, as well as static and dynamic bodies you can have kinematic bodies.  While there isn’t much use for kinematic bodies at the moment they might be quite useful once I’ve implemented scripting.

There is a bunch of stuff still to implement physics wise and I’ll be resetting sprite positions once the editor is put back into edit mode after “running” the physics.

While I initially just wanted a way to place a bunch of sprites in a “level”, by the time I’ve added physics and scripting I’ll have in effect a 2d game creator.  I’m not sure just yet what events to support (collision, level loaded etc) but its funny how a simple project can gradually evolve into something else altogether!

Posted in Uncategorized | Leave a comment

SpritePlacer a level editor

Straight off the code is at https://github.com/chriscamacho/SpritePlacer As its using libGDX its cross platform, however if you want it to work on a Mac or Android device you’ll need to add your own simple platform stub.

There is nothing special about this simple level editor but it does boast a rudimentary file selection dialog, which is separate enough that you should be able to very easily integrate it into your own projects.

I have to say that I struggle somewhat with libGDX’s GUI as do anything in the wrong order and all sorts of odd things happen! This isn’t helped by the far too sparse javadoc and a wiki that usually just shows you a small bit of code instancing some widgets but not really using them or explaining how they are intended to be used…

But still you can usually bully it (eventually) into some sort of behaviour even if you’re unsure you’re using it in the right way!

LibGDX’s Sprite class is wrapped into a pixy class to store extra properties and also utility functions and a static list of all created pixies.

I chose to save and load from XML and while its only a single layer of hierarchy I still found XML useful.

Saving was by far the easiest task after dumping a very simple header its quite straight forward to iterate in turn through each pixy. The pixy class has a simple method to dump an XML representation of itself to a string.

Loading was a little more complex but I used the built in SAX parser as it doesn’t load the whole document into memory as an object.  The SAX parser uses callbacks as its traversing the document, which once you get your head round actually makes like easier.  Still that said saving is a one paragraph method and loading is a whole multiple method class in its own right!

Although probably not an ideal example of an XML parser, its probably a fair real world example to inspire your own parser (off the top of my head I can think a few ways to improving it – oh dear there I go again wanting to fix working things!)

In the future other than on going tidying I plan to add some kind of more useful user defined data than just a string and may also consider adding scripting and even box2d support.

Development is rather sporadic, but then no one knows about it to contribute so its just me when I get chance…

 

Posted in Uncategorized | Leave a comment

Debians “handy” fstab entries

Having just installed Debian (XFCE) on my “new” SSD (and boy does it fly! AND I get an extra hour out of the battery!) I hit a rather irritating puzzle.

Whenever I mounted a USB stick is was mounted without write permissions (rather infuriating as it kind of defeats the purpose of *convenient* portable storage) – Well as you do, I fiddled, googled, swore and then by chance happened to plug in a second USB stick and low and behold that had proper permissions, with a little experimentation I also discovered if I inserted them in a different order the original stick could get proper permissions (providing another had broken permissions)

eventually noticed that some where mounted in

/media/usb0

and some where in

/media/<username>/<uuid>

Well what’s going on here two automount deamons fighting? what?

Eventually I tracked it down to entries for /media/usb0 etc. in /etc/fstab, now I always thought that fstab was really only for fixed none removable devices that *needed* to be mounted at boot time.  Frankly I’d expect better of people from Debian I mean the person who wrote the line to mount /media/usb0 in fstab what, oh what, were they thinking – simply not the place to do it!

Fortunately like most issues in Linux once you know what the issue is, fixing it is trivial – in this case simply removing the misconfigured lines in fstab made the issue go away, now everything is happily mounted in

/media/<username>/<uuid>

where it should be and with the permissions it should have….

 

Posted in Uncategorized | Leave a comment

Whats worse that secure boot ? a badly implemented bios !

NB if you’ve landed here from a search, because you have this issue read below about using a usb keyboard…

All in all I’m very happy with my Fujitsu Lifebook AH532, it’s got a great little cpu with a gpu (HG4000) that’s got plenty of grunt, does all the OpenGL experimenting I throw at it an can even play quite intensive games…

The only one real fly in the ointment is the BIOS, seems if you change your hard drive you are forced to install the new OS in EFI mode (bios mode boot install fails to be booted by the bios) having then installed an EFI bootloader, you can’t get into the BIOS…

A quick google will tell you that its a well known about issue and needs a reflashed BIOS – slight issue you can’t get into the boot menu either, so you have to reset this NVram – great news the two pads you have to short are under the memory – real handy that (still tempted to solder some wires on them and bring it out into a switch (probably in the HD bay) for easier access.

Anyhoo long story short I had allsorts of problems getting back access to by BIOS eventually eventually downgrading to the previous version of the BIOS….

At one point the keyboard wasn’t working at which point I found I could get into the BIOS with a USB keyboard – joy of joys! Now I was in the rest of the laptop to get back a broken tag of plastic that was rattling about and I did reseat the keyboard connector so I can’t tell for sure if that was the issue, but…. I can’t help but think that maybe the inaccessible BIOS and boot menu bug is because the built in keyboard isn’t properly initialised – you will get a beep because its registering a key press – just the wrong one…

If someone does install Linux on a new hard drive and has these same issues, before flashing your BIOS can you try getting into the BIOS with a USB keyboard – if it works or not please DO TELL me by leaving a comment here…. (ta!)

I now finally have a machine booting in BIOS mode (ie grub-pc not grub-efi) and I have access to the BIOS and boot menu… and the really good news – it actually was worth the hassle this SSD I install gives me a 7 second boot time (not that thats important) but it gives an indication of how zippy my machine is…

 

Posted in Uncategorized | Leave a comment

Configuring Alps laptop touch pad

Here mainly for my own historical notes (but if you happen to drop in here via google – you’re most welcome!) is how I configured my Alps touch pad to do tap clicks, middle button and scrolling etc…

First of you’ll need dkms

sudo apt-get install dkms

dkms is rather handy and will automagically(tm) compile and install from source code kernel modules when you install/upgrade a kernel package…

You’ll need the source from http://www.dahetral.com/public-download at the time of writing the source is at version 1.3.   You should end up with the source in usr/src/psmouse-alps-1.3 if you like this can be a symlink to your own development folder…

It behoves me to thank both the original creator and current contributors of this and wonder why it isn’t just part of the kernel source….

Then its just a case of telling dkms where it is and to get on with it…

sudo dkms add psmouse/alps-1.3
sudo dkms autoinstall
sudo rmmod psmouse
sudo modprobe psmouse

Just a quick note – while you can sudo su and execute the above commands without sudo, I prefer not to as its all too easy to forget to exit the su session and end up doing unintended things still using the root account…

While there are skeleton Xorg configs to use in /usr/share I found a more comprehensive example below – while not all of the features work on my hardware they might work for others…

On Debian testing (jessie) I had to create the following directory

 sudo mkdir /etc/X11/xorg.conf.d

into which I dropped the following config file (50-synaptics.conf)

Section "InputClass"
 Identifier "Touchpad" # required
 MatchIsTouchpad "yes" # required
 Driver "synaptics" # required
 Option "MinSpeed" "0.5"
 Option "MaxSpeed" "1.0"
 Option "AccelFactor" "0.075"
 Option "TapButton1" "1"
 Option "TapButton2" "2" # multitouch
 Option "TapButton3" "3" # multitouch
 Option "VertTwoFingerScroll" "1" # multitouch
 Option "HorizTwoFingerScroll" "1" # multitouch
 Option "VertEdgeScroll" "1"
 Option "CoastingSpeed" "8"
 Option "CornerCoasting" "1"
 Option "CircularScrolling" "1"
 Option "CircScrollTrigger" "7"
 Option "EdgeMotionUseAlways" "1"
 Option "LBCornerButton" "8" # browser "back" btn
 Option "RBCornerButton" "9" # browser "forward" btn
EndSection

You should only need to restart your xorg session (log out and back in) but if you want to be paranoid you can do a windows (reboot)

While corner buttons don’t work for me, the useful bits like 2 finger scrolling and best of all middle and right mouse button clicks (2 or 3 finger tap) all work great! double tap and drag all in one gesture will also allow selecting too.

Enjoy!

 

Posted in Uncategorized | Leave a comment

Microsoft helping Linux again…

Well I thought it might be the case and from my recent experiences it seems that yet again Microsoft have shot themselves in the foot. With coming so late to the mobile arena (and by mobile I mean tablets etc as well as phones) MS now seem to be wanting to force their desktop users into a touchscreen / mobile paradigm regardless as to whether that’s appropriate or even useful for their workflow. Given that the hardware requirements for their new OS are so redonkulous, the dropping of XP support has conspired to make the perfect storm which has no doubt blind sided MS.

I’ve noticed in conversation for a while now that people are generally uneasy with the direction computing is heading, whether its the future plans for the MS app store (have no illusions that before long it will be the only way you can install/publish software) or the absurd notion that TV advertisers would have us believe – that you MUST throw away old but perfectly functioning and usable hardware.

It’s from this perspective that I’ve heard increasing interest in Linux, for some its just replacing XP and for others its finding out if they might be able carry on their favorite activities but without MS.

At this point its well worth following an aside and asking does the lack of XP support really matter? Here’s a little thought experiment (which you could try if bored!) Take an unpatched original release of the XP install disk, after doing a default install connect the machine to the internet. Without the need to even browse any dodgy sites, just sat there connected to the internet, I would seriously doubt your experiment would last 10 minutes without being exploited – from now on your machine is helping with DDoS attacks or worse helping people anonymously download the most vile illegal material hopefully beyond your imagination …

This somewhat sobering look of what can happen to a machine without support shows what is to come for XP. I have no doubt that already there are some dodgy sites selling script kiddies nicely prepackaged tools that will scan for and use exploits that MS probably do know of but are now doing nothing about. As anyone who’s used Linux regularly knows this is where Linux scores very highly over Windows (any iteration) not only are updates much more frequent but they are much less of a drama even allowing the practical use of your machine (while they happen) and not necessitating the crossing of fingers.

This is one of the corner stones of security the prompt and frequent patching of exploits or even potential exploits.

So could MS have avoided all this? Well, yes actually – you see for years now MS have viewed an OS as some kind of “experience” (remind me what does XP stand for?) in reality all many of us want is a way to launch applications and a glorified file manager… and if a company really can’t make this run on even really modest hardware, even including an app store, then you have to wonder have they lost the ball let alone dropped it….

 

 

 

Posted in Uncategorized | Leave a comment

Olimex A20 battery consumption

2014-03-07-235844_1366x768_scrotStill no enclosure or firm idea of what I’m putting in it, but a keyboard does look certain!

The first power consumption test I did using a 6600mah (3v7 LiPo) is shown with the brown line, because I was running the LCD backlight at 100% and using a conventional laptop hard drive the power circuit called a halt when the battery was still half charged. I strongly suspect that I was simply drawing too much current for the battery to deliver as it became more depleted.

For the second test (in blue) I used a less retina burning but still quite readable 40% backlight and a solid state hard drive I managed to ride the battery all the way down to 11% with a total duration of over four and a half hours.  Although I’m probably putting a bit more of a drain on the battery than I should, I can set an alarm for 30% and shutdown at 20% and still get a little over four hours battery life, not too shabby.

The (power management) reported current is shown in orange, presumably the current is on an upward slope as the battery delivers decreasing voltage…

During these test, the system was put under a low load (10%-20% single core use) grabbing a web page once every 90 seconds, the readings were take once a minute. As the usage was continuous this for me gave an automated rough equivalent of normal use by an actual user, doing browsing and office type activities – ie not 100% on all cores compiling a kernel, while running an immersive 3d first person perspective shooter!

 

 

 

Posted in Uncategorized | 3 Comments

Olimex A20 GLES2.0 and Open Dynamics Engine

Threw this up cause its what I do almost any new platform I explore ;)

I’m in the process of converting my GLES2.0 framework away from GLFW and back to Xlib as I’ve had different issues with different embedded platforms using GLFW, oddly I’ve not seen these issues with my Xlib code…

The Allwinner A20 board here is showing 128 moving “3d” objects falling on a (very) simple mesh, the shaders in use are very simple texture and single light point shading with ambient lighting.  This is running on top of Debian (armhf) running LXDE.  This isn’t pushing a single thread to its limit on this platform and if I separated the dynamics and rendering into their own threads I could probably get 50% more performance (at a guess!)

If you’re interested in the Allwinner A20 be sure and checkout my previous two posts…

Posted in Uncategorized | Leave a comment