-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Build flat and compressed kernel images
This patch extends Linux RISC-V build system to build and install: Image - Flat uncompressed kernel image Image.gz - Flat and GZip compressed kernel image Quiet a few bootloaders (such as Uboot, UEFI, etc) are capable of booting flat and compressed kernel images. In case of Uboot, booting Image or Image.gz is achieved using bootm command. The flat and uncompressed kernel image (i.e. Image) is very useful in pre-silicon developent and testing because we can create back-door HEX files for RAM on FPGAs from Image. Signed-off-by: Anup Patel <anup@brainfault.org> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
- Loading branch information
Anup Patel
authored and
Palmer Dabbelt
committed
Nov 20, 2018
1 parent
21f70d4
commit c0fbcd9
Showing
6 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Image | ||
Image.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# arch/riscv/boot/Makefile | ||
# | ||
# This file is included by the global makefile so that you can add your own | ||
# architecture-specific flags and dependencies. | ||
# | ||
# This file is subject to the terms and conditions of the GNU General Public | ||
# License. See the file "COPYING" in the main directory of this archive | ||
# for more details. | ||
# | ||
# Copyright (C) 2018, Anup Patel. | ||
# Author: Anup Patel <anup@brainfault.org> | ||
# | ||
# Based on the ia64 and arm64 boot/Makefile. | ||
# | ||
|
||
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S | ||
|
||
targets := Image | ||
|
||
$(obj)/Image: vmlinux FORCE | ||
$(call if_changed,objcopy) | ||
|
||
$(obj)/Image.gz: $(obj)/Image FORCE | ||
$(call if_changed,gzip) | ||
|
||
install: | ||
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ | ||
$(obj)/Image System.map "$(INSTALL_PATH)" | ||
|
||
zinstall: | ||
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ | ||
$(obj)/Image.gz System.map "$(INSTALL_PATH)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
# | ||
# arch/riscv/boot/install.sh | ||
# | ||
# This file is subject to the terms and conditions of the GNU General Public | ||
# License. See the file "COPYING" in the main directory of this archive | ||
# for more details. | ||
# | ||
# Copyright (C) 1995 by Linus Torvalds | ||
# | ||
# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin | ||
# Adapted from code in arch/i386/boot/install.sh by Russell King | ||
# | ||
# "make install" script for the RISC-V Linux port | ||
# | ||
# Arguments: | ||
# $1 - kernel version | ||
# $2 - kernel image file | ||
# $3 - kernel map file | ||
# $4 - default install path (blank if root directory) | ||
# | ||
|
||
verify () { | ||
if [ ! -f "$1" ]; then | ||
echo "" 1>&2 | ||
echo " *** Missing file: $1" 1>&2 | ||
echo ' *** You need to run "make" before "make install".' 1>&2 | ||
echo "" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Make sure the files actually exist | ||
verify "$2" | ||
verify "$3" | ||
|
||
# User may have a custom install script | ||
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi | ||
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi | ||
|
||
if [ "$(basename $2)" = "Image.gz" ]; then | ||
# Compressed install | ||
echo "Installing compressed kernel" | ||
base=vmlinuz | ||
else | ||
# Normal install | ||
echo "Installing normal kernel" | ||
base=vmlinux | ||
fi | ||
|
||
if [ -f $4/$base-$1 ]; then | ||
mv $4/$base-$1 $4/$base-$1.old | ||
fi | ||
cat $2 > $4/$base-$1 | ||
|
||
# Install system map file | ||
if [ -f $4/System.map-$1 ]; then | ||
mv $4/System.map-$1 $4/System.map-$1.old | ||
fi | ||
cp $3 $4/System.map-$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters