Compiling OpenCN on Debian12

Hi guys,

I recently upgraded to Debian 12 as I needed the latest version of GRPC for my linuxcnc project.
I’ve made the update by changing the repositories all my previous setup remained in place.
I tried again to recompile OpenCN, so I pulled the latest master and tried to run the commands described here: 8. User guide — OpenCN 2021.2.0 documentation
I have pasted into a file the messages that I get in the console.

➜  opencn git:(master) ✗ sudo apt install bc bison bridge-utils ca-certificates  capnproto cpio \
  cmake device-tree-compiler default-jdk dosfstools dvipng elfutils fakeroot file flex \
  gcc git graphviz g++ latexmk lib32z1-dev libc6:i386 libcapnp-dev libcapstone3 libepoxy0 \
  libgbm1 libgtk2.0-dev libjpeg62 libssl-dev libstdc++6:i386 libusb-1.0-0 make nano \
  openssh-server patch pkg-config python3 python3-pip python3-crypto python3-pyelftools \
  rsync sudo tex-gyre texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended \
  wget unzip u-boot-tools xz-utils zlib1g:i386
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'libjpeg62-turbo' instead of 'liabjpeg62'
Package python3-crypto is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Unable to locate package libcapstone3
E: Package 'python3-crypto' has no installation candidate
➜  opencn git:(master) ✗ 

Not found: libcapstone3, python3-crypto


➜  / cd ~/Work/opencn/agency 
➜  agency git:(master) ✗ ./build.sh -t x86
➜  agency git:(master) ✗ ./build.sh -a
read target from the file
-- [ Build Linux kernel ] ----------------------------------
LINUX_CONF=x86_defconfig
---------------------------------------------[ BUILDING linux ]---
make -C linux x86_defconfig || exit -1
make[1]: Entering directory '/home/vasimihalca/Work/opencn/agency/linux'
#
# No change to .config
#
make[1]: Leaving directory '/home/vasimihalca/Work/opencn/agency/linux'
make -C linux -rR --no-print-directory bzImage -j$(nproc) || exit -1
  DESCEND  objtool
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CC       /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/help.o
  CC       /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/sigchain.o
In file included from sigchain.c:3:
In function ‘xrealloc’,
    inlined from ‘sigchain_push.isra’ at sigchain.c:26:2:
subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   56 |                 ret = realloc(ptr, size);
      |                       ^~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 |         void *ret = realloc(ptr, size);
      |                     ^~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   58 |                         ret = realloc(ptr, 1);
      |                               ^~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 |         void *ret = realloc(ptr, size);
      |                     ^~~~~~~~~~~~~~~~~~
In function ‘xrealloc’,
    inlined from ‘sigchain_push’ at sigchain.c:26:2,
    inlined from ‘sigchain_push_common’ at sigchain.c:53:2:
subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   56 |                 ret = realloc(ptr, size);
      |                       ^~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 |         void *ret = realloc(ptr, size);
      |                     ^~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   58 |                         ret = realloc(ptr, 1);
      |                               ^~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 |         void *ret = realloc(ptr, size);
      |                     ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
mv: cannot stat '/home/vasimihalca/Work/opencn/agency/linux/tools/objtool/.sigchain.o.tmp': No such file or directory
make[5]: *** [/home/vasimihalca/Work/opencn/agency/linux/tools/build/Makefile.build:96: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/sigchain.o] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from help.c:12:
In function ‘xrealloc’,
    inlined from ‘add_cmdname’ at help.c:24:2:
subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   56 |                 ret = realloc(ptr, size);
      |                       ^~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 |         void *ret = realloc(ptr, size);
      |                     ^~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   58 |                         ret = realloc(ptr, 1);
      |                               ^~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 |         void *ret = realloc(ptr, size);
      |                     ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
mv: cannot stat '/home/vasimihalca/Work/opencn/agency/linux/tools/objtool/.help.o.tmp': No such file or directory
make[5]: *** [/home/vasimihalca/Work/opencn/agency/linux/tools/build/Makefile.build:96: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/help.o] Error 1
make[4]: *** [Makefile:58: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/libsubcmd-in.o] Error 2
make[3]: *** [Makefile:54: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/libsubcmd.a] Error 2
make[2]: *** [Makefile:67: objtool] Error 2
make[1]: *** [Makefile:1850: tools/objtool] Error 2
make: *** [Makefile:73: agency_x86_domain] Error 255

