Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rules to build cavium platform modules #186

Merged
merged 4 commits into from
Jan 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions platform/cavium/cavm_platform_modules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CAVM_PLATFORM_DEB = cavm_platform_modules.deb
$(CAVM_PLATFORM_DEB)_SRC_PATH = $(PLATFORM_PATH)/cavm_platform_modules
SONIC_MAKE_DEBS += $(CAVM_PLATFORM_DEB)

6 changes: 6 additions & 0 deletions platform/cavium/cavm_platform_modules/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package: cavm-platform-modules
Version: 1.0
Architecture: amd64
Depends: linux-3.16.36
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be this one. Depends: linux-image-3.16.0-4-amd64

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to add changelog into the deb package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks.

Maintainer: Nadiya.Stetskovych@cavium.com
Description: kernel modules for platform devices such as fan, led, sfp
27 changes: 27 additions & 0 deletions platform/cavium/cavm_platform_modules/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

MAIN_TARGET = cavm_platform_modules.deb
DEB_BUILD_DIR = cavm-platform-modules-deb
KVERSION = linux-3.16.36
Copy link
Collaborator

@marian-pritsak marian-pritsak Jan 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why different version from what SONiC uses (3.16.04)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SONiC already use 3.16.36


$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# get sources
rm -rf SONiC
git clone https://github.com/edge-core/SONiC.git

# build
pushd SONiC/AS7512-32X/module/

KERNEL_SRC=/sonic/src/sonic-linux-kernel/$(KVERSION)/debian/build/build_amd64_none_amd64 make
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that using a path in sources is a good idea
It is obtained by fetching archives from online repositories during linux kernel build
In case these modules are built before linux kernel, build will fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not built any modules before kernel :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we can
sonic-slave comes with linux-headers for cross-compilation
You can set KERNEL_SRC to /lib/modules/$(KVERSION)/build
But in this case KVERSION provided by buildimage should be used (13.16.0-4-amd64).
This is a release version of kernel that SONiC uses (equal to uname -r) as opposed to 3.16.36 (distribution version as in uname -v)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understated final image (sonic-generic.bin) will have 3.16.36. So built modules for kernel where it will be inserted. Correct if I am wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we install the linux-headers-3.16.0-4-amd64_3.16.36-1+deb8u2_amd64.deb and linux-headers-3.16.0-4-common_3.16.36-1+deb8u2_amd64.deb we have built first?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NStetskovych Kernel release version is unchanged 3.16.0-4-amd64 and should be used for cross-compilation without caring about distro versions.

@lguohan I already wanted to install them, but I didn't find any difference between headers provided by those two distro versions and what we have now. Anyway, it will be better to install them to ensure we won't miss anything in the future. There's going to be a separate PR with headers integrated and variables for distro version and subversion to avoid duplication as it is done for other targets.

Copy link
Contributor Author

@NStetskovych-zz NStetskovych-zz Jan 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marian-pritsak I can change, but I do not understand how I will build modules for 3.16.0-4 but insert for 3.16.36?
Wouldn`t it be strange to have in rules KERNEL_SRC pointing to 3.16.0-4 but put modules in deb package to lib/modules/3.16.36?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every version of linux ships linux-headers that can be installed for modules compilation (linux-headers-3.16.0-4-amd64_3.16.36-1+deb8u2_amd64.deb and linux-headers-3.16.0-4-common_3.16.36-1+deb8u2_amd64.deb for current linux version). These .deb packages contain headers and Makefiles needed in order to compile external modules and are always installed into /lib/modules/linux-headers-$(uname -r)/.

So to compile modules KERNEL_SRC is always equal to /lib/modules/$(KVERSION)/build and KVERSION is always equal to kernel release (3.16.0-4-amd64 in our case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

popd
mkdir -p $(DEB_BUILD_DIR)/lib/modules/$(KVERSION)

cp SONiC/AS7512-32X/module/*.ko $(DEB_BUILD_DIR)/lib/modules/$(KVERSION)
cp -r DEBIAN $(DEB_BUILD_DIR)
dpkg-deb -b $(DEB_BUILD_DIR) $(MAIN_TARGET)

mv $(MAIN_TARGET) $(DEST)/
rm -rf $(DEB_BUILD_DIR)

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package: cavm-platform-modules
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are two copies of same file provided?
(see 2-nd file in PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my fault, will remove. thanks.

Version: 1.0
Architecture: amd64
Depends: linux-3.16.36
Maintainer: n@gmail.com
Description: kernel modules for platform devices such as fan, led, sfp
1 change: 1 addition & 0 deletions platform/cavium/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include $(PLATFORM_GENERIC_PATH)/rules.mk
include $(PLATFORM_PATH)/cavm-sai.mk
include $(PLATFORM_PATH)/docker-syncd-cavm.mk
include $(PLATFORM_PATH)/docker-orchagent-cavm.mk
include $(PLATFORM_PATH)/cavm_platform_modules.mk

SONIC_ALL += $(DOCKER_SYNCD_CAVM) \
$(DOCKER_ORCHAGENT_CAVM)
Expand Down