Jul 2, 2013

Spin Lock vs. Read-Write Lock

http://locklessinc.com/articles/locks/

Jun 16, 2013

Make TMP36 work on Beaglebone Black

Here is how to use the Adadfruit temperature sensor TMP36 (https://www.sparkfun.com/products/10988) on Beaglebone black for reading temperature
1) Wiring the TMP36 to BBB
Refer the following picture for TMP36 pin output

Then we need to
- Connect 1st pin to port 32 of P9 expansion slot (3.3V output)
- Connect 3rd pin to port 1 of P9 expansion slot
- Connect 2nd pin to port 39 (AIN0) of the P9 expansion slot
You can connect the 2nd pin to AIN another port, refer following image for how it is designed



2) Enable AIN on the BBB
We need to enable the AIN driver, by doing following command on the BBB console
# echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots
The above might need a kernel module BONE_CAPE or bone_iio_helper

3) Read the input
Now we can read the AIN input by cat it, for example
root@arm:~# cat /sys/devices/ocp.2/helper.14/AIN0
287
But the AIN0 give me some weird value, I need to use the voltage0_raw under "/sys/bus/iio/devices/iio\:device0/in_voltage0_raw";
root@arm:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
1767
with a C application

#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

//const char AIN_DEV[] = "/sys/devices/ocp.2/helper.14/AIN0";
const char AIN_DEV[] = "/sys/bus/iio/devices/iio\:device0/in_voltage0_raw";

double CtoF(double c)
{
  return (c * 9.0 / 5.0) + 32.0;
}

double temperature(char *string)
{
  int value = atoi(string);
  double millivolts = (value / 4096.0) * 1800;
  double temperature = (millivolts - 500.0) / 10.0;
  return temperature;
}

int main()
{
  int fd = open(AIN_DEV, O_RDONLY);

  while (1)
  {
    char buffer[1024];
    int ret = read(fd, buffer, sizeof(buffer));
    if (ret != -1)
    {
      buffer[ret] = '\0';
      double celsius = temperature(buffer);
      double fahrenheit = CtoF(celsius);
      printf("digital value: %s  celsius: %f  fahrenheit: %f\n", buffer, celsius, fahrenheit);
      lseek(fd, 0, 0);
    }
    sleep(1);
  }

  close(fd);
  return 0;
}

The convert formula is as following
Step Description Example
1 Read the digital value from the ADC interface. #cat
/sys/devices/ocp.2/helper.14/AIN0
1670
2 Convert the digital value to millivolts.
(value / 4096) * 1800mV
(1670 / 4096) * 1800mV = 733.8867mV
3 Convert the millivolts to Celsius temperature.
(millivolts - 500mV) / 10
(733.8867mV – 500mv) / 10 = 23.38867°C
4 Convert Celsius to Fahrenheit.
(Celsius * 9.0 / 5.0) + 32.0
(23.38867°C * 9 / 5) + 32 = 74.09961°F


And here is my wiring


Ref:

Jun 3, 2013

Beaglebone Black

What I bought
- Beaglebone Black
- Breadboard
- Wire
- TMP36
- MQ-3
- and a zigbee wireless sensor...

Sep 23, 2012

Setup poky development environment

The following is to setup development environment for working on poky project.
1) Setup a working directory
mkdir data/poky -p

2) Check out the poky source code
cd data/poky
git init
git remote add yocto git://git.yoctoproject.org/poky.git
git remote update
git branch -b denzil yocto/denzil

3) Check out meta-intel for BSP developmen
mkdir data/poky/meta-intel -p
cd data/poky/meta-intel
git init
git remote add meta-intel git://git.yoctoproject.org/meta-intel.git
git remote update
git branch -b denzil meta-intel/denzil

4) Checkout poky-extras for kernel development
mkdir data/poky/poky-extras -p
cd data/poky/poky-extras
git init
git remote add poky-extras git://git.yoctoproject.org/poky-extras
git remote update
git checkout -b denzil poky-extras/denzil

5) Clone the kernel source code
cd data
git clone --bare git://git.yoctoproject.org/linux-yocto-3.2 linux-yocto-3.2.git

6) Then clone a local copy to make change on that kernel
git clone linux-yocto-3.2.git my-linux-yocto-3.2-work

6) Now we can start a yocto build and development. The layout should be
 [hieult@hieuletrung data]$ tree -L 2
.
├── linux-yocto-3.2.git
│   ├── branches
│   ├── config
│   ├── description
│   ├── HEAD
│   ├── hooks
│   ├── info
│   ├── objects
│   ├── packed-refs
│   └── refs
├── my-linux-yocto-3.2-work
│   ├── arch
│   ├── block
│   ├── COPYING
│   ├── CREDITS
│   ├── crypto
│   ├── Documentation
│   ├── drivers
│   ├── firmware
│   ├── fs
│   ├── include
│   ├── init
│   ├── ipc
│   ├── Kbuild
│   ├── Kconfig
│   ├── kernel
│   ├── lib
│   ├── MAINTAINERS
│   ├── Makefile
│   ├── mm
│   ├── net
│   ├── README
│   ├── REPORTING-BUGS
│   ├── samples
│   ├── scripts
│   ├── security
│   ├── sound
│   ├── tools
│   ├── usr
│   └── virt
└── poky
    ├── bitbake
    ├── documentation
    ├── LICENSE
    ├── meta
    ├── meta-demoapps
    ├── meta-hob
    ├── meta-intel
    ├── meta-skeleton
    ├── meta-yocto
    ├── oe-init-build-env
    ├── poky-extras
    ├── README
    ├── README.hardware
    └── scripts


URL:

Aug 4, 2012

Ubuntu 12.04 NVIDIA 6 screens issue

If you've installed Ubuntu 12.04 and has 6 screens issue on nvidia geforce card, follow this guideline http://ubuntuforums.org/showthread.php?t=1967161&page=2 to fix the issue

It works for me on Geforce G210M

Jan 30, 2012

What motivate me?

Working in GCS for many years, I found some facts about GCSers at the moment. When you first join GCS
  • You don't know what should you do, still being with the university mindset or previous company.
  • Be assigned into a project and keep working daily.
  • You found that when you need to submit leave form go to QMS and only for leave form.
  • You don't know the requirement for your current role (i.e. Engineer). - If you know that it's still very ambiguous because it's not example specific and there's no mapping into your daily work.
  • CP4 is something really interested but HOW can you do that?
  • What motivate you to do good job? Salary?
  • Yes, everything is very confuse and you'll need a good leader to guide you :)

I think to solve this:
  • When a person first join GCS, we should have someone describe on their current role, the requirement for that role, who is his/her mentor, who will he/she report to, list of tools/resources that available to his/her job (Wiki?).
  • If he/she joins a project, the project should have a Getting Start Wiki so that everyone can know where to go and what should they do in project.

There's an issue with current EMB hiring model, that the new hired resource might not join a project but for a resource pool. For this we might think about R&D project, I think we should create an "Open Source department" so that,
  • we improve open-source project which is mostly used by us i.e. Android, Beagleboard, or some other open-source libraries...
  • the employee join this model can gain knowledge on specific library which can help him in his future work
For senior engineer, with current development environment inside GCS, we currently don't have a correct model/workflow yet so
  • if we developed on, we should collect all senior and teach them that new workflow so that they can follow up like orientation for new employee.
  • they've long lived so mindset might different from new one, motivation might be missing already :)
  • ask them HOW!
  • re-evaluate their skill so that we can match them with new model.

Is it true for you and your current work?