Skip to content

Commit

Permalink
- Updated building procedure
Browse files Browse the repository at this point in the history
- Renamed kerbbl to mkbbl
- Renamed patch_bbl to bbl-patch
  • Loading branch information
sh1r4s3 committed Dec 5, 2018
1 parent b9c38d8 commit a490502
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
27 changes: 14 additions & 13 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@ LD=@CC@
PREFIX=@prefix@

CFLAGS=@CFLAGS@
SRC=$(shell find src/ -name "*.c")
PROG=patch_bbl
SRC_PATH=@abs_top_srcdir@
SRC=$(shell find ${SRC_PATH}/src/ -name "*.c")
PROG=bbl-patch
HELPERSH=mkbbl
_ := $() $()
comma := ,

all: $(PROG)

$(PROG): $(SRC:.c=.o)
$(LD) $^ -o $@
cp $(SRC_PATH)/$(HELPERSH) .

%.o: %.c
$(CC) -c $< -o $@

.PHONY: install
install: $(PROG)
install: $(PROG) $(HELPERSH)
mkdir -p $(DESTDIR)/$(PREFIX)/bin
mkdir -p $(DESTDIR)/$(PREFIX)/sbin
cp $< $(DESTDIR)/$(PREFIX)/bin
cp kerbbl $(DESTDIR)/$(PREFIX)/sbin
chmod 755 $(DESTDIR)/$(PREFIX)/bin/$<
chmod 755 $(DESTDIR)/$(PREFIX)/sbin/kerbbl
cp {$(subst $(_),$(comma),$^)} $(DESTDIR)/$(PREFIX)/bin/
chmod 755 $(DESTDIR)/$(PREFIX)/bin/{$(subst $(_),$(comma),$^)}

.PHONY: uninstall
uninstall: $(PROG)
rm -f $(DESTDIR)/$(PREFIX)/bin/$<
rm -f $(DESTDIR)/$(PREFIX)/sbin/kerbbl
uninstall: $(PROG) $(HELPERSH)
rm -f $(DESTDIR)/$(PREFIX)/bin/{$(subst $(_),$(comma),$^)}

.PHONY: clean
clean:
rm -vf $(PROG) src/*.o
rm -vf $(PROG) $(HELPERSH) src/*.o

.PHONY: distclean
distclean:
rm -vrf $(PROG) src/*.o Makefile autom4te.cache config.log config.status
rm -vrf $(PROG) $(SRC:.c=.o) Makefile autom4te.cache config.log config.status
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This is the utils for RISC-V Berkeley Bootloader (BBL).

- patch_bbl -- this util allows one to patch Berkeley Bootloader (bbl) image file with kernel included to it.
- kerbbl -- this script uses objcopy to strip vmlinux ELF and obtain raw binary of a kernel. Then it will concatenate bbl and raw kernel binary, patch it and out to a new binary file.
- bbl-patch -- this util allows one to patch Berkeley Bootloader (bbl) image file with kernel included to it.
- mkbbl -- this script uses objcopy to strip vmlinux ELF and obtain raw binary of a kernel. Then it will concatenate bbl and raw kernel binary, patch it and out to a new binary file.

Author: Nikita Ermakov <arei@basealt.ru> <coffe92@gmail.com>
Author: Nikita Ermakov <arei@altlinux.org> <coffe92@gmail.com>
13 changes: 9 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ dnl Process this file in order to make a configure script
dnl

dnl Setup autoconf
AC_INIT([riscv-bbl], [0.1], [arei@basealt.ru])
AC_INIT([riscv-bbl], [0.2], [arei@altlinux.org])
dnl AM_INIT_AUTOMAKE

dnl debug option
dnl Debug option
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],[enable debugging, defult: no]),
[case "${enableval}" in
yes) debug = true ;;
no) debug = false ;;
*) AC_MSG_ERROR([bad value ${enablevalue} for --enable-debug]) ;;
esac], [debug=false])

dnl Check dependences
echo "Cheking dependences"
AC_LANG(C)
AC_CHECK_TOOL(OBJCOPY, objcopy)
AC_CHECK_TOOL(GDISK, gdisk)
AC_CHECK_TOOL(SGDISK, sgdisk)

dnl disable all CFLAGS if it was not declarated
dnl Disable all CFLAGS if it was not declarated
if [test -z $CFLAGS; ] then
if test x"${debug}" == x"true"; then
CFLAGS="-g -O0"
Expand All @@ -43,7 +44,11 @@ if [ test "x$SGDISK" == "x"; ] then
AC_MSG_ERROR([sgdisk from gdisk package required])
fi

dnl Get source code path
dnl AC_DEFINE_UNQUOTED([SRC_PATH], ["$srcdir"], [source path])

dnl Configure Makefile from Makefile.in
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([$srcdir/Makefile])

AC_OUTPUT
mv $srcdir/Makefile .
23 changes: 11 additions & 12 deletions kerbbl → mkbbl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Author: Nikita Ermakov <arei@basealt.ru> <coffe92@gmail.com>
# Version: v0.1
# Version: v0.2
# Date: 24 Aug 2018
# License: GNU GPL v3
# Description: This script is a part of riscv-bbl package.
Expand All @@ -14,7 +14,7 @@
# variables
IN_VMLINUX=""
OUT_BBL_BIN=""
BBL_BIN="bbl.wopayload.bin"
BBL_BIN=""

# check color support
if test -t 1 ; then
Expand All @@ -35,21 +35,20 @@ if test -t 1 ; then
fi
fi

if [ $# -gt 1 ]; then
if [ $# == 3 ]; then
IN_VMLINUX=$1
OUT_BBL_BIN=$2
if [ $# -gt 2 ]; then
BBL_BIN=$3
fi
BBL_BIN=$2
OUT_BBL_BIN=$3
else
echo -e "Usage: kerbbl IN_VMLINUX OUT_BBL_BIN [IN_BBL_BIN]\nwhere:\
\n\tIN_VMLINUX -- path to the Linux kernel image\
\n\tOUT_BBL_BIN -- path to the output BBL binary\
\n\tIN_BBL_BIN -- input name of BBL without payload\n"
echo -e "Usage: mkbbl IN_VMLINUX IN_BBL_BIN OUT_BBL_BIN\nwhere:\
\n\tIN_VMLINUX -- path to the Linux kernel image\
\n\tIN_BBL_BIN -- input name of BBL without payload\
\n\tOUT_BBL_BIN -- path to the output BBL binary\n"
exit -1
fi

echo ${cyan}Using vmlinux kernel:${normal} $IN_VMLINUX
echo ${cyan}Using input bbl.bin:${normal} $BBL_BIN
echo ${cyan}Using output bbl.bin:${normal} $OUT_BBL_BIN

# extart raw binary from vmlinux
Expand Down Expand Up @@ -85,7 +84,7 @@ mv $OUT_BBL_BIN $OUT_BBL_BIN.tmp

# patch berkeley bootloader
echo -n "${cyan}Patching Berkeley bootloader... ${normal}"
ERROR_CMD=`./patch_bbl -f $OUT_BBL_BIN.tmp -o $OUT_BBL_BIN`
ERROR_CMD=$(bbl-patch -f $OUT_BBL_BIN.tmp -o $OUT_BBL_BIN)
if test -z "$ERROR_CMD"; then
echo "${green}[DONE]${normal}"
else
Expand Down

0 comments on commit a490502

Please sign in to comment.