Is my petalinux image too big? - Page 1
Forum section: electronics / general

author: Boscoe
author_rank: Frequent Contributor
timestamp: March 29, 2024, 09:14:06 am
content: Hi all,I'm having a little confusing time with my custom Zynq 7000 based petalinux attempts. I have 256MiB of DDR3 which is verified passing the DRAM tests that are included in the Vitis examples, the eye width and position seem acceptable at 65% in the worst case condition.I built a petalinux with some extra packages such as build-essentials, USB gadget CDC and a couple of others.I get the error below when trying to boot the petalinux image. ChatGPT says this is because I've ran out of memory the ls -l for the images directory is below as well. I see rootfs.cpio is at ~254MB. How do I determine the total image size? Is it too large? Could anyone give any tips on what's happening here?Many thanks!Code:test@testserver ~/p/camera> ls -l images/linux/total 1289192-rw-r--r-- 1 test test 3473 Mar 29 06:51 boot.scr-rw-r--r-- 1 test test 7819 Mar 29 07:40 config-rw-r--r-- 1 test test 105740524 Mar 29 08:43 image.ubdrwxr-xr-x 2 test test 4096 Mar 29 06:51 pxelinux.cfg/-rw-r--r-- 1 test test 254417920 Mar 29 07:46 rootfs.cpio-rw-r--r-- 1 test test 101047751 Mar 29 07:46 rootfs.cpio.gz-rw-r--r-- 1 test test 101047815 Mar 29 07:46 rootfs.cpio.gz.u-boot-rw-r--r-- 1 test test 479718400 Mar 29 07:46 rootfs.ext4-rw-r--r-- 1 test test 127139840 Mar 29 07:46 rootfs.jffs2-rw-r--r-- 1 test test 29423 Mar 29 07:46 rootfs.manifest-rw-r--r-- 1 test test 111851662 Mar 29 07:46 rootfs.tar.gz-rw-r--r-- 1 test test 4045671 Mar 28 17:06 system.bit-rw-r--r-- 1 test test 18574 Mar 29 07:43 system.dtb-rwxr-xr-x 1 test test 1018400 Mar 29 07:45 u-boot.bin*-rw-r--r-- 1 test test 1036974 Mar 29 07:45 u-boot-dtb.bin-rw-r--r-- 1 test test 1102936 Mar 29 07:45 u-boot-dtb.elf-rwxr-xr-x 1 test test 7906416 Mar 29 07:45 u-boot.elf*-rw-r--r-- 1 test test 4672120 Mar 29 08:43 uImage-rw-r--r-- 1 test test 14139644 Mar 29 08:43 vmlinux-rw-r--r-- 1 test test 4672056 Mar 29 08:43 zImage-rw-r--r-- 1 test test 473860 Mar 29 07:43 zynq_fsbl.elfCode:kworker/u4:0 invoked oom-killer: gfp_mask=0x140cc2(GFP_HIGHUSER|__GFP_COMP), order=0, oom_score_adj=0CPU: 1 PID: 7 Comm: kworker/u4:0 Not tainted 6.1.30-xilinx-v2023.2 #1Hardware name: Xilinx Zynq PlatformWorkqueue: events_unbound async_run_entry_fnunwind_backtrace from show_stack+0x10/0x14show_stack from dump_stack_lvl+0x40/0x4cdump_stack_lvl from dump_header+0x5c/0x294dump_header from out_of_memory+0x14c/0x380out_of_memory from __alloc_pages+0x5e0/0x730__alloc_pages from __filemap_get_folio+0x1a8/0x218__filemap_get_folio from pagecache_get_page+0x14/0x50pagecache_get_page from simple_write_begin+0x1c/0x88simple_write_begin from generic_perform_write+0xb8/0x1c8generic_perform_write from __generic_file_write_iter+0x134/0x15c__generic_file_write_iter from generic_file_write_iter+0x5c/0xe8generic_file_write_iter from __kernel_write_iter+0xcc/0x100__kernel_write_iter from __kernel_write+0x70/0x98__kernel_write from kernel_write+0x40/0x54kernel_write from xwrite+0x38/0xa0xwrite from do_copy+0xe4/0x128do_copy from write_buffer+0x24/0x3cwrite_buffer from flush_buffer+0x38/0x98flush_buffer from __gunzip+0x2c4/0x328__gunzip from gunzip+0x28/0x30gunzip from unpack_to_rootfs+0x1c4/0x2a8unpack_to_rootfs from do_populate_rootfs+0x64/0x16cdo_populate_rootfs from async_run_entry_fn+0x20/0xa8async_run_entry_fn from process_one_work+0x138/0x1e8process_one_work from worker_thread+0x184/0x258worker_thread from kthread+0xf0/0xf8kthread from ret_from_fork+0x14/0x2cException stack(0xd0831fb0 to 0xd0831ff8)1fa0: 00000000 00000000 00000000 000000001fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000001fe0: 00000000 00000000 00000000 00000000 00000013 00000000Mem-Info:active_anon:0 inactive_anon:0 isolated_anon:0active_file:0 inactive_file:0 isolated_file:0unevictable:30910 dirty:0 writeback:0slab_reclaimable:689 slab_unreclaimable:676mapped:0 shmem:0 pagetables:0sec_pagetables:0 bounce:0kernel_misc_reclaimable:0free:4399 free_pcp:31 free_cma:4030Node 0 active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:123640kB isolated(anon):0kB isolated(file):0kB mapped:0kB dirty:0kB writeback:0kB shmem:0kB writeback_tmp:0kB kernel_stack:344kB pagetables:0kB sec_pagetables:0kB all_unreclaimable? yesNormal free:17596kB boost:0kB min:1540kB low:1924kB high:2308kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:123652kB writepending:0kB present:262144kB managed:148856kB mlocked:0kB bounce:0kB free_pcp:124kB local_pcp:24kB free_cma:16120kBlowmem_reserve[]: 0 0 0Normal: 1*4kB (U) 1*8kB (C) 1*16kB (C) 1*32kB (C) 2*64kB (UC) 2*128kB (UC) 1*256kB (U) 3*512kB (UMC) 1*1024kB (C) 1*2048kB (C) 3*4096kB (C) = 17596kB30918 total pagecache pages0 pages in swap cacheFree swap = 0kBTotal swap = 0kB65536 pages RAM0 pages HighMem/MovableOnly28322 pages reserved4096 pages cma reservedTasks state (memory values in pages):[ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj nameOut of memory and no killable processes...Kernel panic - not syncing: System is deadlocked on memoryCPU0: stoppingCPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.1.30-xilinx-v2023.2 #1Hardware name: Xilinx Zynq Platformunwind_backtrace from show_stack+0x10/0x14show_stack from dump_stack_lvl+0x40/0x4cdump_stack_lvl from do_handle_IPI+0x78/0x138do_handle_IPI from ipi_handler+0x14/0x20ipi_handler from handle_percpu_devid_irq+0x4c/0xe8handle_percpu_devid_irq from handle_irq_desc+0x1c/0x2chandle_irq_desc from gic_handle_irq+0x60/0x70gic_handle_irq from generic_handle_arch_irq+0x28/0x3cgeneric_handle_arch_irq from __irq_svc+0x88/0xc8Exception stack(0xc0c01eb8 to 0xc0c01f00)1ea0: 00000000 000000001ec0: 0e28e000 cedcf580 cedce938 f9e2b76c 00000000 00000000 00000001 c0c357e01ee0: f8502b37 00000001 00000000 c0c01f08 c0569004 c0569028 600f0013 ffffffff__irq_svc from cpuidle_enter_state+0x110/0x27ccpuidle_enter_state from cpuidle_enter+0x28/0x38cpuidle_enter from do_idle+0x238/0x25cdo_idle from cpu_startup_entry+0x18/0x1ccpu_startup_entry from rest_init+0xb0/0xccrest_init from arch_post_acpi_subsys_init+0x0/0x8---[ end Kernel panic - not syncing: System is deadlocked on memory ]---