[ERROR] kernel compilation failed !!
➜  agency git:(master) ✗ 

Please provide any hints on what to do next to unblock myself.

Thanks,
Vasi Mihalca

Hi Vasi,

It seems that some packages where not installed. Can you tried to install python3-cryptography and libcapstone4 packages ?

To avoid the environment errors, can can also use the docker image for the compilation.

Hope this helps
J/P

2 small comments:

  • The installation guide was tested on Ubuntu 20.04
  • My personal machine runs Debian 12 :slight_smile:

I have those packages installed, and still the same error.
I tried using docker and I run into a different error. Here is what I encounter with docker:

I had to use pastebin because the code block was limited as number of characters and I wanted to add all the console log.

It seems you have issue with your docker. There is the following error in the log you shared:

docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create”: dial unix /var/run/docker.sock: connect: permission denied.

I think you should add you usr in docker group to avoid having to use sudo (doc),

Just to be 100% can you try the following cmd:

docker run hello-world

If It works, next debug phase is to build and run OpenCN image and try to log, with ssh into it. You have the doc: docker/README

For the native compilation, can you try with another target, x86-qemu, instead of x86 ?

Hope this helps
J-P

I have added the user in the docker group, so now I can run the docker without sudo. However, I still have some issues: OpenCN Docker Issues 2 - Pastebin.com

Thanks for your prompt answer!

Can you try the build cmd without the sudo ?

Sorry, I answered to quickly.

It seems that the build error arrived during rootfs build. Can you try the following cmd:

./build.sh -rc
./build.sh -r

It cleans and restarts the build process of the rootfs part of OpenCN.

I was able to get the server running, I get the following

Starting OpenCN server
/
OK
/root/start_opencn.sh: line 13: /root/opencn-m5-server: No such file or directoy
Starting sshd: OK

opencn ~ # [    5.026126] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flx
[    5.027768] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

Then I tried to build the host and got the following result:

[ 98%] Linking CXX executable user-m5-gui
[ 98%] Built target user-m5-gui
[ 98%] Linking CXX executable user-gui
[ 98%] Built target user-gui
make: *** [Makefile:91: all] Error 2
/home/vasimihalca/Work/opencn/agency/usr
Copy build-host/host/user_gui/user-gui
Copy build-host/host/user_m5_gui/user-m5-gui
Copy host/tooledit/tooledit.sh
➜  usr git:(master) ✗ 

Not sure if that “Error 2” is relevant, but when I try to run the ./user-gui I get a popup that has the following IP: 192.168.53.15 Port: 7001, and when I click ok nothing happens.
Not sure if the IP is correct or how did it come to this IP

This is what I see in the console:

➜  user_gui git:(master) ✗ ./user-gui
Using qt version:  5.15.8
QSocketNotifier: Can only be used with threads started with QThread
QMetaObject::connectSlotsByName: No matching signal for on_space_pressed()
QMetaObject::connectSlotsByName: No matching signal for on_push_gcoderefresh_clicked()
RpcClientQTIntf done 

Thanks for all your replies so far!

Great that you have been able to start OpenCN. It is emulation or native (x86 - rpi4) ?

You arrived at the place where the issue starts (our doc lacks info).

So starting from the beginning:

  • On which branch are you ? I saw the following error which is not expected to happen form master
/root/start_opencn.sh: line 13: /root/opencn-m5-server: No such file or directory
  • The error during the build process may be an issue. It depends where it was generated. As you have the usr-gui and usr-m5-gui maybe not important in current situation

  • The application and the target communicate through IP. The target has an hardcoded IP ( 192.168.53.15). Can you check if a ping between target and host is working ?

Hope this helps

Hi @vasi,

Sorry to see you had that much trouble to run OpenCN.

What is your current status ? Were you able to make it run with the GUI ?

Soltner Xavier

Hi @Xavier @jmi
I was kinda offline in the last month so I did not tried to run it anymore.
I saw the PR that added new functionalities to halcmd, looked over it but it was mostly c/c++ so didn’t had something relevant to say on that PR.

The last issue that I remember while trying to run the client was smth related to LD_LIBRARY_PATH, but before we start debugging it again I will pull the latest sources and try to rebuild again.

Will come back with the result.

Thanks for your support,
Vasi Mihalca

1 Like