Skip to content

Commit

Permalink
Merge pull request #10 from icshwi/devel/ccat_netdev
Browse files Browse the repository at this point in the history
Devel/ccat netdev
  • Loading branch information
jeonghanlee authored Dec 4, 2019
2 parents 15aecce + 6ba4064 commit dd36c80
Show file tree
Hide file tree
Showing 11 changed files with 1,726 additions and 28 deletions.
140 changes: 131 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ In order to remove them and clean the configuration
```sh
etherlabmaster (master)$ sudo systemctl stop ethercat
etherlabmaster (master)$ sudo systemctl disable ethercat
etherlabmaster (master)$ make setup_clean
etherlabmaster (master)$ make conf
etherlabmaster (master)$ make dkms_uninstall
etherlabmaster (master)$ make dkms_remove
etherlabmaster (master)$ make setup_clean

```

## Steps
Expand Down Expand Up @@ -220,7 +222,7 @@ It uses the default variable which one has to set as `ETHERCAT_MASTER0` at the b
$ make show_netdrv
/sys/class/net/enp0s25/device/uevent:DRIVER=e1000e
```
Once the `e1001e` native driver is loaded within the Linux kernel, one cannot see the netdrv anymore, because the device which one allocate is not the network device anymore.
Once the `e1000e` native driver is loaded within the Linux kernel, one cannot see the netdrv anymore, because the device which one allocate is not the network device anymore.

## Troubleshooting

Expand All @@ -243,16 +245,10 @@ Once the `e1001e` native driver is loaded within the Linux kernel, one cannot se
#### Comments
* It is still unclear how to build `ethercat.conf` if we have more than one devices now.


#### Beckhoff CCAT FPGA Kernel Mode Driver

* https://github.com/jeonghanlee/CCAT-env


## CentOS7 with the NATIVE e1000e driver

### Notice and Warning
* This is **NOT** for the genric driver, **BUT** for the **NATIVE** e1000e driver. If one would like to use the genric one, it is not necessary to follow this step. If one doesn't know what difference is, one should go the generic one.
* This is **NOT** for the generic driver, **BUT** for the **NATIVE** e1000e driver. If one would like to use the generic one, it is not necessary to follow this step. If one doesn't know what difference is, one should go the generic one.

Due to `rh_kabi.h`, we cannot compile e1000e native driver the default kernel 3.10. Thus, it needs the special patch file for this purpose. Some functionalities are limited and especially related with kernel log and a network device usage statistics. Both of them are no critical things for the ethercat application. The additional makefile rule command `make centos7_patch` is necessary before `make dkms_add`. The full commands are

Expand All @@ -267,3 +263,129 @@ make dkms_install
make setup
```


## Beckhoff CCAT FPGA Kernel Mode Driver [1]

### Install Beckhoff CCAT Kernel Driver

Please follow the README file in https://github.com/jeonghanlee/CCAT-env
Make sure the kernel drivers are loaded
```
lsmod |grep ccat
ccat_update 16384 0
ccat_systemtime 16384 0
ccat_sram 16384 0
ccat_gpio 16384 0
ccat_netdev 20480 0
ccat 16384 2 ccat_sram,ccat_update
```

### Etherlabmaster code

The etherlab master needs the following patch file in [2]. This repository has the copied version of this file with the hash id `bc9e28f` ( 2019-11-05 ) in `patch/CCAT`. For further information, please look at the header of the patch file. In addition, `ccat_netdev.ko` cannot be removed if it is loaded. With that kernel module, we cannot insert `ec_ccat_netdev.ko`. Thus, we need to have another patch file [3]. Please remember that one should the Beckhoff CCAT first [1,4], then follow the commands.

### Commands

* Set the `ETHERCAT_MASTER0` (This should be verified!!!)

```
echo "ETHERCAT_MASTER0=enp0s25" > ethercatmaster.local
```

* Make sure that there is no existent etherlabmaster EtherCAT kernel



