Giter Site home page Giter Site logo

Comments (7)

hartkopp avatar hartkopp commented on July 16, 2024 1

Hi Łukasz,

the problem is, that the

struct bcm_msg_head {
	__u32 opcode;
	__u32 flags;
	__u32 count;
	struct bcm_timeval ival1, ival2;
	canid_t can_id;
	__u32 nframes;
	struct can_frame frames[];
};

has this

struct bcm_timeval {
	long tv_sec;
	long tv_usec;
};

where the long can be either 32 or 64 bit.
And this is the problem: You have a 32 bit user space running on a 64 bit kernel. And therefore the length check for the sizeof(struct bcm_mag_head) fails with errno 22 ("invalid argument").
That's the story.

IIRC Marc prepared a patch to solve this. I have to take a look at it.

from can-utils.

hartkopp avatar hartkopp commented on July 16, 2024

Hi Łukasz,

I tried your exact setup with a virtual CAN interface "vcan0"
echo "< vcan0 A 1 0 123 8 11 22 33 44 55 66 77 88 >" | nc 0.0.0.0 28600

and it works as expected:

$ candump any -td
 (000.000000)  vcan0  123   [8]  11 22 33 44 55 66 77 88
 (001.000135)  vcan0  123   [8]  11 22 33 44 55 66 77 88
 (001.000146)  vcan0  123   [8]  11 22 33 44 55 66 77 88
...

Maybe there's something wrong with your can0 interface?!?

Can you please check if your system runs fine with a virtual CAN interface?

from can-utils.

hartkopp avatar hartkopp commented on July 16, 2024

I have another idea what might be wrong.

juraszekl@raspberrypi:~ $ uname -a 
Linux raspberrypi 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux

Can you please check whether the bcmserver is a 64 bit binary too?

E.g. with file bcmserver
On my 64 bit X86 it looks like this:

$ file bcmserver
bcmserver: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=eee7e8c285a5dbdb9c0b6bfcf3ceb5f29667fcca, for GNU/Linux 3.2.0, not stripped

from can-utils.

JuraszekL avatar JuraszekL commented on July 16, 2024

Can you please check if your system runs fine with a virtual CAN interface?

So, i have both modules:

$ lsmod | grep can
can_bcm                24576  0
can                    28672  1 can_bcm
vcan                   16384  0
can_dev                40960  2 mcp251xfd,vcan

and operating vcan0:

$ sudo ip link add dev vcan0 type vcan
$ sudo ip link set vcan0 up
$ ip link show vcan0
6: vcan0: <NOARP,UP,LOWER_UP> mtu 72 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/can 

but output is the same:

$ ./bcmserver 
listening
forking
BCM socket opened, sc = 5
BCM socket connected
read '< vcan0 A 1 0 123 8 11 22 33 44 55 66 77 88 >'
sscanf ok! items = 14
res = -1, errno = 22

Can you please check whether the bcmserver is a 64 bit binary too?

Bingo!

$ file bcmserver
bcmserver: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=1bd7bfb49bc9c25fab7e00675c1ccc1e1f807487, for GNU/Linux 3.2.0, not stripped

How can i solve this issue?
I've checked other exec files that were compiled in the same way, all of them are 32-bit and all of them work fine with f.e. RAW sockets.

Just to make that clear - i use Raspbian directly to compile files (no cross-compilation).

from can-utils.

hartkopp avatar hartkopp commented on July 16, 2024

IIRC there was a discussion some time ago.

Can you try to add (or change)
arm_64bit=0

into /boot/config.txt

from can-utils.

JuraszekL avatar JuraszekL commented on July 16, 2024

In my case the right file is under /boot/firmware/config.txt

This solution works fine!

candump can1
  can1  123   [8]  11 22 33 44 55 66 77 88
  can1  123   [8]  11 22 33 44 55 66 77 88
  can1  123   [8]  11 22 33 44 55 66 77 88
  can1  123   [8]  11 22 33 44 55 66 77 88
  can1  123   [8]  11 22 33 44 55 66 77 88

Can You please tell me what is wrong? I just want to understand the issue as a beginner.

Thank You.
Łukasz

from can-utils.

JuraszekL avatar JuraszekL commented on July 16, 2024

How about downgrade my OS to Bullseye and use external toolchain like this one?

from can-utils.

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.