MIPS: add support for gzip/bzip2/lzma compressed kernel images
PATCH 1/1 MIPS: add support for gzip/bzip2/lzma compressed kernel images
This patch will help to generate smaller kernel images for linux-MIPS,
$ wc -c vmlinux 7465416 vmlinux $ wc -c vmlinuz 2059691 vmlinuz
Have tested the 32bit kernel on Qemu/Malta and 64bit kernel on FuLoong Mini PC. both of them works well.
--- arch/mips/Kconfig | 3 + arch/mips/Makefile | 6 +- arch/mips/boot/compressed/Makefile | 52 +++++++++++ arch/mips/boot/compressed/dbg.c | 68 ++++++++++++++ arch/mips/boot/compressed/dbg.h | 5 + arch/mips/boot/compressed/decompress.c | 152 ++++++++++++++++++++++++++++++++ arch/mips/boot/compressed/dummy.c | 4 + arch/mips/boot/compressed/head.S | 85 ++++++++++++++++++ arch/mips/boot/compressed/ld.script | 152 ++++++++++++++++++++++++++++++++ 9 files changed, 526 insertions(+), 1 deletions(-) create mode 100644 arch/mips/boot/compressed/Makefile create mode 100644 arch/mips/boot/compressed/dbg.c create mode 100644 arch/mips/boot/compressed/dbg.h create mode 100644 arch/mips/boot/compressed/decompress.c create mode 100644 arch/mips/boot/compressed/dummy.c create mode 100644 arch/mips/boot/compressed/head.S create mode 100644 arch/mips/boot/compressed/ld.script
arch/mips/Kconfig +3 -0
@@ -4,6 +4,9 @@ config MIPS select HAVE_IDE select HAVE_OPROFILE select HAVE_ARCH_KGDB + select HAVE_KERNEL_GZIP + select HAVE_KERNEL_BZIP2 + select HAVE_KERNEL_LZMA # Horrible source of confusion. Die, die, die ... select EMBEDDED select RTC_LIB
arch/mips/Makefile +5 -1
@@ -709,7 +709,10 @@ vmlinux.64: vmlinux makeboot =$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) $(1) -all: $(all-y) +all: $(all-y) vmlinuz + +vmlinuz: vmlinux + $(Q)$(MAKE) $(build)=arch/mips/boot/compressed $@ vmlinux.bin: $(vmlinux-32) +@$(call makeboot,$@)
@@ -740,6 +743,7 @@ install: archclean: @$(MAKE) $(clean)=arch/mips/boot + @$(MAKE) $(clean)=arch/mips/boot/compressed @$(MAKE) $(clean)=arch/mips/lasat define archhelp
arch/mips/boot/compressed/Makefile new file +52 -0
52 lines not on this page · raw message
arch/mips/boot/compressed/dbg.c new file +68 -0
68 lines not on this page · raw message
arch/mips/boot/compressed/dbg.h new file +5 -0
@@ -0,0 +1,5 @@ +/* +* board-specific serial port +*/ + +#define UART_BASE 0x1fd003f8
arch/mips/boot/compressed/decompress.c new file +152 -0
152 lines not on this page · raw message
arch/mips/boot/compressed/dummy.c new file +4 -0
@@ -0,0 +1,4 @@ +int main (void ) +{ +return 0 ; +}
arch/mips/boot/compressed/head.S new file +85 -0
85 lines not on this page · raw message
arch/mips/boot/compressed/ld.script new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Quoted 3 lines · Wu Zhangjin
This patch will help to generate smaller kernel images for linux-MIPS,
/me gets giddy and wets himself with excitement
This has made my AR7[1] based Linksys WAG54Gv2 (16MB RAM and 4MB flash, limited to a 768kB kernel) useful, finally...thanks!
Quoted 8 lines
$ wc -c vmlinux 7465416 vmlinux $ wc -c vmlinuz 2059691 vmlinuzHave tested the 32bit kernel on Qemu/Malta and 64bit kernel on FuLoong Mini PC. both of them works well.
I got it working (LZMA kernel) however you have hardcoded a lot of bits in there. It looks to my uneducated eye most of the issues lie in that getting a suitable PORT(x), KERNEL_START, KERNEL_SIZE, FREE_MEM_START and FREE_MEM_END is non-trivial on the MIPS platform currently; probably because of the lack of a generic lzma/gzip/bzip2 framework to be used with.
For me I used:
#define FREE_MEM_START CKSEG0ADDR(0x94a00000)
#define FREE_MEM_END CKSEG0ADDR(0x94f00000)
I had to replace (you probably should move this from dbg.c to dbg.h):
#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
The load address is awkward, but I replaced your 0x8100000 in the Makefile with 0x94400000.
Now, the big question is how to work this all out at compile time. :)
As a side note, I would personally leave the DEBUG non-optional and turned on as it all disappears at runtime anyway, but I'm no kernel developer :)
Again, thanks for this, it truely is great stuff.
Cheers
[1] http://www.linux-mips.org/wiki/AR7
Signature · 2 lines
Alexander Clouter .sigmonster says: I will always love the false image I had of you.
Hi,
Quoted 15 lines · Alexander Clouter
This has made my AR7[1] based Linksys WAG54Gv2 (16MB RAM and 4MB flash, limited to a 768kB kernel) useful, finally...thanks!
Quoted 1 line
I got it working (LZMA kernel) however you have hardcoded a lot of bits in there. It looks to my uneducated eye most of the issues lie in that getting a suitable PORT(x),
KERNEL_START,KERNEL_SIZE,FREE_MEM_STARTandFREE_MEM_ENDis non-trivial on the MIPS platform currently; probably because of the lack of a generic lzma/gzip/bzip2 framework to be used with.For me I used:
#defineFREE_MEM_STARTCKSEG0ADDR(0x94a00000)
#defineFREE_MEM_ENDCKSEG0ADDR(0x94f00000)
Quoted 8 lines
I had to replace (you probably should move this from
dbg.ctodbg.h):
#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0)+ (4 * offset))The load address is awkward, but I replaced your
0x8100000in theMakefilewith0x94400000.Now, the big question is how to work this all out at compile time. :)
Thanks very much for your suggestion, just rewritten it and removed almost all of the hard-coded parts(except the size of the HEAP) and a new patch was sent out. and this new one _should_ work for the other MIPS-based machines if not missed something else.
looking forward to your test result on AR7 with the new patch and welcome to comment to this new E-mail thread: [PATCH -v1] MIPS: add support for gzip/bzip2/lzma compressed kernel images
Quoted 3 lines
As a side note, I would personally leave the DEBUG non-optional and turned on as it all disappears at runtime anyway, but I'm no kernel developer :)
ooh, in reality, I'm looking forward to the comment of Ralf and somebody else. to my point of view, this _debug_ interface is only need to help the developers of the other MIPS variants ensure this patch work for them.
Thanks & Regards,
Wu Zhangjin
Quoted 3 lines · Alexander Clouter
As a side note, I would personally leave the DEBUG non-optional and turned on as it all disappears at runtime anyway, but I'm no kernel developer :)
Printing is hardware specific; the debug code will need to be changed for practically every MIPS platform on the planet, so I'm not too fond of the idea unless somebody comes up with a cleaner infrastructure to do so. Unfortunately we're not setup very well to do configuration detection etc. in that debug code without adding tons of baggage.
Ralf
Quoted 11 lines · Ithamar R. Adema
Quoted 6 lines · Ralf Baechle
Printing is hardware specific; the debug code will need to be changed for practically every MIPS platform on the planet, so I'm not too fond of the idea unless somebody comes up with a cleaner infrastructure to do so. Unfortunately we're not setup very well to do configuration detection etc. in that debug code without adding tons of baggage.
Would mimicing the
uncompress.hheader as used in the ARM architecture be an idea? Maybe have one that does nothing in mach-generic and let the machines that want debug output define their own that actually does IO.
Quoted 5 lines
Just a header, defining putc()-ish functions, most architectures already have code for that, so it should be trivial for them to implement it, if wanted...
Just an idea...
Oh, I wasn't trying to kill the debug code entirely but pointing out some difficulties. For some platforms the code would be a little larger and more complex. It could be as bad as dynamically detecting a console and running PPP to talk to it. Or having to carry fonts along and render output into a complex graphics card. but we can still deciede if the feature is useful enough on a per platform base.
An implementation would probably look something like you pointed out though I haven't seen the ARM header you mentioned. Ideally code could be shared with early printk.
Ralf