View Single Post
Old 09-17-2019, 04:07 AM   #13
WaseemAlkurdi
Zealot
WaseemAlkurdi began at the beginning.
 
Posts: 147
Karma: 20
Join Date: Jul 2019
Device: Kindle Touch (K5) Wi-Fi x 2, Kindle (7th Gen, KT2), Paperwhite 3rd Gen
Quote:
Originally Posted by knc1 View Post
Ah, a small problem with your plan ...
QEMU is a 'single program' loader, stock QEMU can not load two programs (u-boot and kernel).

There is published the means to patch QEMU to load the multi-part u-boot and multi-part kernel along with the description of how-to do it and a worked example.
I found that using a common web search tool.
Thanks for the heads-up!
For now, I don't think this is an issue. If I actually get U-Boot successfully built and booted in QEMU, then it would be very easy to follow a set of instructions to patch QEMU accordingly.

Quote:
Originally Posted by pazos View Post
U-boot is normally used as Stage2 bootloader and used to setup cpu timmings and sdram. Stage1 bootloader is normally part of the hardware and it is loaded and executed from On Chip RAM (OCRAM).
Wait, what? So how do we build this stage 1 bootloader? Or we can skip it altogether and start with U-Boot?
Quote:
The process of building u-boot is similar to build the kernel itself. Set a cross compile toolchain, make a .config using an already available defconfig and make to build. Normally (on imx at least) a little header is wrapped at the beginning of the binary and that is specific to your model DRAM configuration.
The Kindle has a custom, ancient U-Boot tree in the sources, and that tree has the appropriate defconfig files, where one executes make imx60_wario_config, for example, to configure the tree for that board. Does this prepare the header you mentioned in your post?
Quote:
I had no idea, I have no CS background and never played with QEMU but sounds to me as a normal bootstrap: stage1/qemu loads stage2 and jumps there, stage2 loads kernel and jumps there and so on. In any case I would like to see the link as my search skills suck and I can't found such info. Thanks in advance
I'm also finding this odd, because qemu-system-x86_64 doesn't have this issue (one can chainload N bootloaders without any issue). But I guess it's ARM architecture quirks.
Quote:
But yeah, OP has a difficult task at hand. Good luck and keep us informed
Thanks! Definitely will!

Quote:
edit: I found a interesting link about the topic. Basically you can try the same but using a different device configuration. It seems that i.MX6 Dual Lite SABRE is available on qemu 2 and should be a good place to start. Use that instead of "versatile"
This board this exactly what I'm using (and reading about the presence of this board is what inspired me to do this, actually). I've never tried the versatile boards because they are too far from the Kindle boards. But both the stock kernel and a custom-built kernel from Amazon's trees don't boot (where QEMU shows a blank serial stdout).

Edit:

1. When doing a chroot with an image of the Kindle's main partition + user-mode QEMU ARM + Xephyr, I noticed that some Kindle executables work, namely xtestlab126. But starting the Kindle's framework properly requires init, or at least executing the Upstart scripts in the correct order. I thought I'd make it easier and scrap that plan, especially when a complete Kindle emulation in QEMU is much more "accurate".

2. According to this message on the U-Boot mailing list, the U-Boot compilation problem is caused by the system's own version of libfdt. But removing that package only makes matters worse:
Code:
$ env TYPE=prod make CROSS_COMPILE=~/arm-2014.05/bin/arm-linux-gnueabi- -j8
for dir in tools examples/standalone examples/api ; do make -C $dir _depend ; done
make[1]: Entering directory '/path/to/uboot_2009.08/tools'
make[1]: Nothing to be done for '_depend'.
make[1]: Leaving directory '/path/to/uboot_2009.08/tools'
make[1]: Entering directory '/path/to/uboot_2009.08/examples/standalone'
make[1]: Nothing to be done for '_depend'.
make[1]: Leaving directory '/path/to/uboot_2009.08/examples/standalone'
make[1]: Entering directory '/path/to/uboot_2009.08/examples/api'
make[1]: Nothing to be done for '_depend'.
make[1]: Leaving directory '/path/to/uboot_2009.08/examples/api'
make -C tools all
make -C examples/standalone all
make[1]: Entering directory '/path/to/uboot_2009.08/tools'
make -C examples/api all
make[1]: Entering directory '/path/to/uboot_2009.08/examples/standalone'
make -C cpu/arm_cortexa8 start.o
make[1]: Entering directory '/path/to/uboot_2009.08/examples/api'
make[1]: *** No rule to make target '/usr/include/libfdt_env.h', needed by 'mkimage.o'.  Stop.
make[1]: Leaving directory '/path/to/uboot_2009.08/tools'
make: *** [Makefile:357: tools] Error 2
make: *** Waiting for unfinished jobs....
make[1]: *** No rule to make target '~/arm-2014.05/lib/gcc/arm-none-linux-gnueabi/4.8.3/include/stdarg.h', needed by 'hello_world.o'.  Stop.
make[1]: Leaving directory '/path/to/uboot_2009.08/examples/standalone'
make: *** [Makefile:357: examples/standalone] Error 2
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/path/to/uboot_2009.08/examples/api'

Last edited by WaseemAlkurdi; 09-17-2019 at 04:58 PM.
WaseemAlkurdi is offline   Reply With Quote