```
make init
echo "WITH_DEV_GENERIC = NO" > configure/CONFIG_OPTIONS.local
echo "WITH_DEV_CCAT = YES" >> configure/CONFIG_OPTIONS.local
make ccat_patch
make build
make install
make dkms_add
make dkms_build
make dkms_install
make setup
```

### Few interesting command results

```
$ echo "WITH_DEV_GENERIC = NO" > configure/CONFIG_OPTIONS.local
$ echo "WITH_DEV_CCAT = YES" >> configure/CONFIG_OPTIONS.local
$ make showopts
>>>> Configuration Options Variables <<<<
E3_EHTERLAB_CONF_OPTIONS is defined as the follows:
--disable-generic --disable-8139too --disable-e100 --disable-e1000 --disable-e1000e --disable-igb --disable-r8169 --enable-ccat_netdev --enable-static=yes --enable-shared=yes --enable-eoe=no --enable-cycles=yes --enable-hrtimer=no --enable-regalias=no --enable-tool=yes --enable-userlib=yes --enable-sii-assign=yes --enable-rt-syslog=yes
WITH_PATCHSET = NO
WITH_DEV_8139TOO = NO
WITH_DEV_CCAT = YES
WITH_DEV_E100 = NO
WITH_DEV_E1000 = NO
WITH_DEV_E1000E = NO
WITH_DEV_GENERIC = NO
WITH_DEV_IGB = NO
WITH_DEV_R8169 = NO
ENABLE_CYCLES = YES
ENABLE_EOE = NO
ENABLE_HRTIMER = NO
ENABLE_REGALIAS = NO
ENABLE_RT_SYSLOG = YES
ENABLE_SII_ASSIGN = YES
ENABLE_STATIC = YES
ENABLE_TOOL = YES
ENABLE_USERLIB = YES
make ccat_patch
Patching etherlabmaster-code with the CCAT patch file : /home/jhlee/ics_gitsrc/etherlabmaster/patch/CCAT/0001-convert-ccat-to-mfd.patch
patching file configure.ac
Hunk #1 succeeded at 539 (offset -1 lines).
Hunk #2 succeeded at 548 (offset -1 lines).
patching file devices/ccat/Kbuild.in
patching file devices/ccat/Makefile.am
patching file devices/ccat/gpio.c
patching file devices/ccat/module.c
patching file devices/ccat/module.h
patching file devices/ccat/netdev.c
patching file devices/ccat/sram.c
patching file devices/ccat/update.c
patching file devices/ccat/update.h
patching file script/ethercat.conf
patching file script/ethercatctl.in
patching file script/sysconfig/ethercat
```


```
# systemctl restart ethercat
# lsmod |grep ccat
ec_ccat_netdev 24576 0
ec_master 331776 1 ec_ccat_netdev
ccat_update 16384 0
ccat_systemtime 16384 0
ccat_sram 16384 0
ccat_gpio 16384 0
ccat 16384 2 ccat_sram,ccat_update
```


## References
[1] https://github.com/Beckhoff/CCAT

[2] https://github.com/Beckhoff/CCAT/blob/master/etherlab-patches/0001-convert-ccat-to-mfd.patch

[3] https://github.com/icshwi/etherlabmaster/blob/devel/ccat_netdev/patch/CCAT/0002-remove-beckhoff-ccat_netdev-if-exists.patch

[4] https://github.com/jeonghanlee/CCAT-env
27 changes: 16 additions & 11 deletions configure/E3/CONFIG_OPTIONS_BUILDER
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@

