x86: Executing a raw vmlinux image (embedded environment)
Hi All, Firstly, a little introduction an background - I am currently the maintainer for the x86 port of Das U-Boot (or more simply U-Boot). While the x86 port is not as well known as the more major ports like ARM and PPC, it is starting to gain more attention and more developer input which has beed nice to see after my solo efforts over the last few years. One of my biggest annoyances with the x86 U-Boot port is that, while it is an embedded boot loader, it still tries to boot Linux as if it was a conventional PC - i.e. it has 'real mode' and 'BIOS' implementation and loads a bzImage. But this approach is completely unnecessary and only adds to the boot time (load bzImage from storage into RAM, decompress, then run). So I want to shortcut bzImage and migrate towards treating the loading of the Linux kernel from U-Boot like any other embedded environment: - Decompress vmlinux directly from storage into the appropriate memory location - Setup required data structures - Jump into vmlinux U-Boot has it's own compressed kernel image container (uImage) and support code which will allow me to decompress the vmlinux directly from storage into RAM. In my current situation, I have ~1.7MB of onboard (i.e. cached) flash memory where I plan to store the compressed kernel and an MMC where I plan to store the file system. So after building a very stripped down kernel (no TCP/IP for example) I get: /vmlinux 2,629,659 bytes /vmlinux.o 2,889,050 bytes /arch/i386/boot/bzImage 1,104,864 bytes /arch/x86/boot/bzImage 1,104,864 bytes /arch/x86/boot/vmlinux.bin 1,092,060 bytes /arch/x86/boot/compressed/vmlinux 1,099,538 bytes /arch/x86/boot/compressed/vmlinux.bin 2,094,132 bytes /arch/x86/boot/compressed/vmlinux.bin.gz 1,074,711 bytes I understand that /arch/x86/boot/compressed/vmlinux.bin.gz is a compressed version of /arch/x86/boot/compressed/vmlinux.bin, and /arch/i386/boot/bzImage and /arch/x86/boot/bzImage are the same file and that it is the 16-bit boot code + /arch/x86/boot/compressed/vmlinux.bin.gz but I don't understand the rest... My guess is that /vmlinux.o is the ELF image generated by the compiler + linker stage and /vmlinux may be /vmlinux.o objdump'd into a raw binary and perhaps /arch/x86/boot/vmlinux.bin is a further stripped version of/vmlinux, but I'm at a loss with /arch/x86/boot/compressed/vmlinux In any event, it looks like either /arch/x86/boot/compressed/vmlinux.bin or /vmlinux is what I need to copy into RAM @ 0x100000 (1MiB) which is where my non-relocatable kernel is compiled to. I also have looked at the documentation for the x86 32-boot protocol found in linux/Documentation/x86/boot.txt So what I'm needing is: - Confirmation of exactly which vmlinux to use - Confirmation that I do load it @ 0x100000 - How to setup the memory map (keeping in mind I have 2GB of contiguous memory with no BIOS/ACPI etc to worry about clobbering - Any other tricks I need to be aware of.. Any help will be greatly appreciated Thanks, Graeme
/vmlinux 2,629,659 bytes /vmlinux.o 2,889,050 bytes /arch/i386/boot/bzImage 1,104,864 bytes /arch/x86/boot/bzImage 1,104,864 bytes /arch/x86/boot/vmlinux.bin 1,092,060 bytes /arch/x86/boot/compressed/vmlinux 1,099,538 bytes /arch/x86/boot/compressed/vmlinux.bin 2,094,132 bytes /arch/x86/boot/compressed/vmlinux.bin.gz 1,074,711 bytes
I understand that /arch/x86/boot/compressed/vmlinux.bin.gz is a compressed version of /arch/x86/boot/compressed/vmlinux.bin, and /arch/i386/boot/bzImage and /arch/x86/boot/bzImage are the same file and that it is the 16-bit boot code + /arch/x86/boot/compressed/vmlinux.bin.gz This is correct. but I don't understand the rest...
My guess is that /vmlinux.o is the ELF image generated by the compiler + linker stage and /vmlinux may be /vmlinux.o objdump'd into a raw binary and perhaps /arch/x86/boot/vmlinux.bin is a further stripped version of/vmlinux, but I'm at a loss with /arch/x86/boot/compressed/vmlinux
vmlinux is ELF image with ELF header. So actual point of kernel entry would be at an offset, somewhere after the ELF header. vmlinux.bin is what you would get after doing #objcopy -O binary vmlinux vmlinux.bin. vmlinux.bin has only obj code and nothing else.
In any event, it looks like either /arch/x86/boot/compressed/vmlinux.bin or /vmlinux is what I need to copy into RAM @ 0x100000 (1MiB) which is where my non-relocatable kernel is compiled to.
copy vmlinux.bin.
- How to setup the memory map (keeping in mind I have 2GB of contiguous memory with no BIOS/ACPI etc to worry about clobbering - Any other tricks I need to be aware of.. Check if x86 kernel expects some parameters(like machineid, bootargs location etc) in some registers. Check if x86 has low level debug support(like DEBUG_LL). Also you might want to check how initial page tables are being setup in kernel.
-syed
Thanks syed, Ok, I did a little more digging... On 22/11/11 16:34, sk.syed2 wrote:
/vmlinux 2,629,659 bytes /vmlinux.o 2,889,050 bytes /arch/i386/boot/bzImage 1,104,864 bytes /arch/x86/boot/bzImage 1,104,864 bytes /arch/x86/boot/vmlinux.bin 1,092,060 bytes /arch/x86/boot/compressed/vmlinux 1,099,538 bytes /arch/x86/boot/compressed/vmlinux.bin 2,094,132 bytes /arch/x86/boot/compressed/vmlinux.bin.gz 1,074,711 bytes
I understand that /arch/x86/boot/compressed/vmlinux.bin.gz is a compressed version of /arch/x86/boot/compressed/vmlinux.bin, and /arch/i386/boot/bzImage and /arch/x86/boot/bzImage are the same file and that it is the 16-bit boot code + /arch/x86/boot/compressed/vmlinux.bin.gz
This is correct.
but I don't understand the rest...
I traced it all out. I sent a separate message to the ML documenting the bzImage build chain - It's rather fascinating
My guess is that /vmlinux.o is the ELF image generated by the compiler + linker stage and /vmlinux may be /vmlinux.o objdump'd into a raw binary and perhaps /arch/x86/boot/vmlinux.bin is a further stripped version of/vmlinux, but I'm at a loss with /arch/x86/boot/compressed/vmlinux
vmlinux is ELF image with ELF header. So actual point of kernel entry would be at an offset, somewhere after the ELF header. vmlinux.bin is what you would get after doing #objcopy -O binary vmlinux vmlinux.bin. vmlinux.bin has only obj code and nothing else.
To be more precise: arch/x86/boot/compressed/vmlinux.bin is the result of #objcopy -R .comment -S vmlinux so it is still an ELF image arch/x86/boot/vmlinux.bin is the result of: #objcopy -O binary -R .note -R .comment -S arch/x86/boot/compressed/vmlinux arch/x86/boot/compressed/vmlinux has the decompression stub + compressed version of arch/x86/boot/compressed/vmlinux.bin
In any event, it looks like either /arch/x86/boot/compressed/vmlinux.bin or /vmlinux is what I need to copy into RAM @ 0x100000 (1MiB) which is where my non-relocatable kernel is compiled to.
copy vmlinux.bin.
I don't think either is what I want - arch/x86/boot/vmlinux.bin still contains a compressed kernel. And the contents of the compressed section is an ELF image which requires more memcpys and memsets What I really want, I think, is: #objcopy -O binary -R .comment -S vmlinux Which is not generated during the build process
- How to setup the memory map (keeping in mind I have 2GB of contiguous memory with no BIOS/ACPI etc to worry about clobbering - Any other tricks I need to be aware of.. Check if x86 kernel expects some parameters(like machineid, bootargs location etc) in some registers. Check if x86 has low level debug support(like DEBUG_LL). Also you might want to check how initial page tables are being setup in kernel.
I need to have a good look at what goes into arch/x86/boot/setup.bin - That will really tell me what I need to do Thanks, Graeme
participants (2)
-
Graeme Russ -
sk.syed2