Machinekit

Machinekit

DEx(x) U-BOOT (initial boot):

Regarding the Terasic based DEx(x) Boards there are 4 crucial u-boot variables to be aware of:

  1. ethaddr,

  2. fdtfile,

  3. fpgaload_on_boot

  4. bitimage (only perhaps):


  • On your very first boot you have to boot into a u-boot console:

U-Boot:

Attach usb cable to port next to ethernet connector and open a separate serial console 115k 8n1

linux example:

me@pc:~$ sudo apt install ckermit
me@pc:~$ sudo kermit
C-Kermit 9.0.302 OPEN SOURCE:, 20 Aug 2011, for Linux+SSL+KRB5 (64-bit)
 Copyright (C) 1985, 2011,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/home/me/) C-Kermit>set line /dev/ttyUSB0
(/home/me/) C-Kermit>set baud 115200
/dev/ttyUSB0, 115200 bps
(/home/me/) C-Kermit>set escape-character ^X
(/home/me/) C-Kermit>log session ~/.kermlog
(/home/me/) C-Kermit>set flow-control none
(/home/me/) C-Kermit>set stop-bits 1
(/home/me/) C-Kermit>set carrier-watch off
(/home/me/) C-Kermit>connect
Connecting to /dev/ttyUSB0, speed 115200
  • press any button on your keyboard in the u-boot console within 2 sec of turning on power to your soc board.


  • first setup the ethaddr variable:

This has to contain a real ipv4 internet mac address in below format; replace the x’es with hex numbers. If you want to have a random mac adress generated, see this link.

=> setenv ethaddr xx:xx:xx:xx:xx:xx

Note: the ethernet nic mac address is a special sticky variable and cannot be changed the same way again. However you can reset all variables to their default first boot settings with:

=> env default -f -a

  • Second check that the fdtfile is set to the generic version that will make all boards boot without the fpga being configured by uboot.

=> print fdtfile
fdtfile=socfpga_cyclone5_de0_sockit.dtb

if this variable shows something else change it with:

=> setenv fdtfile socfpga_cyclone5_de0_sockit.dtb

  • Third Check the fpgaload_on_boot variable is unset:

=> print fpgaload_on_boot
fpgaload_on_boot=0

  • Now you are ready to save the settings and reboot fully into a linux console for the very first time:

=> saveenv
=> reset

  • From any linux console:

Linux:

  • On your initial boot its recomended to update the linux distribuation by doing:

sudo apt update
sudo apt upgrade
  • Bugfix:
    lib5-dev does’nt get installed properly by the image builder, this gives errors if anything tries to build software, solution:

sudo apt install --reinstall libc6-dev

  • Next install the (Altera/Intel socfpga related) bitfiles:

sudo apt install socfpga-rbf

  • Then you are all set to install Machinekit-hal and eventually machinekit-cnc

sudo apt install machinekit-hal-rt-preempt
sudo apt install machinekit-cnc-rt-preempt

###   This ends the initial install for console only mode   ###

To run lxqt desktop with a hdmi display 1024x768@60 (DE10_Nano only) following extra steps are needed:

Linux:

  • install display manager:

sudo apt install lxqt
  • Set the following uboot variables:
    bitimage
    fdtfile
    fpgaload_on_boot+

Either in your linux console:

sudo fw_setenv bitimage '/lib/firmware/socfpga/DE10_Nano_FB_Cramps.3x24_cap_enc.rbf'
sudo sudo fw_setenv fdtfile 'socfpga_cyclone5_de10_nano_uio_fb.dtb'
sudo fw_setenv fpgaload_on_boot 1

then reboot

sudo reboot now

Or:

u-boot:

From the u-boot console:

=> setenv bitimage '/lib/firmware/socfpga/DE10_Nano_FB_Cramps.3x24_cap_enc.rbf'
=> setenv fpgaload_on_boot 1
=> savvenv
=> reset

Fpga config note:

When using the display the fpga must be programmed by u-boot only and not (re)programmed later by machinekit,

  • This has to happen before the linux kernel loads. Reprogramming the fpga after linux is booted will currently give problems, (until partial reconfiguration becomes an option hopefully with quartus 19.1 lite). So machinekit has to use the: "SOC-no-fw-load" config method when loading the hm2_soc_ol driver: (fpga gets programmed by u-boot, setup earlier)

example:

newinst hm2_soc_ol hm2-socfpga0 already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4 num_encoders=1 enable_adc=1" debug=1

More About the "SOC-no-fw-load" config method:

  • This makes Machinekit not (re)program the fpga when MACHINEKIT starts…​ The "fpgaload_on_boot 1" in u-boot makes u-boot program the fpga BEFORE linux starts up so that the Framebuffer then can be picked up, Ensure that the right devicetree (the one with framebuffer enabled: socfpga_cyclone5_de10_nano_uio_fb_hd.dtb) and bitfile are loaded by u-boot:

Current availabe 1024x768 hdmi bitfiles are:

machinekit@mksocfpga-nano-soc:~$ ls -l /lib/firmware/socfpga/DE10_Nano_FB_Cramps*
-rw-r--r-- 1 root root 2413816 May 10 01:26 /lib/firmware/socfpga/DE10_Nano_FB_Cramps.3x24_cap_enc.rbf
-rw-r--r-- 1 root root 2408572 May 10 02:14 /lib/firmware/socfpga/DE10_Nano_FB_Cramps.3x24_cap.rbf
-rw-r--r-- 1 root root 2406916 May 10 01:50 /lib/firmware/socfpga/DE10_Nano_FB_Cramps.3x24_cap_spi.rbf
-rw-r--r-- 1 root root 2405236 May 10 02:36 /lib/firmware/socfpga/DE10_Nano_FB_Cramps.3x24.rbf

### This ends the initial install for desktop hdmi display mode ###