Skip to content

Commit

Permalink
coreboot+linux modules: add helpers to edit config, save in oldconfig…
Browse files Browse the repository at this point in the history
…/defconfig
  • Loading branch information
tlaurion committed Apr 19, 2023
1 parent 8ff4b9a commit 33b7265
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 13 deletions.
25 changes: 25 additions & 0 deletions modules/coreboot
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ coreboot.saveconfig:
DEFCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
savedefconfig

coreboot.save_defconfig_in_place:
$(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
DEFCONFIG="$(build)/$(coreboot_dir)/defconfig" \
savedefconfig \
&& mv "$(build)/$(coreboot_dir)/defconfig" "$(pwd)/$(CONFIG_COREBOOT_CONFIG)"


coreboot.modify_defconfig_in_place:
$(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
menuconfig \
&& $(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
DEFCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
savedefconfig \

coreboot.modify_and_save_oldconfig_in_place:
$(MAKE) menuconfig \
-C "$(build)/$(coreboot_base_dir)" \
obj="$(build)/$(coreboot_dir)" \
DOTCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)"

# if we are not building from a git checkout,
# we must also download the coreboot-blobs tree
Expand Down
88 changes: 75 additions & 13 deletions modules/linux
Original file line number Diff line number Diff line change
Expand Up @@ -206,34 +206,53 @@ $(build)/$(BOARD)/$(LINUX_IMAGE_FILE).bundled: \
@touch $@ # force a timestamp update
@sha256sum "$@" | tee -a "$(HASHES)"

# modifydefconfig target allows us edit current in tree defconfig config
# under linux decompressed+patched directory and put it back in git tree
# to check changes with git difftool
# useful for development cycle of linux kernel version bumps.
linux.modifydefconfig:
# modify_defconfig_menuconfig target allows us edit current in tree defconfig config
# under linux decompressed+patched directory through menuconfig
# and put it back in git tree to check changes with git difftool iteratively
# Useful for development cycle of linux kernel version bumps in defconfig stored format.
linux.modify_defconfig_in_place:
cp "$(pwd)/$(linux_kconfig)" "$(build)/$(linux_dir)/.config" && \
$(MAKE) \
-C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
menuconfig && \
$(MAKE) \
-C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
savedefconfig && \
mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)"
CROSS_COMPILE="$(CROSS)" \
savedefconfig \
&& mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)"

linux.modify_and_save_oldconfig_in_place:
mkdir -p "$(build)/$(linux_dir)" \
&& cp "$(pwd)/$(linux_kconfig)" "$(build)/$(linux_dir)/.config" \
&& $(MAKE) -C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
menuconfig \
&& $(MAKE) -C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
olddefconfig \
&& mv "$(build)/$(linux_dir)/.config" "$(pwd)/$(linux_kconfig)"

# generateoldconfig target allows us to copy current in git tree defconfig
# generate_old_config target allows us to copy current in git tree defconfig
# into decompressed linux directory's .config file. This permits
# us to edit that .config file and remove unneeded stuff prior
# of calling saveconfig target from heads main directory (cd -)
linux.generateoldconfig:
# of calling save_defconfig target from heads main directory (cd -)
# to store it where the board expects it stored and used from.
linux.generate_old_config:
mkdir -p "$(build)/$(linux_dir)" \
&& cp "$(pwd)/$(linux_kconfig)" "$(build)/$(linux_dir)/.config" \
&& $(MAKE) -C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
olddefconfig \
&& echo "" \
&& echo "You can now edit $(build)/$(linux_dir)/.config" \
Expand All @@ -243,6 +262,15 @@ linux.generateoldconfig:
&& echo "" \
&& echo "To save chances in git tree for review, type:" \
&& echo "make BOARD=XYZ linux.saveconfig"
linux.generate_and_save-versioned-oldconfig:
mkdir -p "$(build)/$(linux_dir)" \
&& cp "$(pwd)/$(linux_kconfig)" "$(build)/$(linux_dir)/.config" \
&& $(MAKE) -C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
olddefconfig \
&& mv "$(build)/$(linux_dir)/.config" "$(pwd)/$(linux_kconfig)_oldconfig_$(CONFIG_LINUX_VERSION)"

# menuconfig target allows us to easily reconfigure this Linux kernel
# Afterwards make linux.saveconfig to generate a minimal config from it
Expand All @@ -251,14 +279,48 @@ linux.menuconfig:
-C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
menuconfig \

#Add some tooling to permit us to keep track of what we currently use.
# regenerate_and_save_defconfig: regenerate a defconfig from current board linux config and overwrites it
# regenerate_and_save_versioned_defconfig : same as avove but doesn't overwrite: writes it in seperate versioned file
linux.regenerate_and_save_defconfig:
mkdir -p "$(build)/$(linux_dir)" \
&& cp "$(pwd)/$(linux_kconfig)" "$(build)/$(linux_dir)/.config" \
&& $(MAKE) -C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
savedefconfig \
&& mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)"
linux.regenerate_and_save_versioned_defconfig:
mkdir -p "$(build)/$(linux_dir)" \
&& cp "$(pwd)/$(linux_kconfig)" "$(build)/$(linux_dir)/.config" \
&& $(MAKE) -C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
savedefconfig \
&& mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)_defconfig_$(CONFIG_LINUX_VERSION)"

# The config file in the repo is stored as a "defconfig" format
# which only includes the options that have changed from the defaults.
linux.saveconfig:
# Here dave_defconfig takes .config under extracted linux dir and save it back to where board expects it
linux.save_defconfig:
$(MAKE) \
-C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
CROSS_COMPILE="$(CROSS)" \
savedefconfig \
&& mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)"
#Same as above, but instead of overwriting the board's expected file, we store it in a file versioned by kernel version
linux.save_versioned_defconfig:
$(MAKE) \
-C "$(build)/$(linux_base_dir)" \
O="$(build)/$(linux_dir)" \
ARCH="$(LINUX_ARCH)" \
savedefconfig
mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)"
CROSS_COMPILE="$(CROSS)" \
savedefconfig \
&& mv "$(build)/$(linux_dir)/defconfig" "$(pwd)/$(linux_kconfig)_defconfig_$(CONFIG_LINUX_VERSION)"

0 comments on commit 33b7265

Please sign in to comment.