Skip to content

Commit

Permalink
[board] fix init rd
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzukiTsuru committed Mar 29, 2024
1 parent 6b890d2 commit c8fff79
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 deletions.
75 changes: 40 additions & 35 deletions board/longanpi-4b/extlinux_boot/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,41 +446,41 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {

uint64_t ramdisk_start = (uint64_t) (uintptr_t) image->ramdisk_dest;
uint64_t ramdisk_end = ramdisk_start + ramdisk_size;
if (ramdisk_size > 0) {
uint64_t addr, size;

printk(LOG_LEVEL_DEBUG, "initrd_start = 0x%08x, initrd_end = 0x%08x\n", ramdisk_start, ramdisk_end);
int total = fdt_num_mem_rsv(image->of_dest);

printk(LOG_LEVEL_DEBUG, "Look for an existing entry %d\n", total);

/* Look for an existing entry and update it. If we don't find the entry, we will add a available slot. */
for (int j = 0; j < total; j++) {
ret = fdt_get_mem_rsv(image->of_dest, j, &addr, &size);
if (addr == ramdisk_start) {
fdt_del_mem_rsv(image->of_dest, j);
break;
}
}

ret = fdt_add_mem_rsv(image->of_dest, ramdisk_start, ramdisk_end - ramdisk_start);
if (ret < 0) {
printk(LOG_LEVEL_DEBUG, "fdt_initrd: %s\n", fdt_strerror(ret));
goto _error;
}

ret = fdt_setprop_u64(image->of_dest, chosen_node, "linux,initrd-start", (uint64_t) ramdisk_start);
if (ret < 0) {
printk(LOG_LEVEL_DEBUG, "WARNING: could not set linux,initrd-start %s.\n", fdt_strerror(ret));
goto _error;
}

ret = fdt_setprop_u64(image->of_dest, chosen_node, "linux,initrd-end", (uint64_t) ramdisk_end);
if (ret < 0) {
printk(LOG_LEVEL_DEBUG, "WARNING: could not set linux,initrd-end %s.\n", fdt_strerror(ret));
goto _error;
}
}
// if (ramdisk_size > 0) {
// uint64_t addr, size;

// printk(LOG_LEVEL_DEBUG, "initrd_start = 0x%08x, initrd_end = 0x%08x\n", ramdisk_start, ramdisk_end);
// int total = fdt_num_mem_rsv(image->of_dest);

// printk(LOG_LEVEL_DEBUG, "Look for an existing entry %d\n", total);

// /* Look for an existing entry and update it. If we don't find the entry, we will add a available slot. */
// for (int j = 0; j < total; j++) {
// ret = fdt_get_mem_rsv(image->of_dest, j, &addr, &size);
// if (addr == ramdisk_start) {
// fdt_del_mem_rsv(image->of_dest, j);
// break;
// }
// }

// ret = fdt_add_mem_rsv(image->of_dest, ramdisk_start, ramdisk_end - ramdisk_start);
// if (ret < 0) {
// printk(LOG_LEVEL_DEBUG, "fdt_initrd: %s\n", fdt_strerror(ret));
// goto _error;
// }

// ret = fdt_setprop_u64(image->of_dest, chosen_node, "linux,initrd-start", (uint64_t) ramdisk_start);
// if (ret < 0) {
// printk(LOG_LEVEL_DEBUG, "WARNING: could not set linux,initrd-start %s.\n", fdt_strerror(ret));
// goto _error;
// }

// ret = fdt_setprop_u64(image->of_dest, chosen_node, "linux,initrd-end", (uint64_t) ramdisk_end);
// if (ret < 0) {
// printk(LOG_LEVEL_DEBUG, "WARNING: could not set linux,initrd-end %s.\n", fdt_strerror(ret));
// goto _error;
// }
// }

len = 0;
/* Get bootargs string */
Expand All @@ -497,6 +497,11 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {

strcat(bootargs_str, data.append);

/* initrd small fix */
if (ramdisk_size > 0) {
strcat(bootargs_str, " initrd=0x43000000,8M");
}

printk(LOG_LEVEL_INFO, "Kernel cmdline = [%s]\n", bootargs_str);

_add_dts_size:
Expand Down
2 changes: 1 addition & 1 deletion board/yuzukihomekit/syter_boot/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static int abortboot_single_key(int bootdelay) {
if (tstc()) { /* we got a key press */
uart_getchar(); /* consume input */
printk(LOG_LEVEL_MUTE, "\b\b\b%2d", bootdelay);
abort = 1; /* don't auto boot */
abort = 0; /* auto boot */
}

while ((bootdelay > 0) && (!abort)) {
Expand Down

0 comments on commit c8fff79

Please sign in to comment.