author: Foxxz
author_rank: Regular Contributor
timestamp: March 29, 2024, 03:07:20 pm
content: So if your filesystem is 254MB and you're loading the whole thing into RAM that means you have 2MB of RAM left for your kernel and userspace programs to execute in. Have you tried a barebones image first? I wouldn't want the image to exceed 64MB initially.Edited to add - If you are compressing it with gzip consider you need to load the compressed image into RAM + the uncompressed image into RAM. Plus whatever memory the kernel needs. After decompression the compressed image no longer occupies memory and your RAM needs are the filesystem image + kernel + userspace requirements.

author: Boscoe
author_rank: Frequent Contributor
timestamp: March 29, 2024, 03:52:14 pm
content: Quote from: Foxxz on March 29, 2024, 03:07:20 pmHi Foxxz, thank you for this information, this is what I was thinking, too. I enabled a few packages and I'm curious to know which ones take up the memory. Do you know of any tools that can calculate the usage of each package?

author: ejeffrey
author_rank: Super Contributor
timestamp: March 29, 2024, 05:01:20 pm
content: build-essentials is pretty big, I doubt you will be able to include that in an image that fits in a ramdisk.A system with 256 MB of DRAM is going to have a hard time running anything like a complete OS from a ramdisk with room for the kernel and have space left for userspace. It's certainly possible in a "production" system where you just have your custom program pre-compiled and running on a stripped down system, but if you are trying to add interactive tools and development tools I think you are probably looking for more than that. If that is what you want you should probably figure out how to use a flash based rootfs.

author: Boscoe
author_rank: Frequent Contributor
timestamp: March 29, 2024, 09:06:12 pm
content: Quote from: ejeffrey on March 29, 2024, 05:01:20 pmThanks, even this doesn't seem possible in my 16MB of FLASH. Not to worry as I was only really using Linux to test the system.I did manage to boot Linux on a bare minimum image.

author: Foxxz
author_rank: Regular Contributor
timestamp: March 29, 2024, 09:12:03 pm
content: Quote from: Boscoe on March 29, 2024, 09:06:12 pmSome of my first experience with embedded linux were on systems containing 8MB of flash and 32mb of RAM. It just came down to compiling the kernel to only include what was needed and slimming down the filesystem to the essentials for your task. Many embedded devices use busybox linux.

author: ejeffrey
author_rank: Super Contributor
timestamp: March 30, 2024, 01:45:11 am
content: Quote from: Boscoe on March 29, 2024, 09:06:12 pmMy kernel image for a ZynqMP system is 16 MB so yeah it may be tricky to slim down to that size starting with petalinux, although the zynq7000 will be smaller.The standard boot sequence for Linux uses the initramfs method. There is a small archive in the CPIO format build into the kernel image. That is responsible for loading any modules, configuring some hardware, and mounting the root filesystem. The initramfs on my petalinux install is only 5 MB. For a lot of applications you can just put your executable in the initramfs and never go past that stage. But this environment is very limited. It typically has a shell, a few filesystem utilities like mount, a minimal DHCP client for NFS root, and that's it.

author: Forty-Bot
author_rank: Contributor
timestamp: April 03, 2024, 04:26:40 pm
content: Just don't load everything into ram. Set your root to e.g. /dev/mmc0blk2 or whatever. You can use an initramfs, but there are only two reasons to do so:You want to run fsck on your root partitionYou have to start running some application within X seconds of power on and regular boot is too slow.