Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gc1024 is not detected #52

Closed
moleus opened this issue Jan 15, 2023 · 8 comments
Closed

gc1024 is not detected #52

moleus opened this issue Jan 15, 2023 · 8 comments

Comments

@moleus
Copy link

moleus commented Jan 15, 2023

ipctool -s returns a message Error: unexpected value for SuperPix == 0x78.

Manual detection

I've followed suggestions of OpenIPC's telegram chat members and ran:

# ./ipctool i2cdetect
       0  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f
     : xx xx xx xx xx xx xx xx  xx xx xx xx xx xx xx xx  |
                      ....
   70: xx xx xx xx xx xx xx xx  78 79 xx xx xx xx xx xx  |
                      ....
  f0: xx xx xx xx xx xx xx xx  xx xx xx xx xx xx xx

The sensor id can be found at f0 - 10 24. (Unnecessary lines are removed, file with the original output - i2cdump_0x78.txt)

# ./ipctool i2cdump 0x78 0 0x3ff
       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
    : 00 1F FF 03 98 01 6F 00  A6 00 00 00 08 02 E6 05  |  ......o.........
  10: 08 00 18 11 01 00 C0 17  0A 06 11 4F 11 10 F8 38  |  ...........O...8
...
  e0: 00 AB B6 80 9D EC F1 C7  DA 00 00 00 00 00 1D 40  |  ...............@
  f0: 10 24 0F 00 03 00 00 B9  03 0E 00 78 C4 11 00 00  |  .$.........x....
 100: FF FF FF FF FF FF FF FF  FF FF FF FF FF FF FF FF  |  ...............
...
 1f0: FF FF FF FF FF FF FF FF  FF FF FF FF FF FF FF FF  |  ................
 200: 03 03 03 03 03 03 03 03  03 03 03 03 03 03 03 03  |  ................
 ...
 2d0: 03 03 03 03 03 03 03 03  03 03 03 03 03 03 03 03  |  ................
...
 3f0: 98 98 98 98 98 98 98 98  98 98 98 98 98 98 98     |  ...............

The problem

According to the detection function source code, 3f0 or 3f1 should be FF to read the value from f0 address.

ipctool/src/sensors.c

Lines 664 to 675 in 11f8946

static int detect_galaxycore_sensor(sensor_ctx_t *ctx, int fd,
unsigned char i2c_addr) {
if (i2c_change_addr(fd, i2c_addr) < 0)
return false;
int prod_msb = i2c_read_register(fd, i2c_addr, 0x3f0, 2, 1);
int prod_lsb = i2c_read_register(fd, i2c_addr, 0x3f1, 2, 1);
if (prod_msb == -1 || prod_lsb == -1) {
prod_msb = i2c_read_register(fd, i2c_addr, 0xf0, 1, 1);
prod_lsb = i2c_read_register(fd, i2c_addr, 0xf1, 1, 1);
}

But it's not the case, because 3f0 and 3f1 are filled with a garbage. You can see the output of multiple executions below:

# ./ipctool i2cdump 0x78 0x3f0 0x3ff
       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
 3f0: CE CE CE CE CE CE CE CE  CE CE CE CE CE CE CE
# ./ipctool i2cdump 0x78 0x3f0 0x3ff
       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
 3f0: 50 50 50 50 50 50 50 50  50 50 50 50 50 50 50
# ./ipctool i2cdump 0x78 0x3f0 0x3ff
       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
 3f0: 59 59 59 59 59 59 59 59  59 59 59 59 59 59 59

Side-effects

Also, garbage in fa and in fb addresses prevents the early break in SuperPix detection function

ipctool/src/sensors.c

Lines 746 to 749 in 11f8946

prod_msb = i2c_read_register(fd, i2c_addr, 0xfa, 1, 1);
// early break
if (prod_msb == -1)
return false;

and execution falls into the default case

ipctool/src/sensors.c

Lines 768 to 769 in 11f8946

default:
SENSOR_ERR("SuperPix", res);

, so we get an error message Error: unexpected value for SuperPix == 0x78, but it's not a SuperPix sensor

Solutions?

I'm knew to this topic and don't have a fundamental knowledge in sensors/i2c stuff, so I can't say if it's OK to have a "garbage" in a memory and how to deal with it. But can we check the value of f0 address before 3f0?

@dimerr
Copy link
Collaborator

dimerr commented Jan 15, 2023

What's your soc?

reboot and try ipctool again

@moleus
Copy link
Author

moleus commented Jan 15, 2023

hi3518ev200

# cat cpuinfo
Processor       : ARM926EJ-S rev 5 (v5l)
BogoMIPS        : 269.10
Features        : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 5

Hardware        : hi3518ev200
Revision        : 0000
Serial          : 0000000000000000

The output of ipctool - ipctool_output.txt (after reboot I got the same result)

I've looked at a table with sensor identifiers provided by Paul, and saw that GC1024 has chip_id 0x1004. That's strange.

I'm tinkering with VstarCam C7824WIP and found a note about it's GC1024 sensor - code. Does this mean that it's the GC1024 with invalid id?

@dimerr
Copy link
Collaborator

dimerr commented Jan 15, 2023

try again

@moleus
Copy link
Author

moleus commented Jan 15, 2023

Got the ipctool with the patch. Still doesn't work. Same error.

I think that this condition fails, because 0x78 not listed in possible_i2c_addrs

if (sdata->sensor_type == type) {

As far as I understand list of possible addresses for hisilicon is declared here:

static unsigned char gc_addrs[] = {0x6e, 0x52, 0x42, 0};
static unsigned char superpix_addrs[] = {0x79, 0};
static sensor_addr_t my_possible_i2c_addrs[] = {
{SENSOR_SONY, sony_addrs}, {SENSOR_SOI, soi_addrs},
{SENSOR_ONSEMI, onsemi_addrs}, {SENSOR_SMARTSENS, ssens_addrs},
{SENSOR_OMNIVISION, omni_addrs}, {SENSOR_GALAXYCORE, gc_addrs},
{SENSOR_SUPERPIX, superpix_addrs}, {0, NULL}};

What if we add 0x78 to this array?

@dimerr
Copy link
Collaborator

dimerr commented Jan 15, 2023

it's already added

@moleus
Copy link
Author

moleus commented Jan 15, 2023

I see, in this 34ef8b2 commit you've only added the case statement, and might forgot to push the changes with the address. Am I wrong?

@dimerr
Copy link
Collaborator

dimerr commented Jan 15, 2023

Yeah, really weird, hal_hisi is missing

@moleus
Copy link
Author

moleus commented Jan 15, 2023

It works!

sensors:
- vendor: GalaxyCore
  model: GC1024
  control:
    bus: 0
    type: i2c
    addr: 0x78
  data:
    type: DC
  clock: 24MHz

Thank you!

@moleus moleus closed this as completed Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants