My notes on compiling LiteX-CNC on linuxCNC

More
18 Sep 2022 13:33 - 01 Oct 2022 16:18 #252264 by DePrutser
Hi All,

I am trying to compile LiteX-CNC [1] for a Colorlight 5A-75E [2] on LinuxCNC.
In the next series of reply's I'll document my findings.

[1] github.com/Peter-van-Tol/LiteX-CNC
[2] nl.aliexpress.com/item/1005003349205208....gatewayAdapt=glo2nld

Cheers,
Cedric
Last edit: 01 Oct 2022 16:18 by DePrutser. Reason: It's solved

Please Log in or Create an account to join the conversation.

More
18 Sep 2022 17:52 #252276 by DePrutser
1) Install linuxCNC from this ISO: www.linuxcnc.org/iso/linuxcnc-2.8.2-buster.iso
2) Install packages:
# apt-get update
# apt-get install libjson-c-dev
# apt-get install git
# apt-get install build-essential
3) Get the source
$ git clone github.com/Peter-van-Tol/LiteX-CNC.git
4) replace halcompile
# whereis halcompile
halcompile: /usr/bin/halcompile /usr/share/man/man1/halcompile.1.gz
# cd /home/cedric/LiteX-CNC
# cp halcompile.py /usr/bin/halcompile
5) build LiteX-CNC
# cd /home/cedric/LiteX-CNC/driver/
# halcompile --install litexcnc.c litexcnc_eth.c litexcnc_debug.c
6) load the driver
# loadrt litexcnc
-bash: loadrt: command not found

Hmmm... that does not work yet.

Please Log in or Create an account to join the conversation.

More
18 Sep 2022 18:07 #252279 by tommylight
Pretty sure you need to
halrun
before loading anything with loadrt.

Please Log in or Create an account to join the conversation.

More
18 Sep 2022 18:20 #252280 by DePrutser
I don't think loadrt exists on my system:
# whereis loadrt
loadrt:
root@mill:/home/cedric/LiteX-CNC/driver# cd /
root@mill:/# find -iname loadrt
root@mill:/#

Please Log in or Create an account to join the conversation.

More
18 Sep 2022 19:20 #252287 by tommylight

Please Log in or Create an account to join the conversation.

More
19 Sep 2022 07:30 #252318 by TOLP2

I don't think loadrt exists on my system:
# whereis loadrt
loadrt:
root@mill:/home/cedric/LiteX-CNC/driver# cd /
root@mill:/# find -iname loadrt
root@mill:/#

First run halrun from the shell to start the real-time:
# halrun

Then within the running hal environment you can do
loadrt litexcnc

Side note: While halrun is perfect to check whether the firmware is correctly installed and some basic tasks can be done (i.e. GPIO, PWM and presumably encoder), the stepgen is not designed to work without the motion planner of LinuxCNC.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
19 Sep 2022 16:48 #252354 by DePrutser
It does a little more this time:

root@mill:/# halrun
halcmd: loadrt litexcnc
Refusing to run as root without fallback UID specified
To run under a debugger with I/O, use e.g.,
    sudo env RTAPI_UID=`id -u` RTAPI_FIFO_PATH=$HOME/.rtapi_fifo gdb /usr/bin/rtapi_app
<stdin>:1: waitpid failed /usr/bin/rtapi_app litexcnc
<stdin>:1: /usr/bin/rtapi_app exited without becoming ready
<stdin>:1: insmod for litexcnc failed, returned -1
halcmd: quit
Refusing to run as root without fallback UID specified
To run under a debugger with I/O, use e.g.,
    sudo env RTAPI_UID=`id -u` RTAPI_FIFO_PATH=$HOME/.rtapi_fifo gdb /usr/bin/rtapi_app
root@mill:/#

I guess I have a manual to read before proceeding further.

Please Log in or Create an account to join the conversation.

More
19 Sep 2022 16:56 #252355 by TOLP2
Problem is, your logged in as root. Create a user and login to that user and try again.

Please Log in or Create an account to join the conversation.

More
20 Sep 2022 05:52 #252375 by DePrutser
Thanks, that worked:

cedric@mill:~$ halrun
halcmd: loadrt litexcnc
Note: Using POSIX realtime
litexcnc: Loading Litex CNC driver version 1.0.0
halcmd: exit
litexcnc: LitexCNC driver unloaded
Note: Using POSIX realtime
cedric@mill:~$

Please Log in or Create an account to join the conversation.

More
21 Sep 2022 02:28 - 21 Sep 2022 02:30 #252455 by DePrutser
I tried to compile the gateware for the FPGA, but I got this error:

sudo apt-get install wget
sudo apt-get install python3-pip

wget raw.githubusercontent.com/enjoy-digital/...aster/litex_setup.py
pip3 install --user meson ninja

python3 litex_setup.py --init --install --config=standard --gcc=riscv

wget github.com/YosysHQ/oss-cad-suite-build/r...nux-x64-20220920.tgz
tar -xvf oss-cad-suite-linux-x64-20220920.tgz

mkdir -p ~/bin
ln -s ~/LiteX/oss-cad-suite/bin/* ~/bin/

#start a new bash, so ~/bin is added to the PATH
bash --login
echo $PATH
/home/cedric/.local/bin:/home/cedric/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

#return to the LiteX-CNC repository
cd ~/LiteX-CNC/
python -m firmware examples/5a-75e.json
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "/usr/lib/python2.7/runpy.py", line 111, in _get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "firmware/__init__.py", line 20, in <module>
from .soc import LitexCNC_Firmware
File "firmware/soc.py", line 32
baseclass: Type = Field(
^
SyntaxError: invalid syntax
Last edit: 21 Sep 2022 02:30 by DePrutser. Reason: for got output of a command

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.099 seconds
Powered by Kunena Forum