memtool says 'unknown SOC' for i.mx6ulz

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

memtool says 'unknown SOC' for i.mx6ulz

1,124 Views
Angshu
Contributor III

Hi,


I am trying to read values of some registers using memtool on our custom board with i.mx6ulz chip. But it outputs 'unknown SOC' whenever we put in any command. Is there a config file we can edit to get rid of this behavior or to add the ulz to known SoC list?  


Thanks,

 

Angshu

0 Kudos
Reply
2 Replies

1,120 Views
jamesbone
NXP TechSupport
NXP TechSupport

You need to modify the memtool.c file to add the i.MX6ULZ to avoid the message

 

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/utsname.h>
#include "memtools_register_info.h"
 
int g_size = 4;
@@ -38,6 +39,7 @@ int g_map_vaddr = 0;
int g_map_paddr = 0;
 
#define MAP_SIZE 0x1000
+#define KERN_VER(a, b, c) (((a) << 16) + ((b) << + (c))
 
extern const module_t mx6q[];
extern const module_t mx6dl[];
@@ -234,37 +236,76 @@ void parse_module(char *module, char *reg, char *field, int iswrite)
int n;
char *rev;
 
- fd = open("/proc/cpuinfo", O_RDONLY);
- if (fd < 0)
- die("can't open file /proc/cpuinfo\n");
+ int kv, kv_major, kv_minor, kv_rel;
+ int rev_major, rev_minor;
+ struct utsname sys_name;
+
+ if (uname(&sys_name) < 0)
+ die("uname error");
+
+ if (sscanf(sys_name.release, "%d.%d.%d", &kv_major, &kv_minor, &kv_rel) != 3)
+ die("fail to get release version");
+
+ kv = ((kv_major << 16) + (kv_minor << + kv_rel);
+ if (kv < KERN_VER(3, 10, 0)) {
+ fd = open("/proc/cpuinfo", O_RDONLY);
+ if (fd < 0)
+ die("can't open file /proc/cpuinfo\n");
+
+ n = read(fd, g_buffer, 4095);
+ if ((rev = strstr(g_buffer, "Revision"))) {
+ int r;
+ rev = strstr(rev, ":");
+ if (!rev)
+ die("Unkown CPUInfo format\n");
+
+ r = strtoul(rev + 2, NULL, 16);
+
+ switch (r >> 12) {
+ case 0x63:
+ mx = mx6q;
+ printf("SOC is mx6q\n\n");
+ break;
+ case 0x61:
+ mx = mx6dl;
+ printf("SOC is mx6dl\n\n");
+ break;
+ case 0x60:
+ mx = mx6sl;
+ printf("SOC is mx6sl\n\n");
+ break;
+ default:
+ die("Unknown SOC\n\n");
+ }
+ } else
+ die("Unknown SOC\n");
+ } else {
+ FILE *fp;
+ char soc_name[255];
+
+ fp = fopen("/sys/devices/soc0/soc_id", "r");
+ if (fp == NULL) {
+ perror("/sys/devices/soc0/soc_id");
+ die("fail to get soc_id");
+ }
 
- n = read(fd, g_buffer, 4095);
- if ((rev = strstr(g_buffer, "Revision"))) {
- int r;
- rev = strstr(rev, ":");
- if (!rev)
- die("Unkown CPUInfo format\n");
+ if (fscanf(fp, "%s", soc_name) != 1) {
+ fclose(fp);
+ die("fail to get soc_name");
+ }
+ fclose(fp);
 
- r = strtoul(rev + 2, NULL, 16);
+ printf("SOC: %s\n", soc_name);
 
- switch (r >> 12) {
- case 0x63:
+ if (!strcmp(soc_name, "i.MX6Q"))
mx = mx6q;
- printf("SOC is mx6q\n\n");
- break;
- case 0x61:
+ else if (!strcmp(soc_name, "i.MX6DL"))
mx = mx6dl;
- printf("SOC is mx6dl\n\n");
- break;
- case 0x60:
+ else if (!strcmp(soc_name, "i.MX6SL"))
mx = mx6sl;
- printf("SOC is mx6sl\n\n");
- break;
- default:
- die("Unknown SOC\n\n");
- }
- } else
- die("Unknown SOC\n");
+ else
+ die("Unknown SOC\n");
+ }
 
if (iswrite) {

while (mx) {

 

0 Kudos
Reply

1,116 Views
Angshu
Contributor III

Hi James,

 

Thank you for the info. May I ask where I can find this file? Can I cross compile the .c file and include the binary inside of my boards rootfs? What would be the best way to going about making this change.  Also, the code snippet you provided, am I to manually add/delete the lines suggested or can I use .patch way to patch the file? Sorry for the trivial questions, just not too familiar with this part.

 

Thanks,

 

Angshu

Tags (1)
0 Kudos
Reply