* am335x: load a kernel with integrated initramfs @ 2020-03-20 8:29 Yegor Yefremov 2020-03-23 8:30 ` Sascha Hauer 0 siblings, 1 reply; 9+ messages in thread From: Yegor Yefremov @ 2020-03-20 8:29 UTC (permalink / raw) To: barebox I get an "handler failed with: Out of memory" message when trying to load my 22MB large kernel-fit.itb. Below you can see the related log: mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel YY: bootm_boot YY: read file 0, size 22661672, PAGE_SIZE 4096 YY: fit_open FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) FIT: image 'kernel@1': 'Vanilla Linux kernel' FIT: /images/kernel@1/hash@1: hash OK Loading open firmware Device Tree flattened Binary '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' OS image not yet relocated Passing control to FIT image handler YY: do_bootm_linux YY: before bootm_load_os YY: bootm_load_os YY: kernel size 22484352 YY: for each memory bank: size 22484352 __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf YY: almost at the end handler failed with: Out of memory System information: barebox> / meminfo used: 1057928 free: 132057980 barebox> / iomem 0x00000000 - 0xffffffff (size 0x00000000) iomem 0x44e07000 - 0x44e07fff (size 0x00001000) 44e07000.gpio@0.of 0x44e09000 - 0x44e09fff (size 0x00001000) 44e09000.serial@0.of 0x44e10620 - 0x44e1062f (size 0x00000010) 44e10620.control@620.of 0x44e10648 - 0x44e1064b (size 0x00000004) 44e10620.control@620.of 0x44e10800 - 0x44e10a37 (size 0x00000238) 44e10800.pinmux@800.of 0x47401000 - 0x474011ff (size 0x00000200) 47401400.usb@1400.of 0x47401300 - 0x474013ff (size 0x00000100) 47401300.usb-phy@1300.of 0x47401400 - 0x474017ff (size 0x00000400) 47401400.usb@1400.of 0x47401800 - 0x474019ff (size 0x00000200) 47401c00.usb@1800.of 0x47401b00 - 0x47401bff (size 0x00000100) 47401b00.usb-phy@1b00.of 0x47401c00 - 0x47401fff (size 0x00000400) 47401c00.usb@1800.of 0x47810000 - 0x47810fff (size 0x00001000) 47810000.mmc@0.of 0x4802a000 - 0x4802afff (size 0x00001000) 4802a000.i2c@0.of 0x48040000 - 0x480403ff (size 0x00000400) 48040000.timer@0.of 0x4804c000 - 0x4804cfff (size 0x00001000) 4804c000.gpio@0.of 0x48060000 - 0x48060fff (size 0x00001000) 48060000.mmc@0.of 0x481ac000 - 0x481acfff (size 0x00001000) 481ac000.gpio@0.of 0x481ae000 - 0x481aefff (size 0x00001000) 481ae000.gpio@0.of 0x4a100000 - 0x4a1007ff (size 0x00000800) 4a100000.ethernet@0.of 0x4a101000 - 0x4a1010ff (size 0x00000100) 4a101000.mdio@1000.of 0x50000000 - 0x50000fff (size 0x00001000) gpmc_nand0 0x80000000 - 0x8fffffff (size 0x10000000) ram0 0x87efe860 - 0x8fdfd0bf (size 0x07efe860) malloc space 0x8fdfd0c0 - 0x8fdffffa (size 0x00002f3b) board data 0x8fe00000 - 0x8fe8a6af (size 0x0008a6b0) barebox 0x8fe8a6b0 - 0x8fea3427 (size 0x00018d78) barebox data 0x8fea3428 - 0x8fea97d3 (size 0x000063ac) bss 0x8ffe4000 - 0x8ffe7fff (size 0x00004000) ttb 0x8ffe8000 - 0x8ffeffff (size 0x00008000) stack My defconfig [1]. What can I tweak? In the future I'll need to load even bigger images. [1] https://github.com/visionsystemsgmbh/onrisc_br_bsp/blob/master/board/vscom/baltos/barebox/am335x_baltos_defconfig Yegor _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-20 8:29 am335x: load a kernel with integrated initramfs Yegor Yefremov @ 2020-03-23 8:30 ` Sascha Hauer 2020-03-23 12:22 ` Yegor Yefremov 0 siblings, 1 reply; 9+ messages in thread From: Sascha Hauer @ 2020-03-23 8:30 UTC (permalink / raw) To: Yegor Yefremov; +Cc: barebox, Lucas Stach Hi Yegor, On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > I get an "handler failed with: Out of memory" message when trying to > load my 22MB large kernel-fit.itb. Below you can see the related log: > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > YY: bootm_boot > YY: read file 0, size 22661672, PAGE_SIZE 4096 > YY: fit_open > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > FIT: image 'kernel@1': 'Vanilla Linux kernel' > FIT: /images/kernel@1/hash@1: hash OK > > Loading open firmware Device Tree flattened Binary > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > OS image not yet relocated > Passing control to FIT image handler > YY: do_bootm_linux > YY: before bootm_load_os > YY: bootm_load_os > YY: kernel size 22484352 > YY: for each memory bank: size 22484352 > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf So your kernel has a size of 22484352 bytes. We want to places the kernel at a place where we do not risk that it overwrites itself during decompression. We assume that the kernel gets five times bigger during decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which is already inside the malloc area. Try the attached patch, it should solve that issue. Besides this obvious bug you can also adjust the sime of the malloc area. By default roughly half of the available RAM is used for malloc, but in Kconfig you can adjust it to a smaller size which gives you more place for the kernel. Sascha --------------------------------------8<------------------------------- From ca440da09c3cdb83e17a6f0a99f24f69300c0ba3 Mon Sep 17 00:00:00 2001 From: Sascha Hauer <s.hauer@pengutronix.de> Date: Mon, 23 Mar 2020 09:17:36 +0100 Subject: [PATCH] ARM: bootm: make sure we place the kernel in free memory When placing the kernel image in memory make sure we do not place it too high, outside of the available memory, outside of the available memory. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- arch/arm/lib32/bootm.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c index d64e705c40..971ebee8ac 100644 --- a/arch/arm/lib32/bootm.c +++ b/arch/arm/lib32/bootm.c @@ -104,11 +104,24 @@ static int get_kernel_addresses(size_t image_size, spacing = SZ_1M; if (*load_address == UIMAGE_INVALID_ADDRESS) { + unsigned long mem_end = mem_start + mem_size - 1; + unsigned long kaddr; + /* * Place the kernel at an address where it does not need to * relocate itself before decompression. */ - *load_address = mem_start + image_decomp_size; + kaddr = mem_start + image_decomp_size; + + /* + * Make sure we do not place the image past the end of the + * available memory. + */ + if (kaddr + image_size + spacing >= mem_end) + kaddr = mem_end - image_size - spacing; + + *load_address = PAGE_ALIGN_DOWN(kaddr); + if (verbose) printf("no OS load address, defaulting to 0x%08lx\n", *load_address); -- 2.25.1 -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-23 8:30 ` Sascha Hauer @ 2020-03-23 12:22 ` Yegor Yefremov 2020-03-24 7:35 ` Sascha Hauer 0 siblings, 1 reply; 9+ messages in thread From: Yegor Yefremov @ 2020-03-23 12:22 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox, Lucas Stach Hi Sascha, On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > Hi Yegor, > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > I get an "handler failed with: Out of memory" message when trying to > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > YY: bootm_boot > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > YY: fit_open > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > FIT: /images/kernel@1/hash@1: hash OK > > > > Loading open firmware Device Tree flattened Binary > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > OS image not yet relocated > > Passing control to FIT image handler > > YY: do_bootm_linux > > YY: before bootm_load_os > > YY: bootm_load_os > > YY: kernel size 22484352 > > YY: for each memory bank: size 22484352 > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > So your kernel has a size of 22484352 bytes. We want to places the > kernel at a place where we do not risk that it overwrites itself during > decompression. We assume that the kernel gets five times bigger during > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > is already inside the malloc area. > > Try the attached patch, it should solve that issue. No, it doesn't. But reducing the malloc size helped. I have tried the reduced size with and without the fix. Yegor > Besides this obvious bug you can also adjust the sime of the malloc > area. By default roughly half of the available RAM is used for malloc, > but in Kconfig you can adjust it to a smaller size which gives you more > place for the kernel. > > Sascha > > --------------------------------------8<------------------------------- > > From ca440da09c3cdb83e17a6f0a99f24f69300c0ba3 Mon Sep 17 00:00:00 2001 > From: Sascha Hauer <s.hauer@pengutronix.de> > Date: Mon, 23 Mar 2020 09:17:36 +0100 > Subject: [PATCH] ARM: bootm: make sure we place the kernel in free memory > > When placing the kernel image in memory make sure we do not > place it too high, outside of the available memory, outside of the > available memory. > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- > arch/arm/lib32/bootm.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c > index d64e705c40..971ebee8ac 100644 > --- a/arch/arm/lib32/bootm.c > +++ b/arch/arm/lib32/bootm.c > @@ -104,11 +104,24 @@ static int get_kernel_addresses(size_t image_size, > spacing = SZ_1M; > > if (*load_address == UIMAGE_INVALID_ADDRESS) { > + unsigned long mem_end = mem_start + mem_size - 1; > + unsigned long kaddr; > + > /* > * Place the kernel at an address where it does not need to > * relocate itself before decompression. > */ > - *load_address = mem_start + image_decomp_size; > + kaddr = mem_start + image_decomp_size; > + > + /* > + * Make sure we do not place the image past the end of the > + * available memory. > + */ > + if (kaddr + image_size + spacing >= mem_end) > + kaddr = mem_end - image_size - spacing; > + > + *load_address = PAGE_ALIGN_DOWN(kaddr); > + > if (verbose) > printf("no OS load address, defaulting to 0x%08lx\n", > *load_address); > -- > 2.25.1 > > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-23 12:22 ` Yegor Yefremov @ 2020-03-24 7:35 ` Sascha Hauer 2020-03-24 16:21 ` Yegor Yefremov 0 siblings, 1 reply; 9+ messages in thread From: Sascha Hauer @ 2020-03-24 7:35 UTC (permalink / raw) To: Yegor Yefremov; +Cc: barebox, Lucas Stach On Mon, Mar 23, 2020 at 01:22:33PM +0100, Yegor Yefremov wrote: > Hi Sascha, > > On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > Hi Yegor, > > > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > > I get an "handler failed with: Out of memory" message when trying to > > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > > YY: bootm_boot > > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > > YY: fit_open > > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > > FIT: /images/kernel@1/hash@1: hash OK > > > > > > Loading open firmware Device Tree flattened Binary > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > OS image not yet relocated > > > Passing control to FIT image handler > > > YY: do_bootm_linux > > > YY: before bootm_load_os > > > YY: bootm_load_os > > > YY: kernel size 22484352 > > > YY: for each memory bank: size 22484352 > > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > > > So your kernel has a size of 22484352 bytes. We want to places the > > kernel at a place where we do not risk that it overwrites itself during > > decompression. We assume that the kernel gets five times bigger during > > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > > is already inside the malloc area. > > > > Try the attached patch, it should solve that issue. > > No, it doesn't. But reducing the malloc size helped. I have tried the > reduced size with and without the fix. Nevertheless I would still be interested why the patch doesn't work. Care to have a look? Some printfs of the addresses would be enough to give me a clue. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-24 7:35 ` Sascha Hauer @ 2020-03-24 16:21 ` Yegor Yefremov 2020-03-25 9:58 ` Sascha Hauer 0 siblings, 1 reply; 9+ messages in thread From: Yegor Yefremov @ 2020-03-24 16:21 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox, Lucas Stach On Tue, Mar 24, 2020 at 8:35 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > On Mon, Mar 23, 2020 at 01:22:33PM +0100, Yegor Yefremov wrote: > > Hi Sascha, > > > > On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > Hi Yegor, > > > > > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > > > I get an "handler failed with: Out of memory" message when trying to > > > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > > > YY: bootm_boot > > > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > > > YY: fit_open > > > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > > > FIT: /images/kernel@1/hash@1: hash OK > > > > > > > > Loading open firmware Device Tree flattened Binary > > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > > OS image not yet relocated > > > > Passing control to FIT image handler > > > > YY: do_bootm_linux > > > > YY: before bootm_load_os > > > > YY: bootm_load_os > > > > YY: kernel size 22484352 > > > > YY: for each memory bank: size 22484352 > > > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > > > > > So your kernel has a size of 22484352 bytes. We want to places the > > > kernel at a place where we do not risk that it overwrites itself during > > > decompression. We assume that the kernel gets five times bigger during > > > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > > > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > > > is already inside the malloc area. > > > > > > Try the attached patch, it should solve that issue. > > > > No, it doesn't. But reducing the malloc size helped. I have tried the > > reduced size with and without the fix. > > Nevertheless I would still be interested why the patch doesn't work. > Care to have a look? Some printfs of the addresses would be enough to > give me a clue. Loading open firmware Device Tree flattened Binary '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' YY: mem_start 80000000, mem_size 133163104 YY: image_decomp_size 112422912 YY: mem_end 87efe85f YY: kaddr initial 86b37000 YY: kaddr final 8688d2df YY: load_address 8688d000 YY: mem_free 87eff000 FIT: image 'fdt220@1': 'Flattened Device Tree blob (220)' FIT: /images/fdt220@1/hash@1: hash OK handler failed with: Out of memory I hope this helps. Thanks. Yegor _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-24 16:21 ` Yegor Yefremov @ 2020-03-25 9:58 ` Sascha Hauer 2020-03-25 15:35 ` Yegor Yefremov 0 siblings, 1 reply; 9+ messages in thread From: Sascha Hauer @ 2020-03-25 9:58 UTC (permalink / raw) To: Yegor Yefremov; +Cc: barebox, Lucas Stach On Tue, Mar 24, 2020 at 05:21:16PM +0100, Yegor Yefremov wrote: > On Tue, Mar 24, 2020 at 8:35 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > On Mon, Mar 23, 2020 at 01:22:33PM +0100, Yegor Yefremov wrote: > > > Hi Sascha, > > > > > > On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > > > Hi Yegor, > > > > > > > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > > > > I get an "handler failed with: Out of memory" message when trying to > > > > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > > > > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > > > > YY: bootm_boot > > > > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > > > > YY: fit_open > > > > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > > > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > > > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > > > > FIT: /images/kernel@1/hash@1: hash OK > > > > > > > > > > Loading open firmware Device Tree flattened Binary > > > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > > > OS image not yet relocated > > > > > Passing control to FIT image handler > > > > > YY: do_bootm_linux > > > > > YY: before bootm_load_os > > > > > YY: bootm_load_os > > > > > YY: kernel size 22484352 > > > > > YY: for each memory bank: size 22484352 > > > > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > > > > > > > So your kernel has a size of 22484352 bytes. We want to places the > > > > kernel at a place where we do not risk that it overwrites itself during > > > > decompression. We assume that the kernel gets five times bigger during > > > > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > > > > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > > > > is already inside the malloc area. > > > > > > > > Try the attached patch, it should solve that issue. > > > > > > No, it doesn't. But reducing the malloc size helped. I have tried the > > > reduced size with and without the fix. > > > > Nevertheless I would still be interested why the patch doesn't work. > > Care to have a look? Some printfs of the addresses would be enough to > > give me a clue. > > Loading open firmware Device Tree flattened Binary > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > YY: mem_start 80000000, mem_size 133163104 > YY: image_decomp_size 112422912 > YY: mem_end 87efe85f > YY: kaddr initial 86b37000 > YY: kaddr final 8688d2df > YY: load_address 8688d000 > YY: mem_free 87eff000 > FIT: image 'fdt220@1': 'Flattened Device Tree blob (220)' > FIT: /images/fdt220@1/hash@1: hash OK > handler failed with: Out of memory > > I hope this helps. Yes, that helps, thanks. It seems the kernel now fits into the available memory, but now there's no space left above the kernel to place the device tree, at least that's what I assume. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-25 9:58 ` Sascha Hauer @ 2020-03-25 15:35 ` Yegor Yefremov 2020-03-25 15:36 ` Yegor Yefremov 0 siblings, 1 reply; 9+ messages in thread From: Yegor Yefremov @ 2020-03-25 15:35 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox, Lucas Stach On Wed, Mar 25, 2020 at 10:58 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > On Tue, Mar 24, 2020 at 05:21:16PM +0100, Yegor Yefremov wrote: > > On Tue, Mar 24, 2020 at 8:35 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > On Mon, Mar 23, 2020 at 01:22:33PM +0100, Yegor Yefremov wrote: > > > > Hi Sascha, > > > > > > > > On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > > > > > Hi Yegor, > > > > > > > > > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > > > > > I get an "handler failed with: Out of memory" message when trying to > > > > > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > > > > > > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > > > > > YY: bootm_boot > > > > > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > > > > > YY: fit_open > > > > > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > > > > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > > > > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > > > > > FIT: /images/kernel@1/hash@1: hash OK > > > > > > > > > > > > Loading open firmware Device Tree flattened Binary > > > > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > > > > OS image not yet relocated > > > > > > Passing control to FIT image handler > > > > > > YY: do_bootm_linux > > > > > > YY: before bootm_load_os > > > > > > YY: bootm_load_os > > > > > > YY: kernel size 22484352 > > > > > > YY: for each memory bank: size 22484352 > > > > > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > > > > > > > > > So your kernel has a size of 22484352 bytes. We want to places the > > > > > kernel at a place where we do not risk that it overwrites itself during > > > > > decompression. We assume that the kernel gets five times bigger during > > > > > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > > > > > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > > > > > is already inside the malloc area. > > > > > > > > > > Try the attached patch, it should solve that issue. > > > > > > > > No, it doesn't. But reducing the malloc size helped. I have tried the > > > > reduced size with and without the fix. > > > > > > Nevertheless I would still be interested why the patch doesn't work. > > > Care to have a look? Some printfs of the addresses would be enough to > > > give me a clue. > > > > Loading open firmware Device Tree flattened Binary > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > YY: mem_start 80000000, mem_size 133163104 > > YY: image_decomp_size 112422912 > > YY: mem_end 87efe85f > > YY: kaddr initial 86b37000 > > YY: kaddr final 8688d2df > > YY: load_address 8688d000 > > YY: mem_free 87eff000 > > FIT: image 'fdt220@1': 'Flattened Device Tree blob (220)' > > FIT: /images/fdt220@1/hash@1: hash OK > > handler failed with: Out of memory > > > > I hope this helps. > > Yes, that helps, thanks. It seems the kernel now fits into the available > memory, but now there's no space left above the kernel to place the > device tree, at least that's what I assume. So the solution with reduced malloc size still holds. While we are at it, could you add CONFIG_MALLOC_SIZE and other config options in the related Kconfig? Thanks. Yegor _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-25 15:35 ` Yegor Yefremov @ 2020-03-25 15:36 ` Yegor Yefremov 2020-04-08 17:17 ` Yegor Yefremov 0 siblings, 1 reply; 9+ messages in thread From: Yegor Yefremov @ 2020-03-25 15:36 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox, Lucas Stach On Wed, Mar 25, 2020 at 4:35 PM Yegor Yefremov <yegorslists@googlemail.com> wrote: > > On Wed, Mar 25, 2020 at 10:58 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > On Tue, Mar 24, 2020 at 05:21:16PM +0100, Yegor Yefremov wrote: > > > On Tue, Mar 24, 2020 at 8:35 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > > > On Mon, Mar 23, 2020 at 01:22:33PM +0100, Yegor Yefremov wrote: > > > > > Hi Sascha, > > > > > > > > > > On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > > > > > > > Hi Yegor, > > > > > > > > > > > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > > > > > > I get an "handler failed with: Out of memory" message when trying to > > > > > > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > > > > > > > > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > > > > > > YY: bootm_boot > > > > > > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > > > > > > YY: fit_open > > > > > > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > > > > > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > > > > > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > > > > > > FIT: /images/kernel@1/hash@1: hash OK > > > > > > > > > > > > > > Loading open firmware Device Tree flattened Binary > > > > > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > > > > > OS image not yet relocated > > > > > > > Passing control to FIT image handler > > > > > > > YY: do_bootm_linux > > > > > > > YY: before bootm_load_os > > > > > > > YY: bootm_load_os > > > > > > > YY: kernel size 22484352 > > > > > > > YY: for each memory bank: size 22484352 > > > > > > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > > > > > > > > > > > So your kernel has a size of 22484352 bytes. We want to places the > > > > > > kernel at a place where we do not risk that it overwrites itself during > > > > > > decompression. We assume that the kernel gets five times bigger during > > > > > > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > > > > > > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > > > > > > is already inside the malloc area. > > > > > > > > > > > > Try the attached patch, it should solve that issue. > > > > > > > > > > No, it doesn't. But reducing the malloc size helped. I have tried the > > > > > reduced size with and without the fix. > > > > > > > > Nevertheless I would still be interested why the patch doesn't work. > > > > Care to have a look? Some printfs of the addresses would be enough to > > > > give me a clue. > > > > > > Loading open firmware Device Tree flattened Binary > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > YY: mem_start 80000000, mem_size 133163104 > > > YY: image_decomp_size 112422912 > > > YY: mem_end 87efe85f > > > YY: kaddr initial 86b37000 > > > YY: kaddr final 8688d2df > > > YY: load_address 8688d000 > > > YY: mem_free 87eff000 > > > FIT: image 'fdt220@1': 'Flattened Device Tree blob (220)' > > > FIT: /images/fdt220@1/hash@1: hash OK > > > handler failed with: Out of memory > > > > > > I hope this helps. > > > > Yes, that helps, thanks. It seems the kernel now fits into the available > > memory, but now there's no space left above the kernel to place the > > device tree, at least that's what I assume. > > So the solution with reduced malloc size still holds. > > While we are at it, could you add CONFIG_MALLOC_SIZE and other config > options in the related Kconfig? I mean the help texts? _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: am335x: load a kernel with integrated initramfs 2020-03-25 15:36 ` Yegor Yefremov @ 2020-04-08 17:17 ` Yegor Yefremov 0 siblings, 0 replies; 9+ messages in thread From: Yegor Yefremov @ 2020-04-08 17:17 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox, Lucas Stach Hi Sascha, On Wed, Mar 25, 2020 at 4:36 PM Yegor Yefremov <yegorslists@googlemail.com> wrote: > > On Wed, Mar 25, 2020 at 4:35 PM Yegor Yefremov > <yegorslists@googlemail.com> wrote: > > > > On Wed, Mar 25, 2020 at 10:58 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > On Tue, Mar 24, 2020 at 05:21:16PM +0100, Yegor Yefremov wrote: > > > > On Tue, Mar 24, 2020 at 8:35 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > > > > > On Mon, Mar 23, 2020 at 01:22:33PM +0100, Yegor Yefremov wrote: > > > > > > Hi Sascha, > > > > > > > > > > > > On Mon, Mar 23, 2020 at 9:30 AM Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > > > > > > > > > > > > Hi Yegor, > > > > > > > > > > > > > > On Fri, Mar 20, 2020 at 09:29:04AM +0100, Yegor Yefremov wrote: > > > > > > > > I get an "handler failed with: Out of memory" message when trying to > > > > > > > > load my 22MB large kernel-fit.itb. Below you can see the related log: > > > > > > > > > > > > > > > > mounted /dev/nand0.UBI.ubi.kernel on /mnt/nand0.UBI.ubi.kernel > > > > > > > > YY: bootm_boot > > > > > > > > YY: read file 0, size 22661672, PAGE_SIZE 4096 > > > > > > > > YY: fit_open > > > > > > > > FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob > > > > > > > > FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) > > > > > > > > FIT: image 'kernel@1': 'Vanilla Linux kernel' > > > > > > > > FIT: /images/kernel@1/hash@1: hash OK > > > > > > > > > > > > > > > > Loading open firmware Device Tree flattened Binary > > > > > > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > > > > > > OS image not yet relocated > > > > > > > > Passing control to FIT image handler > > > > > > > > YY: do_bootm_linux > > > > > > > > YY: before bootm_load_os > > > > > > > > YY: bootm_load_os > > > > > > > > YY: kernel size 22484352 > > > > > > > > YY: for each memory bank: size 22484352 > > > > > > > > __request_region: 0x86b37000:0x880a857f conflicts with 0x87efe860:0x8fdfd0bf > > > > > > > > > > > > > > So your kernel has a size of 22484352 bytes. We want to places the > > > > > > > kernel at a place where we do not risk that it overwrites itself during > > > > > > > decompression. We assume that the kernel gets five times bigger during > > > > > > > decompression. So we put it at 0x80000000 + 22484352 * 5. Here the image > > > > > > > takes 22484352 bytes, so ends at 0x80000000 + 22484352 * (5 + 1) which > > > > > > > is already inside the malloc area. > > > > > > > > > > > > > > Try the attached patch, it should solve that issue. > > > > > > > > > > > > No, it doesn't. But reducing the malloc size helped. I have tried the > > > > > > reduced size with and without the fix. > > > > > > > > > > Nevertheless I would still be interested why the patch doesn't work. > > > > > Care to have a look? Some printfs of the addresses would be enough to > > > > > give me a clue. > > > > > > > > Loading open firmware Device Tree flattened Binary > > > > '/mnt/nand0.UBI.ubi.kernel/kernel-fit.itb' > > > > YY: mem_start 80000000, mem_size 133163104 > > > > YY: image_decomp_size 112422912 > > > > YY: mem_end 87efe85f > > > > YY: kaddr initial 86b37000 > > > > YY: kaddr final 8688d2df > > > > YY: load_address 8688d000 > > > > YY: mem_free 87eff000 > > > > FIT: image 'fdt220@1': 'Flattened Device Tree blob (220)' > > > > FIT: /images/fdt220@1/hash@1: hash OK > > > > handler failed with: Out of memory > > > > > > > > I hope this helps. > > > > > > Yes, that helps, thanks. It seems the kernel now fits into the available > > > memory, but now there's no space left above the kernel to place the > > > device tree, at least that's what I assume. > > > > So the solution with reduced malloc size still holds. > > > > While we are at it, could you add CONFIG_MALLOC_SIZE and other config > > options in the related Kconfig? > > I mean the help texts? I slowly came to a limit of my kernel-fit.itb. My CONFIG_MALLOC_SIZE is now 0x2000000 (32MB). With this setting, I could successfully start a 26MB big file. But 29MB doesn't work, i.e. barebox doesn't complain but kernel doesn't really boot: barebox> / mount /dev/mmc0.1 && bootm /mnt/mmc0.1/root/kernel-fit.itb@conf$global.board.id@1 ext4 ext40: EXT2 rev 1, inode_size 128, descriptor size 32 mounted /dev/mmc0.1 on /mnt/mmc0.1 FIT: Opened FIT image: Simple image with single Linux kernel and FDT blob FIT: configuration 'conf221@1': Boot Linux kernel with FDT blob (221) FIT: image 'kernel@1': 'Vanilla Linux kernel' FIT: /images/kernel@1/hash@1: hash OK Loading open firmware Device Tree flattened Binary '/mnt/mmc0.1/root/kernel-fit.itb' YY: mem_start 80000000, mem_size 224383168 YY: image_decomp_size 146268160 YY: mem_end 8d5fd0bf YY: kaddr initial 88b7e000 YY: kaddr final 88b7e000 YY: load_address 88b7e000 YY: mem_free 8a864000 FIT: image 'fdt220@1': 'Flattened Device Tree blob (220)' FIT: /images/fdt220@1/hash@1: hash OK commandline: console=ttyO0,115200n8 I have tested this with and without your patch. File sizes: kernel-fit.itb 29M rootfs.cpio 81M zImage 28M Image 38M If I understand it correctly the decompressed size is 81M + 38M + DTB is about 120MB. Any idea? Yegor _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-04-08 17:17 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-03-20 8:29 am335x: load a kernel with integrated initramfs Yegor Yefremov 2020-03-23 8:30 ` Sascha Hauer 2020-03-23 12:22 ` Yegor Yefremov 2020-03-24 7:35 ` Sascha Hauer 2020-03-24 16:21 ` Yegor Yefremov 2020-03-25 9:58 ` Sascha Hauer 2020-03-25 15:35 ` Yegor Yefremov 2020-03-25 15:36 ` Yegor Yefremov 2020-04-08 17:17 ` Yegor Yefremov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox