View Single Post
Old 05-16-2017, 06:42 AM   #112
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Now that is probably going to turn into a question you really wish you hadn't asked, but the answer:

The Kindles use an "embedded" operating system.
It is made as much a part of the hardware as is possible, not something the user can easily change.
That is what an "embedded" OS is all about, small size, fast, is part of the device (not an add-on to the hardware, a part of it).

When the Kindle's system starts up (from a power-off condition, not just suspended) it goes through a "boot sequence".

Approximately:

The "bootstrap code" manufactured into the SoC devices ROM is run.
There is no changing that, the ROM is not a programmable device.
That code runs another program from a hardware determined, fixed place.
(or a short list of fixed places - a feature I will over look here)

In the case of the Kindles, a "bootstrap program" named: u-boot.
(Technically, u-boot is a multi-stage boot loader, but that point can be ignored here.)
That program is read from eMMC, which is a programmable device.
I.E: the installed copy of u-boot can be changed but normally is never changed.
Two things of interest to the developer -
u-boot can be scripted
u-boot can have its default environment changed (permanently or temporarily)

u-boot, left to its own Amazon/Lab126 provided installation, runs a single application, the Linux kernel.
In the case of the Kindles, one of two pre-installed Linux kernels.
(Kindles since the K4 are dual-boot, like having WinXP and Win10 installed on the same PC)

The Linux kernel, after a bunch of programming handsprings during its start-up, attaches the program storage filesystem, switches from system to user mode, and runs a single user mode start-up (initialization) program.
Historically named: init
As in: initialization, which is indeed what it does. It starts the user mode programs, in the case of the 5.8.x series of firmware about 105 of them, all of them multi-task.
At which point things become difficult to describe.

Ignoring the options available in the ROM boot code stage (which takes hardware changes to change options - coplate is playing with those now) . . . .

u-boot can load the program it runs (the Linux kernel) from a network connection.
Which is handy if a person wants to develop the Linux kernel for a special bit of hardware. (you don't - so ignore this stage also)

The Linux kernel can load the program filesystem it runs from a network connection.
and/or
The Linux kernel can use a (network) remote filesytem for its filesystem.
(Yes, there are technical differences in the above two choices.)

This last describe stage of power-on start-up is the one of interest to an application program meddler.
In the case of this usage on the Kindles, the two directory paths: /lib/firmware and /lib/modules MUST have the same structure and contents that the Amazon provided system images do, but other than that, a person mostly has a free hand in what is included.

How is this last choice made?
On the Kindle's command line, enter:
Code:
cat /proc/cmdline
Which will show you what the command line arguments where that the Linux kernel program (it is just a single program) was started with.
Among those command line options, you should see an:
Code:
ip=0
which turned off its search of network connections for its initial filesystem.

So point that to the network address of the filesystem image you are modifying.
If the modifications you make "brick" the Kindle, change the startup option back to
Code:
ip=0
re-boot and like magic, your Kindle is un-bricked.

Now nearly all of the above is much easier to use when you have the "Operator's Console" connected so you can diddle with each of the sequence of programs involved in the Kindle's start-up process.
The ROM code, the u-boot code and the Linux kernel code all expect the "Operator's Console" to be connected to the first serial port.

But you don't need the serial port, not if you take advantage of the fact that Kindles are dual-boot.
Installing RP installs ssh into the alternate (diags) OS.
Installing CRP adds the feature of switching between the main OS and the diags OS based on if the USB cable is connected to a PC at boot-time.

Without the USB cable connected to anything -
re-boot the Kindle and it will run the main OS (which options you have changed to run from a network system image file rather than a system image file stored in the Kindle's hardware).

With the USB cable connected to the PC -
re-boot the Kindle and it will run the diags OS (which options you have not changed - do not touch them for this use-case).
From the diags OS, you can diddle with the start-up options that (u-boot and) the main OS uses during start-up (such as the ip= option of the kernel command line).

Last edited by knc1; 05-16-2017 at 07:06 AM.
knc1 is offline   Reply With Quote