I found it in /dev/mem (indirectly referenced here: http://gumstix.8.x6.nabble.com/How-to-obtain-Die-ID-other-Unique-ID-from-user-code-td561592.html). The devmem2 software they are referring to is at http://elinux.org/images/a/aa/Devmem2.c.

I have written a small tool to do print it, as well as use it to generate consistent random strings such as MAC addresses, included below but also available at http://pastebin.com/PauHU65x.

The program below assumes 16-byte die ID at /dev/mem offset 0x4830A218. No idea if that is valid for other Gumstix, or if it will continue to be valid in the future.

Jason


==== begin dieid.c ====

/* dieid.c:
 *   Tool to get die ID from Gumstix and to generate random strings from it.
 *
 * Copyright (C) 2013 Jason Cipriani, jason.cipriani@gmail.com
 *
 * If redistributed in source form please include this notice and the entire
 * source. If source is modified, a note must be added identifying the
 * author of the modifications.
 *
 * If redistributed in binary form, no attribution is required.
 *
 * This program can be used for any purpose. It is provided as-is and the
 * author is not responsible for any damage resulting from the use of this
 * software.
 *
 * Tested only on Gumstix Overo WaterSTORM COM.
 */

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

/* these may or may not be appropriate for all platforms... */
#define DIEID_OFFSET ((off_t)0x4830A218)
#define DIEID_LENGTH ((size_t)16)


/**
 * read dieid from /dev/mem.
 * @param dieid buffer to store result on success.
 * @return 0 on success, non-zero on error. prints message stderr on error.
 */
int read_dieid (unsigned char dieid[DIEID_LENGTH]) {

  int f, n;
  size_t pagesize, length;
  off_t start, dieaddr;
  void *m;

  if ((pagesize = sysconf(_SC_PAGESIZE)) == (size_t)-1) {
    perror("sysconf");
    return 1;
  }

  /* calculate page-aligned start and min # of pages required to get the id. */
  start = pagesize * (off_t)(DIEID_OFFSET / pagesize);
  dieaddr = DIEID_OFFSET - start;
  length = pagesize * (off_t)(1 + (DIEID_LENGTH - 1) / pagesize);

  if ((f = open("/dev/mem", O_RDONLY)) < 0) {
    perror("/dev/mem");
    return 1;
  }

  if ((m = mmap(NULL, length, PROT_READ, MAP_SHARED, f, start)) == (void *)-1) {
    perror("mmap");
    close(f);
    return 1;
  }

  /* bytes in memory are reversed from what u-boot prints on boot. */
  for (n = 0; n < (int)DIEID_LENGTH; ++ n)
    dieid[n] = ((const unsigned char *)m)[dieaddr + DIEID_LENGTH - n - 1];

  munmap(m, length);
  close(f);
  return 0;

}


/**
 * replace all ^ in template with random hex digit and print it. we use libc's
 * srand/rand. for libc independence or consistency, implement your own.
 * @param dieid die id, used as random seed.
 * @param template template string.
 */
void gen_template (const unsigned char dieid[DIEID_LENGTH], const char *template, int salt) {

  static const char hex[16] = "0123456789abcdef";
  unsigned long seed = 0, value = 0;
  int n;

  for (n = 0; n < (int)DIEID_LENGTH - 4; n += 4)
    seed += *(unsigned long *)(dieid + n);
  srand(seed + salt);

  while (*template) {
    if (*template == '^') {
      if (value == 0)
    value = rand();
      putchar(hex[value & 15]);
      value >>= 4;
    } else {
      putchar(*template);
    }
    ++ template;
  }

  putchar('\n');

}


int main (int argc, char **argv) {

  int salt = 0;
  const char *template = NULL;
  unsigned char dieid[DIEID_LENGTH];

  /** very basic arg parse. */
  if ((argc == 3 || argc == 4) && !strcmp(argv[1], "-m")) {
    template = argv[2];
    salt = (argc > 3) ? atoi(argv[3]) : 0;
  } else if (argc != 1) {
    fprintf(stderr, "usage: %s [ -m template [ salt ] ]\n\n", argv[0]);
    fprintf(stderr, "  no options: prints die id.\n");
    fprintf(stderr, "  -m template: replace all '^' in template with random hex digit.\n");
    fprintf(stderr, "               salt is an integer to produce different random output.\n\n");
    fprintf(stderr, "example: generate mac address with prefix:\n");
    fprintf(stderr, "  %s -m ab:cd:ef:^^:^^:^^\n\n", argv[0]);
    fprintf(stderr, "example: generate two random macs:\n");
    fprintf(stderr, "  %s -m ^^:^^:^^:^^:^^:^^ 1\n", argv[0]);
    fprintf(stderr, "  %s -m ^^:^^:^^:^^:^^:^^ 2\n\n", argv[0]);
    return 1;
  }

  if (read_dieid(dieid))
    return 1;

  if (template)
    gen_template(dieid, template, salt);
  else {
    int n;
    for (n = 0; n < (int)DIEID_LENGTH; ++ n)
      printf("%02x", (unsigned)dieid[n]);
    putchar('\n');
  }

  return 0;

}

==== end dieid.c ====



On Wed, Oct 23, 2013 at 8:57 PM, Jonathan Kunkee <jonathan.kunkee@gmail.com> wrote:

/dev/kmem and uboot can both read the cpu serial number. There was a thread on the topic a few months ago; my phone is cumbersome enough that I'll have to hunt it down later, sorry.

Jon Kunkee

On Oct 23, 2013 6:39 PM, "Andy Walls" <andy@silverblocksystems.net> wrote:
On Wed, 2013-10-23 at 20:03 -0400, Jason Cipriani wrote:
> I need a unique, invariant number for use in software running on a
> Gumstix Overo WaterSTORM.


> So the question remains, is there some kind of software-readable,
> unique, invariant serial number that can be read from these boards?
> The wiki seems to be entirely off.

The wiki refers to Intel chips.

The OMAP3530 TRM mentions a 128 bit CONTROLCONTROL_DIE_ID register in
Section 1.5.2 "Device Identification".  I'm guessing that's a chip UID.
You probably have to write a small kernel module to read it (unless
anyone knows differently?).

Regards,
Andy




------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users