## Network Devices
## Tested
ifeq ($(WITH_DEV_GENERIC),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-generic
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-generic
endif

## NOT Tested
ifeq ($(WITH_DEV_8139TOO),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-8139too
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-8139too
endif



## NOT Tested
ifeq ($(WITH_DEV_E100),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-e100
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-e100
endif


## NOT Tested
ifeq ($(WITH_DEV_E1000),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-e1000
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-e1000
endif


## Tested
ifeq ($(WITH_DEV_E1000E),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-e1000e
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-e1000e
endif


## NOT Tested
ifeq ($(WITH_DEV_IGB),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-igb
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-igb
endif


## NOT Tested
ifeq ($(WITH_DEV_R8169),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-r8169
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-r8169
endif


## Tested
## Native CCAT needs the convert-ccat-to-mfd.patch
## So, the option should be used as -ccat_netdev instead of -ccat
## Thursday, November 28 23:42:05 CET 2019, jhlee
##
ifeq ($(WITH_DEV_CCAT),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-ccat
E3_ETHERLAB_CONF_OPTIONS+=--enable-ccat_netdev
else
E3_ETHERLAB_CONF_OPTIONS+=--disable-ccat
endif



## Other Options
##
ifeq ($(ENABLE_STATIC),YES)
E3_ETHERLAB_CONF_OPTIONS+=--enable-static=yes
else
Expand Down
28 changes: 24 additions & 4 deletions configure/E3/DEFINES_FT
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ endef

define patch_revert_site
for i in $(wildcard $(TOP)/patch/Site/*p0.patch); do\
printf "\nRevering path %s with the file : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
printf "\nReverting Site patch files in %s : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
patch -R -d $(E3_MODULE_SRC_PATH) --ignore-whitespace -p0 < $$i;\
done
endef
Expand All @@ -39,28 +39,46 @@ endef

define patchset_revert
for i in $(wildcard $(TOP)/patch/patchset/*p0.patch); do\
printf "\nRevering path %s with the Patchset file : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
printf "\nReverting Patchset patch files in %s : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
patch -R -d $(E3_MODULE_SRC_PATH) --ignore-whitespace -p0 < $$i;\
done
endef


define patchcentos7
for i in $(wildcard $(TOP)/patch/CentOS7/*p0.patch); do\
printf "\nPatching %s with the Patchset file : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
printf "\nPatching %s with the CentOS7 file : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
patch -d $(E3_MODULE_SRC_PATH) --ignore-whitespace -p0 < $$i;\
done
endef


define patchcentos7_revert
for i in $(wildcard $(TOP)/patch/CentOS7/*p0.patch); do\
printf "\nRevering path %s with the Patchset file : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
printf "\nReverting CentOS7 patch files in %s : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
patch -R -d $(E3_MODULE_SRC_PATH) --ignore-whitespace -p0 < $$i;\
done
endef


## p1 patch
define patchCCAT
for i in $(wildcard $(TOP)/patch/CCAT/*patch); do\
printf "\nPatching %s with the CCAT patch file : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
patch -d $(E3_MODULE_SRC_PATH) --ignore-whitespace -p1 < $$i;\
done
endef


define patchCCAT_revert
for i in $(wildcard $(TOP)/patch/CCAT/*patch); do\
printf "\nReverting CCAT patch files in %s : %s\n" "$(E3_MODULE_SRC_PATH)" "$$i";\
patch -R -d $(E3_MODULE_SRC_PATH) --ignore-whitespace -p1 < $$i;\
done
endef




ifndef VERBOSE
QUIET := @
Expand All @@ -82,3 +100,5 @@ VARS_EXCLUDES+=QUIET
VARS_EXCLUDES+=SHELL
VARS_EXCLUDES+=patchcentos7
VARS_EXCLUDES+=patchcentos7_revert
VARS_EXCLUDES+=patchCCAT
VARS_EXCLUDES+=patchCCAT_revert
9 changes: 7 additions & 2 deletions configure/E3/RULES_DKMS_BUILDER
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ yesconf:
@init_drv_num=0;\
device_modules="";\
for drv in $(YES_VARS); do\
driver_name=$$(echo $$drv | sed -e "s:WITH_DEV_::g" | sed -e 's/\(.*\)/\L\1/');\
driver_path_name=$$(echo $$drv | sed -e "s:WITH_DEV_::g" | sed -e 's/\(.*\)/\L\1/');\
if [ "$$driver_path_name" = "ccat" ]; then\
driver_name=$$(echo $$driver_path_name)"_netdev";\
else\
driver_name="$$driver_path_name";\
fi;\
device_modules="$$driver_name $$device_modules";\
driver_name="$$driver_name";\
init_drv_num=$$(($$init_drv_num+1));\
# echo "$$init_drv_num $$drv $$driver_name";\
if [ "$$driver_name" = "generic" ]; then\
sed -e "s:__NUMBER__:$$init_drv_num:g" < $(TOP)/dkms/dkmsDevGeneric.in > $(TOP)/dkms/dkmsDev$$init_drv_num.local;\
else\
sed -e "s:__NAME__:$$driver_name:g" -e "s:__NUMBER__:$$init_drv_num:g" < $(TOP)/dkms/dkmsDevN.in > $(TOP)/dkms/dkmsDev$$init_drv_num.local;\
sed -e "s:__PATHNAME__:"$$driver_path_name":g" -e "s:__NAME__:"$$driver_name":g" -e "s:__NUMBER__:$$init_drv_num:g" < $(TOP)/dkms/dkmsDevN.in > $(TOP)/dkms/dkmsDev$$init_drv_num.local;\
fi;\
done;\
echo "DEVICE_MODULES=\"$${device_modules%?}\"" > $(TOP)/scripts/device_modules.conf
Expand Down
7 changes: 7 additions & 0 deletions configure/E3/RULES_ETHERLAB
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@ dkms_uninstall:

.PHONY: setup setup_clean



## Configuration for EtherCAT Master (systemd, ethercat.conf, and others)
setup:
ifeq ($(WITH_DEV_CCAT),YES)
$(QUIET) echo ">>> If /etc/module-load.d/ccat_netdev.conf exists,"
$(QUIET) echo " we are removing it, because it cannot be coexist with ec_ccat_netdev.\n"
$(QUIET) $(SUDO_CMD) find /etc/modules-load.d/ -maxdepth 1 -name "ccat_netdev*" -exec rm {} +
endif
$(QUIET) bash $(TOP)/scripts/etherlab_setup.bash -t $(E3_ETHERLAB_INSTALL_LOCATION)

## Clean up the configuration for EtherCAT Master (systemd, ethercat.conf, and others)
Expand Down
17 changes: 17 additions & 0 deletions configure/E3/RULES_PATCHCCAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

.PHONY: patch patchrevert


## Apply Patch Files
ccat_patch:
$(QUIET) $(call patchCCAT)

## Revert Patch Files
ccat_patchrevert:
$(QUIET) $(call patchCCAT_revert)



VARS_EXCLUDES+=ccat_patchrevert
VARS_EXCLUDES+=ccat_patch

14 changes: 13 additions & 1 deletion configure/E3/RULES_VARS
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,16 @@ info: vers
vers:
$(QUIET)echo "EtherlabMaster_SRCTAG:=$(EPICS_MODULE_TAG)"
$(QUIET)echo "EtherlabMaster_VERSION:=$(E3_MODULE_VERSION)"
$(QUIET)echo "ETHERCAT_MASTER0:=$(ETHERCAT_MASTER0)"
$(QUIET)echo "ETHERCAT_MASTER0:=$(ETHERCAT_MASTER0)"


# https://www.cmcrossroads.com/article/printing-value-makefile-variable
PRINT.%:
$(QUIET)echo $* = $($*)
$(QUIET)echo $*\'s origin is $(origin $*)

print-%:
$(QUIET)echo $* = $($*)
$(QUIET)echo $*\'s origin is $(origin $*)

FORCE:
1 change: 1 addition & 0 deletions configure/RULES
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ include $(TOP)/configure/E3/RULES_DKMS_BUILDER
include $(TOP)/configure/E3/RULES_ETHERLAB
include $(TOP)/configure/E3/RULES_PATCHSET
include $(TOP)/configure/E3/RULES_PATCHCENTOS7
include $(TOP)/configure/E3/RULES_PATCHCCAT

include $(TOP)/configure/E3/RULES_VARS
Loading

0 comments on commit dd36c80

Please sign in to comment.