GithubHelp home page GithubHelp logo

Comments (7)

lsgunth avatar lsgunth commented on June 14, 2024

Hmm, very strange. Tho only place I can see that returns EBADMSG is in the kernel where it checks the status returned by the device to be valid:

https://github.com/Microsemi/switchtec-kernel/blob/e459e54607c31eabb0bb503040d23425e0d3ef9f/switchtec.c#L631

Do you know what kind of hardware and firmware version you have?

My guess is the hardware/firmware are responding improperly to the MRPC_I2C_TWI_PING command (possibly it is too old?) and thus we don't fall back to the gen3 return and it returns an error instead.

from switchtec-user.

arshad512 avatar arshad512 commented on June 14, 2024

Thanks for your response!

Hmm, very strange. Tho only place I can see that returns EBADMSG is in the kernel where it checks the status returned by the device to be valid:

I will check this part. Thanks. However, I am curious to understand. Is not the return value 0 here ? I may be wrong.

(gdb) x /12x buf
0x7fffffffde70:	0x00000000	0x63592f39	0x00179ec8	0x00000000
0x7fffffffde80:	0xffffdf28	0x00007fff	0xf7fe76c0	0x00007fff
0x7fffffffde90:	0xffffdec0	0x00007fff	0x00000008	0x00000000

Do you know what kind of hardware and firmware version you have?

# cat /sys/class/switchtec/switchtec0/fw_version 
01090063
# cat /sys/class/switchtec/switchtec0/vendor_id 
MICROSEM

My guess is the hardware/firmware are responding improperly to the MRPC_I2C_TWI_PING command (possibly it is too old?) >and thus we don't fall back to the gen3 return and it returns an error instead.

This is what I saw a while back when debugging. I thought I should share it here. It looks to recognize "GEN3" correctly. I am not sure if this is what you are mentioning here.

(gdb) p ldev
$5 = (struct switchtec_linux *) 0x648330
(gdb) p *ldev
$6 = {dev = {device_id = 34098, gen = SWITCHTEC_GEN3, var = SWITCHTEC_PFX, pax_id = -1, local_pax_id = -1, partition = 0, partition_count = 1, 
    boot_phase = SWITCHTEC_BOOT_PHASE_FW, name = "/dev/switchtec0", '\000' <repeats 4080 times>, gas_map = 0x0, gas_map_size = 0, ops = 0x644080 <linux_ops>}, fd = 3}

from switchtec-user.

lsgunth avatar lsgunth commented on June 14, 2024

The return value in the buffer is zero. But it's not likely valid if the status is the wrong value.

Is your hardware indeed GEN3? The switchtec_dev stuff you are printing may not be correct given the switchtec_get_device_info() call failed.

What is in:

/sys/class/switchtec/switchtec0/component_id

from switchtec-user.

arshad512 avatar arshad512 commented on June 14, 2024

What is in:
/sys/class/switchtec/switchtec0/component_id

# cat /sys/class/switchtec/switchtec0/component_id
PM8532

Is your hardware indeed GEN3? The switchtec_dev stuff you are printing may not be correct given the switchtec_get_device_info() call failed.

I thought the switchtec_get_device_info() is already populated before calling switchtec_cmd()/linux_cmd(). I will revisit my understanding again.

from switchtec-user.

lsgunth avatar lsgunth commented on June 14, 2024

Yup, this is definitely GEN3 hardware. Perhaps a patch such as this will fix the issue:

diff --git a/lib/switchtec.c b/lib/switchtec.c
index 23b570fc8d30..4640532f5f00 100644
--- a/lib/switchtec.c
+++ b/lib/switchtec.c
@@ -1755,7 +1755,7 @@ int switchtec_get_device_info(struct switchtec_dev *dev,
                        *rev = (dev_info >> 8) & 0x0f;
                if (gen)
                        *gen = map_to_gen((dev_info >> 12) & 0x0f);
-       } else if (ERRNO_MRPC(errno) == ERR_CMD_INVALID) {
+       } else if (errno == EBADMSG || ERRNO_MRPC(errno) == ERR_CMD_INVALID) {
                if (phase)
                        *phase = SWITCHTEC_BOOT_PHASE_FW;
                if (gen)

from switchtec-user.

arshad512 avatar arshad512 commented on June 14, 2024

Yup, this is definitely GEN3 hardware. Perhaps a patch such as this will fix the issue:

diff --git a/lib/switchtec.c b/lib/switchtec.c
index 23b570fc8d30..4640532f5f00 100644
--- a/lib/switchtec.c
+++ b/lib/switchtec.c
@@ -1755,7 +1755,7 @@ int switchtec_get_device_info(struct switchtec_dev *dev,
                        *rev = (dev_info >> 8) & 0x0f;
                if (gen)
                        *gen = map_to_gen((dev_info >> 12) & 0x0f);
-       } else if (ERRNO_MRPC(errno) == ERR_CMD_INVALID) {
+       } else if (errno == EBADMSG || ERRNO_MRPC(errno) == ERR_CMD_INVALID) {
                if (phase)
                        *phase = SWITCHTEC_BOOT_PHASE_FW;
                if (gen)

@lsgunth , Thanks for the patch. I will try out and let you know.

from switchtec-user.

arshad512 avatar arshad512 commented on June 14, 2024

Your patch worked. Thanks @lsgunth !

# ./switchtec info /dev/switchtec0
/dev/switchtec0:
    Generation:  GEN3
    HW Revision: Unknown
    Variant:     PFX
    Device ID:   0x8532
    FW Version:  1.09 B063

This issue can be closed.

from switchtec-user.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.