MIPS: add pre-bootloader (pbl) image support
cover MIPS: add pre-bootloader (pbl) image support
This patch series introduce pre-bootloader (pbl) support on MIPS. The only supported board is qemu-malta.
[PATCH 1/3] MIPS: add pre-bootloader (pbl) image support [PATCH 2/3] MIPS: qemu-malta: add trivial pbl support [PATCH 3/3] MIPS: qemu-malta_defconfig: use pbl
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 MIPS: qemu-malta: add trivial pbl support
Trivial pbl support has no cpu specific setup.
We will add cache setup routines in the future.
--- .../qemu-malta/include/board/board_pbl_start.h | 34 ++++++++++++++++++++ arch/mips/mach-malta/Kconfig | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 arch/mips/boards/qemu-malta/include/board/board_pbl_start.h
arch/mips/boards/qemu-malta/include/board/board_pbl_start.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Startup Code for MIPS CPU +* +* Copyright (C) 2012 Antony Pavlov <[email protected]> +* +* This file is part of barebox. +* See file CREDITS for list of people who contributed to this project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <asm/pbl_macros.h> + + .macro board_pbl_start + .set push + .set noreorder + + mips_disable_interrupts + + /* cpu specific setup ... */ + /* ... absent */ + + copy_to_link_location pbl_start + + .set pop + .endm
arch/mips/mach-malta/Kconfig +2 -0
@@ -9,6 +9,8 @@ choice config BOARD_QEMU_MALTA bool "qemu malta" + select HAVE_PBL_IMAGE + select HAVE_IMAGE_COMPRESSION endchoice
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 MIPS: qemu-malta_defconfig: use pbl
In reply to Antony PavlovUSAGE
$ make qemu-malta_defconfig
...
$ make
...
$ qemu-system-mips -nodefaults -M malta -m 256 \
-nographic -serial stdio -bios ./barebox-flash-image--- arch/mips/configs/qemu-malta_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/configs/qemu-malta_defconfig +1 -0
@@ -1,3 +1,4 @@ +CONFIG_PBL_IMAGE=y CONFIG_STACK_SIZE=0x7000 CONFIG_BROKEN=y CONFIG_EXPERIMENTAL=y
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 MIPS: add pre-bootloader (pbl) image support
In reply to Antony PavlovThis patch is based on ARM pbl support and allows creating a pre-bootloader binary for compressed image.
For different MIPS SoCs (or even for different boards based
on the same SoC) the operations carried on in start-pbl.S
can be very different. The additional constraints can be imposed on the size of the boot code or the special magic labels in the beginning of the boot code; In some cases it could be necessary to show CPU is alive as early as possible (transmit a char via UART or blink a LED).
So the demands for pbl start operation can be very different.
E.g. malta board store boot code at the NOR flash mapped to the MIPS power-on address (0xbfc00000); it is the most simple case: we need just copy pbl image from direct-mapped flash to RAM and jump there.
The XBurst-powered boards store boot code in the beginning of a NAND flash or in the beginning of SD/MMC card. In this case we must use simple and short NAND or SD/MMC access routines to copy pbl image to RAM.
To meet so different demands a simple technique is selected:
* MIPS pbl entry point located in file arch/mips/boot/start-pbl.S.
* MIPS pbl code (see start-pbl.S) assumes that every pbl-enabled board has a arch/mips/boards/<BOARD>/include/board/board_pbl_start.h header file. This file must contain definition of
the board_pbl_start macro. This macro is used as start of pbl image;
* the most popular asm routines (stack setup, relocation to link address, NS16550 initialization (WIP) and so on) are containt in the arch/mips/include/asm/pbl_macros.h header file. So board pbl macro can use it if necessary.
It is possible to create similar headers with macros for each specific SoC; so even if we have many different boards based on the same SoC the board_pbl_start macro for every board can be short and clear.
* after board-specific initialization the stack pointer is initialized and pbl C code is started.
--- arch/mips/Makefile | 18 +++++ arch/mips/boot/Makefile | 2 + arch/mips/boot/main_entry-pbl.c | 87 +++++++++++++++++++++++ arch/mips/boot/start-pbl.S | 46 ++++++++++++ arch/mips/include/asm/pbl_macros.h | 135 ++++++++++++++++++++++++++++++++++++ arch/mips/pbl/.gitignore | 6 ++ arch/mips/pbl/Makefile | 40 +++++++++++ arch/mips/pbl/piggy.gzip.S | 6 ++ arch/mips/pbl/piggy.lzo.S | 6 ++ arch/mips/pbl/zbarebox.lds.S | 57 +++++++++++++++ 10 files changed, 403 insertions(+) create mode 100644 arch/mips/boot/main_entry-pbl.c create mode 100644 arch/mips/boot/start-pbl.S create mode 100644 arch/mips/include/asm/pbl_macros.h create mode 100644 arch/mips/pbl/.gitignore create mode 100644 arch/mips/pbl/Makefile create mode 100644 arch/mips/pbl/piggy.gzip.S create mode 100644 arch/mips/pbl/piggy.lzo.S create mode 100644 arch/mips/pbl/zbarebox.lds.S
arch/mips/Makefile +18 -0
@@ -58,6 +58,15 @@ CPPFLAGS += -fdata-sections -ffunction-sections LDFLAGS_barebox += -static --gc-sections endif +ifdef CONFIG_IMAGE_COMPRESSION +KBUILD_BINARY := arch/mips/pbl/zbarebox.bin +KBUILD_TARGET := zbarebox.bin +$(KBUILD_BINARY): $(KBUILD_TARGET) +else +KBUILD_BINARY := barebox.bin +KBUILD_TARGET := barebox.bin +endif + LDFLAGS_barebox += -nostdlib machine-$(CONFIG_MACH_MIPS_MALTA) := malta
@@ -110,3 +119,12 @@ CFLAGS += $(cflags-y) lds-$(CONFIG_GENERIC_LINKER_SCRIPT) := arch/mips/lib/barebox.lds CLEAN_FILES += arch/mips/lib/barebox.lds barebox.map barebox.S + +pbl := arch/mips/pbl +zbarebox.S zbarebox.bin zbarebox: barebox.bin + $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ + +archclean: + $(MAKE) $(clean)=$(pbl) + +KBUILD_IMAGE ?= $(KBUILD_BINARY)
arch/mips/boot/Makefile +2 -0
@@ -1,2 +1,4 @@ obj-y += start.o obj-y += main_entry.o + +pbl-y += start-pbl.o main_entry-pbl.o
arch/mips/boot/main_entry-pbl.c new file +87 -0
87 lines not on this page · raw message
arch/mips/boot/start-pbl.S new file +46 -0
46 lines not on this page · raw message
arch/mips/include/asm/pbl_macros.h new file +135 -0
135 lines not on this page · raw message
arch/mips/pbl/.gitignore new file +6 -0
@@ -0,0 +1,6 @@ +piggy.gzip +piggy.lzo +zbarebox +zbarebox.bin +zbarebox.lds +zbarebox.map
arch/mips/pbl/Makefile new file +40 -0
@@ -0,0 +1,40 @@ + +suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip +suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo + +OBJCOPYFLAGS_zbarebox.bin = -O binary +piggy_o := piggy.$(suffix_y).o + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ + $(piggy_o) piggy.$(suffix_y) + +# Make sure files are removed during clean +extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern zbarebox.map + +$(obj)/zbarebox.bin: $(obj)/zbarebox FORCE + $(call if_changed,objcopy) + $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) + $(Q)$(kecho) ' Barebox: $@ is ready' + +$(obj)/zbarebox.S: $(obj)/zbarebox FORCE + $(call if_changed,disasm) + +PBL_CPPFLAGS += -fdata-sections -ffunction-sections +LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map +LDFLAGS_zbarebox += -static --gc-sections +zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o) +zbarebox-lds := $(obj)/zbarebox.lds + +quiet_cmd_zbarebox__ ?= LD $@ + cmd_zbarebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \ + -T $(zbarebox-lds) \ + --start-group $(zbarebox-common) --end-group \ + $(filter-out $(zbarebox-lds) $(zbarebox-common) FORCE ,$^) + +$(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE + $(call if_changed,zbarebox__) + +$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE + $(call if_changed,$(suffix_y)) + +$(obj)/$(piggy_o): $(obj)/piggy.$(suffix_y) FORCE
arch/mips/pbl/piggy.gzip.S new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm/asm.h> + + .section .data +EXPORT(input_data) + .incbin "arch/mips/pbl/piggy.gzip" +EXPORT(input_data_end)
arch/mips/pbl/piggy.lzo.S new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm/asm.h> + + .section .data +EXPORT(input_data) + .incbin "arch/mips/pbl/piggy.lzo" +EXPORT(input_data_end)
arch/mips/pbl/zbarebox.lds.S new file +57 -0
57 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 6 lines · Antony Pavlov
This patch series introduce pre-bootloader (pbl) support on MIPS. The only supported board is qemu-malta.
[PATCH 1/3] MIPS: add pre-bootloader (pbl) image support [PATCH 2/3] MIPS: qemu-malta: add trivial pbl support [PATCH 3/3] MIPS: qemu-malta_defconfig: use pbl
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox