How can I read A13's SID

Started by lihuiplus, October 16, 2013, 07:23:51 AM

Previous topic - Next topic

lihuiplus

Accroding to the post http://linux-sunxi.org/A10/SID, I wish to read out the A13's SID as our product serial number. Is there an easy way to do that?

thanks!

JohnS

Use mmap API

Or write a driver.  I'd go for mmap :)

John

lihuiplus

Thanks for your answer.

I used the command 'cat /proc/cpuinfo', but it returned '0000000...'. I knew someting must be missed, but I am a newbie in Linux and had no idea what to do. Could you point out an easy way or make a patch for me?

JohnS

I'm sure you can find examples using it.  I've no interest myself in SID, especially to lock a product.

John

davidefa

You can do something like this ( hope didn't mess anything ):

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

int main(int argc, char **argv)
{
   int fd;
   unsigned int addr_start, a,b,c,d;
   unsigned int PageSize, PageMask;
   unsigned char *mm_addr; // sid base pointer

   fd = open("/dev/mem", O_RDWR);
   if(fd < 0) {
      perror("Unable to open /dev/mem");
      return(-1);
      }

   PageSize = sysconf(_SC_PAGESIZE);
   PageMask = (~(PageSize-1));

   addr_start  = 0x01c23800 &  PageMask;

   mm_addr = mmap(0, 1024, PROT_READ, MAP_SHARED, fd, addr_start);
   if(mm_addr == (unsigned char *)-1)
      {
      perror("Unable to mmap file");
      }

   a=*(unsigned int *)(mm_addr + 0x800);
   b=*(unsigned int *)(mm_addr + 0x800 + 4);
   c=*(unsigned int *)(mm_addr + 0x800 + 8);
   d=*(unsigned int *)(mm_addr + 0x800 +12);


   printf("SID %8.8x %8.8x %8.8x %8.8x\n",a,b,c,d);

   close(fd);
}


My sid is: 162541XX 504b4eXX 353030XX 098104XX
Would be nice to know if it can be used as a serial number ( is unique and can't be easily changed )...