[OpenWrt-Devel] Is it possible to create two images for the same device with a different set of DEVICE_PACKAGES?

Andre Valentin avalentin at marcant.net
Wed Apr 8 03:42:35 EDT 2020


Hi Bjoern,

I made a patch for include/image-commands.mk that allows to building squashfs initrd images.
The reason for me is that the imagebuilder is unable to generate initramfs images.
When building the final images with the imagebuilder you can define which packages to include.
Your platform has to use device-tree!

That's the function:
# This take the vanilla kernel, modifies the bootarg of dtb and appends
# the filesystem to the kernel at the given initrd offset
# address (respect kernelsize!).
# Argument 1 : initrd offset
define Build/prepend-initrd-kernel
	let \
		initrd_offset="$(subst k,* 1024,$(word 1, $(1)))" \
		rootfs_size="$$(stat -c%s $@)/4096*4096+4096" \
		kernel_size="$$(stat -c%s $(KDIR)/$(KERNEL_NAME))" \
		dtb_size_in="$$(stat -c%s $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb )" \
		kernel_dtb_size="kernel_size+dtb_size" \
		initrd_virtual_addr="$(KERNEL_LOADADDR)+initrd_offset" ; \
	if [ $$kernel_dtb_size -ge $$initrd_offset ] ; then \
		echo initrd_offset is too small for kernel ; \
		exit 1 ; \
	fi ; \
	bootargs=$$(printf "root=/dev/ram0 rd_start=0x%x rd_size=0x%x ramdisk_size=0x%x $(wordlist 2,$(words $(1)),$(1))" \
		$$initrd_virtual_addr $$rootfs_size $$rootfs_size ) ; \
	cp $(KDIR)/$(KERNEL_NAME) $@.tmp ; \
	$(LINUX_DIR)/scripts/dtc/dtc -I dtb -O dts -o - $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb | \
	$(TOPDIR)/scripts/patch-dtb-bootargs.pl "$$bootargs" | \
	$(LINUX_DIR)/scripts/dtc/dtc -I dts -O dtb -o - - >> $@.tmp ; \
	dd if=$@.tmp of=$@.tmp.padded conv=sync bs=$$initrd_offset count=1 ; \
	mv $@.tmp.padded $@.tmp ; \
	dd if=$@ bs=$$rootfs_size count=1 conv=sync >> $@.tmp ; \
	mv $@.tmp $@
endef

Kernel needs following symbols:
CONFIG_BLK_DEV_INITRD=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=1
CONFIG_BLK_DEV_RAM_SIZE=0

This is the line for image/Makefile or ...
IMAGE/tftpboot-uImage-ramdisk.bin = append-rootfs | prepend-initrd-kernel 16777216 | lzma | uImage lzma

16777216 is the offset for the initrd in memory (take kernel size into account), may be lowered for you.

Kind regards,

André

Am 08.04.20 um 09:26 schrieb Bjørn Mork:
> Tomasz Maciej Nowak <tomek_n at o2.pl> writes:
>
>> In include/kernel-defaults.mk there is
>> INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt.
>> Maybe You could add a logic for ignore files list if they exist. No other
>> solution comes to my mind.
>
> Thanks for the suggestion.  But I believe this file is used directly as
> config to the initramfs builder in the kernel.  Extending the format
> would mean modifying usr/gen_init_cpio.c in the kernel.  That's a bit
> overkill IMHO.
>
> I am probably ending up with the simplest solution: Dropping the large
> firmware package from DEVICE_PACKAGES. Making defconfig images usable
> for first-time installation is much more important than having every
> necessary package included in the defconfig sysupgrade images.
>
>
> Bjørn
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>

-- 
Mit freundlichen Grüßen
André Valentin

Systemadministration - Projektkoordination


--
MarcanT AG, Herforder Straße 163a, D - 33609 Bielefeld
Fon: +49 (521) 95945-0 | Fax: +49 (521) 95945-18
URL: http://www.marcant.net <http://www.marcant.net/> | http://www.global-m2m.com <http://www.global-m2m.com/>

Internet * Netzwerk * Mobile Daten

Vorstand:
Thorsten Hojas (Vorsitzender)
Marc-Henrik Delker
Dr. Anja-Christina Padberg
Handelsregister: AG Bielefeld, HRB 42260 USt-ID Nr.: DE 190203238



___________________________________________________________
Ausserhalb unserer Geschäftszeiten (Montag bis Freitag von 8:30 Uhr bis
17:30 Uhr, ausgenommen gesetzliche Feiertage in NRW) stehen wir Ihnen
gemäß Ihrer jeweiligen Service-Level-Agreements unter der Ihnen
mitgeteilten Telefonnummer für Störungen und Notfälle zur Verfügung.
Sie können natürlich auch gerne jederzeit unter support at marcant.net ein
Ticket eröffnen, welches am nächsten Arbeitstag bearbeitet wird.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4052 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200408/3ae223b3/attachment.p7s>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list