hansemro / kc1-linux

Documentation of mainline Linux on First Generation Kindle Fire
GNU General Public License v2.0
4 stars 0 forks source link

Add Persistent RAM Console support to device tree #18

Open hansemro opened 3 years ago

hansemro commented 3 years ago

Resources:

I personally have not tried this, but it should create a ram console that lives after a kernel-driven reboot (if you manually power off the device, the ram contents will be cleared).

arch/arm/boot/dts/omap4-kc1.dts

\ {
    ...
    reserved-memory {
        #address-cells = <1>;
        #size-cells = <1>;
        ranges;

        ramoops_region@90000000 { /* 0x80000000 + 256MB */
            no-map;
            reg = <0x90000000 0x200000>; /* ram console size: 2M */
        };
    };
    ...
};

patch proposal based off drebrez's patch: kernel/panic.c#L335

@@ -330,6 +330,15 @@ void panic(const char *fmt, ...)
                 * shutting down.  But if there is a chance of
                 * rebooting the system it will be rebooted.
                 */
+               void* alt_ramoops = ioremap(0x90000000, 0x200000);
+               memset(alt_ramoops, 'A', 0x200000); // clear
+               uint32_t sig = 0x43474244;
+               uint32_t start = 0;
+               uint32_t size = 0x1FFFF4;
+               memcpy(alt_ramoops, &sig, 4);
+               memcpy(alt_ramoops+4, &start, 4);
+               memcpy(alt_ramoops+8, &size, 4);
+               memcpy(alt_ramoops+12, log_buf_addr_get(), min(log_buf_len_get(), 0x1FFFF4));
                emergency_restart();
        }