Embedded Linux

Acceleration Test Functionality Implemented

Acceleration Test View - Bit messy but will do

Acceleration Test View - Bit messy but will do

Over the past day or two I’ve being working on the GUI. I changed it from my original ideas below for the moment as I simply need to get this done soon as the deadline is approaching so no fancy animations for now. Each of the panes (tabs) is a custom widget, so basically I’m using a QStackedWidget with 5 custom QWidgets in it.

Today I mainly focused on the acceleration test functionality. The look of it may not be what I’m looking for now but as I said, deadlines are approaching and functionality is the most important. The acceleration test allows one to test how quick their car can reach a specificed speed. This speed is variable to make it more flexible. It can be changed in increments of 5, using the arrows. The maximum value is 255KPH since the OBD II standard can only read up to this.
Once the user selects this speed and clicks the start acceleration test button, Automon waits until it detects the car moving > ~1 KPH (Using threshold to avoid accidental starts) and starts a timer. As soon as the vehicle’s speed reaches the specified speed, the timer will stop and flash up the elapsed time.

If the car is moving originally when the test is started, it will let the driver know and once they slow down to 0KPH and back up to 1KPH, the timer will start automatically.

I would like to add sounds to it, since the TS7390 includes a speaker but there isn’t a sound driver with the system. However it does include a playwav.c file that I can use to play wav files so I might investigate even calling this as a process using QProcess but I’ll have to see how it affects performance.

Speaking of performance, the GUI is very responsive, everything responding instantly.

Random Pauses on SBC

So it was time to cross compile the Automon project to my ARM board. It starts fine but after a while, it appears that the serial reading misses an important delimiter character ‘>’. This results in a loop to infinity searching for this character. This is obviously a very serious problem. This is my theory: Debian Etch is currently running off an SD card. At times, writes have to occur to the SD card but these writes hang the whole system. The terminal connection to it, don’t even respond at these times. So I’m guessing this happens and some how the > gets discarded or losed in the serial I/O buffer. I would have thought that the buffer would still accept characters at a hardware level but it appears not. The ELM327 sends the ‘>’ character but when a SD write occurs, this character gets refused and is dropped. Eventually my system will be running of NAND on-board flash and I don’t think this will be a problem at all, but a temporary solution will be to implement a timeout feature when searching for the > character. This may require another thread however. I’ll look into this later on.

First GUI Prototype using ElmScan 5 & QT/E 4

GUI Prototype

GUI Prototype

So today I finally decided to create a GUI application that would display the revs. The photo above is taken of the TS7390 connected to the ElmScan 5 USB and my car’s DLC. Even though it is USB, it actually creates a virtual com port so my code didn’t need to be changed from past code. The chip that does this virtual com port emulation is the FT232RL from FTDI. This is supported in Linux kernels > 2.6.9 which mine satisfies. More information from: http://www.ftdichip.com/Drivers/VCP.htm
The code took me about and hour or two, but I did have the QT serial stuff already done so that would have taken quite a bit more. This is only a prototype and cannot be used in any way in the final product. I am only doing proof of concept that I can in fact read from serial while updating a GUI.

Constraints
I noticed that if I reduced the refresh rate to 1/4 of a second, things got funny, it was missing bytes etc so the revs were all over the place. It seem to be perfect at about 300ms but that means refresh rate is only ~3Hz. This is actually quite noticeable when you rev up high quickly in neutral but on the road I’m guessing as you rev gradually in normal driving circumstances that it won’t look so bad.
However, the product is not a problem with my program to the ELM327, the serial part is fine. It is a limitation of the OBD side and my car is using KWP2000/ISO 14230 so I will have to figure out more timing details on this protocol. Other protocols such as CAN should be OK speed wise but I will have to investigate more into that.

Modified SD Card – More Space!

So today I bought a new USB card reader so I could work on partitioning my new SD card with a bigger root filesystem partition. The one that comes by default is something around 400MB and its 90% full which is no use to me.

To do this I downloaded this file: ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7390-linux/binaries/ts-images/512mbsd-aug252008.dd.bz2. Bunzip2′d it and with my usb card reader in VMWare (/dev/sdb) I wrote the new image to it using command: dd if=512mbsd-aug252008.dd.bz2 of=/dev/sdb. Perfect, out comes my card and bootable but the paritition is too small! I mounted the final partition (mkdir /mnt/filesystem; mount /dev/sdb4 /mnt/filesystem) and created a tar of all the files to back up. I then downloaded Gparted (sudo apt-get install gparted) and used this to delete the last parition (the rootfs) and create a new one using all the unalocated space. Ends up close to the 2GB as the other paritions small. Only problem is that jfs was not option to format with which is what we need. I continued anyways.
Note: That you can use fdisk (sudo fdisk /dev/sdb) with option d to delete the final partition and create new one to the full size.
Next we must make sure that our partition has jfs file system so I downloaded the jfs_mkfs tool that comes part of jfsutils (sudo apt-get install jfsutils). I also enabled jfs support in the kernel by modprobe jfs. (I think that was it from my head). Next unmount the partition (umount /mnt/filesystem). Change file system to jfs (sudo jfs_mkfs /dev/sdb4) and after this remounted like above. Now I untarred all my files back onto the partition.

I think there are probably errors in the file system but you can run a check yourself on them.

Tuesday, January 27th, 2009 Embedded Linux, Single Board Computer 1 Comment

Problems backing up the SD Card. 2GB card = 1GB

Spent a good bit of time wasting there attempting to create a bootable SD with Linux for the SBC.
First I wanted to create a backup of the current SD card so I can put it aside in case anything goes wrong. This proved a little awkward.

I am using VMWare so I have to use a external USB card reader since VMWare doesn’t have access to my internal one. I opened up a terminal window and went to the /dev folder in search of what my USB card reader name is. After bit of investigation it was clearly under /dev/sdd. To create an image of the card I placed my card in the card reader and done a dd -if /dev/sdd -of ~/sdimage.img. This took a bit of time and it finally stopped without errors with a 1GB result. This looked kind of strange to me since it was a 2GB card. I didn’t take anymore notice of it and just tried it out. The SBC screen stayed black and every 10 seconds would attempt a reboot. Clearly it wasn’t booting from SD properly (even though I assumed it would at least boot from NAND Flash). I opened the card in my VMWare machine again and done a fdisk /dev/sdd. Using the p option to print the partition details it gave a few errors about partitions ending on incorrect cylinders. With more investigation I worked out fdisk was reporting my card as 1GB. I tried the original card and I got exactly the same result.
I couldn’t use my internal card reader since not accessible to VMware and I didn’t want to try any windows copying utilities since I’d eventually have to get it working in VMWare anyways. So I rebooted and booted into Kubuntu’s Live CD and done fdisk in there. The card was reporting correctly at 2GB. I done a new copy of the image (storying to my mounted C Drive) and then wrote it back out to the new SD Card and all is well!

I was actually given a USB Card reader in the development kit and I haven’t tried it yet but I’m sure it will work so I will be able to use VMWare and create a new image for the SD card with better partition sizes as currently there’s no hope of storing anything on with the partition being 90% full.

So tomorrow I am going to re size the FS partition and copy over the QT/E binaries and have a go getting that working. I am guessing it won’t go smoothly though especially with tslib and all but nothing really goes smoothly in this project. Learning a lot though so that counts.

Monday, January 26th, 2009 Embedded Linux, Single Board Computer No Comments